forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#97819 - compiler-errors:use-import, r=wesle…
…ywiser Recover `import` instead of `use` in item When we definitely don't have a macro invocation (i.e. when we don't have `import ::`), then it's more productive to parse `import` as if it was incorrectly mistaken for `use`. Not sure if this needs to be a verbose suggestion, but it renders strangely when it's not verbose: ``` error: expected item, found `import` --> /home/michael/test.rs:1:1 | 1 | import std::{io::{self, Write}, rc::Rc}; | ^^^^^^ help: items are imported using the `use` keyword: `use` ``` Happy to change it to `span_suggestion` instead of `span_suggestion_verbose` though. Fixes rust-lang#97788
- Loading branch information
Showing
4 changed files
with
93 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
|
||
use std::{ | ||
//~^ ERROR expected item, found `import` | ||
io::Write, | ||
rc::Rc, | ||
}; | ||
|
||
pub use std::io; | ||
//~^ ERROR expected item, found `using` | ||
|
||
fn main() { | ||
let x = Rc::new(1); | ||
let _ = write!(io::stdout(), "{:?}", x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// run-rustfix | ||
|
||
import std::{ | ||
//~^ ERROR expected item, found `import` | ||
io::Write, | ||
rc::Rc, | ||
}; | ||
|
||
pub using std::io; | ||
//~^ ERROR expected item, found `using` | ||
|
||
fn main() { | ||
let x = Rc::new(1); | ||
let _ = write!(io::stdout(), "{:?}", x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: expected item, found `import` | ||
--> $DIR/use_instead_of_import.rs:3:1 | ||
| | ||
LL | import std::{ | ||
| ^^^^^^ help: items are imported using the `use` keyword | ||
|
||
error: expected item, found `using` | ||
--> $DIR/use_instead_of_import.rs:9:5 | ||
| | ||
LL | pub using std::io; | ||
| ^^^^^ help: items are imported using the `use` keyword | ||
|
||
error: aborting due to 2 previous errors | ||
|