diff --git a/tests/ui/traits/fully-qualified-syntax-cast.rs b/tests/ui/traits/fully-qualified-syntax-cast.rs new file mode 100644 index 0000000000000..740220a074b33 --- /dev/null +++ b/tests/ui/traits/fully-qualified-syntax-cast.rs @@ -0,0 +1,15 @@ +// Regression test for #98565: Provide diagnostics when the user uses +// the built-in type `str` in a cast where a trait is expected. + +trait Foo { + fn foo(&self); +} + +impl Foo for String { + fn foo(&self) { + ::trim(self); + //~^ ERROR expected trait, found builtin type `str` + } +} + +fn main() {} diff --git a/tests/ui/traits/fully-qualified-syntax-cast.stderr b/tests/ui/traits/fully-qualified-syntax-cast.stderr new file mode 100644 index 0000000000000..1848c9184c6e7 --- /dev/null +++ b/tests/ui/traits/fully-qualified-syntax-cast.stderr @@ -0,0 +1,9 @@ +error[E0404]: expected trait, found builtin type `str` + --> $DIR/fully-qualified-syntax-cast.rs:10:18 + | +LL | ::trim(self); + | ^^^ not a trait + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0404`.