Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
== Some(&self.binding_parent_modules[&binding])
{
// FIXME: this error is too conservative and technically unnecessary now when module
// scope is split into two scopes, remove it with lang team approval.
// scope is split into two scopes, at least when not resolving in `ScopeSet::Module`,
// remove it with lang team approval.
Some(AmbiguityKind::GlobVsExpanded)
} else {
None
Expand Down
15 changes: 1 addition & 14 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
(old_glob @ true, false) | (old_glob @ false, true) => {
let (glob_binding, non_glob_binding) =
if old_glob { (old_binding, binding) } else { (binding, old_binding) };
if ns == MacroNS
&& non_glob_binding.expansion != LocalExpnId::ROOT
&& glob_binding.res() != non_glob_binding.res()
{
resolution.non_glob_binding = Some(this.new_ambiguity_binding(
AmbiguityKind::GlobVsExpanded,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yaahc you may be interested, this PR removes one of the "gray areas".

non_glob_binding,
glob_binding,
false,
));
} else {
resolution.non_glob_binding = Some(non_glob_binding);
}

resolution.non_glob_binding = Some(non_glob_binding);
if let Some(old_glob_binding) = resolution.glob_binding {
assert!(old_glob_binding.is_glob_import());
if glob_binding.res() != old_glob_binding.res() {
Expand Down
1 change: 0 additions & 1 deletion tests/ui/imports/issue-114682-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ mac!();
fn main() {
A!();
//~^ ERROR `A` is ambiguous
//~| ERROR `A` is ambiguous
}
27 changes: 1 addition & 26 deletions tests/ui/imports/issue-114682-1.stderr
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
error[E0659]: `A` is ambiguous
--> $DIR/issue-114682-1.rs:23:5
|
LL | A!();
| ^ ambiguous name
|
= note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
note: `A` could refer to the macro defined here
--> $DIR/issue-114682-1.rs:7:9
|
LL | / pub macro A() {
LL | | println!("non import")
LL | | }
| |_________^
...
LL | mac!();
| ------ in this macro invocation
note: `A` could also refer to the macro imported here
--> $DIR/issue-114682-1.rs:19:9
|
LL | pub use m::*;
| ^^^^
= help: consider adding an explicit import of `A` to disambiguate
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0659]: `A` is ambiguous
--> $DIR/issue-114682-1.rs:23:5
|
Expand All @@ -49,6 +24,6 @@ LL | pub use m::*;
= help: use `crate::A` to refer to this macro unambiguously
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0659`.
1 change: 0 additions & 1 deletion tests/ui/imports/local-modularized-tricky-fail-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ mod inner1 {
}

exported!(); //~ ERROR `exported` is ambiguous
//~| ERROR `exported` is ambiguous

mod inner2 {
define_exported!();
Expand Down
31 changes: 3 additions & 28 deletions tests/ui/imports/local-modularized-tricky-fail-1.stderr
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
error[E0659]: `exported` is ambiguous
--> $DIR/local-modularized-tricky-fail-1.rs:29:1
|
LL | exported!();
| ^^^^^^^^ ambiguous name
|
= note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
note: `exported` could refer to the macro defined here
--> $DIR/local-modularized-tricky-fail-1.rs:6:5
|
LL | / macro_rules! exported {
LL | | () => ()
LL | | }
| |_____^
...
LL | define_exported!();
| ------------------ in this macro invocation
note: `exported` could also refer to the macro imported here
--> $DIR/local-modularized-tricky-fail-1.rs:23:5
|
LL | use inner1::*;
| ^^^^^^^^^
= help: consider adding an explicit import of `exported` to disambiguate
= note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0659]: `exported` is ambiguous
--> $DIR/local-modularized-tricky-fail-1.rs:29:1
|
Expand Down Expand Up @@ -50,7 +25,7 @@ LL | use inner1::*;
= note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0659]: `panic` is ambiguous
--> $DIR/local-modularized-tricky-fail-1.rs:37:5
--> $DIR/local-modularized-tricky-fail-1.rs:36:5
|
LL | panic!();
| ^^^^^ ambiguous name
Expand All @@ -71,7 +46,7 @@ LL | define_panic!();
= note: this error originates in the macro `define_panic` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0659]: `include` is ambiguous
--> $DIR/local-modularized-tricky-fail-1.rs:48:1
--> $DIR/local-modularized-tricky-fail-1.rs:47:1
|
LL | include!();
| ^^^^^^^ ambiguous name
Expand All @@ -91,6 +66,6 @@ LL | define_include!();
= help: use `crate::include` to refer to this macro unambiguously
= note: this error originates in the macro `define_include` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0659`.
2 changes: 1 addition & 1 deletion tests/ui/imports/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod m1 {

mod m2 {
use two_macros::*;
m! { //~ ERROR ambiguous
m! {
use crate::foo::m;
}
}
Expand Down
21 changes: 1 addition & 20 deletions tests/ui/imports/macros.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
error[E0659]: `m` is ambiguous
--> $DIR/macros.rs:16:5
|
LL | m! {
| ^ ambiguous name
|
= note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
note: `m` could refer to the macro imported here
--> $DIR/macros.rs:17:13
|
LL | use crate::foo::m;
| ^^^^^^^^^^^^^
note: `m` could also refer to the macro imported here
--> $DIR/macros.rs:15:9
|
LL | use two_macros::*;
| ^^^^^^^^^^^^^
= help: consider adding an explicit import of `m` to disambiguate

error[E0659]: `m` is ambiguous
--> $DIR/macros.rs:29:9
|
Expand All @@ -36,6 +17,6 @@ LL | use two_macros::m;
| ^^^^^^^^^^^^^
= help: use `self::m` to refer to this macro unambiguously

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0659`.