Skip to content

Commit b5c714c

Browse files
committed
Migrate BuiltinLintDiag::UnexpectedBuiltinCfg to use LintDiagnostic directly
1 parent c993201 commit b5c714c

File tree

7 files changed

+17
-26
lines changed

7 files changed

+17
-26
lines changed

compiler/rustc_lint/messages.ftl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,6 @@ lint_undropped_manually_drops = calls to `std::mem::drop` with `std::mem::Manual
870870
.label = argument has type `{$arg_ty}`
871871
.suggestion = use `std::mem::ManuallyDrop::into_inner` to get the inner value
872872
873-
lint_unexpected_builtin_cfg = unexpected `--cfg {$cfg}` flag
874-
.controlled_by = config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`
875-
.incoherent = manually setting a built-in cfg can and does create incoherent behaviors
876-
877873
lint_unexpected_cfg_add_build_rs_println = or consider adding `{$build_rs_println}` to the top of the `build.rs`
878874
lint_unexpected_cfg_add_cargo_feature = consider using a Cargo feature instead
879875
lint_unexpected_cfg_add_cargo_toml_lint_cfg = or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:{$cargo_toml_lint_cfg}

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,5 @@ pub fn decorate_builtin_lint(
475475
BuiltinLintDiag::OutOfScopeMacroCalls { span, path, location } => {
476476
lints::OutOfScopeMacroCalls { span, path, location }.decorate_lint(diag)
477477
}
478-
BuiltinLintDiag::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by } => {
479-
lints::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by }.decorate_lint(diag)
480-
}
481478
}
482479
}

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,16 +2566,6 @@ pub(crate) mod unexpected_cfg_value {
25662566
}
25672567
}
25682568

2569-
#[derive(LintDiagnostic)]
2570-
#[diag(lint_unexpected_builtin_cfg)]
2571-
#[note(lint_controlled_by)]
2572-
#[note(lint_incoherent)]
2573-
pub(crate) struct UnexpectedBuiltinCfg {
2574-
pub(crate) cfg: String,
2575-
pub(crate) cfg_name: Symbol,
2576-
pub(crate) controlled_by: &'static str,
2577-
}
2578-
25792569
#[derive(LintDiagnostic)]
25802570
#[diag(lint_macro_use_deprecated)]
25812571
#[help]

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,6 @@ pub enum BuiltinLintDiag {
810810
path: String,
811811
location: String,
812812
},
813-
UnexpectedBuiltinCfg {
814-
cfg: String,
815-
cfg_name: Symbol,
816-
controlled_by: &'static str,
817-
},
818813
}
819814

820815
pub type RegisteredTools = FxIndexSet<Ident>;

compiler/rustc_session/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ session_target_small_data_threshold_not_supported = `-Z small-data-threshold` is
131131
132132
session_target_stack_protector_not_supported = `-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored
133133
134+
session_unexpected_builtin_cfg = unexpected `--cfg {$cfg}` flag
135+
.controlled_by = config `{$cfg_name}` is only supposed to be controlled by `{$controlled_by}`
136+
.incoherent = manually setting a built-in cfg can and does create incoherent behaviors
137+
134138
session_unleashed_feature_help_named = skipping check for `{$gate}` feature
135139
session_unleashed_feature_help_unnamed = skipping check that does not even have a feature gate
136140

compiler/rustc_session/src/config/cfg.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ use std::iter;
2626
use rustc_abi::Align;
2727
use rustc_ast::ast;
2828
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
29-
use rustc_lint_defs::BuiltinLintDiag;
3029
use rustc_lint_defs::builtin::EXPLICIT_BUILTIN_CFGS_IN_FLAGS;
3130
use rustc_span::{Symbol, sym};
3231
use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target};
3332

34-
use crate::Session;
3533
use crate::config::{CrateType, FmtDebug};
34+
use crate::{Session, errors};
3635

3736
/// The parsed `--cfg` options that define the compilation environment of the
3837
/// crate, used to drive conditional compilation.
@@ -99,7 +98,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
9998
EXPLICIT_BUILTIN_CFGS_IN_FLAGS,
10099
None,
101100
ast::CRATE_NODE_ID,
102-
BuiltinLintDiag::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by }.into(),
101+
errors::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by }.into(),
103102
)
104103
};
105104

compiler/rustc_session/src/errors.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_errors::{
77
Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, Level,
88
MultiSpan,
99
};
10-
use rustc_macros::{Diagnostic, Subdiagnostic};
10+
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
1111
use rustc_span::{Span, Symbol};
1212
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTuple};
1313

@@ -505,3 +505,13 @@ pub(crate) struct SoftFloatIgnored;
505505
#[note]
506506
#[note(session_soft_float_deprecated_issue)]
507507
pub(crate) struct SoftFloatDeprecated;
508+
509+
#[derive(LintDiagnostic)]
510+
#[diag(session_unexpected_builtin_cfg)]
511+
#[note(session_controlled_by)]
512+
#[note(session_incoherent)]
513+
pub(crate) struct UnexpectedBuiltinCfg {
514+
pub(crate) cfg: String,
515+
pub(crate) cfg_name: Symbol,
516+
pub(crate) controlled_by: &'static str,
517+
}

0 commit comments

Comments
 (0)