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#71863 - mibac138:self-import, r=estebank
Suggest fixes and add error recovery for `use foo::self` Fixes rust-lang#63741. I have implemented 2 suggestions on how to fix a `use foo::self` import, however I feel like showing them both might be too verbose. Additionally, I have also implemented error recovery as [menitoned](rust-lang#63741 (comment)) by @comex. I believe r? @estebank deals with diagnostics.
- Loading branch information
Showing
12 changed files
with
186 additions
and
23 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
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
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
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
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,13 @@ | ||
mod foo { | ||
pub mod bar { | ||
pub fn drop() {} | ||
} | ||
} | ||
|
||
use foo::bar::self; | ||
//~^ ERROR `self` imports are only allowed within a { } list | ||
|
||
fn main() { | ||
// Because of error recovery this shouldn't error | ||
bar::drop(); | ||
} |
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,18 @@ | ||
error[E0429]: `self` imports are only allowed within a { } list | ||
--> $DIR/use-mod-5.rs:7:13 | ||
| | ||
LL | use foo::bar::self; | ||
| ^^^^^^ | ||
| | ||
help: consider importing the module directly | ||
| | ||
LL | use foo::bar; | ||
| -- | ||
help: alternatively, use the multi-path `use` syntax to import `self` | ||
| | ||
LL | use foo::bar::{self}; | ||
| ^ ^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0429`. |
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,13 @@ | ||
mod foo { | ||
pub mod bar { | ||
pub fn drop() {} | ||
} | ||
} | ||
|
||
use foo::bar::self as abc; | ||
//~^ ERROR `self` imports are only allowed within a { } list | ||
|
||
fn main() { | ||
// Because of error recovery this shouldn't error | ||
abc::drop(); | ||
} |
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,18 @@ | ||
error[E0429]: `self` imports are only allowed within a { } list | ||
--> $DIR/use-mod-6.rs:7:13 | ||
| | ||
LL | use foo::bar::self as abc; | ||
| ^^^^^^ | ||
| | ||
help: consider importing the module directly | ||
| | ||
LL | use foo::bar as abc; | ||
| -- | ||
help: alternatively, use the multi-path `use` syntax to import `self` | ||
| | ||
LL | use foo::bar::{self as abc}; | ||
| ^ ^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0429`. |