Skip to content

Commit 67588e7

Browse files
authored
Unrolled build for rust-lang#131991
Rollup merge of rust-lang#131991 - jannden:issue-98565-test, r=jieyouxu test: Add test for trait in FQS cast, issue rust-lang#98565 Closes rust-lang#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 edbd939 + d5cfcc7 commit 67588e7

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)