Skip to content

Commit a944814

Browse files
committed
Revert "[WIP] [BROKEN] Move early buffered check-cfg lints to dyn lint diagnostics"
This reverts commit c97e79f.
1 parent c97e79f commit a944814

File tree

10 files changed

+429
-434
lines changed

10 files changed

+429
-434
lines changed

compiler/rustc_attr_parsing/messages.ftl

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -217,50 +217,6 @@ attr_parsing_stability_outside_std = stability attributes may not be used outsid
217217
attr_parsing_suffixed_literal_in_attribute = suffixed literals are not allowed in attributes
218218
.help = instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
219219
220-
attr_parsing_unexpected_cfg_add_build_rs_println = or consider adding `{$build_rs_println}` to the top of the `build.rs`
221-
attr_parsing_unexpected_cfg_add_cargo_feature = consider using a Cargo feature instead
222-
attr_parsing_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}
223-
attr_parsing_unexpected_cfg_add_cmdline_arg = to expect this configuration use `{$cmdline_arg}`
224-
attr_parsing_unexpected_cfg_cargo_update = the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}`
225-
226-
attr_parsing_unexpected_cfg_define_features = consider defining some features in `Cargo.toml`
227-
attr_parsing_unexpected_cfg_doc_cargo = see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
228-
attr_parsing_unexpected_cfg_doc_rustc = see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
229-
230-
attr_parsing_unexpected_cfg_from_external_macro_origin = using a cfg inside a {$macro_kind} will use the cfgs from the destination crate and not the ones from the defining crate
231-
attr_parsing_unexpected_cfg_from_external_macro_refer = try referring to `{$macro_name}` crate for guidance on how handle this unexpected cfg
232-
attr_parsing_unexpected_cfg_name = unexpected `cfg` condition name: `{$name}`
233-
attr_parsing_unexpected_cfg_name_expected_names = expected names are: {$possibilities}{$and_more ->
234-
[0] {""}
235-
*[other] {" "}and {$and_more} more
236-
}
237-
attr_parsing_unexpected_cfg_name_expected_values = expected values for `{$best_match}` are: {$possibilities}
238-
attr_parsing_unexpected_cfg_name_similar_name = there is a config with a similar name
239-
attr_parsing_unexpected_cfg_name_similar_name_different_values = there is a config with a similar name and different values
240-
attr_parsing_unexpected_cfg_name_similar_name_no_value = there is a config with a similar name and no value
241-
attr_parsing_unexpected_cfg_name_similar_name_value = there is a config with a similar name and value
242-
attr_parsing_unexpected_cfg_name_version_syntax = there is a similar config predicate: `version("..")`
243-
attr_parsing_unexpected_cfg_name_with_similar_value = found config with similar value
244-
245-
attr_parsing_unexpected_cfg_value = unexpected `cfg` condition value: {$has_value ->
246-
[true] `{$value}`
247-
*[false] (none)
248-
}
249-
attr_parsing_unexpected_cfg_value_add_feature = consider adding `{$value}` as a feature in `Cargo.toml`
250-
attr_parsing_unexpected_cfg_value_expected_values = expected values for `{$name}` are: {$have_none_possibility ->
251-
[true] {"(none), "}
252-
*[false] {""}
253-
}{$possibilities}{$and_more ->
254-
[0] {""}
255-
*[other] {" "}and {$and_more} more
256-
}
257-
attr_parsing_unexpected_cfg_value_no_expected_value = no expected value for `{$name}`
258-
attr_parsing_unexpected_cfg_value_no_expected_values = no expected values for `{$name}`
259-
attr_parsing_unexpected_cfg_value_remove_condition = remove the condition
260-
attr_parsing_unexpected_cfg_value_remove_value = remove the value
261-
attr_parsing_unexpected_cfg_value_similar_name = there is a expected value with a similar name
262-
attr_parsing_unexpected_cfg_value_specify_value = specify a config value
263-
264220
attr_parsing_unknown_meta_item =
265221
unknown meta item '{$item}'
266222
.label = expected one of {$expected}

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ use crate::{
1616
CfgMatchesLintEmitter, fluent_generated, parse_version, session_diagnostics, try_gate_cfg,
1717
};
1818

19-
// NOTE: Crate-public since it's also used in sibling module `cfg_old`.
20-
pub(crate) mod check_cfg;
21-
2219
pub const CFG_TEMPLATE: AttributeTemplate = template!(
2320
List: &["predicate"],
2421
"https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute"
@@ -237,37 +234,35 @@ pub fn eval_config_entry(
237234
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: *span }
238235
}
239236
}
240-
&CfgEntry::NameValue { name, name_span, value, span } => {
237+
CfgEntry::NameValue { name, name_span, value, span } => {
241238
if let ShouldEmit::ErrorsAndLints = emit_lints {
242-
match sess.psess.check_config.expecteds.get(&name) {
239+
match sess.psess.check_config.expecteds.get(name) {
243240
Some(ExpectedValues::Some(values))
244241
if !values.contains(&value.map(|(v, _)| v)) =>
245242
{
246243
id.emit_span_lint(
247244
sess,
248245
UNEXPECTED_CFGS,
249-
span,
250-
// TODO: Do it lazily! Somehow pass a TyCtxt if possible
251-
check_cfg::unexpected_cfg_value(sess, None, (name, name_span), value),
246+
*span,
247+
BuiltinLintDiag::UnexpectedCfgValue((*name, *name_span), *value),
252248
);
253249
}
254250
None if sess.psess.check_config.exhaustive_names => {
255251
id.emit_span_lint(
256252
sess,
257253
UNEXPECTED_CFGS,
258-
span,
259-
// TODO: Do it lazily! Somehow pass a TyCtxt if possible
260-
check_cfg::unexpected_cfg_name(sess, None, (name, name_span), value),
254+
*span,
255+
BuiltinLintDiag::UnexpectedCfgName((*name, *name_span), *value),
261256
);
262257
}
263258
_ => { /* not unexpected */ }
264259
}
265260
}
266261

267-
if sess.psess.config.contains(&(name, value.map(|(v, _)| v))) {
262+
if sess.psess.config.contains(&(*name, value.map(|(v, _)| v))) {
268263
EvalConfigResult::True
269264
} else {
270-
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: span }
265+
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: *span }
271266
}
272267
}
273268
CfgEntry::Version(min_version, version_span) => {

compiler/rustc_attr_parsing/src/attributes/cfg_old.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ pub fn cfg_matches(
5151
sess,
5252
UNEXPECTED_CFGS,
5353
cfg.span,
54-
// TODO: Do it lazily! Somehow pass a TyCtxt if possible
55-
super::cfg::check_cfg::unexpected_cfg_value(
56-
sess,
57-
None,
54+
BuiltinLintDiag::UnexpectedCfgValue(
5855
(cfg.name, cfg.name_span),
5956
cfg.value.map(|v| (v, cfg.value_span.unwrap())),
6057
),
@@ -65,10 +62,7 @@ pub fn cfg_matches(
6562
sess,
6663
UNEXPECTED_CFGS,
6764
cfg.span,
68-
// TODO: Do it lazily! Somehow pass a TyCtxt if possible
69-
super::cfg::check_cfg::unexpected_cfg_name(
70-
sess,
71-
None,
65+
BuiltinLintDiag::UnexpectedCfgName(
7266
(cfg.name, cfg.name_span),
7367
cfg.value.map(|v| (v, cfg.value_span.unwrap())),
7468
),

0 commit comments

Comments
 (0)