Skip to content

Commit 50b76d4

Browse files
committed
Convert early lints to diag structs
1 parent 034b6d0 commit 50b76d4

21 files changed

+656
-352
lines changed

compiler/rustc_lint/messages.ftl

+64-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
lint_abs_path_with_module =
2-
absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
1+
lint_abs_path_with_module = absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
2+
.suggestion = use `crate`
33
44
lint_ambiguous_glob_reexport = ambiguous glob re-exports
55
@@ -235,6 +235,8 @@ lint_dropping_references = calls to `std::mem::drop` with a reference instead of
235235
lint_duplicate_macro_attribute =
236236
duplicated attribute
237237
238+
lint_duplicate_matcher_binding = duplicate matcher binding
239+
238240
lint_elided_lifetime_not_allowed = `'_` cannot be used here
239241
240242
lint_enum_intrinsics_mem_discriminant =
@@ -312,6 +314,11 @@ lint_identifier_uncommon_codepoints = identifier contains {$codepoints_len ->
312314
313315
lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level
314316
317+
lint_ill_formed_attribute_input = {$num_suggestions ->
318+
[1] attribute must be of the form {$suggestions}
319+
*[other] valid forms for the attribute are {$suggestions}
320+
}
321+
315322
lint_improper_ctypes = `extern` {$desc} uses type `{$ty}`, which is not FFI-safe
316323
.label = not FFI-safe
317324
.note = the type is defined here
@@ -377,6 +384,7 @@ lint_incomplete_include =
377384
lint_inner_macro_attribute_unstable = inner macro attributes are unstable
378385
379386
lint_invalid_crate_type_value = invalid `crate_type` value
387+
.suggestion = did you mean
380388
381389
# FIXME: we should ordinalize $valid_up_to when we add support for doing so
382390
lint_invalid_from_utf8_checked = calls to `{$method}` with a invalid literal always return an error
@@ -412,8 +420,18 @@ lint_legacy_derive_helpers =
412420
lint_lintpass_by_hand = implementing `LintPass` by hand
413421
.help = try using `declare_lint_pass!` or `impl_lint_pass!` instead
414422
415-
lint_macro_expanded_macro_exports_accessed_by_absolute_paths =
416-
macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
423+
lint_macro_expanded_macro_exports_accessed_by_absolute_paths = macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
424+
.note = the macro is defined here
425+
426+
lint_macro_is_private = macro `{$ident}` is private
427+
428+
lint_macro_rule_never_used = {NUMBER($n, type: "ordinal") ->
429+
[1] first
430+
[one] {$n}st
431+
[two] {$n}nd
432+
[few] {$n}rd
433+
*[other] {$n}th
434+
} rule of macro `{$name}` is never used
417435
418436
lint_macro_use_deprecated =
419437
deprecated `#[macro_use]` attribute used to import macros should be replaced at use sites with a `use` item to import the macro instead
@@ -427,6 +445,10 @@ lint_map_unit_fn = `Iterator::map` call that discard the iterator's values
427445
.map_label = after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items
428446
.suggestion = you might have meant to use `Iterator::for_each`
429447
448+
lint_metavariable_still_repeating = variable '{$name}' is still repeating at this depth
449+
450+
lint_metavariable_wrong_operator = meta-variable repeats with different Kleene operator
451+
430452
lint_missing_fragment_specifier = missing fragment specifier
431453
432454
lint_mixed_script_confusables =
@@ -583,8 +605,14 @@ lint_pattern_in_bodiless = patterns aren't allowed in functions without bodies
583605
lint_pattern_in_foreign = patterns aren't allowed in foreign function declarations
584606
.label = pattern not allowed in foreign function
585607
608+
lint_private_extern_crate_reexport =
609+
extern crate `{$ident}` is private, and cannot be re-exported (error E0365), consider declaring with `pub`
610+
586611
lint_proc_macro_back_compat_rental = using an old version of `rental`
587612
613+
lint_proc_macro_derive_resolution_fallback = cannot find {$ns} `{$ident}` in this scope
614+
.label = names from parent modules are not accessible without an explicit import
615+
588616
lint_ptr_null_checks_fn_ptr = function pointers are not nullable, so checking them for null will always return false
589617
.help = wrap the function pointer inside an `Option` and use `Option::is_none` to check for null pointer value
590618
.label = expression has type `{$orig_ty}`
@@ -606,6 +634,12 @@ lint_reason_must_be_string_literal = reason must be a string literal
606634
607635
lint_reason_must_come_last = reason in lint attribute must come last
608636
637+
lint_redundant_import = the item `{$ident}` is imported redundantly
638+
.label_imported_here = the item `{ident}` is already imported here
639+
.label_defined_here = the item `{ident}` is already defined here
640+
.label_imported_prelude = the item `{ident}` is already imported by the extern prelude
641+
.label_defined_prelude = the item `{ident}` is already defined by the extern prelude
642+
609643
lint_redundant_semicolons =
610644
unnecessary trailing {$multiple ->
611645
[true] semicolons
@@ -658,8 +692,15 @@ lint_undropped_manually_drops = calls to `std::mem::drop` with `std::mem::Manual
658692
lint_ungated_async_fn_track_caller = `#[track_caller]` on async functions is a no-op
659693
.label = this function will not propagate the caller location
660694
661-
lint_unicode_text_flow =
662-
unicode codepoint changing visible direction of text present in comment
695+
lint_unicode_text_flow = unicode codepoint changing visible direction of text present in comment
696+
.label = {$num_codepoints ->
697+
[1] this comment contains an invisible unicode text flow control codepoint
698+
*[other] this comment contains invisible unicode text flow control codepoints
699+
}
700+
.note = these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen
701+
.suggestion = if their presence wasn't intentional, you can remove them
702+
.label_comment_char = {$c_debug}
703+
663704
664705
lint_unit_bindings = binding has unit type `()`
665706
.label = this pattern is inferred to be the unit type `()`
@@ -681,6 +722,8 @@ lint_unknown_lint =
681722
*[false] did you mean: `{$replace}`
682723
}
683724
725+
lint_unknown_macro_variable = unknown macro variable `{$name}`
726+
684727
lint_unknown_tool_in_scoped_lint = unknown tool name `{$tool_name}` found in scoped lint: `{$tool_name}::{$lint_name}`
685728
.help = add `#![register_tool({$tool_name})]` to the crate root
686729
@@ -711,6 +754,8 @@ lint_unused_coroutine =
711754
}{$post} that must be used
712755
.note = coroutines are lazy and do nothing unless resumed
713756
757+
lint_unused_crate_dependency = external crate `{$extern_crate}` unused in `{$local_crate}`: remove the dependency or add `use {$extern_crate} as _;`
758+
714759
lint_unused_def = unused {$pre}`{$def}`{$post} that must be used
715760
.suggestion = use `let _ = ...` to ignore the resulting value
716761
@@ -721,8 +766,21 @@ lint_unused_doc_comment = unused doc comment
721766
722767
lint_unused_import_braces = braces around {$node} is unnecessary
723768
769+
lint_unused_imports = {$num_snippets ->
770+
[one] unused import: {$span_snippets}
771+
*[other] unused imports: {$span_snippets}
772+
}
773+
.suggestion_remove_whole_use = remove the whole `use` item
774+
.suggestion_remove_imports = {$num_to_remove ->
775+
[one] remove the unused import
776+
*[other] remove the unused imports
777+
}
778+
.help = if this is a test module, consider adding a `#[cfg(test)]` to the containing module
779+
724780
lint_unused_label = unused label
725781
782+
lint_unused_macro_definition = unused macro definition: `{$name}`
783+
726784
lint_unused_macro_use = unused `#[macro_use]` import
727785
728786
lint_unused_op = unused {$op} that must be used

0 commit comments

Comments
 (0)