Skip to content

Commit 8f68c43

Browse files
committed
Auto merge of #99925 - JohnTitor:rollup-4bt9ou3, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #99227 (Fix thumbv4t-none-eabi frame pointer setting) - #99518 (Let-else: break out scopes when a let-else pattern fails to match) - #99671 (Suggest dereferencing index when trying to use a reference of usize as index) - #99831 (Add Fuchsia platform support documentation) - #99881 (fix ICE when computing codegen_fn_attrs on closure with non-fn parent) - #99888 (Streamline lint checking) - #99891 (Adjust an expr span to account for macros) - #99904 (Cleanup html whitespace) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 211637d + cfbf7be commit 8f68c43

36 files changed

+629
-190
lines changed

compiler/rustc_ast/src/visit.rs

+3-16
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
use crate::ast::*;
1717

18-
use rustc_span::symbol::{Ident, Symbol};
18+
use rustc_span::symbol::Ident;
1919
use rustc_span::Span;
2020

2121
#[derive(Copy, Clone, Debug, PartialEq)]
@@ -109,12 +109,7 @@ pub enum LifetimeCtxt {
109109
/// to monitor future changes to `Visitor` in case a new method with a
110110
/// new default implementation gets introduced.)
111111
pub trait Visitor<'ast>: Sized {
112-
fn visit_name(&mut self, _span: Span, _name: Symbol) {
113-
// Nothing to do.
114-
}
115-
fn visit_ident(&mut self, ident: Ident) {
116-
walk_ident(self, ident);
117-
}
112+
fn visit_ident(&mut self, _ident: Ident) {}
118113
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) {
119114
walk_foreign_item(self, i)
120115
}
@@ -267,10 +262,6 @@ macro_rules! walk_list {
267262
}
268263
}
269264

270-
pub fn walk_ident<'a, V: Visitor<'a>>(visitor: &mut V, ident: Ident) {
271-
visitor.visit_name(ident.span, ident.name);
272-
}
273-
274265
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) {
275266
walk_list!(visitor, visit_item, &krate.items);
276267
walk_list!(visitor, visit_attribute, &krate.attrs);
@@ -315,11 +306,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
315306
visitor.visit_vis(&item.vis);
316307
visitor.visit_ident(item.ident);
317308
match item.kind {
318-
ItemKind::ExternCrate(orig_name) => {
319-
if let Some(orig_name) = orig_name {
320-
visitor.visit_name(item.span, orig_name);
321-
}
322-
}
309+
ItemKind::ExternCrate(_) => {}
323310
ItemKind::Use(ref use_tree) => visitor.visit_use_tree(use_tree, item.id, false),
324311
ItemKind::Static(ref typ, _, ref expr) | ItemKind::Const(_, ref typ, ref expr) => {
325312
visitor.visit_ty(typ);

compiler/rustc_ast_passes/src/node_count.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ impl NodeCounter {
1616
}
1717

1818
impl<'ast> Visitor<'ast> for NodeCounter {
19-
fn visit_ident(&mut self, ident: Ident) {
19+
fn visit_ident(&mut self, _ident: Ident) {
2020
self.count += 1;
21-
walk_ident(self, ident);
2221
}
2322
fn visit_foreign_item(&mut self, i: &ForeignItem) {
2423
self.count += 1;

compiler/rustc_lint/src/early.rs

-17
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
9090

9191
fn visit_foreign_item(&mut self, it: &'a ast::ForeignItem) {
9292
self.with_lint_attrs(it.id, &it.attrs, |cx| {
93-
run_early_pass!(cx, check_foreign_item, it);
9493
ast_visit::walk_foreign_item(cx, it);
95-
run_early_pass!(cx, check_foreign_item_post, it);
9694
})
9795
}
9896

@@ -104,7 +102,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
104102
}
105103

106104
fn visit_anon_const(&mut self, c: &'a ast::AnonConst) {
107-
run_early_pass!(self, check_anon_const, c);
108105
self.check_id(c.id);
109106
ast_visit::walk_anon_const(self, c);
110107
}
@@ -154,22 +151,17 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
154151
self.check_id(closure_id);
155152
}
156153
}
157-
158-
run_early_pass!(self, check_fn_post, fk, span, id);
159154
}
160155

161156
fn visit_variant_data(&mut self, s: &'a ast::VariantData) {
162-
run_early_pass!(self, check_struct_def, s);
163157
if let Some(ctor_hir_id) = s.ctor_id() {
164158
self.check_id(ctor_hir_id);
165159
}
166160
ast_visit::walk_struct_def(self, s);
167-
run_early_pass!(self, check_struct_def_post, s);
168161
}
169162

170163
fn visit_field_def(&mut self, s: &'a ast::FieldDef) {
171164
self.with_lint_attrs(s.id, &s.attrs, |cx| {
172-
run_early_pass!(cx, check_field_def, s);
173165
ast_visit::walk_field_def(cx, s);
174166
})
175167
}
@@ -178,7 +170,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
178170
self.with_lint_attrs(v.id, &v.attrs, |cx| {
179171
run_early_pass!(cx, check_variant, v);
180172
ast_visit::walk_variant(cx, v);
181-
run_early_pass!(cx, check_variant_post, v);
182173
})
183174
}
184175

@@ -203,7 +194,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
203194
run_early_pass!(self, check_block, b);
204195
self.check_id(b.id);
205196
ast_visit::walk_block(self, b);
206-
run_early_pass!(self, check_block_post, b);
207197
}
208198

209199
fn visit_arm(&mut self, a: &'a ast::Arm) {
@@ -214,8 +204,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
214204
}
215205

216206
fn visit_expr_post(&mut self, e: &'a ast::Expr) {
217-
run_early_pass!(self, check_expr_post, e);
218-
219207
// Explicitly check for lints associated with 'closure_id', since
220208
// it does not have a corresponding AST node
221209
match e.kind {
@@ -242,7 +230,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
242230
}
243231

244232
fn visit_where_predicate(&mut self, p: &'a ast::WherePredicate) {
245-
run_early_pass!(self, check_where_predicate, p);
246233
ast_visit::walk_where_predicate(self, p);
247234
}
248235

@@ -256,23 +243,19 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
256243
ast_visit::AssocCtxt::Trait => {
257244
run_early_pass!(cx, check_trait_item, item);
258245
ast_visit::walk_assoc_item(cx, item, ctxt);
259-
run_early_pass!(cx, check_trait_item_post, item);
260246
}
261247
ast_visit::AssocCtxt::Impl => {
262248
run_early_pass!(cx, check_impl_item, item);
263249
ast_visit::walk_assoc_item(cx, item, ctxt);
264-
run_early_pass!(cx, check_impl_item_post, item);
265250
}
266251
});
267252
}
268253

269254
fn visit_lifetime(&mut self, lt: &'a ast::Lifetime, _: ast_visit::LifetimeCtxt) {
270-
run_early_pass!(self, check_lifetime, lt);
271255
self.check_id(lt.id);
272256
}
273257

274258
fn visit_path(&mut self, p: &'a ast::Path, id: ast::NodeId) {
275-
run_early_pass!(self, check_path, p, id);
276259
self.check_id(id);
277260
ast_visit::walk_path(self, p);
278261
}

compiler/rustc_lint/src/late.rs

-14
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
8181
fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) {
8282
lint_callback!(self, check_mod, m, s, n);
8383
hir_visit::walk_mod(self, m, n);
84-
lint_callback!(self, check_mod_post, m, s, n);
8584
}
8685
}
8786

@@ -118,7 +117,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
118117

119118
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
120119
self.with_lint_attrs(param.hir_id, |cx| {
121-
lint_callback!(cx, check_param, param);
122120
hir_visit::walk_param(cx, param);
123121
});
124122
}
@@ -151,7 +149,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
151149
cx.with_param_env(it.hir_id(), |cx| {
152150
lint_callback!(cx, check_foreign_item, it);
153151
hir_visit::walk_foreign_item(cx, it);
154-
lint_callback!(cx, check_foreign_item_post, it);
155152
});
156153
})
157154
}
@@ -193,7 +190,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
193190
let body = self.context.tcx.hir().body(body_id);
194191
lint_callback!(self, check_fn, fk, decl, body, span, id);
195192
hir_visit::walk_fn(self, fk, decl, body_id, span, id);
196-
lint_callback!(self, check_fn_post, fk, decl, body, span, id);
197193
self.context.enclosing_body = old_enclosing_body;
198194
self.context.cached_typeck_results.set(old_cached_typeck_results);
199195
}
@@ -208,7 +204,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
208204
) {
209205
lint_callback!(self, check_struct_def, s);
210206
hir_visit::walk_struct_def(self, s);
211-
lint_callback!(self, check_struct_def_post, s);
212207
}
213208

214209
fn visit_field_def(&mut self, s: &'tcx hir::FieldDef<'tcx>) {
@@ -227,7 +222,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
227222
self.with_lint_attrs(v.id, |cx| {
228223
lint_callback!(cx, check_variant, v);
229224
hir_visit::walk_variant(cx, v, g, item_id);
230-
lint_callback!(cx, check_variant_post, v);
231225
})
232226
}
233227

@@ -237,14 +231,9 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
237231
}
238232

239233
fn visit_infer(&mut self, inf: &'tcx hir::InferArg) {
240-
lint_callback!(self, check_infer, inf);
241234
hir_visit::walk_inf(self, inf);
242235
}
243236

244-
fn visit_name(&mut self, sp: Span, name: Symbol) {
245-
lint_callback!(self, check_name, sp, name);
246-
}
247-
248237
fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) {
249238
if !self.context.only_module {
250239
self.process_mod(m, s, n);
@@ -280,7 +269,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
280269
}
281270

282271
fn visit_where_predicate(&mut self, p: &'tcx hir::WherePredicate<'tcx>) {
283-
lint_callback!(self, check_where_predicate, p);
284272
hir_visit::walk_where_predicate(self, p);
285273
}
286274

@@ -300,7 +288,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
300288
cx.with_param_env(trait_item.hir_id(), |cx| {
301289
lint_callback!(cx, check_trait_item, trait_item);
302290
hir_visit::walk_trait_item(cx, trait_item);
303-
lint_callback!(cx, check_trait_item_post, trait_item);
304291
});
305292
});
306293
self.context.generics = generics;
@@ -320,7 +307,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
320307
}
321308

322309
fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) {
323-
lint_callback!(self, check_lifetime, lt);
324310
hir_visit::walk_lifetime(self, lt);
325311
}
326312

compiler/rustc_lint/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ use rustc_middle::ty::TyCtxt;
7575
use rustc_session::lint::builtin::{
7676
BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS,
7777
};
78-
use rustc_span::symbol::{Ident, Symbol};
78+
use rustc_span::symbol::Ident;
7979
use rustc_span::Span;
8080

8181
use array_into_iter::ArrayIntoIter;

compiler/rustc_lint/src/passes.rs

+1-38
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@ use rustc_data_structures::sync;
55
use rustc_hir as hir;
66
use rustc_session::lint::builtin::HardwiredLints;
77
use rustc_session::lint::LintPass;
8-
use rustc_span::symbol::{Ident, Symbol};
8+
use rustc_span::symbol::Ident;
99
use rustc_span::Span;
1010

1111
#[macro_export]
1212
macro_rules! late_lint_methods {
1313
($macro:path, $args:tt, [$hir:tt]) => (
1414
$macro!($args, [$hir], [
15-
fn check_param(a: &$hir hir::Param<$hir>);
1615
fn check_body(a: &$hir hir::Body<$hir>);
1716
fn check_body_post(a: &$hir hir::Body<$hir>);
18-
fn check_name(a: Span, b: Symbol);
1917
fn check_crate();
2018
fn check_crate_post();
2119
fn check_mod(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId);
22-
fn check_mod_post(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId);
2320
fn check_foreign_item(a: &$hir hir::ForeignItem<$hir>);
24-
fn check_foreign_item_post(a: &$hir hir::ForeignItem<$hir>);
2521
fn check_item(a: &$hir hir::Item<$hir>);
2622
fn check_item_post(a: &$hir hir::Item<$hir>);
2723
fn check_local(a: &$hir hir::Local<$hir>);
@@ -33,35 +29,21 @@ macro_rules! late_lint_methods {
3329
fn check_expr(a: &$hir hir::Expr<$hir>);
3430
fn check_expr_post(a: &$hir hir::Expr<$hir>);
3531
fn check_ty(a: &$hir hir::Ty<$hir>);
36-
fn check_infer(a: &$hir hir::InferArg);
37-
fn check_generic_arg(a: &$hir hir::GenericArg<$hir>);
3832
fn check_generic_param(a: &$hir hir::GenericParam<$hir>);
3933
fn check_generics(a: &$hir hir::Generics<$hir>);
40-
fn check_where_predicate(a: &$hir hir::WherePredicate<$hir>);
4134
fn check_poly_trait_ref(a: &$hir hir::PolyTraitRef<$hir>, b: hir::TraitBoundModifier);
4235
fn check_fn(
4336
a: rustc_hir::intravisit::FnKind<$hir>,
4437
b: &$hir hir::FnDecl<$hir>,
4538
c: &$hir hir::Body<$hir>,
4639
d: Span,
4740
e: hir::HirId);
48-
fn check_fn_post(
49-
a: rustc_hir::intravisit::FnKind<$hir>,
50-
b: &$hir hir::FnDecl<$hir>,
51-
c: &$hir hir::Body<$hir>,
52-
d: Span,
53-
e: hir::HirId
54-
);
5541
fn check_trait_item(a: &$hir hir::TraitItem<$hir>);
56-
fn check_trait_item_post(a: &$hir hir::TraitItem<$hir>);
5742
fn check_impl_item(a: &$hir hir::ImplItem<$hir>);
5843
fn check_impl_item_post(a: &$hir hir::ImplItem<$hir>);
5944
fn check_struct_def(a: &$hir hir::VariantData<$hir>);
60-
fn check_struct_def_post(a: &$hir hir::VariantData<$hir>);
6145
fn check_field_def(a: &$hir hir::FieldDef<$hir>);
6246
fn check_variant(a: &$hir hir::Variant<$hir>);
63-
fn check_variant_post(a: &$hir hir::Variant<$hir>);
64-
fn check_lifetime(a: &$hir hir::Lifetime);
6547
fn check_path(a: &$hir hir::Path<$hir>, b: hir::HirId);
6648
fn check_attribute(a: &$hir ast::Attribute);
6749

@@ -161,44 +143,25 @@ macro_rules! early_lint_methods {
161143
fn check_ident(a: Ident);
162144
fn check_crate(a: &ast::Crate);
163145
fn check_crate_post(a: &ast::Crate);
164-
fn check_foreign_item(a: &ast::ForeignItem);
165-
fn check_foreign_item_post(a: &ast::ForeignItem);
166146
fn check_item(a: &ast::Item);
167147
fn check_item_post(a: &ast::Item);
168148
fn check_local(a: &ast::Local);
169149
fn check_block(a: &ast::Block);
170-
fn check_block_post(a: &ast::Block);
171150
fn check_stmt(a: &ast::Stmt);
172151
fn check_arm(a: &ast::Arm);
173152
fn check_pat(a: &ast::Pat);
174-
fn check_anon_const(a: &ast::AnonConst);
175153
fn check_pat_post(a: &ast::Pat);
176154
fn check_expr(a: &ast::Expr);
177-
fn check_expr_post(a: &ast::Expr);
178155
fn check_ty(a: &ast::Ty);
179156
fn check_generic_arg(a: &ast::GenericArg);
180157
fn check_generic_param(a: &ast::GenericParam);
181158
fn check_generics(a: &ast::Generics);
182-
fn check_where_predicate(a: &ast::WherePredicate);
183159
fn check_poly_trait_ref(a: &ast::PolyTraitRef,
184160
b: &ast::TraitBoundModifier);
185161
fn check_fn(a: rustc_ast::visit::FnKind<'_>, c: Span, d_: ast::NodeId);
186-
fn check_fn_post(
187-
a: rustc_ast::visit::FnKind<'_>,
188-
c: Span,
189-
d: ast::NodeId
190-
);
191162
fn check_trait_item(a: &ast::AssocItem);
192-
fn check_trait_item_post(a: &ast::AssocItem);
193163
fn check_impl_item(a: &ast::AssocItem);
194-
fn check_impl_item_post(a: &ast::AssocItem);
195-
fn check_struct_def(a: &ast::VariantData);
196-
fn check_struct_def_post(a: &ast::VariantData);
197-
fn check_field_def(a: &ast::FieldDef);
198164
fn check_variant(a: &ast::Variant);
199-
fn check_variant_post(a: &ast::Variant);
200-
fn check_lifetime(a: &ast::Lifetime);
201-
fn check_path(a: &ast::Path, b: ast::NodeId);
202165
fn check_attribute(a: &ast::Attribute);
203166
fn check_mac_def(a: &ast::MacroDef, b: ast::NodeId);
204167
fn check_mac(a: &ast::MacCall);

compiler/rustc_mir_build/src/build/block.rs

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
132132
initializer_span,
133133
else_block,
134134
visibility_scope,
135+
*remainder_scope,
135136
remainder_span,
136137
pattern,
137138
)

0 commit comments

Comments
 (0)