]> git.lizzy.rs Git - rust.git/commitdiff
add test files
authorGuanqun Lu <guanqun.lu@gmail.com>
Tue, 24 Sep 2019 15:02:21 +0000 (23:02 +0800)
committerGuanqun Lu <guanqun.lu@gmail.com>
Wed, 2 Oct 2019 01:06:37 +0000 (09:06 +0800)
src/librustc_typeck/check/method/suggest.rs
src/test/ui/suggestions/remove-as_str.rs [new file with mode: 0644]
src/test/ui/suggestions/remove-as_str.stderr [new file with mode: 0644]

index e68e3211cade1021c07f350fddbed485d173772d..6efa304559210f09ef9bf31f69223dbfc643e748 100644 (file)
@@ -518,7 +518,7 @@ macro_rules! report_function {
                     }
                 }
 
-                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),
diff --git a/src/test/ui/suggestions/remove-as_str.rs b/src/test/ui/suggestions/remove-as_str.rs
new file mode 100644 (file)
index 0000000..d10300b
--- /dev/null
@@ -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() {}
diff --git a/src/test/ui/suggestions/remove-as_str.stderr b/src/test/ui/suggestions/remove-as_str.stderr
new file mode 100644 (file)
index 0000000..090a359
--- /dev/null
@@ -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`.