mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Rollup merge of #131991 - jannden:issue-98565-test, r=jieyouxu
test: Add test for trait in FQS cast, issue #98565 Closes #98565 by adding a test to check for diagnostics when the built-in type `str` is used in a cast where a trait is expected.
This commit is contained in:
commit
a9da2be010
15
tests/ui/traits/fully-qualified-syntax-cast.rs
Normal file
15
tests/ui/traits/fully-qualified-syntax-cast.rs
Normal file
@ -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
tests/ui/traits/fully-qualified-syntax-cast.stderr
Normal file
9
tests/ui/traits/fully-qualified-syntax-cast.stderr
Normal file
@ -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…
Reference in New Issue
Block a user