|
| 1 | +#![deny(rustc::untranslatable_diagnostic)] |
| 2 | +#![deny(rustc::diagnostic_outside_of_impl)] |
| 3 | +use crate::lints::{ |
| 4 | + ConfusableIdentifierPair, IdentifierNonAsciiChar, IdentifierUncommonCodepoints, |
| 5 | + MixedScriptConfusables, |
| 6 | +}; |
1 | 7 | use crate::{EarlyContext, EarlyLintPass, LintContext};
|
2 | 8 | use rustc_ast as ast;
|
3 | 9 | use rustc_data_structures::fx::FxHashMap;
|
4 |
| -use rustc_errors::fluent; |
5 | 10 | use rustc_span::symbol::Symbol;
|
6 | 11 |
|
7 | 12 | declare_lint! {
|
@@ -180,21 +185,11 @@ impl EarlyLintPass for NonAsciiIdents {
|
180 | 185 | continue;
|
181 | 186 | }
|
182 | 187 | has_non_ascii_idents = true;
|
183 |
| - cx.struct_span_lint( |
184 |
| - NON_ASCII_IDENTS, |
185 |
| - sp, |
186 |
| - fluent::lint_identifier_non_ascii_char, |
187 |
| - |lint| lint, |
188 |
| - ); |
| 188 | + cx.emit_spanned_lint(NON_ASCII_IDENTS, sp, IdentifierNonAsciiChar); |
189 | 189 | if check_uncommon_codepoints
|
190 | 190 | && !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed)
|
191 | 191 | {
|
192 |
| - cx.struct_span_lint( |
193 |
| - UNCOMMON_CODEPOINTS, |
194 |
| - sp, |
195 |
| - fluent::lint_identifier_uncommon_codepoints, |
196 |
| - |lint| lint, |
197 |
| - ) |
| 192 | + cx.emit_spanned_lint(UNCOMMON_CODEPOINTS, sp, IdentifierUncommonCodepoints); |
198 | 193 | }
|
199 | 194 | }
|
200 | 195 |
|
@@ -222,14 +217,13 @@ impl EarlyLintPass for NonAsciiIdents {
|
222 | 217 | .entry(skeleton_sym)
|
223 | 218 | .and_modify(|(existing_symbol, existing_span, existing_is_ascii)| {
|
224 | 219 | if !*existing_is_ascii || !is_ascii {
|
225 |
| - cx.struct_span_lint( |
| 220 | + cx.emit_spanned_lint( |
226 | 221 | CONFUSABLE_IDENTS,
|
227 | 222 | sp,
|
228 |
| - fluent::lint_confusable_identifier_pair, |
229 |
| - |lint| { |
230 |
| - lint.set_arg("existing_sym", *existing_symbol) |
231 |
| - .set_arg("sym", symbol) |
232 |
| - .span_label(*existing_span, fluent::label) |
| 223 | + ConfusableIdentifierPair { |
| 224 | + existing_sym: *existing_symbol, |
| 225 | + sym: symbol, |
| 226 | + label: *existing_span, |
233 | 227 | },
|
234 | 228 | );
|
235 | 229 | }
|
@@ -331,24 +325,18 @@ impl EarlyLintPass for NonAsciiIdents {
|
331 | 325 | }
|
332 | 326 |
|
333 | 327 | for ((sp, ch_list), script_set) in lint_reports {
|
334 |
| - cx.struct_span_lint( |
| 328 | + let mut includes = String::new(); |
| 329 | + for (idx, ch) in ch_list.into_iter().enumerate() { |
| 330 | + if idx != 0 { |
| 331 | + includes += ", "; |
| 332 | + } |
| 333 | + let char_info = format!("'{}' (U+{:04X})", ch, ch as u32); |
| 334 | + includes += &char_info; |
| 335 | + } |
| 336 | + cx.emit_spanned_lint( |
335 | 337 | MIXED_SCRIPT_CONFUSABLES,
|
336 | 338 | sp,
|
337 |
| - fluent::lint_mixed_script_confusables, |
338 |
| - |lint| { |
339 |
| - let mut includes = String::new(); |
340 |
| - for (idx, ch) in ch_list.into_iter().enumerate() { |
341 |
| - if idx != 0 { |
342 |
| - includes += ", "; |
343 |
| - } |
344 |
| - let char_info = format!("'{}' (U+{:04X})", ch, ch as u32); |
345 |
| - includes += &char_info; |
346 |
| - } |
347 |
| - lint.set_arg("set", script_set.to_string()) |
348 |
| - .set_arg("includes", includes) |
349 |
| - .note(fluent::includes_note) |
350 |
| - .note(fluent::note) |
351 |
| - }, |
| 339 | + MixedScriptConfusables { set: script_set.to_string(), includes }, |
352 | 340 | );
|
353 | 341 | }
|
354 | 342 | }
|
|
0 commit comments