Skip to content

Commit f5023e4

Browse files
committed
Remove --check-cfg checking of --cfg args
1 parent 78efca8 commit f5023e4

File tree

6 files changed

+4
-47
lines changed

6 files changed

+4
-47
lines changed

compiler/rustc_lint/messages.ftl

-6
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,6 @@ lint_builtin_type_alias_generic_bounds = bounds on generic parameters are not en
128128
lint_builtin_type_alias_where_clause = where clauses are not enforced in type aliases
129129
.suggestion = the clause will not be checked when the type alias is used, and should be removed
130130
131-
lint_builtin_unexpected_cli_config_name = unexpected `{$name}` as condition name
132-
.help = was set with `--cfg` but isn't in the `--check-cfg` expected names
133-
134-
lint_builtin_unexpected_cli_config_value = unexpected condition value `{$value}` for condition name `{$name}`
135-
.help = was set with `--cfg` but isn't in the `--check-cfg` expected values
136-
137131
lint_builtin_unpermitted_type_init_label = this code causes undefined behavior when executed
138132
lint_builtin_unpermitted_type_init_label_suggestion = help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
139133

compiler/rustc_lint/src/builtin.rs

-25
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use crate::{
3333
BuiltinMutablesTransmutes, BuiltinNoMangleGeneric, BuiltinNonShorthandFieldPatterns,
3434
BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds, BuiltinTypeAliasGenericBounds,
3535
BuiltinTypeAliasGenericBoundsSuggestion, BuiltinTypeAliasWhereClause,
36-
BuiltinUnexpectedCliConfigName, BuiltinUnexpectedCliConfigValue,
3736
BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit,
3837
BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, BuiltinUnsafe,
3938
BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub,
@@ -60,7 +59,6 @@ use rustc_middle::ty::GenericArgKind;
6059
use rustc_middle::ty::ToPredicate;
6160
use rustc_middle::ty::TypeVisitableExt;
6261
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
63-
use rustc_session::config::ExpectedValues;
6462
use rustc_session::lint::{BuiltinLintDiagnostics, FutureIncompatibilityReason};
6563
use rustc_span::edition::Edition;
6664
use rustc_span::source_map::Spanned;
@@ -2889,26 +2887,3 @@ impl EarlyLintPass for SpecialModuleName {
28892887
}
28902888
}
28912889
}
2892-
2893-
pub use rustc_session::lint::builtin::UNEXPECTED_CFGS;
2894-
2895-
declare_lint_pass!(UnexpectedCfgs => [UNEXPECTED_CFGS]);
2896-
2897-
impl EarlyLintPass for UnexpectedCfgs {
2898-
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
2899-
let cfg = &cx.sess().parse_sess.config;
2900-
let check_cfg = &cx.sess().parse_sess.check_config;
2901-
for &(name, value) in cfg {
2902-
match check_cfg.expecteds.get(&name) {
2903-
Some(ExpectedValues::Some(values)) if !values.contains(&value) => {
2904-
let value = value.unwrap_or(kw::Empty);
2905-
cx.emit_lint(UNEXPECTED_CFGS, BuiltinUnexpectedCliConfigValue { name, value });
2906-
}
2907-
None if check_cfg.exhaustive_names => {
2908-
cx.emit_lint(UNEXPECTED_CFGS, BuiltinUnexpectedCliConfigName { name });
2909-
}
2910-
_ => { /* expected */ }
2911-
}
2912-
}
2913-
}
2914-
}

compiler/rustc_lint/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ early_lint_methods!(
179179
IncompleteInternalFeatures: IncompleteInternalFeatures,
180180
RedundantSemicolons: RedundantSemicolons,
181181
UnusedDocComment: UnusedDocComment,
182-
UnexpectedCfgs: UnexpectedCfgs,
183182
]
184183
]
185184
);

compiler/rustc_lint/src/lints.rs

-15
Original file line numberDiff line numberDiff line change
@@ -553,21 +553,6 @@ pub enum BuiltinSpecialModuleNameUsed {
553553
Main,
554554
}
555555

556-
#[derive(LintDiagnostic)]
557-
#[diag(lint_builtin_unexpected_cli_config_name)]
558-
#[help]
559-
pub struct BuiltinUnexpectedCliConfigName {
560-
pub name: Symbol,
561-
}
562-
563-
#[derive(LintDiagnostic)]
564-
#[diag(lint_builtin_unexpected_cli_config_value)]
565-
#[help]
566-
pub struct BuiltinUnexpectedCliConfigValue {
567-
pub name: Symbol,
568-
pub value: Symbol,
569-
}
570-
571556
// deref_into_dyn_supertrait.rs
572557
#[derive(LintDiagnostic)]
573558
#[diag(lint_supertrait_as_deref_target)]

compiler/rustc_lint_defs/src/builtin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3439,6 +3439,7 @@ declare_lint_pass! {
34393439
UNCONDITIONAL_PANIC,
34403440
UNCONDITIONAL_RECURSION,
34413441
UNDEFINED_NAKED_FUNCTION_ABI,
3442+
UNEXPECTED_CFGS,
34423443
UNFULFILLED_LINT_EXPECTATIONS,
34433444
UNINHABITED_STATIC,
34443445
UNKNOWN_CRATE_TYPES,

src/doc/unstable-book/src/compiler-flags/check-cfg.md

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ and `cfg!(name = "value")` call. It will check that the `"value"` specified is p
3535
list of expected values. If `"value"` is not in it, then `rustc` will report an `unexpected_cfgs`
3636
lint diagnostic. The default diagnostic level for this lint is `Warn`.
3737

38+
The command line `--cfg` arguments are currently *NOT* checked but may very well be checked in
39+
the future.
40+
3841
To enable checking of values, but to provide an empty set of expected values, use these forms:
3942

4043
```bash

0 commit comments

Comments
 (0)