X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_lint%2Fsrc%2Fnon_ascii_idents.rs;h=f130a98185d611aeb243c676e8b428d1c1068a01;hb=e385ca25be4e6893228bcc7b9c6020e98a0742ad;hp=dea9506acb200fcec3e4a02afdcd857cf64007e1;hpb=90711a86e5bdd4b0b65d293f0c2c48fd2db761b3;p=rust.git diff --git a/compiler/rustc_lint/src/non_ascii_idents.rs b/compiler/rustc_lint/src/non_ascii_idents.rs index dea9506acb2..f130a98185d 100644 --- a/compiler/rustc_lint/src/non_ascii_idents.rs +++ b/compiler/rustc_lint/src/non_ascii_idents.rs @@ -1,7 +1,10 @@ +use crate::lints::{ + ConfusableIdentifierPair, IdentifierNonAsciiChar, IdentifierUncommonCodepoints, + MixedScriptConfusables, +}; use crate::{EarlyContext, EarlyLintPass, LintContext}; use rustc_ast as ast; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::fluent; use rustc_span::symbol::Symbol; declare_lint! { @@ -180,21 +183,11 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) { continue; } has_non_ascii_idents = true; - cx.struct_span_lint( - NON_ASCII_IDENTS, - sp, - fluent::lint_identifier_non_ascii_char, - |lint| lint, - ); + cx.emit_spanned_lint(NON_ASCII_IDENTS, sp, IdentifierNonAsciiChar); if check_uncommon_codepoints && !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed) { - cx.struct_span_lint( - UNCOMMON_CODEPOINTS, - sp, - fluent::lint_identifier_uncommon_codepoints, - |lint| lint, - ) + cx.emit_spanned_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints); } } @@ -222,14 +215,13 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) { .entry(skeleton_sym) .and_modify(|(existing_symbol, existing_span, existing_is_ascii)| { if !*existing_is_ascii || !is_ascii { - cx.struct_span_lint( + cx.emit_spanned_lint( CONFUSABLE_IDENTS, sp, - fluent::lint_confusable_identifier_pair, - |lint| { - lint.set_arg("existing_sym", *existing_symbol) - .set_arg("sym", symbol) - .span_label(*existing_span, fluent::label) + ConfusableIdentifierPair { + existing_sym: *existing_symbol, + sym: symbol, + label: *existing_span, }, ); } @@ -331,24 +323,18 @@ enum ScriptSetUsage { } for ((sp, ch_list), script_set) in lint_reports { - cx.struct_span_lint( + let mut includes = String::new(); + for (idx, ch) in ch_list.into_iter().enumerate() { + if idx != 0 { + includes += ", "; + } + let char_info = format!("'{}' (U+{:04X})", ch, ch as u32); + includes += &char_info; + } + cx.emit_spanned_lint( MIXED_SCRIPT_CONFUSABLES, sp, - fluent::lint_mixed_script_confusables, - |lint| { - let mut includes = String::new(); - for (idx, ch) in ch_list.into_iter().enumerate() { - if idx != 0 { - includes += ", "; - } - let char_info = format!("'{}' (U+{:04X})", ch, ch as u32); - includes += &char_info; - } - lint.set_arg("set", script_set.to_string()) - .set_arg("includes", includes) - .note(fluent::includes_note) - .note(fluent::note) - }, + MixedScriptConfusables { set: script_set.to_string(), includes }, ); } }