File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 1+ // run-rustfix
2+ fn main() {
3+ let pi = std::f32::consts::PI; //~ ERROR ambiguous associated type
4+ let bytes = "hello world".as_bytes();
5+ let string = std::str::from_utf8(bytes).unwrap();
6+ //~^ ERROR no function or associated item named `from_utf8` found
7+ println!("{pi} {bytes:?} {string}");
8+ }
Original file line number Diff line number Diff line change 1+ // run-rustfix
12fn main ( ) {
23 let pi = f32:: consts:: PI ; //~ ERROR ambiguous associated type
34 let bytes = "hello world" . as_bytes ( ) ;
4- let string = unsafe {
5- str :: from_utf8 ( bytes ) //~ ERROR no function or associated item named `from_utf8` found
6- } ;
5+ let string = str :: from_utf8 ( bytes ) . unwrap ( ) ;
6+ //~^ ERROR no function or associated item named `from_utf8` found
7+ println ! ( "{pi} {bytes:?} {string}" ) ;
78}
Original file line number Diff line number Diff line change 11error[E0223]: ambiguous associated type
2- --> $DIR/suggest-std-when-using-type.rs:2 :14
2+ --> $DIR/suggest-std-when-using-type.rs:3 :14
33 |
44LL | let pi = f32::consts::PI;
55 | ^^^^^^^^^^^
@@ -10,15 +10,15 @@ LL | let pi = std::f32::consts::PI;
1010 | +++++
1111
1212error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope
13- --> $DIR/suggest-std-when-using-type.rs:5:14
13+ --> $DIR/suggest-std-when-using-type.rs:5:23
1414 |
15- LL | str::from_utf8(bytes)
16- | ^^^^^^^^^ function or associated item not found in `str`
15+ LL | let string = str::from_utf8(bytes).unwrap();
16+ | ^^^^^^^^^ function or associated item not found in `str`
1717 |
1818help: you are looking for the module in `std`, not the primitive type
1919 |
20- LL | std::str::from_utf8(bytes)
21- | +++++
20+ LL | let string = std::str::from_utf8(bytes).unwrap();
21+ | +++++
2222
2323error: aborting due to 2 previous errors
2424
You can’t perform that action at this time.
0 commit comments