Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco
Rework `untranslatable_diagnostic` lint Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`. r? ``@davidtwco``
This commit is contained in:
commit
efe9deace8
42 changed files with 305 additions and 89 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,
|
||||
|
|
|
@ -168,6 +168,7 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
|
|||
/// This variant allows you to control whether it is a library or language feature.
|
||||
/// Almost always, you want to use this for a language feature. If so, prefer
|
||||
/// `add_feature_diagnostics`.
|
||||
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
|
||||
pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
|
||||
err: &mut Diag<'_, G>,
|
||||
sess: &Session,
|
||||
|
|
|
@ -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`");
|
||||
}
|
||||
|
||||
|
|
|
@ -312,6 +312,7 @@ impl Session {
|
|||
) -> Diag<'a> {
|
||||
let mut err = self.dcx().create_err(err);
|
||||
if err.code.is_none() {
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
err.code(E0658);
|
||||
}
|
||||
add_feature_diagnostics(&mut err, self, feature);
|
||||
|
@ -1022,6 +1023,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