about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-06-10 22:32:34 +0200
committerGitHub <noreply@github.com>2022-06-10 22:32:34 +0200
commit5d04bc828e511d548f57656940ead49e3e897650 (patch)
treef81239d56cc87f858ae19c9b3f3b485cf8fe0329
parentdd409dad850c42c2384ac104110ec408f1d9cf86 (diff)
parent725952a738c4b62f574e6bbcb903ae82f7d972a2 (diff)
downloadrust-5d04bc828e511d548f57656940ead49e3e897650.tar.gz
rust-5d04bc828e511d548f57656940ead49e3e897650.zip
Rollup merge of #97957 - estebank:spancito, r=compiler-errors
Make `std::` prefix suggestion test `run-rustfix`
-rw-r--r--src/test/ui/suggestions/suggest-std-when-using-type.fixed8
-rw-r--r--src/test/ui/suggestions/suggest-std-when-using-type.rs7
-rw-r--r--src/test/ui/suggestions/suggest-std-when-using-type.stderr12
3 files changed, 18 insertions, 9 deletions
diff --git a/src/test/ui/suggestions/suggest-std-when-using-type.fixed b/src/test/ui/suggestions/suggest-std-when-using-type.fixed
new file mode 100644
index 00000000000..102c5c1868f
--- /dev/null
+++ b/src/test/ui/suggestions/suggest-std-when-using-type.fixed
@@ -0,0 +1,8 @@
+// run-rustfix
+fn main() {
+    let pi = std::f32::consts::PI; //~ ERROR ambiguous associated type
+    let bytes = "hello world".as_bytes();
+    let string = std::str::from_utf8(bytes).unwrap();
+    //~^ ERROR no function or associated item named `from_utf8` found
+    println!("{pi} {bytes:?} {string}");
+}
diff --git a/src/test/ui/suggestions/suggest-std-when-using-type.rs b/src/test/ui/suggestions/suggest-std-when-using-type.rs
index 9ca68a635da..5abc016deb0 100644
--- a/src/test/ui/suggestions/suggest-std-when-using-type.rs
+++ b/src/test/ui/suggestions/suggest-std-when-using-type.rs
@@ -1,7 +1,8 @@
+// run-rustfix
 fn main() {
     let pi = f32::consts::PI; //~ ERROR ambiguous associated type
     let bytes = "hello world".as_bytes();
-    let string = unsafe {
-        str::from_utf8(bytes) //~ ERROR no function or associated item named `from_utf8` found
-    };
+    let string = str::from_utf8(bytes).unwrap();
+    //~^ ERROR no function or associated item named `from_utf8` found
+    println!("{pi} {bytes:?} {string}");
 }
diff --git a/src/test/ui/suggestions/suggest-std-when-using-type.stderr b/src/test/ui/suggestions/suggest-std-when-using-type.stderr
index 2840fa121a7..6f890b87b24 100644
--- a/src/test/ui/suggestions/suggest-std-when-using-type.stderr
+++ b/src/test/ui/suggestions/suggest-std-when-using-type.stderr
@@ -1,5 +1,5 @@
 error[E0223]: ambiguous associated type
-  --> $DIR/suggest-std-when-using-type.rs:2:14
+  --> $DIR/suggest-std-when-using-type.rs:3:14
    |
 LL |     let pi = f32::consts::PI;
    |              ^^^^^^^^^^^
@@ -10,15 +10,15 @@ LL |     let pi = std::f32::consts::PI;
    |              +++++
 
 error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope
-  --> $DIR/suggest-std-when-using-type.rs:5:14
+  --> $DIR/suggest-std-when-using-type.rs:5:23
    |
-LL |         str::from_utf8(bytes)
-   |              ^^^^^^^^^ function or associated item not found in `str`
+LL |     let string = str::from_utf8(bytes).unwrap();
+   |                       ^^^^^^^^^ function or associated item not found in `str`
    |
 help: you are looking for the module in `std`, not the primitive type
    |
-LL |         std::str::from_utf8(bytes)
-   |         +++++
+LL |     let string = std::str::from_utf8(bytes).unwrap();
+   |                  +++++
 
 error: aborting due to 2 previous errors