Skip to content

Commit ef09ed2

Browse files
committed
resolve: Relax macro resolution consistency check to account for any errors
1 parent 2e8a54a commit ef09ed2

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

compiler/rustc_resolve/src/macros.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_feature::is_builtin_attr_name;
1919
use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
2020
use rustc_hir::def_id;
2121
use rustc_middle::middle::stability;
22-
use rustc_middle::{span_bug, ty};
22+
use rustc_middle::ty;
2323
use rustc_session::lint::builtin::UNUSED_MACROS;
2424
use rustc_session::Session;
2525
use rustc_span::edition::Edition;
@@ -885,11 +885,11 @@ impl<'a> Resolver<'a> {
885885
initial_res: Option<Res>,
886886
res: Res| {
887887
if let Some(initial_res) = initial_res {
888-
if res != initial_res && res != Res::Err && this.ambiguity_errors.is_empty() {
888+
if res != initial_res {
889889
// Make sure compilation does not succeed if preferred macro resolution
890890
// has changed after the macro had been expanded. In theory all such
891-
// situations should be reported as ambiguity errors, so this is a bug.
892-
span_bug!(span, "inconsistent resolution for a macro");
891+
// situations should be reported as errors, so this is a bug.
892+
this.session.delay_span_bug(span, "inconsistent resolution for a macro");
893893
}
894894
} else {
895895
// It's possible that the macro was unresolved (indeterminate) and silently
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
macro_rules! define_other_core {
2+
( ) => {
3+
extern crate std as core;
4+
//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
5+
};
6+
}
7+
8+
fn main() {
9+
core::panic!();
10+
}
11+
12+
define_other_core!();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
2+
--> $DIR/issue-78325-inconsistent-resolution.rs:3:9
3+
|
4+
LL | extern crate std as core;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6+
...
7+
LL | define_other_core!();
8+
| --------------------- in this macro invocation
9+
|
10+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
11+
12+
error: aborting due to previous error
13+

0 commit comments

Comments
 (0)