Rewrite the untranslatable_diagnostic
lint.
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`.
This commit is contained in:
parent
d602394827
commit
b7d58eef4b
35 changed files with 224 additions and 63 deletions
|
@ -1,6 +1,8 @@
|
|||
//! Contains infrastructure for configuring the compiler, including parsing
|
||||
//! command-line options.
|
||||
|
||||
#![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
|
||||
pub use crate::options::*;
|
||||
|
||||
use crate::errors::FileWriteFail;
|
||||
|
@ -2468,9 +2470,7 @@ pub fn parse_externs(
|
|||
));
|
||||
let adjusted_name = name.replace('-', "_");
|
||||
if is_ascii_ident(&adjusted_name) {
|
||||
// FIXME: make this translatable
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
|
||||
error.help(format!(
|
||||
"consider replacing the dashes with underscores: `{adjusted_name}`"
|
||||
));
|
||||
|
|
|
@ -320,6 +320,7 @@ macro_rules! redirect_field {
|
|||
type OptionSetter<O> = fn(&mut O, v: Option<&str>) -> bool;
|
||||
type OptionDescrs<O> = &'static [(&'static str, OptionSetter<O>, &'static str, &'static str)];
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
fn build_options<O: Default>(
|
||||
early_dcx: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
|
|
|
@ -61,6 +61,7 @@ impl SearchPath {
|
|||
(PathKind::All, path)
|
||||
};
|
||||
if path.is_empty() {
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
early_dcx.early_fatal("empty search path given via `-L`");
|
||||
}
|
||||
|
||||
|
|
|
@ -1022,6 +1022,7 @@ fn default_emitter(
|
|||
|
||||
// JUSTIFICATION: literally session construction
|
||||
#[allow(rustc::bad_opt_access)]
|
||||
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
|
||||
pub fn build_session(
|
||||
early_dcx: EarlyDiagCtxt,
|
||||
sopts: config::Options,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue