Skip to content

Commit

Permalink
resolve: Relax macro resolution consistency check to account for any …
Browse files Browse the repository at this point in the history
…errors
  • Loading branch information
petrochenkov committed Oct 24, 2020
1 parent 2e8a54a commit ef09ed2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rustc_feature::is_builtin_attr_name;
use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
use rustc_hir::def_id;
use rustc_middle::middle::stability;
use rustc_middle::{span_bug, ty};
use rustc_middle::ty;
use rustc_session::lint::builtin::UNUSED_MACROS;
use rustc_session::Session;
use rustc_span::edition::Edition;
Expand Down Expand Up @@ -885,11 +885,11 @@ impl<'a> Resolver<'a> {
initial_res: Option<Res>,
res: Res| {
if let Some(initial_res) = initial_res {
if res != initial_res && res != Res::Err && this.ambiguity_errors.is_empty() {
if res != initial_res {
// Make sure compilation does not succeed if preferred macro resolution
// has changed after the macro had been expanded. In theory all such
// situations should be reported as ambiguity errors, so this is a bug.
span_bug!(span, "inconsistent resolution for a macro");
// situations should be reported as errors, so this is a bug.
this.session.delay_span_bug(span, "inconsistent resolution for a macro");
}
} else {
// It's possible that the macro was unresolved (indeterminate) and silently
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/macros/issue-78325-inconsistent-resolution.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
macro_rules! define_other_core {
( ) => {
extern crate std as core;
//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
};
}

fn main() {
core::panic!();
}

define_other_core!();
13 changes: 13 additions & 0 deletions src/test/ui/macros/issue-78325-inconsistent-resolution.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
--> $DIR/issue-78325-inconsistent-resolution.rs:3:9
|
LL | extern crate std as core;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | define_other_core!();
| --------------------- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

0 comments on commit ef09ed2

Please sign in to comment.