This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree 3 files changed +18
-9
lines changed 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
1
2
fn main ( ) {
2
3
let pi = f32:: consts:: PI ; //~ ERROR ambiguous associated type
3
4
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}" ) ;
7
8
}
Original file line number Diff line number Diff line change 1
1
error[E0223]: ambiguous associated type
2
- --> $DIR/suggest-std-when-using-type.rs:2 :14
2
+ --> $DIR/suggest-std-when-using-type.rs:3 :14
3
3
|
4
4
LL | let pi = f32::consts::PI;
5
5
| ^^^^^^^^^^^
@@ -10,15 +10,15 @@ LL | let pi = std::f32::consts::PI;
10
10
| +++++
11
11
12
12
error[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
14
14
|
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`
17
17
|
18
18
help: you are looking for the module in `std`, not the primitive type
19
19
|
20
- LL | std::str::from_utf8(bytes)
21
- | +++++
20
+ LL | let string = std::str::from_utf8(bytes).unwrap();
21
+ | +++++
22
22
23
23
error: aborting due to 2 previous errors
24
24
You can’t perform that action at this time.
0 commit comments