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