1
Fork 0

Add missing #[rustc_lint_diagnostics] attributes.

Prior to the previous commit, `#[rust_lint_diagnostics]` attributes
could only be used on methods with an `impl Into<{D,Subd}iagMessage>`
parameter. But there are many other nearby diagnostic methods (e.g.
`Diag::span`) that don't take such a parameter and should have the
attribute.

This commit adds the missing attribute to these `Diag` methods. This
requires adding some missing
`#[allow(rustc::diagnostic_outside_of_impl)]` markers at call sites to
these methods.
This commit is contained in:
Nicholas Nethercote 2024-02-29 08:53:46 +11:00
parent b7d58eef4b
commit 3591e77b35
6 changed files with 45 additions and 3 deletions

View file

@ -76,6 +76,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
/// LL | for (key, value) in dict { /// LL | for (key, value) in dict {
/// | ^^^^ /// | ^^^^
/// ``` /// ```
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
pub(super) fn add_moved_or_invoked_closure_note( pub(super) fn add_moved_or_invoked_closure_note(
&self, &self,
location: Location, location: Location,
@ -585,6 +586,7 @@ impl UseSpans<'_> {
} }
/// Add a span label to the arguments of the closure, if it exists. /// Add a span label to the arguments of the closure, if it exists.
#[allow(rustc::diagnostic_outside_of_impl)]
pub(super) fn args_subdiag( pub(super) fn args_subdiag(
self, self,
dcx: &rustc_errors::DiagCtxt, dcx: &rustc_errors::DiagCtxt,
@ -598,6 +600,7 @@ impl UseSpans<'_> {
/// Add a span label to the use of the captured variable, if it exists. /// Add a span label to the use of the captured variable, if it exists.
/// only adds label to the `path_span` /// only adds label to the `path_span`
#[allow(rustc::diagnostic_outside_of_impl)]
pub(super) fn var_path_only_subdiag( pub(super) fn var_path_only_subdiag(
self, self,
dcx: &rustc_errors::DiagCtxt, dcx: &rustc_errors::DiagCtxt,
@ -635,6 +638,7 @@ impl UseSpans<'_> {
} }
/// Add a subdiagnostic to the use of the captured variable, if it exists. /// Add a subdiagnostic to the use of the captured variable, if it exists.
#[allow(rustc::diagnostic_outside_of_impl)]
pub(super) fn var_subdiag( pub(super) fn var_subdiag(
self, self,
dcx: &rustc_errors::DiagCtxt, dcx: &rustc_errors::DiagCtxt,
@ -1008,6 +1012,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
self.borrow_spans(span, borrow.reserve_location) self.borrow_spans(span, borrow.reserve_location)
} }
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn explain_captures( fn explain_captures(
&mut self, &mut self,

View file

@ -201,6 +201,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// For generic associated types (GATs) which implied 'static requirement // For generic associated types (GATs) which implied 'static requirement
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait // from higher-ranked trait bounds (HRTB). Try to locate span of the trait
// and the span which bounded to the trait for adding 'static lifetime suggestion // and the span which bounded to the trait for adding 'static lifetime suggestion
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn suggest_static_lifetime_for_gat_from_hrtb( fn suggest_static_lifetime_for_gat_from_hrtb(
&self, &self,
@ -255,9 +256,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
hrtb_bounds.iter().for_each(|bound| { hrtb_bounds.iter().for_each(|bound| {
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; }; let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
// FIXME: make this translatable
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)]
diag.span_note( diag.span_note(
*trait_span, *trait_span,
"due to current limitations in the borrow checker, this implies a `'static` lifetime" "due to current limitations in the borrow checker, this implies a `'static` lifetime"
@ -581,6 +579,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
/// executing... /// executing...
/// = note: ...therefore, returned references to captured variables will escape the closure /// = note: ...therefore, returned references to captured variables will escape the closure
/// ``` /// ```
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
fn report_fnmut_error( fn report_fnmut_error(
&self, &self,
errci: &ErrorConstraintInfo<'tcx>, errci: &ErrorConstraintInfo<'tcx>,
@ -762,6 +761,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
/// | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it /// | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it
/// | is returning data with lifetime `'b` /// | is returning data with lifetime `'b`
/// ``` /// ```
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
fn report_general_error(&self, errci: &ErrorConstraintInfo<'tcx>) -> Diag<'tcx> { fn report_general_error(&self, errci: &ErrorConstraintInfo<'tcx>) -> Diag<'tcx> {
let ErrorConstraintInfo { let ErrorConstraintInfo {
fr, fr,
@ -823,6 +823,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
/// LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + 'a { /// LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + 'a {
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// ``` /// ```
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn add_static_impl_trait_suggestion( fn add_static_impl_trait_suggestion(
&self, &self,
@ -974,6 +975,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
self.suggest_constrain_dyn_trait_in_impl(diag, &visitor.0, ident, self_ty); self.suggest_constrain_dyn_trait_in_impl(diag, &visitor.0, ident, self_ty);
} }
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
#[instrument(skip(self, err), level = "debug")] #[instrument(skip(self, err), level = "debug")]
fn suggest_constrain_dyn_trait_in_impl( fn suggest_constrain_dyn_trait_in_impl(
@ -1037,6 +1039,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
suggest_adding_lifetime_params(self.infcx.tcx, sub, ty_sup, ty_sub, diag); suggest_adding_lifetime_params(self.infcx.tcx, sub, ty_sup, ty_sub, diag);
} }
#[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) { fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) {
let map = self.infcx.tcx.hir(); let map = self.infcx.tcx.hir();

View file

@ -598,6 +598,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// ///
/// In the meantime, though, callsites are required to deal with the "bug" /// In the meantime, though, callsites are required to deal with the "bug"
/// locally in whichever way makes the most sense. /// locally in whichever way makes the most sense.
#[rustc_lint_diagnostics]
#[track_caller] #[track_caller]
pub fn downgrade_to_delayed_bug(&mut self) { pub fn downgrade_to_delayed_bug(&mut self) {
assert!( assert!(
@ -631,6 +632,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_span_labels, with_fn! { with_span_labels,
/// Labels all the given spans with the provided label. /// Labels all the given spans with the provided label.
/// See [`Self::span_label()`] for more information. /// See [`Self::span_label()`] for more information.
#[rustc_lint_diagnostics]
pub fn span_labels(&mut self, spans: impl IntoIterator<Item = Span>, label: &str) -> &mut Self { pub fn span_labels(&mut self, spans: impl IntoIterator<Item = Span>, label: &str) -> &mut Self {
for span in spans { for span in spans {
self.span_label(span, label.to_string()); self.span_label(span, label.to_string());
@ -638,6 +640,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self self
} } } }
#[rustc_lint_diagnostics]
pub fn replace_span_with(&mut self, after: Span, keep_label: bool) -> &mut Self { pub fn replace_span_with(&mut self, after: Span, keep_label: bool) -> &mut Self {
let before = self.span.clone(); let before = self.span.clone();
self.span(after); self.span(after);
@ -653,6 +656,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self self
} }
#[rustc_lint_diagnostics]
pub fn note_expected_found( pub fn note_expected_found(
&mut self, &mut self,
expected_label: &dyn fmt::Display, expected_label: &dyn fmt::Display,
@ -663,6 +667,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self.note_expected_found_extra(expected_label, expected, found_label, found, &"", &"") self.note_expected_found_extra(expected_label, expected, found_label, found, &"", &"")
} }
#[rustc_lint_diagnostics]
pub fn note_expected_found_extra( pub fn note_expected_found_extra(
&mut self, &mut self,
expected_label: &dyn fmt::Display, expected_label: &dyn fmt::Display,
@ -705,6 +710,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self self
} }
#[rustc_lint_diagnostics]
pub fn note_trait_signature(&mut self, name: Symbol, signature: String) -> &mut Self { pub fn note_trait_signature(&mut self, name: Symbol, signature: String) -> &mut Self {
self.highlighted_note(vec![ self.highlighted_note(vec![
StringPart::normal(format!("`{name}` from trait: `")), StringPart::normal(format!("`{name}` from trait: `")),
@ -722,12 +728,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self self
} } } }
#[rustc_lint_diagnostics]
fn highlighted_note(&mut self, msg: Vec<StringPart>) -> &mut Self { fn highlighted_note(&mut self, msg: Vec<StringPart>) -> &mut Self {
self.sub_with_highlights(Level::Note, msg, MultiSpan::new()); self.sub_with_highlights(Level::Note, msg, MultiSpan::new());
self self
} }
/// This is like [`Diag::note()`], but it's only printed once. /// This is like [`Diag::note()`], but it's only printed once.
#[rustc_lint_diagnostics]
pub fn note_once(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self { pub fn note_once(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self {
self.sub(Level::OnceNote, msg, MultiSpan::new()); self.sub(Level::OnceNote, msg, MultiSpan::new());
self self
@ -748,6 +756,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// Prints the span with a note above it. /// Prints the span with a note above it.
/// This is like [`Diag::note_once()`], but it gets its own span. /// This is like [`Diag::note_once()`], but it gets its own span.
#[rustc_lint_diagnostics]
pub fn span_note_once<S: Into<MultiSpan>>( pub fn span_note_once<S: Into<MultiSpan>>(
&mut self, &mut self,
sp: S, sp: S,
@ -786,12 +795,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
} } } }
/// This is like [`Diag::help()`], but it's only printed once. /// This is like [`Diag::help()`], but it's only printed once.
#[rustc_lint_diagnostics]
pub fn help_once(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self { pub fn help_once(&mut self, msg: impl Into<SubdiagMessage>) -> &mut Self {
self.sub(Level::OnceHelp, msg, MultiSpan::new()); self.sub(Level::OnceHelp, msg, MultiSpan::new());
self self
} }
/// Add a help message attached to this diagnostic with a customizable highlighted message. /// Add a help message attached to this diagnostic with a customizable highlighted message.
#[rustc_lint_diagnostics]
pub fn highlighted_help(&mut self, msg: Vec<StringPart>) -> &mut Self { pub fn highlighted_help(&mut self, msg: Vec<StringPart>) -> &mut Self {
self.sub_with_highlights(Level::Help, msg, MultiSpan::new()); self.sub_with_highlights(Level::Help, msg, MultiSpan::new());
self self
@ -812,12 +823,14 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// Disallow attaching suggestions this diagnostic. /// Disallow attaching suggestions this diagnostic.
/// Any suggestions attached e.g. with the `span_suggestion_*` methods /// Any suggestions attached e.g. with the `span_suggestion_*` methods
/// (before and after the call to `disable_suggestions`) will be ignored. /// (before and after the call to `disable_suggestions`) will be ignored.
#[rustc_lint_diagnostics]
pub fn disable_suggestions(&mut self) -> &mut Self { pub fn disable_suggestions(&mut self) -> &mut Self {
self.suggestions = Err(SuggestionsDisabled); self.suggestions = Err(SuggestionsDisabled);
self self
} }
/// Helper for pushing to `self.suggestions`, if available (not disable). /// Helper for pushing to `self.suggestions`, if available (not disable).
#[rustc_lint_diagnostics]
fn push_suggestion(&mut self, suggestion: CodeSuggestion) { fn push_suggestion(&mut self, suggestion: CodeSuggestion) {
for subst in &suggestion.substitutions { for subst in &suggestion.substitutions {
for part in &subst.parts { for part in &subst.parts {
@ -838,6 +851,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_multipart_suggestion, with_fn! { with_multipart_suggestion,
/// Show a suggestion that has multiple parts to it. /// Show a suggestion that has multiple parts to it.
/// In other words, multiple changes need to be applied as part of this suggestion. /// In other words, multiple changes need to be applied as part of this suggestion.
#[rustc_lint_diagnostics]
pub fn multipart_suggestion( pub fn multipart_suggestion(
&mut self, &mut self,
msg: impl Into<SubdiagMessage>, msg: impl Into<SubdiagMessage>,
@ -854,6 +868,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic. /// Show a suggestion that has multiple parts to it, always as it's own subdiagnostic.
/// In other words, multiple changes need to be applied as part of this suggestion. /// In other words, multiple changes need to be applied as part of this suggestion.
#[rustc_lint_diagnostics]
pub fn multipart_suggestion_verbose( pub fn multipart_suggestion_verbose(
&mut self, &mut self,
msg: impl Into<SubdiagMessage>, msg: impl Into<SubdiagMessage>,
@ -869,6 +884,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
} }
/// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`]. /// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`].
#[rustc_lint_diagnostics]
pub fn multipart_suggestion_with_style( pub fn multipart_suggestion_with_style(
&mut self, &mut self,
msg: impl Into<SubdiagMessage>, msg: impl Into<SubdiagMessage>,
@ -911,6 +927,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// be from the message, showing the span label inline would be visually unpleasant /// be from the message, showing the span label inline would be visually unpleasant
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't /// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
/// improve understandability. /// improve understandability.
#[rustc_lint_diagnostics]
pub fn tool_only_multipart_suggestion( pub fn tool_only_multipart_suggestion(
&mut self, &mut self,
msg: impl Into<SubdiagMessage>, msg: impl Into<SubdiagMessage>,
@ -943,6 +960,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// * may contain a name of a function, variable, or type, but not whole expressions /// * may contain a name of a function, variable, or type, but not whole expressions
/// ///
/// See `CodeSuggestion` for more information. /// See `CodeSuggestion` for more information.
#[rustc_lint_diagnostics]
pub fn span_suggestion( pub fn span_suggestion(
&mut self, &mut self,
sp: Span, sp: Span,
@ -961,6 +979,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
} } } }
/// [`Diag::span_suggestion()`] but you can set the [`SuggestionStyle`]. /// [`Diag::span_suggestion()`] but you can set the [`SuggestionStyle`].
#[rustc_lint_diagnostics]
pub fn span_suggestion_with_style( pub fn span_suggestion_with_style(
&mut self, &mut self,
sp: Span, sp: Span,
@ -986,6 +1005,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_span_suggestion_verbose, with_fn! { with_span_suggestion_verbose,
/// Always show the suggested change. /// Always show the suggested change.
#[rustc_lint_diagnostics]
pub fn span_suggestion_verbose( pub fn span_suggestion_verbose(
&mut self, &mut self,
sp: Span, sp: Span,
@ -1006,6 +1026,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_span_suggestions, with_fn! { with_span_suggestions,
/// Prints out a message with multiple suggested edits of the code. /// Prints out a message with multiple suggested edits of the code.
/// See also [`Diag::span_suggestion()`]. /// See also [`Diag::span_suggestion()`].
#[rustc_lint_diagnostics]
pub fn span_suggestions( pub fn span_suggestions(
&mut self, &mut self,
sp: Span, sp: Span,
@ -1022,6 +1043,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
) )
} } } }
#[rustc_lint_diagnostics]
pub fn span_suggestions_with_style( pub fn span_suggestions_with_style(
&mut self, &mut self,
sp: Span, sp: Span,
@ -1052,6 +1074,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// Prints out a message with multiple suggested edits of the code, where each edit consists of /// Prints out a message with multiple suggested edits of the code, where each edit consists of
/// multiple parts. /// multiple parts.
/// See also [`Diag::multipart_suggestion()`]. /// See also [`Diag::multipart_suggestion()`].
#[rustc_lint_diagnostics]
pub fn multipart_suggestions( pub fn multipart_suggestions(
&mut self, &mut self,
msg: impl Into<SubdiagMessage>, msg: impl Into<SubdiagMessage>,
@ -1098,6 +1121,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// inline, it will only show the message and not the suggestion. /// inline, it will only show the message and not the suggestion.
/// ///
/// See `CodeSuggestion` for more information. /// See `CodeSuggestion` for more information.
#[rustc_lint_diagnostics]
pub fn span_suggestion_short( pub fn span_suggestion_short(
&mut self, &mut self,
sp: Span, sp: Span,
@ -1121,6 +1145,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// be from the message, showing the span label inline would be visually unpleasant /// be from the message, showing the span label inline would be visually unpleasant
/// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't /// (marginally overlapping spans or multiline spans) and showing the snippet window wouldn't
/// improve understandability. /// improve understandability.
#[rustc_lint_diagnostics]
pub fn span_suggestion_hidden( pub fn span_suggestion_hidden(
&mut self, &mut self,
sp: Span, sp: Span,
@ -1165,6 +1190,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
/// [rustc_macros::Subdiagnostic]). Performs eager translation of any translatable messages /// [rustc_macros::Subdiagnostic]). Performs eager translation of any translatable messages
/// used in the subdiagnostic, so suitable for use with repeated messages (i.e. re-use of /// used in the subdiagnostic, so suitable for use with repeated messages (i.e. re-use of
/// interpolated variables). /// interpolated variables).
#[rustc_lint_diagnostics]
pub fn subdiagnostic( pub fn subdiagnostic(
&mut self, &mut self,
dcx: &crate::DiagCtxt, dcx: &crate::DiagCtxt,
@ -1180,6 +1206,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_span, with_fn! { with_span,
/// Add a span. /// Add a span.
#[rustc_lint_diagnostics]
pub fn span(&mut self, sp: impl Into<MultiSpan>) -> &mut Self { pub fn span(&mut self, sp: impl Into<MultiSpan>) -> &mut Self {
self.span = sp.into(); self.span = sp.into();
if let Some(span) = self.span.primary_span() { if let Some(span) = self.span.primary_span() {
@ -1188,6 +1215,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self self
} } } }
#[rustc_lint_diagnostics]
pub fn is_lint(&mut self, name: String, has_future_breakage: bool) -> &mut Self { pub fn is_lint(&mut self, name: String, has_future_breakage: bool) -> &mut Self {
self.is_lint = Some(IsLint { name, has_future_breakage }); self.is_lint = Some(IsLint { name, has_future_breakage });
self self
@ -1195,6 +1223,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_code, with_fn! { with_code,
/// Add an error code. /// Add an error code.
#[rustc_lint_diagnostics]
pub fn code(&mut self, code: ErrCode) -> &mut Self { pub fn code(&mut self, code: ErrCode) -> &mut Self {
self.code = Some(code); self.code = Some(code);
self self
@ -1202,6 +1231,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_primary_message, with_fn! { with_primary_message,
/// Add a primary message. /// Add a primary message.
#[rustc_lint_diagnostics]
pub fn primary_message(&mut self, msg: impl Into<DiagMessage>) -> &mut Self { pub fn primary_message(&mut self, msg: impl Into<DiagMessage>) -> &mut Self {
self.messages[0] = (msg.into(), Style::NoStyle); self.messages[0] = (msg.into(), Style::NoStyle);
self self
@ -1209,6 +1239,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
with_fn! { with_arg, with_fn! { with_arg,
/// Add an argument. /// Add an argument.
#[rustc_lint_diagnostics]
pub fn arg( pub fn arg(
&mut self, &mut self,
name: impl Into<DiagArgName>, name: impl Into<DiagArgName>,

View file

@ -2330,6 +2330,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
let hir_sig = tcx.hir().fn_sig_by_hir_id(hir_id); let hir_sig = tcx.hir().fn_sig_by_hir_id(hir_id);
if let Some(hir_sig) = hir_sig { if let Some(hir_sig) = hir_sig {
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
match terr { match terr {
TypeError::ArgumentMutability(idx) | TypeError::ArgumentSorts(_, idx) => { TypeError::ArgumentMutability(idx) | TypeError::ArgumentSorts(_, idx) => {
if let Some(ty) = hir_sig.decl.inputs.get(idx) { if let Some(ty) = hir_sig.decl.inputs.get(idx) {

View file

@ -168,6 +168,7 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
/// This variant allows you to control whether it is a library or language feature. /// This variant allows you to control whether it is a library or language feature.
/// Almost always, you want to use this for a language feature. If so, prefer /// Almost always, you want to use this for a language feature. If so, prefer
/// `add_feature_diagnostics`. /// `add_feature_diagnostics`.
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>( pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
err: &mut Diag<'_, G>, err: &mut Diag<'_, G>,
sess: &Session, sess: &Session,

View file

@ -312,6 +312,7 @@ impl Session {
) -> Diag<'a> { ) -> Diag<'a> {
let mut err = self.dcx().create_err(err); let mut err = self.dcx().create_err(err);
if err.code.is_none() { if err.code.is_none() {
#[allow(rustc::diagnostic_outside_of_impl)]
err.code(E0658); err.code(E0658);
} }
add_feature_diagnostics(&mut err, self, feature); add_feature_diagnostics(&mut err, self, feature);