Rollup merge of #117522 - Urgau:check-cfg-cli-own-lint, r=petrochenkov
Remove `--check-cfg` checking of command line `--cfg` args Back in https://github.com/rust-lang/rust/pull/100574 we added to the `unexpected_cfgs` lint the checking of `--cfg` CLI arguments and emitted unexpected names and values for them. The implementation works as expected, but it's usability in particular when using it in combination with Cargo+`RUSTFLAGS` as people who set `RUSTFLAGS=--cfg=tokio_unstable` (or whatever) have `unexpected_cfgs` warnings on all of their crates is debatable. ~~To fix this issue this PR proposes that we split the CLI argument checking into it's own separate allow-by-default lint: `unexpected_cli_cfgs`.~~ ~~This has the advantage of letting people who want CLI warnings have them (although not by default anymore), while still linting on every unexpected cfg name and values in the code.~~ After some discussion with the Cargo team ([Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/check-cfg.20and.20RUSTFLAGS.20interaction)) and member of the compiler team (see below), I propose that we follow the suggestion from `@epage:` never check `--cfg` arguments, but still reserve us the possibility to do it later. We would still lint on unexpected cfgs found in the source code no matter the `--cfg` args passed. This mean reverting https://github.com/rust-lang/rust/pull/100574 but NOT https://github.com/rust-lang/rust/pull/99519. r? `@petrochenkov`
This commit is contained in:
commit
aff407eef5
19 changed files with 32 additions and 130 deletions
|
@ -33,7 +33,6 @@ use crate::{
|
|||
BuiltinMutablesTransmutes, BuiltinNoMangleGeneric, BuiltinNonShorthandFieldPatterns,
|
||||
BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds, BuiltinTypeAliasGenericBounds,
|
||||
BuiltinTypeAliasGenericBoundsSuggestion, BuiltinTypeAliasWhereClause,
|
||||
BuiltinUnexpectedCliConfigName, BuiltinUnexpectedCliConfigValue,
|
||||
BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit,
|
||||
BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, BuiltinUnsafe,
|
||||
BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub,
|
||||
|
@ -60,7 +59,6 @@ use rustc_middle::ty::GenericArgKind;
|
|||
use rustc_middle::ty::ToPredicate;
|
||||
use rustc_middle::ty::TypeVisitableExt;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
|
||||
use rustc_session::config::ExpectedValues;
|
||||
use rustc_session::lint::{BuiltinLintDiagnostics, FutureIncompatibilityReason};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::Spanned;
|
||||
|
@ -2889,26 +2887,3 @@ impl EarlyLintPass for SpecialModuleName {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub use rustc_session::lint::builtin::UNEXPECTED_CFGS;
|
||||
|
||||
declare_lint_pass!(UnexpectedCfgs => [UNEXPECTED_CFGS]);
|
||||
|
||||
impl EarlyLintPass for UnexpectedCfgs {
|
||||
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
||||
let cfg = &cx.sess().parse_sess.config;
|
||||
let check_cfg = &cx.sess().parse_sess.check_config;
|
||||
for &(name, value) in cfg {
|
||||
match check_cfg.expecteds.get(&name) {
|
||||
Some(ExpectedValues::Some(values)) if !values.contains(&value) => {
|
||||
let value = value.unwrap_or(kw::Empty);
|
||||
cx.emit_lint(UNEXPECTED_CFGS, BuiltinUnexpectedCliConfigValue { name, value });
|
||||
}
|
||||
None if check_cfg.exhaustive_names => {
|
||||
cx.emit_lint(UNEXPECTED_CFGS, BuiltinUnexpectedCliConfigName { name });
|
||||
}
|
||||
_ => { /* expected */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,7 +179,6 @@ early_lint_methods!(
|
|||
IncompleteInternalFeatures: IncompleteInternalFeatures,
|
||||
RedundantSemicolons: RedundantSemicolons,
|
||||
UnusedDocComment: UnusedDocComment,
|
||||
UnexpectedCfgs: UnexpectedCfgs,
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
|
@ -553,21 +553,6 @@ pub enum BuiltinSpecialModuleNameUsed {
|
|||
Main,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_builtin_unexpected_cli_config_name)]
|
||||
#[help]
|
||||
pub struct BuiltinUnexpectedCliConfigName {
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_builtin_unexpected_cli_config_value)]
|
||||
#[help]
|
||||
pub struct BuiltinUnexpectedCliConfigValue {
|
||||
pub name: Symbol,
|
||||
pub value: Symbol,
|
||||
}
|
||||
|
||||
// deref_into_dyn_supertrait.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_supertrait_as_deref_target)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue