From 43f9d0ae7e0733b1e4e7ad84165ddd57144f2db7 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Wed, 14 Apr 2021 18:56:13 +0200 Subject: [PATCH] Cancel emitting FCW lint if it is an edition fixing lint --- compiler/rustc_middle/src/lint.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 26e61ec8cf8..7adaf54fa23 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -272,11 +272,13 @@ pub fn struct_lint_level<'s, 'd>( // emit shouldn't be automatically fixed by rustfix. err.allow_suggestions(false); - // If this is a future incompatible lint it'll become a hard error, so - // we have to emit *something*. Also, if this lint occurs in the - // expansion of a macro from an external crate, allow individual lints - // to opt-out from being reported. - if future_incompatible.is_none() && !lint.report_in_external_macro { + // If this is a future incompatible that is not an edition fixing lint + // it'll become a hard error, so we have to emit *something*. Also, + // if this lint occurs in the expansion of a macro from an external crate, + // allow individual lints to opt-out from being reported. + let not_future_incompatible = + future_incompatible.map(|f| f.edition.is_some()).unwrap_or(true); + if not_future_incompatible && !lint.report_in_external_macro { err.cancel(); // Don't continue further, since we don't want to have // `diag_span_note_once` called for a diagnostic that isn't emitted.