-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add test for trait in FQS cast, issue #98565
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |