1
Fork 0

Rollup merge of #78327 - petrochenkov:inconsist, r=Aaron1011

resolve: Relax macro resolution consistency check to account for any errors

The check was previously omitted only when ambiguity errors or `Res::Err` were encountered, but the "macro-expanded `extern crate` items cannot shadow..." error (at least) can cause same inconsistencies as well.

Fixes https://github.com/rust-lang/rust/issues/78325
This commit is contained in:
Jonas Schievink 2020-10-24 22:40:00 +02:00 committed by GitHub
commit 58ae889779
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 4 deletions

View file

@ -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;
@ -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