Skip to content

Commit a9da2be

Browse files
authored
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.
2 parents 1cc8c8d + d5cfcc7 commit a9da2be

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Regression test for #98565: Provide diagnostics when the user uses
2+
// the built-in type `str` in a cast where a trait is expected.
3+
4+
trait Foo {
5+
fn foo(&self);
6+
}
7+
8+
impl Foo for String {
9+
fn foo(&self) {
10+
<Self as str>::trim(self);
11+
//~^ ERROR expected trait, found builtin type `str`
12+
}
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0404]: expected trait, found builtin type `str`
2+
--> $DIR/fully-qualified-syntax-cast.rs:10:18
3+
|
4+
LL | <Self as str>::trim(self);
5+
| ^^^ not a trait
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0404`.

0 commit comments

Comments
 (0)