Skip to content

Commit 086b1f7

Browse files
committed
resolve: Migrate one more special ambiguity for glob vs non-glob bindings
in the same module to the usual ambiguity infra in `resolve_ident_in_scope_set`
1 parent e471ea8 commit 086b1f7

File tree

8 files changed

+9
-92
lines changed

8 files changed

+9
-92
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
848848
== Some(&self.binding_parent_modules[&binding])
849849
{
850850
// FIXME: this error is too conservative and technically unnecessary now when module
851-
// scope is split into two scopes, remove it with lang team approval.
851+
// scope is split into two scopes, at least when not resolving in `ScopeSet::Module`,
852+
// remove it with lang team approval.
852853
Some(AmbiguityKind::GlobVsExpanded)
853854
} else {
854855
None

compiler/rustc_resolve/src/imports.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -390,20 +390,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
390390
(old_glob @ true, false) | (old_glob @ false, true) => {
391391
let (glob_binding, non_glob_binding) =
392392
if old_glob { (old_binding, binding) } else { (binding, old_binding) };
393-
if ns == MacroNS
394-
&& non_glob_binding.expansion != LocalExpnId::ROOT
395-
&& glob_binding.res() != non_glob_binding.res()
396-
{
397-
resolution.non_glob_binding = Some(this.new_ambiguity_binding(
398-
AmbiguityKind::GlobVsExpanded,
399-
non_glob_binding,
400-
glob_binding,
401-
false,
402-
));
403-
} else {
404-
resolution.non_glob_binding = Some(non_glob_binding);
405-
}
406-
393+
resolution.non_glob_binding = Some(non_glob_binding);
407394
if let Some(old_glob_binding) = resolution.glob_binding {
408395
assert!(old_glob_binding.is_glob_import());
409396
if glob_binding.res() != old_glob_binding.res() {

tests/ui/imports/issue-114682-1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ mac!();
2222
fn main() {
2323
A!();
2424
//~^ ERROR `A` is ambiguous
25-
//~| ERROR `A` is ambiguous
2625
}
Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
error[E0659]: `A` is ambiguous
2-
--> $DIR/issue-114682-1.rs:23:5
3-
|
4-
LL | A!();
5-
| ^ ambiguous name
6-
|
7-
= 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
8-
note: `A` could refer to the macro defined here
9-
--> $DIR/issue-114682-1.rs:7:9
10-
|
11-
LL | / pub macro A() {
12-
LL | | println!("non import")
13-
LL | | }
14-
| |_________^
15-
...
16-
LL | mac!();
17-
| ------ in this macro invocation
18-
note: `A` could also refer to the macro imported here
19-
--> $DIR/issue-114682-1.rs:19:9
20-
|
21-
LL | pub use m::*;
22-
| ^^^^
23-
= help: consider adding an explicit import of `A` to disambiguate
24-
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
25-
261
error[E0659]: `A` is ambiguous
272
--> $DIR/issue-114682-1.rs:23:5
283
|
@@ -49,6 +24,6 @@ LL | pub use m::*;
4924
= help: use `crate::A` to refer to this macro unambiguously
5025
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
5126

52-
error: aborting due to 2 previous errors
27+
error: aborting due to 1 previous error
5328

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

tests/ui/imports/local-modularized-tricky-fail-1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ mod inner1 {
2727
}
2828

2929
exported!(); //~ ERROR `exported` is ambiguous
30-
//~| ERROR `exported` is ambiguous
3130

3231
mod inner2 {
3332
define_exported!();

tests/ui/imports/local-modularized-tricky-fail-1.stderr

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
error[E0659]: `exported` is ambiguous
2-
--> $DIR/local-modularized-tricky-fail-1.rs:29:1
3-
|
4-
LL | exported!();
5-
| ^^^^^^^^ ambiguous name
6-
|
7-
= 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
8-
note: `exported` could refer to the macro defined here
9-
--> $DIR/local-modularized-tricky-fail-1.rs:6:5
10-
|
11-
LL | / macro_rules! exported {
12-
LL | | () => ()
13-
LL | | }
14-
| |_____^
15-
...
16-
LL | define_exported!();
17-
| ------------------ in this macro invocation
18-
note: `exported` could also refer to the macro imported here
19-
--> $DIR/local-modularized-tricky-fail-1.rs:23:5
20-
|
21-
LL | use inner1::*;
22-
| ^^^^^^^^^
23-
= help: consider adding an explicit import of `exported` to disambiguate
24-
= note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
25-
261
error[E0659]: `exported` is ambiguous
272
--> $DIR/local-modularized-tricky-fail-1.rs:29:1
283
|
@@ -50,7 +25,7 @@ LL | use inner1::*;
5025
= note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
5126

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

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

94-
error: aborting due to 4 previous errors
69+
error: aborting due to 3 previous errors
9570

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

tests/ui/imports/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod m1 {
1313

1414
mod m2 {
1515
use two_macros::*;
16-
m! { //~ ERROR ambiguous
16+
m! {
1717
use crate::foo::m;
1818
}
1919
}

tests/ui/imports/macros.stderr

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
error[E0659]: `m` is ambiguous
2-
--> $DIR/macros.rs:16:5
3-
|
4-
LL | m! {
5-
| ^ ambiguous name
6-
|
7-
= 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
8-
note: `m` could refer to the macro imported here
9-
--> $DIR/macros.rs:17:13
10-
|
11-
LL | use crate::foo::m;
12-
| ^^^^^^^^^^^^^
13-
note: `m` could also refer to the macro imported here
14-
--> $DIR/macros.rs:15:9
15-
|
16-
LL | use two_macros::*;
17-
| ^^^^^^^^^^^^^
18-
= help: consider adding an explicit import of `m` to disambiguate
19-
201
error[E0659]: `m` is ambiguous
212
--> $DIR/macros.rs:29:9
223
|
@@ -36,6 +17,6 @@ LL | use two_macros::m;
3617
| ^^^^^^^^^^^^^
3718
= help: use `self::m` to refer to this macro unambiguously
3819

39-
error: aborting due to 2 previous errors
20+
error: aborting due to 1 previous error
4021

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

0 commit comments

Comments
 (0)