mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Auto merge of #42580 - tommyip:import-error, r=petrochenkov
Only emit one error for `use foo::self;` Currently `use foo::self;` would emit both E0429 and E0432. This commit silence the latter one (assuming `foo` is a valid module). Fixes #42559
This commit is contained in:
commit
4bf5c99afc
@ -482,6 +482,16 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
|||||||
if let Some(err) = self.finalize_import(import) {
|
if let Some(err) = self.finalize_import(import) {
|
||||||
errors = true;
|
errors = true;
|
||||||
|
|
||||||
|
if let SingleImport { source, ref result, .. } = import.subclass {
|
||||||
|
if source.name == "self" {
|
||||||
|
// Silence `unresolved import` error if E0429 is already emitted
|
||||||
|
match result.value_ns.get() {
|
||||||
|
Err(Determined) => continue,
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If the error is a single failed import then create a "fake" import
|
// If the error is a single failed import then create a "fake" import
|
||||||
// resolution for it so that later resolve stages won't complain.
|
// resolution for it so that later resolve stages won't complain.
|
||||||
self.import_dummy_binding(import);
|
self.import_dummy_binding(import);
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::fmt::self; //~ ERROR E0429
|
use std::fmt::self; //~ ERROR E0429
|
||||||
//~^ ERROR E0432
|
|
||||||
|
|
||||||
fn main () {
|
fn main () {
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,8 @@
|
|||||||
|
|
||||||
mod a {
|
mod a {
|
||||||
mod b {
|
mod b {
|
||||||
use self as A; //~ ERROR `self` imports are only allowed within a { } list
|
use self as A;
|
||||||
//~^ ERROR unresolved import `self` [E0432]
|
//~^ ERROR `self` imports are only allowed within a { } list
|
||||||
//~| no `self` in the root
|
|
||||||
use super as B;
|
use super as B;
|
||||||
//~^ ERROR unresolved import `super` [E0432]
|
//~^ ERROR unresolved import `super` [E0432]
|
||||||
//~| no `super` in the root
|
//~| no `super` in the root
|
||||||
|
@ -11,4 +11,7 @@
|
|||||||
use foo::self; //~ ERROR unresolved import `foo::self`
|
use foo::self; //~ ERROR unresolved import `foo::self`
|
||||||
//~^ ERROR `self` imports are only allowed within a { } list
|
//~^ ERROR `self` imports are only allowed within a { } list
|
||||||
|
|
||||||
|
use std::mem::self;
|
||||||
|
//~^ ERROR `self` imports are only allowed within a { } list
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user