Skip to content

test: Add test for trait in FQS cast, issue #98565 #131991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/ui/traits/fully-qualified-syntax-cast.rs
Original file line number Diff line number Diff line change
@@ -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) {
<Self as str>::trim(self);
//~^ ERROR expected trait, found builtin type `str`
}
}

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/traits/fully-qualified-syntax-cast.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0404]: expected trait, found builtin type `str`
--> $DIR/fully-qualified-syntax-cast.rs:10:18
|
LL | <Self as str>::trim(self);
| ^^^ not a trait

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0404`.
Loading