Skip to content

Commit bb3c030

Browse files
author
Guanqun Lu
committed
add test files
1 parent a5d9310 commit bb3c030

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

src/librustc_typeck/check/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
518518
}
519519
}
520520

521-
fn is_str_ref<'tcx>(ty: Ty<'tcx>) -> bool {
521+
fn is_str_ref(ty: Ty<'_>) -> bool {
522522
match ty.sty {
523523
ty::Str => true,
524524
ty::Ref(_, ty, _) => is_str_ref(&ty),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
fn foo1(s: &str) {
2+
s.as_str();
3+
//~^ ERROR no method named `as_str` found for type `&str` in the current scope
4+
}
5+
6+
fn foo2<'a>(s: &'a str) {
7+
s.as_str();
8+
//~^ ERROR no method named `as_str` found for type `&'a str` in the current scope
9+
}
10+
11+
fn foo3(s: &mut str) {
12+
s.as_str();
13+
//~^ ERROR no method named `as_str` found for type `&mut str` in the current scope
14+
}
15+
16+
fn foo4(s: &&str) {
17+
s.as_str();
18+
//~^ ERROR no method named `as_str` found for type `&&str` in the current scope
19+
}
20+
21+
fn main() {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0599]: no method named `as_str` found for type `&str` in the current scope
2+
--> $DIR/remove-as_str.rs:2:7
3+
|
4+
LL | s.as_str();
5+
| ^^^^^^ help: try to remove `as_str`
6+
7+
error[E0599]: no method named `as_str` found for type `&'a str` in the current scope
8+
--> $DIR/remove-as_str.rs:7:7
9+
|
10+
LL | s.as_str();
11+
| ^^^^^^ help: try to remove `as_str`
12+
13+
error[E0599]: no method named `as_str` found for type `&mut str` in the current scope
14+
--> $DIR/remove-as_str.rs:12:7
15+
|
16+
LL | s.as_str();
17+
| ^^^^^^ help: try to remove `as_str`
18+
19+
error[E0599]: no method named `as_str` found for type `&&str` in the current scope
20+
--> $DIR/remove-as_str.rs:17:7
21+
|
22+
LL | s.as_str();
23+
| ^^^^^^ help: try to remove `as_str`
24+
25+
error: aborting due to 4 previous errors
26+
27+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)