Also simplify macro_rules doctest code

This commit is contained in:
Urgau 2024-06-13 19:23:30 +02:00
parent ab0e72781f
commit 94c282197d
2 changed files with 6 additions and 10 deletions

View File

@ -1368,8 +1368,7 @@ pub enum NonLocalDefinitionsDiag {
depth: u32, depth: u32,
body_kind_descr: &'static str, body_kind_descr: &'static str,
body_name: String, body_name: String,
help: Option<()>, doctest: bool,
doctest_help: Option<()>,
cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>, cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
}, },
} }
@ -1448,8 +1447,7 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
depth, depth,
body_kind_descr, body_kind_descr,
body_name, body_name,
help, doctest,
doctest_help,
cargo_update, cargo_update,
} => { } => {
diag.primary_message(fluent::lint_non_local_definitions_macro_rules); diag.primary_message(fluent::lint_non_local_definitions_macro_rules);
@ -1457,11 +1455,10 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
diag.arg("body_kind_descr", body_kind_descr); diag.arg("body_kind_descr", body_kind_descr);
diag.arg("body_name", body_name); diag.arg("body_name", body_name);
if let Some(()) = help { if doctest {
diag.help(fluent::lint_help);
}
if let Some(()) = doctest_help {
diag.help(fluent::lint_help_doctest); diag.help(fluent::lint_help_doctest);
} else {
diag.help(fluent::lint_help);
} }
diag.note(fluent::lint_non_local); diag.note(fluent::lint_non_local);

View File

@ -304,8 +304,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
.map(|s| s.to_ident_string()) .map(|s| s.to_ident_string())
.unwrap_or_else(|| "<unnameable>".to_string()), .unwrap_or_else(|| "<unnameable>".to_string()),
cargo_update: cargo_update(), cargo_update: cargo_update(),
help: (!is_at_toplevel_doctest()).then_some(()), doctest: is_at_toplevel_doctest(),
doctest_help: is_at_toplevel_doctest().then_some(()),
}, },
) )
} }