Auto merge of #125722 - Urgau:non_local_defs-macro-to-change, r=estebank
Indicate in `non_local_defs` lint that the macro needs to change This PR adds a note to indicate that the macro needs to change in the `non_local_definitions` lint output. Address https://github.com/rust-lang/rust/pull/125089#discussion_r1616311862 Fixes #125681 r? `@estebank`
This commit is contained in:
commit
1d1356d0f6
5 changed files with 23 additions and 4 deletions
|
@ -1362,6 +1362,7 @@ pub enum NonLocalDefinitionsDiag {
|
|||
has_trait: bool,
|
||||
self_ty_str: String,
|
||||
of_trait_str: Option<String>,
|
||||
macro_to_change: Option<(String, &'static str)>,
|
||||
},
|
||||
MacroRules {
|
||||
depth: u32,
|
||||
|
@ -1387,6 +1388,7 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
|
|||
has_trait,
|
||||
self_ty_str,
|
||||
of_trait_str,
|
||||
macro_to_change,
|
||||
} => {
|
||||
diag.primary_message(fluent::lint_non_local_definitions_impl);
|
||||
diag.arg("depth", depth);
|
||||
|
@ -1397,6 +1399,15 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
|
|||
diag.arg("of_trait_str", of_trait_str);
|
||||
}
|
||||
|
||||
if let Some((macro_to_change, macro_kind)) = macro_to_change {
|
||||
diag.arg("macro_to_change", macro_to_change);
|
||||
diag.arg("macro_kind", macro_kind);
|
||||
diag.note(fluent::lint_macro_to_change);
|
||||
}
|
||||
if let Some(cargo_update) = cargo_update {
|
||||
diag.subdiagnostic(&diag.dcx, cargo_update);
|
||||
}
|
||||
|
||||
if has_trait {
|
||||
diag.note(fluent::lint_bounds);
|
||||
diag.note(fluent::lint_with_trait);
|
||||
|
@ -1422,9 +1433,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
|
|||
);
|
||||
}
|
||||
|
||||
if let Some(cargo_update) = cargo_update {
|
||||
diag.subdiagnostic(&diag.dcx, cargo_update);
|
||||
}
|
||||
if let Some(const_anon) = const_anon {
|
||||
diag.note(fluent::lint_exception);
|
||||
if let Some(const_anon) = const_anon {
|
||||
|
|
|
@ -258,6 +258,13 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
|
|||
Some((cx.tcx.def_span(parent), may_move))
|
||||
};
|
||||
|
||||
let macro_to_change =
|
||||
if let ExpnKind::Macro(kind, name) = item.span.ctxt().outer_expn_data().kind {
|
||||
Some((name.to_string(), kind.descr()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
NON_LOCAL_DEFINITIONS,
|
||||
ms,
|
||||
|
@ -274,6 +281,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
|
|||
move_to,
|
||||
may_remove,
|
||||
has_trait: impl_.of_trait.is_some(),
|
||||
macro_to_change,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue