Skip to content

Commit abb82ad

Browse files
Remove attr_parsing_unexpected_cfg_cargo_update because it is sadly no longer triggered
1 parent 082820f commit abb82ad

File tree

8 files changed

+20
-50
lines changed

8 files changed

+20
-50
lines changed

compiler/rustc_attr_parsing/messages.ftl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ attr_parsing_unexpected_cfg_add_build_rs_println = or consider adding `{$build_r
223223
attr_parsing_unexpected_cfg_add_cargo_feature = consider using a Cargo feature instead
224224
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}
225225
attr_parsing_unexpected_cfg_add_cmdline_arg = to expect this configuration use `{$cmdline_arg}`
226-
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}`
227226
228227
attr_parsing_unexpected_cfg_define_features = consider defining some features in `Cargo.toml`
229228
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

compiler/rustc_attr_parsing/src/attributes/cfg/check_cfg.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_hir::def_id::LOCAL_CRATE;
22
use rustc_middle::bug;
3-
use rustc_middle::ty::TyCtxt;
43
use rustc_session::Session;
54
use rustc_session::config::ExpectedValues;
65
use rustc_span::edit_distance::find_best_match_for_name;
@@ -89,29 +88,20 @@ fn rustc_macro_help(span: Span) -> Option<lints::UnexpectedCfgRustcMacroHelp> {
8988
}
9089
}
9190

92-
fn cargo_macro_help(
93-
tcx: Option<TyCtxt<'_>>,
94-
span: Span,
95-
) -> Option<lints::UnexpectedCfgCargoMacroHelp> {
91+
fn cargo_macro_help(span: Span) -> Option<lints::UnexpectedCfgCargoMacroHelp> {
9692
let oexpn = span.ctxt().outer_expn_data();
9793
if let Some(def_id) = oexpn.macro_def_id
9894
&& let ExpnKind::Macro(macro_kind, macro_name) = oexpn.kind
9995
&& def_id.krate != LOCAL_CRATE
100-
&& let Some(tcx) = tcx
10196
{
102-
Some(lints::UnexpectedCfgCargoMacroHelp {
103-
macro_kind: macro_kind.descr(),
104-
macro_name,
105-
crate_name: tcx.crate_name(def_id.krate),
106-
})
97+
Some(lints::UnexpectedCfgCargoMacroHelp { macro_kind: macro_kind.descr(), macro_name })
10798
} else {
10899
None
109100
}
110101
}
111102

112103
pub fn unexpected_cfg_name(
113104
sess: &Session,
114-
tcx: Option<TyCtxt<'_>>,
115105
(name, name_span): (Symbol, Span),
116106
value: Option<(Symbol, Span)>,
117107
) -> lints::UnexpectedCfgName {
@@ -253,7 +243,7 @@ pub fn unexpected_cfg_name(
253243
};
254244
lints::unexpected_cfg_name::InvocationHelp::Cargo {
255245
help,
256-
macro_help: cargo_macro_help(tcx, name_span),
246+
macro_help: cargo_macro_help(name_span),
257247
}
258248
} else {
259249
let help = lints::UnexpectedCfgRustcHelp::new(&inst(EscapeQuotes::No));
@@ -268,7 +258,6 @@ pub fn unexpected_cfg_name(
268258

269259
pub fn unexpected_cfg_value(
270260
sess: &Session,
271-
tcx: Option<TyCtxt<'_>>,
272261
(name, name_span): (Symbol, Span),
273262
value: Option<(Symbol, Span)>,
274263
) -> lints::UnexpectedCfgValue {
@@ -373,7 +362,7 @@ pub fn unexpected_cfg_value(
373362
};
374363
lints::unexpected_cfg_value::InvocationHelp::Cargo {
375364
help,
376-
macro_help: cargo_macro_help(tcx, name_span),
365+
macro_help: cargo_macro_help(name_span),
377366
}
378367
} else {
379368
let help = if can_suggest_adding_value {

compiler/rustc_attr_parsing/src/lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ pub fn emit_attribute_lint<L: LintEmitter>(
109109
rustc_session::lint::builtin::UNEXPECTED_CFGS,
110110
*id,
111111
*span,
112-
unexpected_cfg_name(sess, None, (name, name_span), value),
112+
unexpected_cfg_name(sess, (name, name_span), value),
113113
),
114114
&AttributeLintKind::UnexpectedCfgValue { name, name_span, value } => lint_emitter
115115
.emit_node_span_lint(
116116
rustc_session::lint::builtin::UNEXPECTED_CFGS,
117117
*id,
118118
*span,
119-
unexpected_cfg_value(sess, None, (name, name_span), value),
119+
unexpected_cfg_value(sess, (name, name_span), value),
120120
),
121121
}
122122
}

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,11 +1050,9 @@ pub struct UnexpectedCfgRustcMacroHelp {
10501050
#[derive(Subdiagnostic)]
10511051
#[note(attr_parsing_unexpected_cfg_from_external_macro_origin)]
10521052
#[help(attr_parsing_unexpected_cfg_from_external_macro_refer)]
1053-
#[help(attr_parsing_unexpected_cfg_cargo_update)]
10541053
pub struct UnexpectedCfgCargoMacroHelp {
10551054
pub macro_kind: &'static str,
10561055
pub macro_name: Symbol,
1057-
pub crate_name: Symbol,
10581056
}
10591057

10601058
#[derive(LintDiagnostic)]

compiler/rustc_interface/src/passes.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ fn pre_expansion_lint<'a>(
9494
|| {
9595
rustc_lint::check_ast_node(
9696
sess,
97-
None,
9897
features,
9998
true,
10099
lint_store,
@@ -470,7 +469,6 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
470469
let lint_store = unerased_lint_store(tcx.sess);
471470
rustc_lint::check_ast_node(
472471
sess,
473-
Some(tcx),
474472
tcx.features(),
475473
false,
476474
lint_store,

compiler/rustc_lint/src/early.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_ast::{self as ast, HasAttrs};
99
use rustc_data_structures::stack::ensure_sufficient_stack;
1010
use rustc_errors::{BufferedEarlyLint, DecorateDiagCompat, LintBuffer};
1111
use rustc_feature::Features;
12-
use rustc_middle::ty::{RegisteredTools, TyCtxt};
12+
use rustc_middle::ty::RegisteredTools;
1313
use rustc_session::Session;
1414
use rustc_session::lint::LintPass;
1515
use rustc_span::{Ident, Span};
@@ -26,20 +26,19 @@ macro_rules! lint_callback { ($cx:expr, $f:ident, $($args:expr),*) => ({
2626

2727
/// Implements the AST traversal for early lint passes. `T` provides the
2828
/// `check_*` methods.
29-
pub struct EarlyContextAndPass<'ecx, 'tcx, T: EarlyLintPass> {
29+
pub struct EarlyContextAndPass<'ecx, T: EarlyLintPass> {
3030
context: EarlyContext<'ecx>,
31-
tcx: Option<TyCtxt<'tcx>>,
3231
pass: T,
3332
}
3433

35-
impl<'ecx, 'tcx, T: EarlyLintPass> EarlyContextAndPass<'ecx, 'tcx, T> {
34+
impl<'ecx, T: EarlyLintPass> EarlyContextAndPass<'ecx, T> {
3635
#[allow(rustc::diagnostic_outside_of_impl)]
3736
fn check_id(&mut self, id: ast::NodeId) {
3837
for early_lint in self.context.buffered.take(id) {
3938
let BufferedEarlyLint { span, node_id: _, lint_id, diagnostic } = early_lint;
4039
self.context.opt_span_lint(lint_id.lint, span, |diag| match diagnostic {
4140
DecorateDiagCompat::Builtin(b) => {
42-
diagnostics::decorate_builtin_lint(self.context.sess(), self.tcx, b, diag);
41+
diagnostics::decorate_builtin_lint(self.context.sess(), b, diag);
4342
}
4443
DecorateDiagCompat::Dynamic(d) => d.decorate_lint_box(diag),
4544
});
@@ -66,9 +65,7 @@ impl<'ecx, 'tcx, T: EarlyLintPass> EarlyContextAndPass<'ecx, 'tcx, T> {
6665
}
6766
}
6867

69-
impl<'ast, 'ecx, 'tcx, T: EarlyLintPass> ast_visit::Visitor<'ast>
70-
for EarlyContextAndPass<'ecx, 'tcx, T>
71-
{
68+
impl<'ast, 'ecx, T: EarlyLintPass> ast_visit::Visitor<'ast> for EarlyContextAndPass<'ecx, T> {
7269
fn visit_id(&mut self, id: rustc_ast::NodeId) {
7370
self.check_id(id);
7471
}
@@ -283,7 +280,7 @@ crate::early_lint_methods!(impl_early_lint_pass, []);
283280
pub trait EarlyCheckNode<'a>: Copy {
284281
fn id(self) -> ast::NodeId;
285282
fn attrs(self) -> &'a [ast::Attribute];
286-
fn check<'ecx, 'tcx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, 'tcx, T>);
283+
fn check<'ecx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, T>);
287284
}
288285

289286
impl<'a> EarlyCheckNode<'a> for (&'a ast::Crate, &'a [ast::Attribute]) {
@@ -293,7 +290,7 @@ impl<'a> EarlyCheckNode<'a> for (&'a ast::Crate, &'a [ast::Attribute]) {
293290
fn attrs(self) -> &'a [ast::Attribute] {
294291
self.1
295292
}
296-
fn check<'ecx, 'tcx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, 'tcx, T>) {
293+
fn check<'ecx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, T>) {
297294
lint_callback!(cx, check_crate, self.0);
298295
ast_visit::walk_crate(cx, self.0);
299296
lint_callback!(cx, check_crate_post, self.0);
@@ -307,15 +304,14 @@ impl<'a> EarlyCheckNode<'a> for (ast::NodeId, &'a [ast::Attribute], &'a [Box<ast
307304
fn attrs(self) -> &'a [ast::Attribute] {
308305
self.1
309306
}
310-
fn check<'ecx, 'tcx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, 'tcx, T>) {
307+
fn check<'ecx, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'ecx, T>) {
311308
walk_list!(cx, visit_attribute, self.1);
312309
walk_list!(cx, visit_item, self.2);
313310
}
314311
}
315312

316313
pub fn check_ast_node<'a>(
317314
sess: &Session,
318-
tcx: Option<TyCtxt<'_>>,
319315
features: &Features,
320316
pre_expansion: bool,
321317
lint_store: &LintStore,
@@ -339,23 +335,22 @@ pub fn check_ast_node<'a>(
339335
let passes =
340336
if pre_expansion { &lint_store.pre_expansion_passes } else { &lint_store.early_passes };
341337
if passes.is_empty() {
342-
check_ast_node_inner(sess, tcx, check_node, context, builtin_lints);
338+
check_ast_node_inner(sess, check_node, context, builtin_lints);
343339
} else {
344340
let mut passes: Vec<_> = passes.iter().map(|mk_pass| (mk_pass)()).collect();
345341
passes.push(Box::new(builtin_lints));
346342
let pass = RuntimeCombinedEarlyLintPass { passes: &mut passes[..] };
347-
check_ast_node_inner(sess, tcx, check_node, context, pass);
343+
check_ast_node_inner(sess, check_node, context, pass);
348344
}
349345
}
350346

351347
fn check_ast_node_inner<'a, T: EarlyLintPass>(
352348
sess: &Session,
353-
tcx: Option<TyCtxt<'_>>,
354349
check_node: impl EarlyCheckNode<'a>,
355350
context: EarlyContext<'_>,
356351
pass: T,
357352
) {
358-
let mut cx = EarlyContextAndPass { context, tcx, pass };
353+
let mut cx = EarlyContextAndPass { context, pass };
359354

360355
cx.with_lint_attrs(check_node.id(), check_node.attrs(), |cx| check_node.check(cx));
361356

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@ use rustc_errors::{
55
Applicability, Diag, DiagArgValue, LintDiagnostic, elided_lifetime_in_path_suggestion,
66
};
77
use rustc_middle::middle::stability;
8-
use rustc_middle::ty::TyCtxt;
98
use rustc_session::Session;
109
use rustc_session::lint::BuiltinLintDiag;
1110
use rustc_span::BytePos;
1211
use tracing::debug;
1312

1413
use crate::lints;
1514

16-
pub fn decorate_builtin_lint(
17-
sess: &Session,
18-
tcx: Option<TyCtxt<'_>>,
19-
diagnostic: BuiltinLintDiag,
20-
diag: &mut Diag<'_, ()>,
21-
) {
15+
pub fn decorate_builtin_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Diag<'_, ()>) {
2216
match diagnostic {
2317
BuiltinLintDiag::UnicodeTextFlow(comment_span, content) => {
2418
let spans: Vec<_> = content
@@ -167,10 +161,10 @@ pub fn decorate_builtin_lint(
167161
.decorate_lint(diag);
168162
}
169163
BuiltinLintDiag::UnexpectedCfgName(name, value) => {
170-
rustc_attr_parsing::unexpected_cfg_name(sess, tcx, name, value).decorate_lint(diag);
164+
rustc_attr_parsing::unexpected_cfg_name(sess, name, value).decorate_lint(diag);
171165
}
172166
BuiltinLintDiag::UnexpectedCfgValue(name, value) => {
173-
rustc_attr_parsing::unexpected_cfg_value(sess, tcx, name, value).decorate_lint(diag);
167+
rustc_attr_parsing::unexpected_cfg_value(sess, name, value).decorate_lint(diag);
174168
}
175169
BuiltinLintDiag::DeprecatedWhereclauseLocation(left_sp, sugg) => {
176170
let suggestion = match sugg {

tests/ui/check-cfg/report-in-external-macros.cargo.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL | cfg_macro::my_lib_macro!();
77
= help: expected names are: `feature` and 31 more
88
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
99
= help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg
10-
= help: the macro `cfg_macro::my_lib_macro` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro`
1110
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
1211
= note: `#[warn(unexpected_cfgs)]` on by default
1312
= note: this warning originates in the macro `cfg_macro::my_lib_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -21,7 +20,6 @@ LL | cfg_macro::my_lib_macro_value!();
2120
= note: expected values for `panic` are: `abort`, `immediate-abort`, and `unwind`
2221
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
2322
= help: try referring to `cfg_macro::my_lib_macro_value` crate for guidance on how handle this unexpected cfg
24-
= help: the macro `cfg_macro::my_lib_macro_value` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro`
2523
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
2624
= note: this warning originates in the macro `cfg_macro::my_lib_macro_value` (in Nightly builds, run with -Z macro-backtrace for more info)
2725

@@ -34,7 +32,6 @@ LL | cfg_macro::my_lib_macro_feature!();
3432
= note: no expected values for `feature`
3533
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
3634
= help: try referring to `cfg_macro::my_lib_macro_feature` crate for guidance on how handle this unexpected cfg
37-
= help: the macro `cfg_macro::my_lib_macro_feature` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro`
3835
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
3936
= note: this warning originates in the macro `cfg_macro::my_lib_macro_feature` (in Nightly builds, run with -Z macro-backtrace for more info)
4037

0 commit comments

Comments
 (0)