Skip to content

Make std:: prefix suggestion test run-rustfix #97957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/test/ui/suggestions/suggest-std-when-using-type.fixed
Original file line number Diff line number Diff line change
@@ -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}");
}
7 changes: 4 additions & 3 deletions src/test/ui/suggestions/suggest-std-when-using-type.rs
Original file line number Diff line number Diff line change
@@ -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}");
}
12 changes: 6 additions & 6 deletions src/test/ui/suggestions/suggest-std-when-using-type.stderr
Original file line number Diff line number Diff line change
@@ -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;
| ^^^^^^^^^^^
Expand All @@ -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

Expand Down