add test files

This commit is contained in:
Guanqun Lu 2019-09-24 23:02:21 +08:00
parent a5d931050e
commit bb3c03049d
3 changed files with 49 additions and 1 deletions

View file

@ -518,7 +518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
fn is_str_ref<'tcx>(ty: Ty<'tcx>) -> bool {
fn is_str_ref(ty: Ty<'_>) -> bool {
match ty.sty {
ty::Str => true,
ty::Ref(_, ty, _) => is_str_ref(&ty),

View file

@ -0,0 +1,21 @@
fn foo1(s: &str) {
s.as_str();
//~^ ERROR no method named `as_str` found for type `&str` in the current scope
}
fn foo2<'a>(s: &'a str) {
s.as_str();
//~^ ERROR no method named `as_str` found for type `&'a str` in the current scope
}
fn foo3(s: &mut str) {
s.as_str();
//~^ ERROR no method named `as_str` found for type `&mut str` in the current scope
}
fn foo4(s: &&str) {
s.as_str();
//~^ ERROR no method named `as_str` found for type `&&str` in the current scope
}
fn main() {}

View file

@ -0,0 +1,27 @@
error[E0599]: no method named `as_str` found for type `&str` in the current scope
--> $DIR/remove-as_str.rs:2:7
|
LL | s.as_str();
| ^^^^^^ help: try to remove `as_str`
error[E0599]: no method named `as_str` found for type `&'a str` in the current scope
--> $DIR/remove-as_str.rs:7:7
|
LL | s.as_str();
| ^^^^^^ help: try to remove `as_str`
error[E0599]: no method named `as_str` found for type `&mut str` in the current scope
--> $DIR/remove-as_str.rs:12:7
|
LL | s.as_str();
| ^^^^^^ help: try to remove `as_str`
error[E0599]: no method named `as_str` found for type `&&str` in the current scope
--> $DIR/remove-as_str.rs:17:7
|
LL | s.as_str();
| ^^^^^^ help: try to remove `as_str`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0599`.