Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #99925

Merged
merged 28 commits into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
86ab4a0
word-wrap the comments.
Lokathor Jul 14, 2022
7be0b87
Update thumbv4t_none_eabi.rs
Lokathor Jul 14, 2022
6c22b44
add missing imports.
Lokathor Jul 14, 2022
0e78c73
conform to the tidy expectations
Lokathor Jul 14, 2022
26e0787
tidy demands this whitespace go away
Lokathor Jul 14, 2022
9b56640
break out scopes when let-else fails to match
dingxiangfei2009 Jul 20, 2022
baf9a7c
provide a test for #93951
dingxiangfei2009 Jul 21, 2022
60be2de
include a demo that more programs can be compiled
dingxiangfei2009 Jul 22, 2022
1d4ddab
suggest dereferencing index when trying to use a reference of usize a…
TaKO8Ki Jul 24, 2022
9cf5b2d
Update thumbv4t_none_eabi.rs
Lokathor Jul 28, 2022
2eac6f3
once again tidy was unhappy
Lokathor Jul 28, 2022
0fcb86b
Add Fuchsia platform support documentation
Jul 20, 2022
b67ba9b
fix ICE when computing codegen_fn_attrs on closure with non-fn parent
compiler-errors Jul 29, 2022
06f89b7
implement `point_at_index_if_possible`
TaKO8Ki Jul 29, 2022
3ae669d
check if T is slice
TaKO8Ki Jul 29, 2022
ab44b5a
Remove some early `check_*` functions.
nnethercote Jul 29, 2022
6dced80
Remove `visit_name` from the AST visitor.
nnethercote Jul 29, 2022
74e9a29
Remove some late `check_*` functions.
nnethercote Jul 29, 2022
dec29b1
Adjust an expr span to account for macros
compiler-errors Jul 29, 2022
6149cf9
Remove unwanted extra white space characters from HTML
GuillaumeGomez Jul 29, 2022
36ab4ec
Rollup merge of #99227 - Lokathor:fix-thumbv4t-none-eabi-frame-pointe…
JohnTitor Jul 29, 2022
955091b
Rollup merge of #99518 - dingxiangfei2009:let-else-additional-tests, …
JohnTitor Jul 29, 2022
4a44efa
Rollup merge of #99671 - TaKO8Ki:suggest-dereferencing-index, r=compi…
JohnTitor Jul 29, 2022
59320d5
Rollup merge of #99831 - djkoloski:add_fuchsia_target_documentation, …
JohnTitor Jul 29, 2022
c1a5c11
Rollup merge of #99881 - compiler-errors:issue-99876, r=tmiasko
JohnTitor Jul 29, 2022
5c3b6d6
Rollup merge of #99888 - nnethercote:streamline-visitors, r=cjgillot
JohnTitor Jul 29, 2022
735969e
Rollup merge of #99891 - compiler-errors:suggest-slicing-carefully, r…
JohnTitor Jul 29, 2022
cfbf7be
Rollup merge of #99904 - GuillaumeGomez:cleanup-html-whitespace, r=no…
JohnTitor Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use crate::ast::*;

use rustc_span::symbol::{Ident, Symbol};
use rustc_span::symbol::Ident;
use rustc_span::Span;

#[derive(Copy, Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -109,12 +109,7 @@ pub enum LifetimeCtxt {
/// to monitor future changes to `Visitor` in case a new method with a
/// new default implementation gets introduced.)
pub trait Visitor<'ast>: Sized {
fn visit_name(&mut self, _span: Span, _name: Symbol) {
// Nothing to do.
}
fn visit_ident(&mut self, ident: Ident) {
walk_ident(self, ident);
}
fn visit_ident(&mut self, _ident: Ident) {}
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) {
walk_foreign_item(self, i)
}
Expand Down Expand Up @@ -267,10 +262,6 @@ macro_rules! walk_list {
}
}

pub fn walk_ident<'a, V: Visitor<'a>>(visitor: &mut V, ident: Ident) {
visitor.visit_name(ident.span, ident.name);
}

pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) {
walk_list!(visitor, visit_item, &krate.items);
walk_list!(visitor, visit_attribute, &krate.attrs);
Expand Down Expand Up @@ -315,11 +306,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
visitor.visit_vis(&item.vis);
visitor.visit_ident(item.ident);
match item.kind {
ItemKind::ExternCrate(orig_name) => {
if let Some(orig_name) = orig_name {
visitor.visit_name(item.span, orig_name);
}
}
ItemKind::ExternCrate(_) => {}
ItemKind::Use(ref use_tree) => visitor.visit_use_tree(use_tree, item.id, false),
ItemKind::Static(ref typ, _, ref expr) | ItemKind::Const(_, ref typ, ref expr) => {
visitor.visit_ty(typ);
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast_passes/src/node_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ impl NodeCounter {
}

impl<'ast> Visitor<'ast> for NodeCounter {
fn visit_ident(&mut self, ident: Ident) {
fn visit_ident(&mut self, _ident: Ident) {
self.count += 1;
walk_ident(self, ident);
}
fn visit_foreign_item(&mut self, i: &ForeignItem) {
self.count += 1;
Expand Down
17 changes: 0 additions & 17 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>

fn visit_foreign_item(&mut self, it: &'a ast::ForeignItem) {
self.with_lint_attrs(it.id, &it.attrs, |cx| {
run_early_pass!(cx, check_foreign_item, it);
ast_visit::walk_foreign_item(cx, it);
run_early_pass!(cx, check_foreign_item_post, it);
})
}

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

fn visit_anon_const(&mut self, c: &'a ast::AnonConst) {
run_early_pass!(self, check_anon_const, c);
self.check_id(c.id);
ast_visit::walk_anon_const(self, c);
}
Expand Down Expand Up @@ -154,22 +151,17 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
self.check_id(closure_id);
}
}

run_early_pass!(self, check_fn_post, fk, span, id);
}

fn visit_variant_data(&mut self, s: &'a ast::VariantData) {
run_early_pass!(self, check_struct_def, s);
if let Some(ctor_hir_id) = s.ctor_id() {
self.check_id(ctor_hir_id);
}
ast_visit::walk_struct_def(self, s);
run_early_pass!(self, check_struct_def_post, s);
}

fn visit_field_def(&mut self, s: &'a ast::FieldDef) {
self.with_lint_attrs(s.id, &s.attrs, |cx| {
run_early_pass!(cx, check_field_def, s);
ast_visit::walk_field_def(cx, s);
})
}
Expand All @@ -178,7 +170,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
self.with_lint_attrs(v.id, &v.attrs, |cx| {
run_early_pass!(cx, check_variant, v);
ast_visit::walk_variant(cx, v);
run_early_pass!(cx, check_variant_post, v);
})
}

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

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

fn visit_expr_post(&mut self, e: &'a ast::Expr) {
run_early_pass!(self, check_expr_post, e);

// Explicitly check for lints associated with 'closure_id', since
// it does not have a corresponding AST node
match e.kind {
Expand All @@ -242,7 +230,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
}

fn visit_where_predicate(&mut self, p: &'a ast::WherePredicate) {
run_early_pass!(self, check_where_predicate, p);
ast_visit::walk_where_predicate(self, p);
}

Expand All @@ -256,23 +243,19 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
ast_visit::AssocCtxt::Trait => {
run_early_pass!(cx, check_trait_item, item);
ast_visit::walk_assoc_item(cx, item, ctxt);
run_early_pass!(cx, check_trait_item_post, item);
}
ast_visit::AssocCtxt::Impl => {
run_early_pass!(cx, check_impl_item, item);
ast_visit::walk_assoc_item(cx, item, ctxt);
run_early_pass!(cx, check_impl_item_post, item);
}
});
}

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

fn visit_path(&mut self, p: &'a ast::Path, id: ast::NodeId) {
run_early_pass!(self, check_path, p, id);
self.check_id(id);
ast_visit::walk_path(self, p);
}
Expand Down
14 changes: 0 additions & 14 deletions compiler/rustc_lint/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
fn process_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) {
lint_callback!(self, check_mod, m, s, n);
hir_visit::walk_mod(self, m, n);
lint_callback!(self, check_mod_post, m, s, n);
}
}

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

fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
self.with_lint_attrs(param.hir_id, |cx| {
lint_callback!(cx, check_param, param);
hir_visit::walk_param(cx, param);
});
}
Expand Down Expand Up @@ -151,7 +149,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
cx.with_param_env(it.hir_id(), |cx| {
lint_callback!(cx, check_foreign_item, it);
hir_visit::walk_foreign_item(cx, it);
lint_callback!(cx, check_foreign_item_post, it);
});
})
}
Expand Down Expand Up @@ -193,7 +190,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
let body = self.context.tcx.hir().body(body_id);
lint_callback!(self, check_fn, fk, decl, body, span, id);
hir_visit::walk_fn(self, fk, decl, body_id, span, id);
lint_callback!(self, check_fn_post, fk, decl, body, span, id);
self.context.enclosing_body = old_enclosing_body;
self.context.cached_typeck_results.set(old_cached_typeck_results);
}
Expand All @@ -208,7 +204,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
) {
lint_callback!(self, check_struct_def, s);
hir_visit::walk_struct_def(self, s);
lint_callback!(self, check_struct_def_post, s);
}

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

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

fn visit_infer(&mut self, inf: &'tcx hir::InferArg) {
lint_callback!(self, check_infer, inf);
hir_visit::walk_inf(self, inf);
}

fn visit_name(&mut self, sp: Span, name: Symbol) {
lint_callback!(self, check_name, sp, name);
}

fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, s: Span, n: hir::HirId) {
if !self.context.only_module {
self.process_mod(m, s, n);
Expand Down Expand Up @@ -280,7 +269,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
}

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

Expand All @@ -300,7 +288,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
cx.with_param_env(trait_item.hir_id(), |cx| {
lint_callback!(cx, check_trait_item, trait_item);
hir_visit::walk_trait_item(cx, trait_item);
lint_callback!(cx, check_trait_item_post, trait_item);
});
});
self.context.generics = generics;
Expand All @@ -320,7 +307,6 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
}

fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) {
lint_callback!(self, check_lifetime, lt);
hir_visit::walk_lifetime(self, lt);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ use rustc_middle::ty::TyCtxt;
use rustc_session::lint::builtin::{
BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS,
};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::symbol::Ident;
use rustc_span::Span;

use array_into_iter::ArrayIntoIter;
Expand Down
39 changes: 1 addition & 38 deletions compiler/rustc_lint/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@ use rustc_data_structures::sync;
use rustc_hir as hir;
use rustc_session::lint::builtin::HardwiredLints;
use rustc_session::lint::LintPass;
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::symbol::Ident;
use rustc_span::Span;

#[macro_export]
macro_rules! late_lint_methods {
($macro:path, $args:tt, [$hir:tt]) => (
$macro!($args, [$hir], [
fn check_param(a: &$hir hir::Param<$hir>);
fn check_body(a: &$hir hir::Body<$hir>);
fn check_body_post(a: &$hir hir::Body<$hir>);
fn check_name(a: Span, b: Symbol);
fn check_crate();
fn check_crate_post();
fn check_mod(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId);
fn check_mod_post(a: &$hir hir::Mod<$hir>, b: Span, c: hir::HirId);
fn check_foreign_item(a: &$hir hir::ForeignItem<$hir>);
fn check_foreign_item_post(a: &$hir hir::ForeignItem<$hir>);
fn check_item(a: &$hir hir::Item<$hir>);
fn check_item_post(a: &$hir hir::Item<$hir>);
fn check_local(a: &$hir hir::Local<$hir>);
Expand All @@ -33,35 +29,21 @@ macro_rules! late_lint_methods {
fn check_expr(a: &$hir hir::Expr<$hir>);
fn check_expr_post(a: &$hir hir::Expr<$hir>);
fn check_ty(a: &$hir hir::Ty<$hir>);
fn check_infer(a: &$hir hir::InferArg);
fn check_generic_arg(a: &$hir hir::GenericArg<$hir>);
fn check_generic_param(a: &$hir hir::GenericParam<$hir>);
fn check_generics(a: &$hir hir::Generics<$hir>);
fn check_where_predicate(a: &$hir hir::WherePredicate<$hir>);
fn check_poly_trait_ref(a: &$hir hir::PolyTraitRef<$hir>, b: hir::TraitBoundModifier);
fn check_fn(
a: rustc_hir::intravisit::FnKind<$hir>,
b: &$hir hir::FnDecl<$hir>,
c: &$hir hir::Body<$hir>,
d: Span,
e: hir::HirId);
fn check_fn_post(
a: rustc_hir::intravisit::FnKind<$hir>,
b: &$hir hir::FnDecl<$hir>,
c: &$hir hir::Body<$hir>,
d: Span,
e: hir::HirId
);
fn check_trait_item(a: &$hir hir::TraitItem<$hir>);
fn check_trait_item_post(a: &$hir hir::TraitItem<$hir>);
fn check_impl_item(a: &$hir hir::ImplItem<$hir>);
fn check_impl_item_post(a: &$hir hir::ImplItem<$hir>);
fn check_struct_def(a: &$hir hir::VariantData<$hir>);
fn check_struct_def_post(a: &$hir hir::VariantData<$hir>);
fn check_field_def(a: &$hir hir::FieldDef<$hir>);
fn check_variant(a: &$hir hir::Variant<$hir>);
fn check_variant_post(a: &$hir hir::Variant<$hir>);
fn check_lifetime(a: &$hir hir::Lifetime);
fn check_path(a: &$hir hir::Path<$hir>, b: hir::HirId);
fn check_attribute(a: &$hir ast::Attribute);

Expand Down Expand Up @@ -161,44 +143,25 @@ macro_rules! early_lint_methods {
fn check_ident(a: Ident);
fn check_crate(a: &ast::Crate);
fn check_crate_post(a: &ast::Crate);
fn check_foreign_item(a: &ast::ForeignItem);
fn check_foreign_item_post(a: &ast::ForeignItem);
fn check_item(a: &ast::Item);
fn check_item_post(a: &ast::Item);
fn check_local(a: &ast::Local);
fn check_block(a: &ast::Block);
fn check_block_post(a: &ast::Block);
fn check_stmt(a: &ast::Stmt);
fn check_arm(a: &ast::Arm);
fn check_pat(a: &ast::Pat);
fn check_anon_const(a: &ast::AnonConst);
fn check_pat_post(a: &ast::Pat);
fn check_expr(a: &ast::Expr);
fn check_expr_post(a: &ast::Expr);
fn check_ty(a: &ast::Ty);
fn check_generic_arg(a: &ast::GenericArg);
fn check_generic_param(a: &ast::GenericParam);
fn check_generics(a: &ast::Generics);
fn check_where_predicate(a: &ast::WherePredicate);
fn check_poly_trait_ref(a: &ast::PolyTraitRef,
b: &ast::TraitBoundModifier);
fn check_fn(a: rustc_ast::visit::FnKind<'_>, c: Span, d_: ast::NodeId);
fn check_fn_post(
a: rustc_ast::visit::FnKind<'_>,
c: Span,
d: ast::NodeId
);
fn check_trait_item(a: &ast::AssocItem);
fn check_trait_item_post(a: &ast::AssocItem);
fn check_impl_item(a: &ast::AssocItem);
fn check_impl_item_post(a: &ast::AssocItem);
fn check_struct_def(a: &ast::VariantData);
fn check_struct_def_post(a: &ast::VariantData);
fn check_field_def(a: &ast::FieldDef);
fn check_variant(a: &ast::Variant);
fn check_variant_post(a: &ast::Variant);
fn check_lifetime(a: &ast::Lifetime);
fn check_path(a: &ast::Path, b: ast::NodeId);
fn check_attribute(a: &ast::Attribute);
fn check_mac_def(a: &ast::MacroDef, b: ast::NodeId);
fn check_mac(a: &ast::MacCall);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_build/src/build/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
initializer_span,
else_block,
visibility_scope,
*remainder_scope,
remainder_span,
pattern,
)
Expand Down
Loading