Auto merge of #64813 - varkor:node-to-kind, r=Centril
Rename `*.node` to `*.kind`, and `hair::Pattern*` to `hair::Pat*` In both `ast::Expr` and `hir::Expr`: - Rename `Expr.node` to `Expr.kind`. - Rename `Pat.node` to `Pat.kind`. - Rename `ImplItem.node` to `ImplItem.kind`. - Rename `Lit.node` to `Lit.kind`. - Rename `TraitItem.node` to `TraitItem.kind`. - Rename `Ty.node` to `Ty.kind`. - Rename `Stmt.node` to `Stmt.kind`. - Rename `Item.node` to `Item.kind`. - Rename `ForeignItem.node` to `ForeignItem.kind`. - Rename `MetaItem.node` to `MetaItem.kind`. Also: - Rename `hair::FieldPattern` to `hair::FieldPat`. - Rename `hair::PatternKind` to `hair::PatKind`. - Rename `hair::PatternRange` to `hair::PatRange`. - Rename `PatternContext` to `PatCtxt`. - Rename `PatternTypeProjection` to `PatTyProj`. - Rename `hair::Pattern` to `hair::Pat`. These two sets of changes are grouped together to aid with merging. The only changes are renamings. r? @petrochenkov
This commit is contained in:
commit
590ae0ec4d
177 changed files with 1574 additions and 1587 deletions
|
|
@ -65,7 +65,7 @@ impl Display for Target {
|
|||
|
||||
impl Target {
|
||||
pub(crate) fn from_item(item: &hir::Item) -> Target {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(..) => Target::ExternCrate,
|
||||
hir::ItemKind::Use(..) => Target::Use,
|
||||
hir::ItemKind::Static(..) => Target::Static,
|
||||
|
|
@ -262,7 +262,7 @@ impl CheckAttrVisitor<'tcx> {
|
|||
|
||||
fn check_stmt_attributes(&self, stmt: &hir::Stmt) {
|
||||
// When checking statements ignore expressions, they will be checked later
|
||||
if let hir::StmtKind::Local(ref l) = stmt.node {
|
||||
if let hir::StmtKind::Local(ref l) = stmt.kind {
|
||||
for attr in l.attrs.iter() {
|
||||
if attr.check_name(sym::inline) {
|
||||
self.check_inline(attr, &stmt.span, Target::Statement);
|
||||
|
|
@ -280,7 +280,7 @@ impl CheckAttrVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn check_expr_attributes(&self, expr: &hir::Expr) {
|
||||
let target = match expr.node {
|
||||
let target = match expr.kind {
|
||||
hir::ExprKind::Closure(..) => Target::Closure,
|
||||
_ => Target::Expression,
|
||||
};
|
||||
|
|
@ -333,7 +333,7 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn is_c_like_enum(item: &hir::Item) -> bool {
|
||||
if let hir::ItemKind::Enum(ref def, _) = item.node {
|
||||
if let hir::ItemKind::Enum(ref def, _) = item.kind {
|
||||
for variant in &def.variants {
|
||||
match variant.data {
|
||||
hir::VariantData::Unit(..) => { /* continue */ }
|
||||
|
|
|
|||
|
|
@ -465,7 +465,7 @@ pub fn walk_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Param) {
|
|||
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
visitor.visit_vis(&item.vis);
|
||||
visitor.visit_ident(item.ident);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::ExternCrate(orig_name) => {
|
||||
visitor.visit_id(item.hir_id);
|
||||
if let Some(orig_name) = orig_name {
|
||||
|
|
@ -594,7 +594,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
|
|||
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
|
||||
visitor.visit_id(typ.hir_id);
|
||||
|
||||
match typ.node {
|
||||
match typ.kind {
|
||||
TyKind::Slice(ref ty) => {
|
||||
visitor.visit_ty(ty)
|
||||
}
|
||||
|
|
@ -696,7 +696,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
|
|||
|
||||
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
|
||||
visitor.visit_id(pattern.hir_id);
|
||||
match pattern.node {
|
||||
match pattern.kind {
|
||||
PatKind::TupleStruct(ref qpath, ref children, _) => {
|
||||
visitor.visit_qpath(qpath, pattern.hir_id, pattern.span);
|
||||
walk_list!(visitor, visit_pat, children);
|
||||
|
|
@ -743,7 +743,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v
|
|||
visitor.visit_vis(&foreign_item.vis);
|
||||
visitor.visit_ident(foreign_item.ident);
|
||||
|
||||
match foreign_item.node {
|
||||
match foreign_item.kind {
|
||||
ForeignItemKind::Fn(ref function_declaration, ref param_names, ref generics) => {
|
||||
visitor.visit_generics(generics);
|
||||
visitor.visit_fn_decl(function_declaration);
|
||||
|
|
@ -856,7 +856,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
|||
visitor.visit_ident(trait_item.ident);
|
||||
walk_list!(visitor, visit_attribute, &trait_item.attrs);
|
||||
visitor.visit_generics(&trait_item.generics);
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
TraitItemKind::Const(ref ty, default) => {
|
||||
visitor.visit_id(trait_item.hir_id);
|
||||
visitor.visit_ty(ty);
|
||||
|
|
@ -905,7 +905,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
|
|||
ref defaultness,
|
||||
ref attrs,
|
||||
ref generics,
|
||||
ref node,
|
||||
ref kind,
|
||||
span: _,
|
||||
} = *impl_item;
|
||||
|
||||
|
|
@ -914,7 +914,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
|
|||
visitor.visit_defaultness(defaultness);
|
||||
walk_list!(visitor, visit_attribute, attrs);
|
||||
visitor.visit_generics(generics);
|
||||
match *node {
|
||||
match *kind {
|
||||
ImplItemKind::Const(ref ty, body) => {
|
||||
visitor.visit_id(impl_item.hir_id);
|
||||
visitor.visit_ty(ty);
|
||||
|
|
@ -974,7 +974,7 @@ pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {
|
|||
|
||||
pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
|
||||
visitor.visit_id(statement.hir_id);
|
||||
match statement.node {
|
||||
match statement.kind {
|
||||
StmtKind::Local(ref local) => visitor.visit_local(local),
|
||||
StmtKind::Item(item) => visitor.visit_nested_item(item),
|
||||
StmtKind::Expr(ref expression) |
|
||||
|
|
@ -992,7 +992,7 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo
|
|||
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
||||
visitor.visit_id(expression.hir_id);
|
||||
walk_list!(visitor, visit_attribute, expression.attrs.iter());
|
||||
match expression.node {
|
||||
match expression.kind {
|
||||
ExprKind::Box(ref subexpression) => {
|
||||
visitor.visit_expr(subexpression)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ struct ImplTraitTypeIdVisitor<'a> { ids: &'a mut SmallVec<[NodeId; 1]> }
|
|||
|
||||
impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> {
|
||||
fn visit_ty(&mut self, ty: &'a Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
| TyKind::Typeof(_)
|
||||
| TyKind::BareFn(_)
|
||||
=> return,
|
||||
|
|
@ -425,7 +425,7 @@ impl<'a> LoweringContext<'a> {
|
|||
|
||||
impl<'tcx, 'interner> Visitor<'tcx> for MiscCollector<'tcx, 'interner> {
|
||||
fn visit_pat(&mut self, p: &'tcx Pat) {
|
||||
if let PatKind::Paren(..) | PatKind::Rest = p.node {
|
||||
if let PatKind::Paren(..) | PatKind::Rest = p.kind {
|
||||
// Doesn't generate a HIR node
|
||||
} else if let Some(owner) = self.hir_id_owner {
|
||||
self.lctx.lower_node_id_with_owner(p.id, owner);
|
||||
|
|
@ -437,7 +437,7 @@ impl<'a> LoweringContext<'a> {
|
|||
fn visit_item(&mut self, item: &'tcx Item) {
|
||||
let hir_id = self.lctx.allocate_hir_id_counter(item.id);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Struct(_, ref generics)
|
||||
| ItemKind::Union(_, ref generics)
|
||||
| ItemKind::Enum(_, ref generics)
|
||||
|
|
@ -469,7 +469,7 @@ impl<'a> LoweringContext<'a> {
|
|||
fn visit_trait_item(&mut self, item: &'tcx TraitItem) {
|
||||
self.lctx.allocate_hir_id_counter(item.id);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Method(_, None) => {
|
||||
// Ignore patterns in trait methods without bodies
|
||||
self.with_hir_id_owner(None, |this| {
|
||||
|
|
@ -497,7 +497,7 @@ impl<'a> LoweringContext<'a> {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, t: &'tcx Ty) {
|
||||
match t.node {
|
||||
match t.kind {
|
||||
// Mirrors the case in visit::walk_ty
|
||||
TyKind::BareFn(ref f) => {
|
||||
walk_list!(
|
||||
|
|
@ -1104,7 +1104,7 @@ impl<'a> LoweringContext<'a> {
|
|||
let ty = this.lower_ty(
|
||||
&Ty {
|
||||
id: this.sess.next_node_id(),
|
||||
node: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()),
|
||||
kind: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()),
|
||||
span: constraint.span,
|
||||
},
|
||||
itctx,
|
||||
|
|
@ -1165,14 +1165,14 @@ impl<'a> LoweringContext<'a> {
|
|||
let id = self.lower_node_id(t.id);
|
||||
let qpath = self.lower_qpath(t.id, qself, path, param_mode, itctx);
|
||||
let ty = self.ty_path(id, t.span, qpath);
|
||||
if let hir::TyKind::TraitObject(..) = ty.node {
|
||||
if let hir::TyKind::TraitObject(..) = ty.kind {
|
||||
self.maybe_lint_bare_trait(t.span, t.id, qself.is_none() && path.is_global());
|
||||
}
|
||||
ty
|
||||
}
|
||||
|
||||
fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::Ty {
|
||||
let kind = match t.node {
|
||||
let kind = match t.kind {
|
||||
TyKind::Infer => hir::TyKind::Infer,
|
||||
TyKind::Err => hir::TyKind::Err,
|
||||
TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)),
|
||||
|
|
@ -1345,7 +1345,7 @@ impl<'a> LoweringContext<'a> {
|
|||
};
|
||||
|
||||
hir::Ty {
|
||||
node: kind,
|
||||
kind,
|
||||
span: t.span,
|
||||
hir_id: self.lower_node_id(t.id),
|
||||
}
|
||||
|
|
@ -1445,7 +1445,7 @@ impl<'a> LoweringContext<'a> {
|
|||
hir_id: opaque_ty_id,
|
||||
ident: Ident::invalid(),
|
||||
attrs: Default::default(),
|
||||
node: opaque_ty_item_kind,
|
||||
kind: opaque_ty_item_kind,
|
||||
vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),
|
||||
span: opaque_ty_span,
|
||||
};
|
||||
|
|
@ -1505,7 +1505,7 @@ impl<'a> LoweringContext<'a> {
|
|||
|
||||
fn visit_ty(&mut self, t: &'v hir::Ty) {
|
||||
// Don't collect elided lifetimes used inside of `fn()` syntax.
|
||||
if let hir::TyKind::BareFn(_) = t.node {
|
||||
if let hir::TyKind::BareFn(_) = t.kind {
|
||||
let old_collect_elided_lifetimes = self.collect_elided_lifetimes;
|
||||
self.collect_elided_lifetimes = false;
|
||||
|
||||
|
|
@ -2026,7 +2026,7 @@ impl<'a> LoweringContext<'a> {
|
|||
.map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed()))
|
||||
.collect();
|
||||
let mk_tup = |this: &mut Self, tys, span| {
|
||||
hir::Ty { node: hir::TyKind::Tup(tys), hir_id: this.next_id(), span }
|
||||
hir::Ty { kind: hir::TyKind::Tup(tys), hir_id: this.next_id(), span }
|
||||
};
|
||||
(
|
||||
hir::GenericArgs {
|
||||
|
|
@ -2095,7 +2095,7 @@ impl<'a> LoweringContext<'a> {
|
|||
fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> hir::HirVec<Ident> {
|
||||
decl.inputs
|
||||
.iter()
|
||||
.map(|param| match param.pat.node {
|
||||
.map(|param| match param.pat.kind {
|
||||
PatKind::Ident(_, ident, _) => ident,
|
||||
_ => Ident::new(kw::Invalid, param.pat.span),
|
||||
})
|
||||
|
|
@ -2172,23 +2172,23 @@ impl<'a> LoweringContext<'a> {
|
|||
implicit_self: decl.inputs.get(0).map_or(
|
||||
hir::ImplicitSelfKind::None,
|
||||
|arg| {
|
||||
let is_mutable_pat = match arg.pat.node {
|
||||
let is_mutable_pat = match arg.pat.kind {
|
||||
PatKind::Ident(BindingMode::ByValue(mt), _, _) |
|
||||
PatKind::Ident(BindingMode::ByRef(mt), _, _) =>
|
||||
mt == Mutability::Mutable,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
match arg.ty.node {
|
||||
match arg.ty.kind {
|
||||
TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut,
|
||||
TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm,
|
||||
// Given we are only considering `ImplicitSelf` types, we needn't consider
|
||||
// the case where we have a mutable pattern to a reference as that would
|
||||
// no longer be an `ImplicitSelf`.
|
||||
TyKind::Rptr(_, ref mt) if mt.ty.node.is_implicit_self() &&
|
||||
TyKind::Rptr(_, ref mt) if mt.ty.kind.is_implicit_self() &&
|
||||
mt.mutbl == ast::Mutability::Mutable =>
|
||||
hir::ImplicitSelfKind::MutRef,
|
||||
TyKind::Rptr(_, ref mt) if mt.ty.node.is_implicit_self() =>
|
||||
TyKind::Rptr(_, ref mt) if mt.ty.kind.is_implicit_self() =>
|
||||
hir::ImplicitSelfKind::ImmRef,
|
||||
_ => hir::ImplicitSelfKind::None,
|
||||
}
|
||||
|
|
@ -2403,7 +2403,7 @@ impl<'a> LoweringContext<'a> {
|
|||
let opaque_ty_ref = hir::TyKind::Def(hir::ItemId { id: opaque_ty_id }, generic_args.into());
|
||||
|
||||
hir::FunctionRetTy::Return(P(hir::Ty {
|
||||
node: opaque_ty_ref,
|
||||
kind: opaque_ty_ref,
|
||||
span,
|
||||
hir_id: self.next_id(),
|
||||
}))
|
||||
|
|
@ -2424,7 +2424,7 @@ impl<'a> LoweringContext<'a> {
|
|||
FunctionRetTy::Default(ret_ty_span) => {
|
||||
P(hir::Ty {
|
||||
hir_id: self.next_id(),
|
||||
node: hir::TyKind::Tup(hir_vec![]),
|
||||
kind: hir::TyKind::Tup(hir_vec![]),
|
||||
span: *ret_ty_span,
|
||||
})
|
||||
}
|
||||
|
|
@ -2660,7 +2660,7 @@ impl<'a> LoweringContext<'a> {
|
|||
|
||||
for (index, stmt) in b.stmts.iter().enumerate() {
|
||||
if index == b.stmts.len() - 1 {
|
||||
if let StmtKind::Expr(ref e) = stmt.node {
|
||||
if let StmtKind::Expr(ref e) = stmt.kind {
|
||||
expr = Some(P(self.lower_expr(e)));
|
||||
} else {
|
||||
stmts.extend(self.lower_stmt(stmt));
|
||||
|
|
@ -2688,7 +2688,7 @@ impl<'a> LoweringContext<'a> {
|
|||
}
|
||||
|
||||
fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
|
||||
let node = match p.node {
|
||||
let node = match p.kind {
|
||||
PatKind::Wild => hir::PatKind::Wild,
|
||||
PatKind::Ident(ref binding_mode, ident, ref sub) => {
|
||||
let lower_sub = |this: &mut Self| sub.as_ref().map(|x| this.lower_pat(x));
|
||||
|
|
@ -2805,7 +2805,7 @@ impl<'a> LoweringContext<'a> {
|
|||
let mut iter = pats.iter();
|
||||
while let Some(pat) = iter.next() {
|
||||
// Interpret the first `((ref mut?)? x @)? ..` pattern as a subslice pattern.
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Rest => {
|
||||
prev_rest_span = Some(pat.span);
|
||||
slice = Some(self.pat_wild_with_node_id_of(pat));
|
||||
|
|
@ -2827,7 +2827,7 @@ impl<'a> LoweringContext<'a> {
|
|||
|
||||
while let Some(pat) = iter.next() {
|
||||
// There was a previous subslice pattern; make sure we don't allow more.
|
||||
let rest_span = match pat.node {
|
||||
let rest_span = match pat.kind {
|
||||
PatKind::Rest => Some(pat.span),
|
||||
PatKind::Ident(.., Some(ref sub)) if sub.is_rest() => {
|
||||
// The `HirValidator` is merciless; add a `_` pattern to avoid ICEs.
|
||||
|
|
@ -2884,10 +2884,10 @@ impl<'a> LoweringContext<'a> {
|
|||
}
|
||||
|
||||
/// Construct a `Pat` with the `HirId` of `p.id` lowered.
|
||||
fn pat_with_node_id_of(&mut self, p: &Pat, node: hir::PatKind) -> P<hir::Pat> {
|
||||
fn pat_with_node_id_of(&mut self, p: &Pat, kind: hir::PatKind) -> P<hir::Pat> {
|
||||
P(hir::Pat {
|
||||
hir_id: self.lower_node_id(p.id),
|
||||
node,
|
||||
kind,
|
||||
span: p.span,
|
||||
})
|
||||
}
|
||||
|
|
@ -2931,7 +2931,7 @@ impl<'a> LoweringContext<'a> {
|
|||
}
|
||||
|
||||
fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt; 1]> {
|
||||
let node = match s.node {
|
||||
let kind = match s.kind {
|
||||
StmtKind::Local(ref l) => {
|
||||
let (l, item_ids) = self.lower_local(l);
|
||||
let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids
|
||||
|
|
@ -2944,7 +2944,7 @@ impl<'a> LoweringContext<'a> {
|
|||
ids.push({
|
||||
hir::Stmt {
|
||||
hir_id: self.lower_node_id(s.id),
|
||||
node: hir::StmtKind::Local(P(l)),
|
||||
kind: hir::StmtKind::Local(P(l)),
|
||||
span: s.span,
|
||||
}
|
||||
});
|
||||
|
|
@ -2962,7 +2962,7 @@ impl<'a> LoweringContext<'a> {
|
|||
|
||||
hir::Stmt {
|
||||
hir_id,
|
||||
node: hir::StmtKind::Item(item_id),
|
||||
kind: hir::StmtKind::Item(item_id),
|
||||
span: s.span,
|
||||
}
|
||||
})
|
||||
|
|
@ -2974,7 +2974,7 @@ impl<'a> LoweringContext<'a> {
|
|||
};
|
||||
smallvec![hir::Stmt {
|
||||
hir_id: self.lower_node_id(s.id),
|
||||
node,
|
||||
kind,
|
||||
span: s.span,
|
||||
}]
|
||||
}
|
||||
|
|
@ -3011,8 +3011,8 @@ impl<'a> LoweringContext<'a> {
|
|||
|
||||
// Helper methods for building HIR.
|
||||
|
||||
fn stmt(&mut self, span: Span, node: hir::StmtKind) -> hir::Stmt {
|
||||
hir::Stmt { span, node, hir_id: self.next_id() }
|
||||
fn stmt(&mut self, span: Span, kind: hir::StmtKind) -> hir::Stmt {
|
||||
hir::Stmt { span, kind, hir_id: self.next_id() }
|
||||
}
|
||||
|
||||
fn stmt_expr(&mut self, span: Span, expr: hir::Expr) -> hir::Stmt {
|
||||
|
|
@ -3112,7 +3112,7 @@ impl<'a> LoweringContext<'a> {
|
|||
(
|
||||
P(hir::Pat {
|
||||
hir_id,
|
||||
node: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
|
||||
kind: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
|
||||
span,
|
||||
}),
|
||||
hir_id
|
||||
|
|
@ -3123,10 +3123,10 @@ impl<'a> LoweringContext<'a> {
|
|||
self.pat(span, hir::PatKind::Wild)
|
||||
}
|
||||
|
||||
fn pat(&mut self, span: Span, pat: hir::PatKind) -> P<hir::Pat> {
|
||||
fn pat(&mut self, span: Span, kind: hir::PatKind) -> P<hir::Pat> {
|
||||
P(hir::Pat {
|
||||
hir_id: self.next_id(),
|
||||
node: pat,
|
||||
kind,
|
||||
span,
|
||||
})
|
||||
}
|
||||
|
|
@ -3164,7 +3164,7 @@ impl<'a> LoweringContext<'a> {
|
|||
}
|
||||
|
||||
fn ty_path(&mut self, mut hir_id: hir::HirId, span: Span, qpath: hir::QPath) -> hir::Ty {
|
||||
let node = match qpath {
|
||||
let kind = match qpath {
|
||||
hir::QPath::Resolved(None, path) => {
|
||||
// Turn trait object paths into `TyKind::TraitObject` instead.
|
||||
match path.res {
|
||||
|
|
@ -3188,9 +3188,10 @@ impl<'a> LoweringContext<'a> {
|
|||
}
|
||||
_ => hir::TyKind::Path(qpath),
|
||||
};
|
||||
|
||||
hir::Ty {
|
||||
hir_id,
|
||||
node,
|
||||
kind,
|
||||
span,
|
||||
}
|
||||
}
|
||||
|
|
@ -3378,7 +3379,7 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
|
|||
}
|
||||
};
|
||||
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
// All built-in range literals but `..=` and `..` desugar to `Struct`s.
|
||||
ExprKind::Struct(ref qpath, _, _) => {
|
||||
if let QPath::Resolved(None, ref path) = **qpath {
|
||||
|
|
@ -3393,8 +3394,8 @@ pub fn is_range_literal(sess: &Session, expr: &hir::Expr) -> bool {
|
|||
|
||||
// `..=` desugars into `::std::ops::RangeInclusive::new(...)`.
|
||||
ExprKind::Call(ref func, _) => {
|
||||
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.node {
|
||||
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node {
|
||||
if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.kind {
|
||||
if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.kind {
|
||||
let new_call = segment.ident.as_str() == "new";
|
||||
return is_range_path(&path) && is_lit(sess, &expr.span) && new_call;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ impl LoweringContext<'_> {
|
|||
}
|
||||
|
||||
pub(super) fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
|
||||
let kind = match e.node {
|
||||
let kind = match e.kind {
|
||||
ExprKind::Box(ref inner) => hir::ExprKind::Box(P(self.lower_expr(inner))),
|
||||
ExprKind::Array(ref exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
|
||||
ExprKind::Repeat(ref expr, ref count) => {
|
||||
|
|
@ -54,7 +54,7 @@ impl LoweringContext<'_> {
|
|||
let ohs = P(self.lower_expr(ohs));
|
||||
hir::ExprKind::Unary(op, ohs)
|
||||
}
|
||||
ExprKind::Lit(ref l) => hir::ExprKind::Lit(respan(l.span, l.node.clone())),
|
||||
ExprKind::Lit(ref l) => hir::ExprKind::Lit(respan(l.span, l.kind.clone())),
|
||||
ExprKind::Cast(ref expr, ref ty) => {
|
||||
let expr = P(self.lower_expr(expr));
|
||||
hir::ExprKind::Cast(expr, self.lower_ty(ty, ImplTraitContext::disallowed()))
|
||||
|
|
@ -184,7 +184,7 @@ impl LoweringContext<'_> {
|
|||
|
||||
hir::Expr {
|
||||
hir_id: self.lower_node_id(e.id),
|
||||
node: kind,
|
||||
kind,
|
||||
span: e.span,
|
||||
attrs: e.attrs.clone(),
|
||||
}
|
||||
|
|
@ -282,7 +282,7 @@ impl LoweringContext<'_> {
|
|||
|
||||
// Handle then + scrutinee:
|
||||
let then_expr = self.lower_block_expr(then);
|
||||
let (then_pat, scrutinee, desugar) = match cond.node {
|
||||
let (then_pat, scrutinee, desugar) = match cond.kind {
|
||||
// `<pat> => <then>`:
|
||||
ExprKind::Let(ref pat, ref scrutinee) => {
|
||||
let scrutinee = self.lower_expr(scrutinee);
|
||||
|
|
@ -332,7 +332,7 @@ impl LoweringContext<'_> {
|
|||
|
||||
// Handle then + scrutinee:
|
||||
let then_expr = self.lower_block_expr(body);
|
||||
let (then_pat, scrutinee, desugar, source) = match cond.node {
|
||||
let (then_pat, scrutinee, desugar, source) = match cond.kind {
|
||||
ExprKind::Let(ref pat, ref scrutinee) => {
|
||||
// to:
|
||||
//
|
||||
|
|
@ -459,7 +459,7 @@ impl LoweringContext<'_> {
|
|||
});
|
||||
|
||||
// `static || -> <ret_ty> { body }`:
|
||||
let generator_node = hir::ExprKind::Closure(
|
||||
let generator_kind = hir::ExprKind::Closure(
|
||||
capture_clause,
|
||||
decl,
|
||||
body_id,
|
||||
|
|
@ -468,7 +468,7 @@ impl LoweringContext<'_> {
|
|||
);
|
||||
let generator = hir::Expr {
|
||||
hir_id: self.lower_node_id(closure_node_id),
|
||||
node: generator_node,
|
||||
kind: generator_kind,
|
||||
span,
|
||||
attrs: ThinVec::new(),
|
||||
};
|
||||
|
|
@ -625,7 +625,7 @@ impl LoweringContext<'_> {
|
|||
// loop { .. }
|
||||
let loop_expr = P(hir::Expr {
|
||||
hir_id: loop_hir_id,
|
||||
node: hir::ExprKind::Loop(
|
||||
kind: hir::ExprKind::Loop(
|
||||
loop_block,
|
||||
None,
|
||||
hir::LoopSource::Loop,
|
||||
|
|
@ -1135,14 +1135,14 @@ impl LoweringContext<'_> {
|
|||
));
|
||||
|
||||
// `[opt_ident]: loop { ... }`
|
||||
let loop_expr = hir::ExprKind::Loop(
|
||||
let kind = hir::ExprKind::Loop(
|
||||
loop_block,
|
||||
self.lower_label(opt_label),
|
||||
hir::LoopSource::ForLoop,
|
||||
);
|
||||
let loop_expr = P(hir::Expr {
|
||||
hir_id: self.lower_node_id(e.id),
|
||||
node: loop_expr,
|
||||
kind,
|
||||
span: e.span,
|
||||
attrs: ThinVec::new(),
|
||||
});
|
||||
|
|
@ -1443,15 +1443,10 @@ impl LoweringContext<'_> {
|
|||
pub(super) fn expr(
|
||||
&mut self,
|
||||
span: Span,
|
||||
node: hir::ExprKind,
|
||||
kind: hir::ExprKind,
|
||||
attrs: ThinVec<Attribute>
|
||||
) -> hir::Expr {
|
||||
hir::Expr {
|
||||
hir_id: self.next_id(),
|
||||
node,
|
||||
span,
|
||||
attrs,
|
||||
}
|
||||
hir::Expr { hir_id: self.next_id(), kind, span, attrs }
|
||||
}
|
||||
|
||||
fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ impl<'tcx, 'interner> Visitor<'tcx> for ItemLowerer<'tcx, 'interner> {
|
|||
if let Some(hir_id) = item_hir_id {
|
||||
self.lctx.with_parent_item_lifetime_defs(hir_id, |this| {
|
||||
let this = &mut ItemLowerer { lctx: this };
|
||||
if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.node {
|
||||
if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.kind {
|
||||
this.with_trait_impl_ref(opt_trait_ref, |this| {
|
||||
visit::walk_item(this, item)
|
||||
});
|
||||
|
|
@ -119,7 +119,7 @@ impl LoweringContext<'_> {
|
|||
) -> T {
|
||||
let old_len = self.in_scope_lifetimes.len();
|
||||
|
||||
let parent_generics = match self.items.get(&parent_hir_id).unwrap().node {
|
||||
let parent_generics = match self.items.get(&parent_hir_id).unwrap().kind {
|
||||
hir::ItemKind::Impl(_, _, _, ref generics, ..)
|
||||
| hir::ItemKind::Trait(_, _, ref generics, ..) => {
|
||||
&generics.params[..]
|
||||
|
|
@ -168,7 +168,7 @@ impl LoweringContext<'_> {
|
|||
}
|
||||
|
||||
pub(super) fn lower_item_id(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> {
|
||||
let node_ids = match i.node {
|
||||
let node_ids = match i.kind {
|
||||
ItemKind::Use(ref use_tree) => {
|
||||
let mut vec = smallvec![i.id];
|
||||
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
|
||||
|
|
@ -235,7 +235,7 @@ impl LoweringContext<'_> {
|
|||
}
|
||||
let attrs = attrs.into();
|
||||
|
||||
if let ItemKind::MacroDef(ref def) = i.node {
|
||||
if let ItemKind::MacroDef(ref def) = i.kind {
|
||||
if !def.legacy || attr::contains_name(&i.attrs, sym::macro_export) {
|
||||
let body = self.lower_token_stream(def.stream());
|
||||
let hir_id = self.lower_node_id(i.id);
|
||||
|
|
@ -254,13 +254,13 @@ impl LoweringContext<'_> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let node = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.node);
|
||||
let kind = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.kind);
|
||||
|
||||
Some(hir::Item {
|
||||
hir_id: self.lower_node_id(i.id),
|
||||
ident,
|
||||
attrs,
|
||||
node,
|
||||
kind,
|
||||
vis,
|
||||
span: i.span,
|
||||
})
|
||||
|
|
@ -542,7 +542,7 @@ impl LoweringContext<'_> {
|
|||
let res = this.lower_res(res);
|
||||
let path =
|
||||
this.lower_path_extra(res, &path, ParamMode::Explicit, None);
|
||||
let item = hir::ItemKind::Use(P(path), hir::UseKind::Single);
|
||||
let kind = hir::ItemKind::Use(P(path), hir::UseKind::Single);
|
||||
let vis = this.rebuild_vis(&vis);
|
||||
|
||||
this.insert_item(
|
||||
|
|
@ -550,7 +550,7 @@ impl LoweringContext<'_> {
|
|||
hir_id: new_id,
|
||||
ident,
|
||||
attrs: attrs.into_iter().cloned().collect(),
|
||||
node: item,
|
||||
kind,
|
||||
vis,
|
||||
span,
|
||||
},
|
||||
|
|
@ -558,8 +558,7 @@ impl LoweringContext<'_> {
|
|||
});
|
||||
}
|
||||
|
||||
let path =
|
||||
P(self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None));
|
||||
let path = P(self.lower_path_extra(ret_res, &path, ParamMode::Explicit, None));
|
||||
hir::ItemKind::Use(path, hir::UseKind::Single)
|
||||
}
|
||||
UseTreeKind::Glob => {
|
||||
|
|
@ -623,7 +622,7 @@ impl LoweringContext<'_> {
|
|||
let mut vis = this.rebuild_vis(&vis);
|
||||
let mut ident = *ident;
|
||||
|
||||
let item = this.lower_use_tree(use_tree,
|
||||
let kind = this.lower_use_tree(use_tree,
|
||||
&prefix,
|
||||
id,
|
||||
&mut vis,
|
||||
|
|
@ -635,7 +634,7 @@ impl LoweringContext<'_> {
|
|||
hir_id: new_hir_id,
|
||||
ident,
|
||||
attrs: attrs.into_iter().cloned().collect(),
|
||||
node: item,
|
||||
kind,
|
||||
vis,
|
||||
span: use_tree.span,
|
||||
},
|
||||
|
|
@ -712,7 +711,7 @@ impl LoweringContext<'_> {
|
|||
hir_id: self.lower_node_id(i.id),
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
node: match i.node {
|
||||
kind: match i.kind {
|
||||
ForeignItemKind::Fn(ref fdec, ref generics) => {
|
||||
let (generics, (fn_dec, fn_args)) = self.add_in_band_defs(
|
||||
generics,
|
||||
|
|
@ -789,7 +788,7 @@ impl LoweringContext<'_> {
|
|||
}
|
||||
|
||||
fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::StructField {
|
||||
let ty = if let TyKind::Path(ref qself, ref path) = f.ty.node {
|
||||
let ty = if let TyKind::Path(ref qself, ref path) = f.ty.kind {
|
||||
let t = self.lower_path_ty(
|
||||
&f.ty,
|
||||
qself,
|
||||
|
|
@ -818,7 +817,7 @@ impl LoweringContext<'_> {
|
|||
fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
|
||||
let trait_item_def_id = self.resolver.definitions().local_def_id(i.id);
|
||||
|
||||
let (generics, node) = match i.node {
|
||||
let (generics, kind) = match i.kind {
|
||||
TraitItemKind::Const(ref ty, ref default) => (
|
||||
self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
|
||||
hir::TraitItemKind::Const(
|
||||
|
|
@ -852,14 +851,14 @@ impl LoweringContext<'_> {
|
|||
}
|
||||
TraitItemKind::Type(ref bounds, ref default) => {
|
||||
let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
|
||||
let node = hir::TraitItemKind::Type(
|
||||
let kind = hir::TraitItemKind::Type(
|
||||
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
|
||||
default
|
||||
.as_ref()
|
||||
.map(|x| self.lower_ty(x, ImplTraitContext::disallowed())),
|
||||
);
|
||||
|
||||
(generics, node)
|
||||
(generics, kind)
|
||||
},
|
||||
TraitItemKind::Macro(..) => bug!("macro item shouldn't exist at this point"),
|
||||
};
|
||||
|
|
@ -869,13 +868,13 @@ impl LoweringContext<'_> {
|
|||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
generics,
|
||||
node,
|
||||
kind,
|
||||
span: i.span,
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_trait_item_ref(&mut self, i: &TraitItem) -> hir::TraitItemRef {
|
||||
let (kind, has_default) = match i.node {
|
||||
let (kind, has_default) = match i.kind {
|
||||
TraitItemKind::Const(_, ref default) => {
|
||||
(hir::AssocItemKind::Const, default.is_some())
|
||||
}
|
||||
|
|
@ -902,7 +901,7 @@ impl LoweringContext<'_> {
|
|||
fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
|
||||
let impl_item_def_id = self.resolver.definitions().local_def_id(i.id);
|
||||
|
||||
let (generics, node) = match i.node {
|
||||
let (generics, kind) = match i.kind {
|
||||
ImplItemKind::Const(ref ty, ref expr) => (
|
||||
self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
|
||||
hir::ImplItemKind::Const(
|
||||
|
|
@ -946,7 +945,7 @@ impl LoweringContext<'_> {
|
|||
generics,
|
||||
vis: self.lower_visibility(&i.vis, None),
|
||||
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
|
||||
node,
|
||||
kind,
|
||||
span: i.span,
|
||||
}
|
||||
|
||||
|
|
@ -960,7 +959,7 @@ impl LoweringContext<'_> {
|
|||
span: i.span,
|
||||
vis: self.lower_visibility(&i.vis, Some(i.id)),
|
||||
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
|
||||
kind: match i.node {
|
||||
kind: match i.kind {
|
||||
ImplItemKind::Const(..) => hir::AssocItemKind::Const,
|
||||
ImplItemKind::TyAlias(..) => hir::AssocItemKind::Type,
|
||||
ImplItemKind::OpaqueTy(..) => hir::AssocItemKind::OpaqueTy,
|
||||
|
|
@ -1133,7 +1132,7 @@ impl LoweringContext<'_> {
|
|||
|
||||
// Check if this is a binding pattern, if so, we can optimize and avoid adding a
|
||||
// `let <pat> = __argN;` statement. In this case, we do not rename the parameter.
|
||||
let (ident, is_simple_parameter) = match parameter.pat.node {
|
||||
let (ident, is_simple_parameter) = match parameter.pat.kind {
|
||||
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, _) =>
|
||||
(ident, true),
|
||||
_ => {
|
||||
|
|
@ -1343,7 +1342,7 @@ impl LoweringContext<'_> {
|
|||
);
|
||||
};
|
||||
// Check if the where clause type is a plain type parameter.
|
||||
match bound_pred.bounded_ty.node {
|
||||
match bound_pred.bounded_ty.kind {
|
||||
TyKind::Path(None, ref path)
|
||||
if path.segments.len() == 1
|
||||
&& bound_pred.bound_generic_params.is_empty() =>
|
||||
|
|
|
|||
|
|
@ -37,19 +37,25 @@ trait MaybeFnLike { fn is_fn_like(&self) -> bool; }
|
|||
|
||||
impl MaybeFnLike for ast::Item {
|
||||
fn is_fn_like(&self) -> bool {
|
||||
match self.node { ast::ItemKind::Fn(..) => true, _ => false, }
|
||||
match self.kind {
|
||||
ast::ItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MaybeFnLike for ast::ImplItem {
|
||||
fn is_fn_like(&self) -> bool {
|
||||
match self.node { ast::ImplItemKind::Method(..) => true, _ => false, }
|
||||
match self.kind {
|
||||
ast::ImplItemKind::Method(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MaybeFnLike for ast::TraitItem {
|
||||
fn is_fn_like(&self) -> bool {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ast::TraitItemKind::Method(_, ast::TraitMethod::Provided(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -58,7 +64,7 @@ impl MaybeFnLike for ast::TraitItem {
|
|||
|
||||
impl MaybeFnLike for ast::Expr {
|
||||
fn is_fn_like(&self) -> bool {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ast::ExprKind::Closure(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -212,7 +218,7 @@ impl<'a> FnLikeNode<'a> {
|
|||
C: FnOnce(ClosureParts<'a>) -> A,
|
||||
{
|
||||
match self.node {
|
||||
map::Node::Item(i) => match i.node {
|
||||
map::Node::Item(i) => match i.kind {
|
||||
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
|
||||
item_fn(ItemFnParts {
|
||||
id: i.hir_id,
|
||||
|
|
@ -227,21 +233,21 @@ impl<'a> FnLikeNode<'a> {
|
|||
}),
|
||||
_ => bug!("item FnLikeNode that is not fn-like"),
|
||||
},
|
||||
map::Node::TraitItem(ti) => match ti.node {
|
||||
map::Node::TraitItem(ti) => match ti.kind {
|
||||
ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => {
|
||||
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
|
||||
}
|
||||
_ => bug!("trait method FnLikeNode that is not fn-like"),
|
||||
},
|
||||
map::Node::ImplItem(ii) => {
|
||||
match ii.node {
|
||||
match ii.kind {
|
||||
ast::ImplItemKind::Method(ref sig, body) => {
|
||||
method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
|
||||
}
|
||||
_ => bug!("impl method FnLikeNode that is not fn-like")
|
||||
}
|
||||
},
|
||||
map::Node::Expr(e) => match e.node {
|
||||
map::Node::Expr(e) => match e.kind {
|
||||
ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
|
||||
closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)),
|
||||
_ => bug!("expr FnLikeNode that is not fn-like"),
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
|||
self.with_dep_node_owner(i.hir_id.owner, i, |this| {
|
||||
this.insert(i.span, i.hir_id, Node::Item(i));
|
||||
this.with_parent(i.hir_id, |this| {
|
||||
if let ItemKind::Struct(ref struct_def, _) = i.node {
|
||||
if let ItemKind::Struct(ref struct_def, _) = i.kind {
|
||||
// If this is a tuple or unit-like struct, register the constructor.
|
||||
if let Some(ctor_hir_id) = struct_def.ctor_hir_id() {
|
||||
this.insert(i.span, ctor_hir_id, Node::Ctor(struct_def));
|
||||
|
|
@ -427,7 +427,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
|||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &'hir Pat) {
|
||||
let node = if let PatKind::Binding(..) = pat.node {
|
||||
let node = if let PatKind::Binding(..) = pat.kind {
|
||||
Node::Binding(pat)
|
||||
} else {
|
||||
Node::Pat(pat)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
|
||||
// Pick the def data. This need not be unique, but the more
|
||||
// information we encapsulate into, the better
|
||||
let def_data = match i.node {
|
||||
let def_data = match i.kind {
|
||||
ItemKind::Impl(..) => DefPathData::Impl,
|
||||
ItemKind::Mod(..) if i.ident.name == kw::Invalid => {
|
||||
return visit::walk_item(self, i);
|
||||
|
|
@ -138,7 +138,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
let def = self.create_def(i.id, def_data, i.span);
|
||||
|
||||
self.with_parent(def, |this| {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ItemKind::Struct(ref struct_def, _) | ItemKind::Union(ref struct_def, _) => {
|
||||
// If this is a unit or tuple-like struct, register the constructor.
|
||||
if let Some(ctor_hir_id) = struct_def.ctor_id() {
|
||||
|
|
@ -157,7 +157,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, foreign_item: &'a ForeignItem) {
|
||||
if let ForeignItemKind::Macro(_) = foreign_item.node {
|
||||
if let ForeignItemKind::Macro(_) = foreign_item.kind {
|
||||
return self.visit_macro_invoc(foreign_item.id);
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'a TraitItem) {
|
||||
let def_data = match ti.node {
|
||||
let def_data = match ti.kind {
|
||||
TraitItemKind::Method(..) | TraitItemKind::Const(..) =>
|
||||
DefPathData::ValueNs(ti.ident.as_interned_str()),
|
||||
TraitItemKind::Type(..) => {
|
||||
|
|
@ -228,7 +228,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
|
||||
let def_data = match ii.node {
|
||||
let def_data = match ii.kind {
|
||||
ImplItemKind::Method(MethodSig {
|
||||
ref header,
|
||||
ref decl,
|
||||
|
|
@ -257,7 +257,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &'a Pat) {
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Mac(..) => return self.visit_macro_invoc(pat.id),
|
||||
_ => visit::walk_pat(self, pat),
|
||||
}
|
||||
|
|
@ -271,7 +271,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'a Expr) {
|
||||
let parent_def = match expr.node {
|
||||
let parent_def = match expr.kind {
|
||||
ExprKind::Mac(..) => return self.visit_macro_invoc(expr.id),
|
||||
ExprKind::Closure(_, asyncness, ..) => {
|
||||
// Async closures desugar to closures inside of closures, so
|
||||
|
|
@ -292,7 +292,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'a Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id),
|
||||
TyKind::ImplTrait(node_id, _) => {
|
||||
self.create_def(node_id, DefPathData::ImplTrait, ty.span);
|
||||
|
|
@ -303,7 +303,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
}
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &'a Stmt) {
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
StmtKind::Mac(..) => self.visit_macro_invoc(stmt.id),
|
||||
_ => visit::walk_stmt(self, stmt),
|
||||
}
|
||||
|
|
@ -312,7 +312,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
fn visit_token(&mut self, t: Token) {
|
||||
if let token::Interpolated(nt) = t.kind {
|
||||
if let token::NtExpr(ref expr) = *nt {
|
||||
if let ExprKind::Mac(..) = expr.node {
|
||||
if let ExprKind::Mac(..) = expr.kind {
|
||||
self.visit_macro_invoc(expr.id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,28 +50,28 @@ impl<'hir> Entry<'hir> {
|
|||
fn fn_decl(&self) -> Option<&'hir FnDecl> {
|
||||
match self.node {
|
||||
Node::Item(ref item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(ref fn_decl, _, _, _) => Some(fn_decl),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Node::TraitItem(ref item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
Node::ImplItem(ref item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ImplItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Node::Expr(ref expr) => {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
ExprKind::Closure(_, ref fn_decl, ..) => Some(fn_decl),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ impl<'hir> Entry<'hir> {
|
|||
fn associated_body(self) -> Option<BodyId> {
|
||||
match self.node {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Const(_, body) |
|
||||
ItemKind::Static(.., body) |
|
||||
ItemKind::Fn(_, _, _, body) => Some(body),
|
||||
|
|
@ -93,7 +93,7 @@ impl<'hir> Entry<'hir> {
|
|||
}
|
||||
|
||||
Node::TraitItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Const(_, Some(body)) |
|
||||
TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body),
|
||||
_ => None
|
||||
|
|
@ -101,7 +101,7 @@ impl<'hir> Entry<'hir> {
|
|||
}
|
||||
|
||||
Node::ImplItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ImplItemKind::Const(_, body) |
|
||||
ImplItemKind::Method(_, body) => Some(body),
|
||||
_ => None,
|
||||
|
|
@ -111,7 +111,7 @@ impl<'hir> Entry<'hir> {
|
|||
Node::AnonConst(constant) => Some(constant.body),
|
||||
|
||||
Node::Expr(expr) => {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
ExprKind::Closure(.., body, _, _) => Some(body),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -293,7 +293,7 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
Some(match node {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Static(..) => DefKind::Static,
|
||||
ItemKind::Const(..) => DefKind::Const,
|
||||
ItemKind::Fn(..) => DefKind::Fn,
|
||||
|
|
@ -313,21 +313,21 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
}
|
||||
Node::ForeignItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ForeignItemKind::Fn(..) => DefKind::Fn,
|
||||
ForeignItemKind::Static(..) => DefKind::Static,
|
||||
ForeignItemKind::Type => DefKind::ForeignTy,
|
||||
}
|
||||
}
|
||||
Node::TraitItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Const(..) => DefKind::AssocConst,
|
||||
TraitItemKind::Method(..) => DefKind::Method,
|
||||
TraitItemKind::Type(..) => DefKind::AssocTy,
|
||||
}
|
||||
}
|
||||
Node::ImplItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ImplItemKind::Const(..) => DefKind::AssocConst,
|
||||
ImplItemKind::Method(..) => DefKind::Method,
|
||||
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
|
||||
|
|
@ -453,22 +453,22 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
|
||||
Node::ImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) |
|
||||
Node::Item(&Item { kind: ItemKind::Const(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { kind: TraitItemKind::Const(..), .. }) |
|
||||
Node::ImplItem(&ImplItem { kind: ImplItemKind::Const(..), .. }) |
|
||||
Node::AnonConst(_) => {
|
||||
BodyOwnerKind::Const
|
||||
}
|
||||
Node::Ctor(..) |
|
||||
Node::Item(&Item { node: ItemKind::Fn(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { node: TraitItemKind::Method(..), .. }) |
|
||||
Node::ImplItem(&ImplItem { node: ImplItemKind::Method(..), .. }) => {
|
||||
Node::Item(&Item { kind: ItemKind::Fn(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. }) |
|
||||
Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => {
|
||||
BodyOwnerKind::Fn
|
||||
}
|
||||
Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => {
|
||||
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => {
|
||||
BodyOwnerKind::Static(m)
|
||||
}
|
||||
Node::Expr(&Expr { node: ExprKind::Closure(..), .. }) => {
|
||||
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => {
|
||||
BodyOwnerKind::Closure
|
||||
}
|
||||
node => bug!("{:#?} is not a body node", node),
|
||||
|
|
@ -477,8 +477,8 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
pub fn ty_param_owner(&self, id: HirId) -> HirId {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
|
||||
Node::Item(&Item { kind: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { kind: ItemKind::TraitAlias(..), .. }) => id,
|
||||
Node::GenericParam(_) => self.get_parent_node(id),
|
||||
_ => bug!("ty_param_owner: {} not a type parameter", self.node_to_string(id))
|
||||
}
|
||||
|
|
@ -486,8 +486,8 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
pub fn ty_param_name(&self, id: HirId) -> Name {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
|
||||
Node::Item(&Item { kind: ItemKind::Trait(..), .. }) |
|
||||
Node::Item(&Item { kind: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
|
||||
Node::GenericParam(param) => param.name.ident().name,
|
||||
_ => bug!("ty_param_name: {} not a type parameter", self.node_to_string(id)),
|
||||
}
|
||||
|
|
@ -517,7 +517,7 @@ impl<'hir> Map<'hir> {
|
|||
match self.find_entry(hir_id).unwrap().node {
|
||||
Node::Item(&Item {
|
||||
span,
|
||||
node: ItemKind::Mod(ref m),
|
||||
kind: ItemKind::Mod(ref m),
|
||||
..
|
||||
}) => (m, span, hir_id),
|
||||
Node::Crate => (&self.forest.krate.module, self.forest.krate.span, hir_id),
|
||||
|
|
@ -568,7 +568,7 @@ impl<'hir> Map<'hir> {
|
|||
Node::ImplItem(ref impl_item) => Some(&impl_item.generics),
|
||||
Node::TraitItem(ref trait_item) => Some(&trait_item.generics),
|
||||
Node::Item(ref item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(_, _, ref generics, _) |
|
||||
ItemKind::TyAlias(_, ref generics) |
|
||||
ItemKind::Enum(_, ref generics) |
|
||||
|
|
@ -634,7 +634,7 @@ impl<'hir> Map<'hir> {
|
|||
Some(Node::TraitItem(_)) |
|
||||
Some(Node::ImplItem(_)) => true,
|
||||
Some(Node::Expr(e)) => {
|
||||
match e.node {
|
||||
match e.kind {
|
||||
ExprKind::Closure(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -649,24 +649,24 @@ impl<'hir> Map<'hir> {
|
|||
let parent_id = self.get_parent_item(hir_id);
|
||||
match self.get(parent_id) {
|
||||
Node::Item(&Item {
|
||||
node: ItemKind::Const(..),
|
||||
kind: ItemKind::Const(..),
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&TraitItem {
|
||||
node: TraitItemKind::Const(..),
|
||||
kind: TraitItemKind::Const(..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&ImplItem {
|
||||
node: ImplItemKind::Const(..),
|
||||
kind: ImplItemKind::Const(..),
|
||||
..
|
||||
})
|
||||
| Node::AnonConst(_)
|
||||
| Node::Item(&Item {
|
||||
node: ItemKind::Static(..),
|
||||
kind: ItemKind::Static(..),
|
||||
..
|
||||
}) => true,
|
||||
Node::Item(&Item {
|
||||
node: ItemKind::Fn(_, header, ..),
|
||||
kind: ItemKind::Fn(_, header, ..),
|
||||
..
|
||||
}) => header.constness == Constness::Const,
|
||||
_ => false,
|
||||
|
|
@ -676,7 +676,7 @@ impl<'hir> Map<'hir> {
|
|||
/// Wether `hir_id` corresponds to a `mod` or a crate.
|
||||
pub fn is_hir_id_module(&self, hir_id: HirId) -> bool {
|
||||
match self.lookup(hir_id) {
|
||||
Some(Entry { node: Node::Item(Item { node: ItemKind::Mod(_), .. }), .. }) |
|
||||
Some(Entry { node: Node::Item(Item { kind: ItemKind::Mod(_), .. }), .. }) |
|
||||
Some(Entry { node: Node::Crate, .. }) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -749,7 +749,7 @@ impl<'hir> Map<'hir> {
|
|||
Node::Item(_) |
|
||||
Node::ForeignItem(_) |
|
||||
Node::TraitItem(_) |
|
||||
Node::Expr(Expr { node: ExprKind::Closure(..), ..}) |
|
||||
Node::Expr(Expr { kind: ExprKind::Closure(..), ..}) |
|
||||
Node::ImplItem(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -757,7 +757,7 @@ impl<'hir> Map<'hir> {
|
|||
let match_non_returning_block = |node: &Node<'_>| {
|
||||
match *node {
|
||||
Node::Expr(ref expr) => {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
ExprKind::Loop(..) | ExprKind::Ret(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -796,7 +796,7 @@ impl<'hir> Map<'hir> {
|
|||
/// module parent is in this map.
|
||||
pub fn get_module_parent_node(&self, hir_id: HirId) -> HirId {
|
||||
match self.walk_parent_nodes(hir_id, |node| match *node {
|
||||
Node::Item(&Item { node: ItemKind::Mod(_), .. }) => true,
|
||||
Node::Item(&Item { kind: ItemKind::Mod(_), .. }) => true,
|
||||
_ => false,
|
||||
}, |_| false) {
|
||||
Ok(id) => id,
|
||||
|
|
@ -808,7 +808,7 @@ impl<'hir> Map<'hir> {
|
|||
pub fn get_enclosing_scope(&self, hir_id: HirId) -> Option<HirId> {
|
||||
self.walk_parent_nodes(hir_id, |node| match *node {
|
||||
Node::Item(i) => {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ItemKind::Fn(..)
|
||||
| ItemKind::Mod(..)
|
||||
| ItemKind::Enum(..)
|
||||
|
|
@ -820,19 +820,19 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
},
|
||||
Node::ForeignItem(fi) => {
|
||||
match fi.node {
|
||||
match fi.kind {
|
||||
ForeignItemKind::Fn(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
},
|
||||
Node::TraitItem(ti) => {
|
||||
match ti.node {
|
||||
match ti.kind {
|
||||
TraitItemKind::Method(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
},
|
||||
Node::ImplItem(ii) => {
|
||||
match ii.node {
|
||||
match ii.kind {
|
||||
ImplItemKind::Method(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -852,7 +852,7 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
match self.get(scope) {
|
||||
Node::Item(i) => {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ItemKind::OpaqueTy(OpaqueTy { impl_trait_fn: None, .. }) => {}
|
||||
_ => break,
|
||||
}
|
||||
|
|
@ -872,7 +872,7 @@ impl<'hir> Map<'hir> {
|
|||
let parent = self.get_parent_item(hir_id);
|
||||
if let Some(entry) = self.find_entry(parent) {
|
||||
if let Entry {
|
||||
node: Node::Item(Item { node: ItemKind::ForeignMod(ref nm), .. }), .. } = entry
|
||||
node: Node::Item(Item { kind: ItemKind::ForeignMod(ref nm), .. }), .. } = entry
|
||||
{
|
||||
self.read(hir_id); // reveals some of the content of a node
|
||||
return nm.abi;
|
||||
|
|
@ -905,7 +905,7 @@ impl<'hir> Map<'hir> {
|
|||
pub fn expect_variant_data(&self, id: HirId) -> &'hir VariantData {
|
||||
match self.find(id) {
|
||||
Some(Node::Item(i)) => {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
ItemKind::Struct(ref struct_def, _) |
|
||||
ItemKind::Union(ref struct_def, _) => struct_def,
|
||||
_ => bug!("struct ID bound to non-struct {}", self.node_to_string(id))
|
||||
|
|
@ -948,7 +948,7 @@ impl<'hir> Map<'hir> {
|
|||
Node::Field(f) => f.ident.name,
|
||||
Node::Lifetime(lt) => lt.name.ident().name,
|
||||
Node::GenericParam(param) => param.name.ident().name,
|
||||
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
|
||||
Node::Binding(&Pat { kind: PatKind::Binding(_, _, l, _), .. }) => l.name,
|
||||
Node::Ctor(..) => self.name(self.get_parent_item(id)),
|
||||
_ => bug!("no name for {}", self.node_to_string(id))
|
||||
}
|
||||
|
|
@ -968,7 +968,7 @@ impl<'hir> Map<'hir> {
|
|||
Some(Node::Variant(ref v)) => Some(&v.attrs[..]),
|
||||
Some(Node::Field(ref f)) => Some(&f.attrs[..]),
|
||||
Some(Node::Expr(ref e)) => Some(&*e.attrs),
|
||||
Some(Node::Stmt(ref s)) => Some(s.node.attrs()),
|
||||
Some(Node::Stmt(ref s)) => Some(s.kind.attrs()),
|
||||
Some(Node::Arm(ref a)) => Some(&*a.attrs),
|
||||
Some(Node::GenericParam(param)) => Some(¶m.attrs[..]),
|
||||
// Unit/tuple structs/variants take the attributes straight from
|
||||
|
|
@ -1123,7 +1123,7 @@ impl<'a> NodesMatchingSuffix<'a> {
|
|||
}
|
||||
|
||||
fn item_is_mod(item: &Item) -> bool {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Mod(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
@ -1286,7 +1286,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
|
|||
|
||||
match map.find(id) {
|
||||
Some(Node::Item(item)) => {
|
||||
let item_str = match item.node {
|
||||
let item_str = match item.kind {
|
||||
ItemKind::ExternCrate(..) => "extern crate",
|
||||
ItemKind::Use(..) => "use",
|
||||
ItemKind::Static(..) => "static",
|
||||
|
|
@ -1310,7 +1310,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
|
|||
format!("foreign item {}{}", path_str(), id_str)
|
||||
}
|
||||
Some(Node::ImplItem(ii)) => {
|
||||
match ii.node {
|
||||
match ii.kind {
|
||||
ImplItemKind::Const(..) => {
|
||||
format!("assoc const {} in {}{}", ii.ident, path_str(), id_str)
|
||||
}
|
||||
|
|
@ -1326,7 +1326,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
|
|||
}
|
||||
}
|
||||
Some(Node::TraitItem(ti)) => {
|
||||
let kind = match ti.node {
|
||||
let kind = match ti.kind {
|
||||
TraitItemKind::Const(..) => "assoc constant",
|
||||
TraitItemKind::Method(..) => "trait method",
|
||||
TraitItemKind::Type(..) => "assoc type",
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ impl GenericArgs {
|
|||
match arg {
|
||||
GenericArg::Lifetime(_) => {}
|
||||
GenericArg::Type(ref ty) => {
|
||||
if let TyKind::Tup(ref tys) = ty.node {
|
||||
if let TyKind::Tup(ref tys) = ty.kind {
|
||||
return tys;
|
||||
}
|
||||
break;
|
||||
|
|
@ -869,7 +869,7 @@ pub struct Block {
|
|||
pub struct Pat {
|
||||
#[stable_hasher(ignore)]
|
||||
pub hir_id: HirId,
|
||||
pub node: PatKind,
|
||||
pub kind: PatKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -888,7 +888,7 @@ impl Pat {
|
|||
}
|
||||
|
||||
use PatKind::*;
|
||||
match &self.node {
|
||||
match &self.kind {
|
||||
Wild | Lit(_) | Range(..) | Binding(.., None) | Path(_) => true,
|
||||
Box(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_short_(it),
|
||||
Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
|
||||
|
|
@ -919,7 +919,7 @@ impl Pat {
|
|||
}
|
||||
|
||||
use PatKind::*;
|
||||
match &self.node {
|
||||
match &self.kind {
|
||||
Wild | Lit(_) | Range(..) | Binding(.., None) | Path(_) => {},
|
||||
Box(s) | Ref(s, _) | Binding(.., Some(s)) => s.walk_(it),
|
||||
Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
|
||||
|
|
@ -1221,7 +1221,7 @@ impl UnOp {
|
|||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct Stmt {
|
||||
pub hir_id: HirId,
|
||||
pub node: StmtKind,
|
||||
pub kind: StmtKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -1295,7 +1295,7 @@ impl Arm {
|
|||
// HACK(or_patterns; Centril | dlrobertson): Remove this and
|
||||
// correctly handle each case in which this method is used.
|
||||
pub fn top_pats_hack(&self) -> &[P<Pat>] {
|
||||
match &self.pat.node {
|
||||
match &self.pat.kind {
|
||||
PatKind::Or(pats) => pats,
|
||||
_ => std::slice::from_ref(&self.pat),
|
||||
}
|
||||
|
|
@ -1434,7 +1434,7 @@ pub struct AnonConst {
|
|||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct Expr {
|
||||
pub hir_id: HirId,
|
||||
pub node: ExprKind,
|
||||
pub kind: ExprKind,
|
||||
pub attrs: ThinVec<Attribute>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
|
@ -1445,7 +1445,7 @@ static_assert_size!(Expr, 72);
|
|||
|
||||
impl Expr {
|
||||
pub fn precedence(&self) -> ExprPrecedence {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ExprKind::Box(_) => ExprPrecedence::Box,
|
||||
ExprKind::Array(_) => ExprPrecedence::Array,
|
||||
ExprKind::Call(..) => ExprPrecedence::Call,
|
||||
|
|
@ -1478,7 +1478,7 @@ impl Expr {
|
|||
}
|
||||
|
||||
pub fn is_place_expr(&self) -> bool {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ExprKind::Path(QPath::Resolved(_, ref path)) => {
|
||||
match path.res {
|
||||
Res::Local(..)
|
||||
|
|
@ -1830,7 +1830,7 @@ pub struct TraitItem {
|
|||
pub hir_id: HirId,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub generics: Generics,
|
||||
pub node: TraitItemKind,
|
||||
pub kind: TraitItemKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -1873,7 +1873,7 @@ pub struct ImplItem {
|
|||
pub defaultness: Defaultness,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub generics: Generics,
|
||||
pub node: ImplItemKind,
|
||||
pub kind: ImplItemKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -1939,7 +1939,7 @@ impl TypeBinding {
|
|||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct Ty {
|
||||
pub hir_id: HirId,
|
||||
pub node: TyKind,
|
||||
pub kind: TyKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
|
@ -2416,7 +2416,7 @@ pub struct Item {
|
|||
pub ident: Ident,
|
||||
pub hir_id: HirId,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub node: ItemKind,
|
||||
pub kind: ItemKind,
|
||||
pub vis: Visibility,
|
||||
pub span: Span,
|
||||
}
|
||||
|
|
@ -2581,7 +2581,7 @@ pub struct ForeignItem {
|
|||
#[stable_hasher(project(name))]
|
||||
pub ident: Ident,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub node: ForeignItemKind,
|
||||
pub kind: ForeignItemKind,
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
pub vis: Visibility,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
|
|||
|
||||
impl hir::Pat {
|
||||
pub fn is_refutable(&self) -> bool {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
PatKind::Lit(_) |
|
||||
PatKind::Range(..) |
|
||||
PatKind::Path(hir::QPath::Resolved(Some(..), _)) |
|
||||
|
|
@ -68,7 +68,7 @@ impl hir::Pat {
|
|||
/// `match foo() { Some(a) => (), None => () }`
|
||||
pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident)) {
|
||||
self.walk(|p| {
|
||||
if let PatKind::Binding(binding_mode, _, ident, _) = p.node {
|
||||
if let PatKind::Binding(binding_mode, _, ident, _) = p.kind {
|
||||
f(binding_mode, p.hir_id, p.span, ident);
|
||||
}
|
||||
true
|
||||
|
|
@ -83,7 +83,7 @@ impl hir::Pat {
|
|||
&self,
|
||||
f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, ast::Ident),
|
||||
) {
|
||||
self.walk(|p| match &p.node {
|
||||
self.walk(|p| match &p.kind {
|
||||
PatKind::Or(ps) => {
|
||||
ps[0].each_binding_or_first(f);
|
||||
false
|
||||
|
|
@ -99,7 +99,7 @@ impl hir::Pat {
|
|||
/// Checks if the pattern contains any patterns that bind something to
|
||||
/// an ident, e.g., `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
|
||||
pub fn contains_bindings(&self) -> bool {
|
||||
self.satisfies(|p| match p.node {
|
||||
self.satisfies(|p| match p.kind {
|
||||
PatKind::Binding(..) => true,
|
||||
_ => false,
|
||||
})
|
||||
|
|
@ -108,7 +108,7 @@ impl hir::Pat {
|
|||
/// Checks if the pattern contains any patterns that bind something to
|
||||
/// an ident or wildcard, e.g., `foo`, or `Foo(_)`, `foo @ Bar(..)`,
|
||||
pub fn contains_bindings_or_wild(&self) -> bool {
|
||||
self.satisfies(|p| match p.node {
|
||||
self.satisfies(|p| match p.kind {
|
||||
PatKind::Binding(..) | PatKind::Wild => true,
|
||||
_ => false,
|
||||
})
|
||||
|
|
@ -129,7 +129,7 @@ impl hir::Pat {
|
|||
}
|
||||
|
||||
pub fn simple_ident(&self) -> Option<ast::Ident> {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) |
|
||||
PatKind::Binding(hir::BindingAnnotation::Mutable, _, ident, None) => Some(ident),
|
||||
_ => None,
|
||||
|
|
@ -139,7 +139,7 @@ impl hir::Pat {
|
|||
/// Returns variants that are necessary to exist for the pattern to match.
|
||||
pub fn necessary_variants(&self) -> Vec<DefId> {
|
||||
let mut variants = vec![];
|
||||
self.walk(|p| match &p.node {
|
||||
self.walk(|p| match &p.kind {
|
||||
PatKind::Or(_) => false,
|
||||
PatKind::Path(hir::QPath::Resolved(_, path)) |
|
||||
PatKind::TupleStruct(hir::QPath::Resolved(_, path), ..) |
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ impl<'a> State<'a> {
|
|||
pub fn print_type(&mut self, ty: &hir::Ty) {
|
||||
self.maybe_print_comment(ty.span.lo());
|
||||
self.ibox(0);
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
hir::TyKind::Slice(ref ty) => {
|
||||
self.s.word("[");
|
||||
self.print_type(&ty);
|
||||
|
|
@ -372,7 +372,7 @@ impl<'a> State<'a> {
|
|||
self.hardbreak_if_not_bol();
|
||||
self.maybe_print_comment(item.span.lo());
|
||||
self.print_outer_attributes(&item.attrs);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ForeignItemKind::Fn(ref decl, ref arg_names, ref generics) => {
|
||||
self.head("");
|
||||
self.print_fn(decl,
|
||||
|
|
@ -474,7 +474,7 @@ impl<'a> State<'a> {
|
|||
self.maybe_print_comment(item.span.lo());
|
||||
self.print_outer_attributes(&item.attrs);
|
||||
self.ann.pre(self, AnnNode::Item(item));
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(orig_name) => {
|
||||
self.head(visibility_qualified(&item.vis, "extern crate"));
|
||||
if let Some(orig_name) = orig_name {
|
||||
|
|
@ -858,7 +858,7 @@ impl<'a> State<'a> {
|
|||
self.hardbreak_if_not_bol();
|
||||
self.maybe_print_comment(ti.span.lo());
|
||||
self.print_outer_attributes(&ti.attrs);
|
||||
match ti.node {
|
||||
match ti.kind {
|
||||
hir::TraitItemKind::Const(ref ty, default) => {
|
||||
let vis = Spanned { span: syntax_pos::DUMMY_SP,
|
||||
node: hir::VisibilityKind::Inherited };
|
||||
|
|
@ -896,7 +896,7 @@ impl<'a> State<'a> {
|
|||
self.print_outer_attributes(&ii.attrs);
|
||||
self.print_defaultness(ii.defaultness);
|
||||
|
||||
match ii.node {
|
||||
match ii.kind {
|
||||
hir::ImplItemKind::Const(ref ty, expr) => {
|
||||
self.print_associated_const(ii.ident, &ty, Some(expr), &ii.vis);
|
||||
}
|
||||
|
|
@ -944,7 +944,7 @@ impl<'a> State<'a> {
|
|||
|
||||
pub fn print_stmt(&mut self, st: &hir::Stmt) {
|
||||
self.maybe_print_comment(st.span.lo());
|
||||
match st.node {
|
||||
match st.kind {
|
||||
hir::StmtKind::Local(ref loc) => {
|
||||
self.print_local(loc.init.as_deref(), |this| this.print_local_decl(&loc));
|
||||
}
|
||||
|
|
@ -961,7 +961,7 @@ impl<'a> State<'a> {
|
|||
self.s.word(";");
|
||||
}
|
||||
}
|
||||
if stmt_ends_with_semi(&st.node) {
|
||||
if stmt_ends_with_semi(&st.kind) {
|
||||
self.s.word(";");
|
||||
}
|
||||
self.maybe_print_trailing_comment(st.span, None)
|
||||
|
|
@ -1035,7 +1035,7 @@ impl<'a> State<'a> {
|
|||
/// Print an expr using syntax that's acceptable in a condition position, such as the `cond` in
|
||||
/// `if cond { ... }`.
|
||||
pub fn print_expr_as_cond(&mut self, expr: &hir::Expr) {
|
||||
let needs_par = match expr.node {
|
||||
let needs_par = match expr.kind {
|
||||
// These cases need parens due to the parse error observed in #26461: `if return {}`
|
||||
// parses as the erroneous construct `if (return {})`, not `if (return) {}`.
|
||||
hir::ExprKind::Closure(..) |
|
||||
|
|
@ -1119,11 +1119,10 @@ impl<'a> State<'a> {
|
|||
}
|
||||
|
||||
fn print_expr_call(&mut self, func: &hir::Expr, args: &[hir::Expr]) {
|
||||
let prec =
|
||||
match func.node {
|
||||
hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
|
||||
_ => parser::PREC_POSTFIX,
|
||||
};
|
||||
let prec = match func.kind {
|
||||
hir::ExprKind::Field(..) => parser::PREC_FORCE_PAREN,
|
||||
_ => parser::PREC_POSTFIX,
|
||||
};
|
||||
|
||||
self.print_expr_maybe_paren(func, prec);
|
||||
self.print_call_post(args)
|
||||
|
|
@ -1161,7 +1160,7 @@ impl<'a> State<'a> {
|
|||
Fixity::None => (prec + 1, prec + 1),
|
||||
};
|
||||
|
||||
let left_prec = match (&lhs.node, op.node) {
|
||||
let left_prec = match (&lhs.kind, op.node) {
|
||||
// These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is
|
||||
// the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead
|
||||
// of `(x as i32) < ...`. We need to convince it _not_ to do that.
|
||||
|
|
@ -1200,7 +1199,7 @@ impl<'a> State<'a> {
|
|||
self.print_outer_attributes(&expr.attrs);
|
||||
self.ibox(INDENT_UNIT);
|
||||
self.ann.pre(self, AnnNode::Expr(expr));
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Box(ref expr) => {
|
||||
self.word_space("box");
|
||||
self.print_expr_maybe_paren(expr, parser::PREC_PREFIX);
|
||||
|
|
@ -1618,7 +1617,7 @@ impl<'a> State<'a> {
|
|||
self.ann.pre(self, AnnNode::Pat(pat));
|
||||
// Pat isn't normalized, but the beauty of it
|
||||
// is that it doesn't matter
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Wild => self.s.word("_"),
|
||||
PatKind::Binding(binding_mode, _, ident, ref sub) => {
|
||||
match binding_mode {
|
||||
|
|
@ -1711,7 +1710,7 @@ impl<'a> State<'a> {
|
|||
self.pclose();
|
||||
}
|
||||
PatKind::Box(ref inner) => {
|
||||
let is_range_inner = match inner.node {
|
||||
let is_range_inner = match inner.kind {
|
||||
PatKind::Range(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
|
@ -1725,7 +1724,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
}
|
||||
PatKind::Ref(ref inner, mutbl) => {
|
||||
let is_range_inner = match inner.node {
|
||||
let is_range_inner = match inner.kind {
|
||||
PatKind::Range(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
|
@ -1758,7 +1757,7 @@ impl<'a> State<'a> {
|
|||
if !before.is_empty() {
|
||||
self.word_space(",");
|
||||
}
|
||||
if let PatKind::Wild = p.node {
|
||||
if let PatKind::Wild = p.kind {
|
||||
// Print nothing.
|
||||
} else {
|
||||
self.print_pat(&p);
|
||||
|
|
@ -1803,7 +1802,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
self.word_space("=>");
|
||||
|
||||
match arm.body.node {
|
||||
match arm.body.kind {
|
||||
hir::ExprKind::Block(ref blk, opt_label) => {
|
||||
if let Some(label) = opt_label {
|
||||
self.print_ident(label.ident);
|
||||
|
|
@ -1881,7 +1880,7 @@ impl<'a> State<'a> {
|
|||
s.ann.nested(s, Nested::BodyParamPat(body_id, i));
|
||||
i += 1;
|
||||
|
||||
if let hir::TyKind::Infer = ty.node {
|
||||
if let hir::TyKind::Infer = ty.kind {
|
||||
// Print nothing.
|
||||
} else {
|
||||
s.s.word(":");
|
||||
|
|
@ -2222,7 +2221,7 @@ impl<'a> State<'a> {
|
|||
//
|
||||
// Duplicated from `parse::classify`, but adapted for the HIR.
|
||||
fn expr_requires_semi_to_be_stmt(e: &hir::Expr) -> bool {
|
||||
match e.node {
|
||||
match e.kind {
|
||||
hir::ExprKind::Match(..) |
|
||||
hir::ExprKind::Block(..) |
|
||||
hir::ExprKind::Loop(..) => false,
|
||||
|
|
@ -2273,7 +2272,7 @@ fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp {
|
|||
/// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and
|
||||
/// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.
|
||||
fn contains_exterior_struct_lit(value: &hir::Expr) -> bool {
|
||||
match value.node {
|
||||
match value.kind {
|
||||
hir::ExprKind::Struct(..) => true,
|
||||
|
||||
hir::ExprKind::Assign(ref lhs, ref rhs) |
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ impl Visitor<'tcx> for LocalCollector {
|
|||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
|
||||
if let hir::PatKind::Binding(_, hir_id, ..) = pat.node {
|
||||
if let hir::PatKind::Binding(_, hir_id, ..) = pat.kind {
|
||||
self.locals.insert(hir_id);
|
||||
}
|
||||
intravisit::walk_pat(self, pat);
|
||||
|
|
@ -82,7 +82,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
if let hir::ExprKind::Closure(..) = expr.node {
|
||||
if let hir::ExprKind::Closure(..) = expr.kind {
|
||||
let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
|
||||
if let Some(upvars) = self.tcx.upvars(closure_def_id) {
|
||||
// Every capture of a closure expression is a local in scope,
|
||||
|
|
|
|||
|
|
@ -144,11 +144,11 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
|
|||
hcx.while_hashing_hir_bodies(true, |hcx| {
|
||||
let hir::Ty {
|
||||
hir_id: _,
|
||||
ref node,
|
||||
ref kind,
|
||||
ref span,
|
||||
} = *self;
|
||||
|
||||
node.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
span.hash_stable(hcx, hasher);
|
||||
})
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ impl_stable_hash_for_spanned!(hir::BinOpKind);
|
|||
|
||||
impl_stable_hash_for!(struct hir::Stmt {
|
||||
hir_id,
|
||||
node,
|
||||
kind,
|
||||
span,
|
||||
});
|
||||
|
||||
|
|
@ -173,12 +173,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
|
|||
let hir::Expr {
|
||||
hir_id: _,
|
||||
ref span,
|
||||
ref node,
|
||||
ref kind,
|
||||
ref attrs
|
||||
} = *self;
|
||||
|
||||
span.hash_stable(hcx, hasher);
|
||||
node.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
attrs.hash_stable(hcx, hasher);
|
||||
})
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
|
|||
ident,
|
||||
ref attrs,
|
||||
ref generics,
|
||||
ref node,
|
||||
ref kind,
|
||||
span
|
||||
} = *self;
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
|
|||
ident.name.hash_stable(hcx, hasher);
|
||||
attrs.hash_stable(hcx, hasher);
|
||||
generics.hash_stable(hcx, hasher);
|
||||
node.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
span.hash_stable(hcx, hasher);
|
||||
});
|
||||
}
|
||||
|
|
@ -226,7 +226,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem {
|
|||
defaultness,
|
||||
ref attrs,
|
||||
ref generics,
|
||||
ref node,
|
||||
ref kind,
|
||||
span
|
||||
} = *self;
|
||||
|
||||
|
|
@ -236,7 +236,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem {
|
|||
defaultness.hash_stable(hcx, hasher);
|
||||
attrs.hash_stable(hcx, hasher);
|
||||
generics.hash_stable(hcx, hasher);
|
||||
node.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
span.hash_stable(hcx, hasher);
|
||||
});
|
||||
}
|
||||
|
|
@ -312,7 +312,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
|
|||
ident,
|
||||
ref attrs,
|
||||
hir_id: _,
|
||||
ref node,
|
||||
ref kind,
|
||||
ref vis,
|
||||
span
|
||||
} = *self;
|
||||
|
|
@ -320,7 +320,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
|
|||
hcx.hash_hir_item_like(|hcx| {
|
||||
ident.name.hash_stable(hcx, hasher);
|
||||
attrs.hash_stable(hcx, hasher);
|
||||
node.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
vis.hash_stable(hcx, hasher);
|
||||
span.hash_stable(hcx, hasher);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitIntType {
|
|||
});
|
||||
|
||||
impl_stable_hash_for!(struct ::syntax::ast::Lit {
|
||||
node,
|
||||
kind,
|
||||
token,
|
||||
span
|
||||
});
|
||||
|
|
@ -361,7 +361,7 @@ impl_stable_hash_for!(enum ::syntax::ast::NestedMetaItem {
|
|||
|
||||
impl_stable_hash_for!(struct ::syntax::ast::MetaItem {
|
||||
path,
|
||||
node,
|
||||
kind,
|
||||
span
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let span = scope.span(self, region_scope_tree);
|
||||
let tag = match self.hir().find(scope.hir_id(region_scope_tree)) {
|
||||
Some(Node::Block(_)) => "block",
|
||||
Some(Node::Expr(expr)) => match expr.node {
|
||||
Some(Node::Expr(expr)) => match expr.kind {
|
||||
hir::ExprKind::Call(..) => "call",
|
||||
hir::ExprKind::MethodCall(..) => "method call",
|
||||
hir::ExprKind::Match(.., hir::MatchSource::IfLetDesugar { .. }) => "if let",
|
||||
|
|
@ -248,7 +248,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
fn item_scope_tag(item: &hir::Item) -> &'static str {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Impl(..) => "impl",
|
||||
hir::ItemKind::Struct(..) => "struct",
|
||||
hir::ItemKind::Union(..) => "union",
|
||||
|
|
@ -260,14 +260,14 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
fn trait_item_scope_tag(item: &hir::TraitItem) -> &'static str {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::TraitItemKind::Method(..) => "method body",
|
||||
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => "associated item",
|
||||
}
|
||||
}
|
||||
|
||||
fn impl_item_scope_tag(item: &hir::ImplItem) -> &'static str {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ImplItemKind::Method(..) => "method body",
|
||||
hir::ImplItemKind::Const(..)
|
||||
| hir::ImplItemKind::OpaqueTy(..)
|
||||
|
|
@ -639,7 +639,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
hir::MatchSource::TryDesugar => {
|
||||
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
|
||||
let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id);
|
||||
let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node {
|
||||
let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.kind {
|
||||
let arg_expr = args.first().expect("try desugaring call w/out arg");
|
||||
self.in_progress_tables.and_then(|tables| {
|
||||
tables.borrow().expr_ty_opt(arg_expr)
|
||||
|
|
|
|||
|
|
@ -92,10 +92,10 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> {
|
|||
|
||||
fn visit_expr(&mut self, expr: &'tcx Expr) {
|
||||
if let (ExprKind::Closure(_, _fn_decl, _id, _sp, _), Some(_)) = (
|
||||
&expr.node,
|
||||
&expr.kind,
|
||||
self.node_matches_type(expr.hir_id),
|
||||
) {
|
||||
self.found_closure = Some(&expr.node);
|
||||
self.found_closure = Some(&expr.kind);
|
||||
}
|
||||
intravisit::walk_expr(self, expr);
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ fn closure_return_type_suggestion(
|
|||
FunctionRetTy::DefaultReturn(_) => ("-> ", " "),
|
||||
_ => ("", ""),
|
||||
};
|
||||
let suggestion = match body.value.node {
|
||||
let suggestion = match body.value.kind {
|
||||
ExprKind::Block(..) => {
|
||||
vec![(output.span(), format!("{}{}{}", arrow, ret, post))]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,15 +31,15 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) {
|
||||
let fndecl = match self.tcx().hir().get(hir_id) {
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(ref fndecl, ..),
|
||||
kind: hir::ItemKind::Fn(ref fndecl, ..),
|
||||
..
|
||||
}) => &fndecl,
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(ref m, ..),
|
||||
kind: hir::TraitItemKind::Method(ref m, ..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&hir::ImplItem {
|
||||
node: hir::ImplItemKind::Method(ref m, ..),
|
||||
kind: hir::ImplItemKind::Method(ref m, ..),
|
||||
..
|
||||
}) => &m.decl,
|
||||
_ => return None,
|
||||
|
|
@ -98,7 +98,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, arg: &'tcx hir::Ty) {
|
||||
match arg.node {
|
||||
match arg.kind {
|
||||
hir::TyKind::BareFn(_) => {
|
||||
self.current_index.shift_in(1);
|
||||
intravisit::walk_ty(self, arg);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
return None;
|
||||
}
|
||||
if let FunctionRetTy::Return(ty) = &fndecl.output {
|
||||
if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.node, sub) {
|
||||
if let (TyKind::Def(_, _), ty::ReStatic) = (&ty.kind, sub) {
|
||||
// This is an impl Trait return that evaluates de need of 'static.
|
||||
// We handle this case better in `static_impl_trait`.
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
let hir = &self.tcx().hir();
|
||||
if let Some(hir_id) = hir.as_local_hir_id(free_region.scope) {
|
||||
if let Node::Expr(Expr {
|
||||
node: Closure(_, _, _, closure_span, None),
|
||||
kind: Closure(_, _, _, closure_span, None),
|
||||
..
|
||||
}) = hir.get(hir_id) {
|
||||
let sup_sp = sup_origin.span();
|
||||
|
|
|
|||
|
|
@ -1036,7 +1036,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
|||
.local_def_id(opaque_parent_hir_id)
|
||||
};
|
||||
let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) {
|
||||
Some(Node::Item(item)) => match item.node {
|
||||
Some(Node::Item(item)) => match item.kind {
|
||||
// Anonymous `impl Trait`
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
|
||||
impl_trait_fn: Some(parent),
|
||||
|
|
@ -1060,7 +1060,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
|||
(def_scope_default(), hir::OpaqueTyOrigin::TypeAlias)
|
||||
}
|
||||
},
|
||||
Some(Node::ImplItem(item)) => match item.node {
|
||||
Some(Node::ImplItem(item)) => match item.kind {
|
||||
hir::ImplItemKind::OpaqueTy(_) => (
|
||||
may_define_opaque_type(
|
||||
tcx,
|
||||
|
|
|
|||
|
|
@ -981,7 +981,7 @@ for LateContextAndPass<'a, 'tcx, T> {
|
|||
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
let generics = self.context.generics.take();
|
||||
self.context.generics = it.node.generics();
|
||||
self.context.generics = it.kind.generics();
|
||||
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
|
||||
cx.with_param_env(it.hir_id, |cx| {
|
||||
lint_callback!(cx, check_item, it);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind {
|
|||
}
|
||||
|
||||
fn check_ty(&mut self, cx: &LateContext<'_, '_>, ty: &'tcx Ty) {
|
||||
match &ty.node {
|
||||
match &ty.kind {
|
||||
TyKind::Path(qpath) => {
|
||||
if let QPath::Resolved(_, path) = qpath {
|
||||
if let Some(last) = path.segments.iter().last() {
|
||||
|
|
@ -169,7 +169,7 @@ fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment) -> bool {
|
|||
}
|
||||
|
||||
fn is_ty_or_ty_ctxt(cx: &LateContext<'_, '_>, ty: &Ty) -> Option<String> {
|
||||
match &ty.node {
|
||||
match &ty.kind {
|
||||
TyKind::Path(qpath) => {
|
||||
if let QPath::Resolved(_, path) = qpath {
|
||||
let did = path.res.opt_def_id()?;
|
||||
|
|
@ -218,7 +218,7 @@ declare_lint_pass!(LintPassImpl => [LINT_PASS_IMPL_WITHOUT_MACRO]);
|
|||
|
||||
impl EarlyLintPass for LintPassImpl {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
||||
if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.node {
|
||||
if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.kind {
|
||||
if let Some(last) = lint_pass.path.segments.last() {
|
||||
if last.ident.name == sym::LintPass {
|
||||
let expn_data = lint_pass.path.span.ctxt().outer_expn_data();
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ impl<'a> LintLevelsBuilder<'a> {
|
|||
let mut reason = None;
|
||||
let tail_li = &metas[metas.len()-1];
|
||||
if let Some(item) = tail_li.meta_item() {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::MetaItemKind::Word => {} // actual lint names handled later
|
||||
ast::MetaItemKind::NameValue(ref name_value) => {
|
||||
if item.path == sym::reason {
|
||||
|
|
@ -226,7 +226,7 @@ impl<'a> LintLevelsBuilder<'a> {
|
|||
metas = &metas[0..metas.len()-1];
|
||||
// FIXME (#55112): issue unused-attributes lint if we thereby
|
||||
// don't have any lint names (`#[level(reason = "foo")]`)
|
||||
if let ast::LitKind::Str(rationale, _) = name_value.node {
|
||||
if let ast::LitKind::Str(rationale, _) = name_value.kind {
|
||||
if !self.sess.features_untracked().lint_reasons {
|
||||
feature_gate::emit_feature_err(
|
||||
&self.sess.parse_sess,
|
||||
|
|
@ -264,7 +264,7 @@ impl<'a> LintLevelsBuilder<'a> {
|
|||
let mut err = bad_attr(sp);
|
||||
let mut add_label = true;
|
||||
if let Some(item) = li.meta_item() {
|
||||
if let ast::MetaItemKind::NameValue(_) = item.node {
|
||||
if let ast::MetaItemKind::NameValue(_) = item.kind {
|
||||
if item.path == sym::reason {
|
||||
err.span_label(sp, "reason in lint attribute must come last");
|
||||
add_label = false;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
|
||||
};
|
||||
for pat in pats {
|
||||
if let PatKind::Wild = pat.pat.node {
|
||||
if let PatKind::Wild = pat.pat.kind {
|
||||
continue;
|
||||
}
|
||||
let index = self.tcx.field_index(pat.hir_id, self.tables);
|
||||
|
|
@ -166,7 +166,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
self.inherited_pub_visibility = false;
|
||||
match node {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
let def = self.tcx.adt_def(def_id);
|
||||
|
|
@ -236,7 +236,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => {
|
||||
let res = self.tables.qpath_res(qpath, expr.hir_id);
|
||||
self.handle_res(res);
|
||||
|
|
@ -269,7 +269,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Struct(ref path, ref fields, _) => {
|
||||
let res = self.tables.qpath_res(path, pat.hir_id);
|
||||
self.handle_field_pattern_match(pat, res, fields);
|
||||
|
|
@ -292,7 +292,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
TyKind::Def(item_id, _) => {
|
||||
let item = self.tcx.hir().expect_item(item_id.id);
|
||||
intravisit::walk_item(self, item);
|
||||
|
|
@ -369,7 +369,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
|||
if allow_dead_code {
|
||||
self.worklist.push(item.hir_id);
|
||||
}
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(ref enum_def, _) => {
|
||||
if allow_dead_code {
|
||||
self.worklist.extend(enum_def.variants.iter().map(|variant| variant.id));
|
||||
|
|
@ -384,7 +384,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
|||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
for trait_item_ref in trait_item_refs {
|
||||
let trait_item = self.krate.trait_item(trait_item_ref.id);
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Const(_, Some(_)) |
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
|
||||
if has_allow_dead_code_or_lang_attr(self.tcx,
|
||||
|
|
@ -482,7 +482,7 @@ struct DeadVisitor<'tcx> {
|
|||
|
||||
impl DeadVisitor<'tcx> {
|
||||
fn should_warn_about_item(&mut self, item: &hir::Item) -> bool {
|
||||
let should_warn = match item.node {
|
||||
let should_warn = match item.kind {
|
||||
hir::ItemKind::Static(..)
|
||||
| hir::ItemKind::Const(..)
|
||||
| hir::ItemKind::Fn(..)
|
||||
|
|
@ -571,7 +571,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
if self.should_warn_about_item(item) {
|
||||
// For items that have a definition with a signature followed by a
|
||||
// block, point only at the signature.
|
||||
let span = match item.node {
|
||||
let span = match item.kind {
|
||||
hir::ItemKind::Fn(..) |
|
||||
hir::ItemKind::Mod(..) |
|
||||
hir::ItemKind::Enum(..) |
|
||||
|
|
@ -581,7 +581,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
hir::ItemKind::Impl(..) => self.tcx.sess.source_map().def_span(item.span),
|
||||
_ => item.span,
|
||||
};
|
||||
let participle = match item.node {
|
||||
let participle = match item.kind {
|
||||
hir::ItemKind::Struct(..) => "constructed", // Issue #52325
|
||||
_ => "used"
|
||||
};
|
||||
|
|
@ -589,7 +589,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
item.hir_id,
|
||||
span,
|
||||
item.ident.name,
|
||||
item.node.descriptive_variant(),
|
||||
item.kind.descriptive_variant(),
|
||||
participle,
|
||||
);
|
||||
} else {
|
||||
|
|
@ -613,7 +613,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) {
|
||||
if self.should_warn_about_foreign_item(fi) {
|
||||
self.warn_dead_code(fi.hir_id, fi.span, fi.ident.name,
|
||||
fi.node.descriptive_variant(), "used");
|
||||
fi.kind.descriptive_variant(), "used");
|
||||
}
|
||||
intravisit::walk_foreign_item(self, fi);
|
||||
}
|
||||
|
|
@ -626,7 +626,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
match impl_item.node {
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(_, body_id) => {
|
||||
if !self.symbol_is_live(impl_item.hir_id) {
|
||||
self.warn_dead_code(impl_item.hir_id,
|
||||
|
|
@ -652,7 +652,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
|||
|
||||
// Overwrite so that we don't warn the trait item itself.
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Const(_, Some(body_id)) |
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => {
|
||||
self.visit_nested_body(body_id)
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(DefId, EntryFnType)> {
|
|||
// Beware, this is duplicated in `libsyntax/entry.rs`, so make sure to keep
|
||||
// them in sync.
|
||||
fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(..) => {
|
||||
if attr::contains_name(&item.attrs, sym::start) {
|
||||
EntryPointType::Start
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
|
||||
self.walk_adjustment(expr);
|
||||
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Path(_) => { }
|
||||
|
||||
hir::ExprKind::Type(ref subexpr, _) => {
|
||||
|
|
@ -590,7 +590,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn walk_stmt(&mut self, stmt: &hir::Stmt) {
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
hir::StmtKind::Local(ref local) => {
|
||||
self.walk_local(&local);
|
||||
}
|
||||
|
|
@ -812,7 +812,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr, pat);
|
||||
|
||||
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| {
|
||||
if let PatKind::Binding(..) = pat.node {
|
||||
if let PatKind::Binding(..) = pat.kind {
|
||||
let bm = *self.mc.tables.pat_binding_modes()
|
||||
.get(pat.hir_id)
|
||||
.expect("missing binding mode");
|
||||
|
|
@ -839,7 +839,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
let tcx = self.tcx();
|
||||
let ExprUseVisitor { ref mc, ref mut delegate, param_env } = *self;
|
||||
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |cmt_pat, pat| {
|
||||
if let PatKind::Binding(_, canonical_id, ..) = pat.node {
|
||||
if let PatKind::Binding(_, canonical_id, ..) = pat.kind {
|
||||
debug!(
|
||||
"walk_pat: binding cmt_pat={:?} pat={:?} match_mode={:?}",
|
||||
cmt_pat,
|
||||
|
|
@ -885,7 +885,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||
// to the above loop's visit of than the bindings that form
|
||||
// the leaves of the pattern tree structure.
|
||||
return_if_err!(mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| {
|
||||
let qpath = match pat.node {
|
||||
let qpath = match pat.kind {
|
||||
PatKind::Path(ref qpath) |
|
||||
PatKind::TupleStruct(ref qpath, ..) |
|
||||
PatKind::Struct(ref qpath, ..) => qpath,
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ impl Visitor<'tcx> for ExprVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
let res = if let hir::ExprKind::Path(ref qpath) = expr.node {
|
||||
let res = if let hir::ExprKind::Path(ref qpath) = expr.kind {
|
||||
self.tables.qpath_res(qpath, expr.hir_id)
|
||||
} else {
|
||||
Res::Err
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl LibFeatureCollector<'tcx> {
|
|||
attr.check_name(**stab_attr)
|
||||
}) {
|
||||
let meta_item = attr.meta();
|
||||
if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta_item {
|
||||
if let Some(MetaItem { kind: MetaItemKind::List(ref metas), .. }) = meta_item {
|
||||
let mut feature = None;
|
||||
let mut since = None;
|
||||
for meta in metas {
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ fn visit_fn<'tcx>(
|
|||
let body = ir.tcx.hir().body(body_id);
|
||||
|
||||
for param in &body.params {
|
||||
let is_shorthand = match param.pat.node {
|
||||
let is_shorthand = match param.pat.kind {
|
||||
crate::hir::PatKind::Struct(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
|
@ -412,7 +412,7 @@ fn add_from_pat(ir: &mut IrMaps<'_>, pat: &P<hir::Pat>) {
|
|||
pats.push_back(pat);
|
||||
while let Some(pat) = pats.pop_front() {
|
||||
use crate::hir::PatKind::*;
|
||||
match &pat.node {
|
||||
match &pat.kind {
|
||||
Binding(.., inner_pat) => {
|
||||
pats.extend(inner_pat.iter());
|
||||
}
|
||||
|
|
@ -456,7 +456,7 @@ fn visit_arm<'tcx>(ir: &mut IrMaps<'tcx>, arm: &'tcx hir::Arm) {
|
|||
}
|
||||
|
||||
fn visit_expr<'tcx>(ir: &mut IrMaps<'tcx>, expr: &'tcx Expr) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
// live nodes required for uses or definitions of variables:
|
||||
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
|
||||
debug!("expr {}: path that leads to {:?}", expr.hir_id, path.res);
|
||||
|
|
@ -947,7 +947,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
fn propagate_through_stmt(&mut self, stmt: &hir::Stmt, succ: LiveNode)
|
||||
-> LiveNode {
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
hir::StmtKind::Local(ref local) => {
|
||||
// Note: we mark the variable as defined regardless of whether
|
||||
// there is an initializer. Initially I had thought to only mark
|
||||
|
|
@ -991,7 +991,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
-> LiveNode {
|
||||
debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id));
|
||||
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
// Interesting cases with control flow or which gen/kill
|
||||
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
|
||||
self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE)
|
||||
|
|
@ -1259,7 +1259,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
// these errors are detected in the later pass borrowck. We
|
||||
// just ignore such cases and treat them as reads.
|
||||
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Path(_) => succ,
|
||||
hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ),
|
||||
_ => self.propagate_through_expr(expr, succ)
|
||||
|
|
@ -1268,7 +1268,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
// see comment on propagate_through_place()
|
||||
fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) -> LiveNode {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
|
||||
self.access_path(expr.hir_id, path, succ, acc)
|
||||
}
|
||||
|
|
@ -1377,7 +1377,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Assign(ref l, _) => {
|
||||
this.check_place(&l);
|
||||
}
|
||||
|
|
@ -1420,7 +1420,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) {
|
|||
|
||||
impl<'tcx> Liveness<'_, 'tcx> {
|
||||
fn check_place(&mut self, expr: &'tcx Expr) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
|
||||
if let Res::Local(var_hid) = path.res {
|
||||
let upvars = self.ir.tcx.upvars(self.ir.body_owner);
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ impl MutabilityCategory {
|
|||
id: hir::HirId,
|
||||
) -> MutabilityCategory {
|
||||
let ret = match tcx.hir().get(id) {
|
||||
Node::Binding(p) => match p.node {
|
||||
Node::Binding(p) => match p.kind {
|
||||
PatKind::Binding(..) => {
|
||||
let bm = *tables.pat_binding_modes()
|
||||
.get(p.hir_id)
|
||||
|
|
@ -486,7 +486,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
|
||||
// This code detects whether we are looking at a `ref x`,
|
||||
// and if so, figures out what the type *being borrowed* is.
|
||||
let ret_ty = match pat.node {
|
||||
let ret_ty = match pat.kind {
|
||||
PatKind::Binding(..) => {
|
||||
let bm = *self.tables
|
||||
.pat_binding_modes()
|
||||
|
|
@ -577,7 +577,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
|
||||
|
||||
let expr_ty = self.expr_ty(expr)?;
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Unary(hir::UnDeref, ref e_base) => {
|
||||
if self.tables.is_method_call(expr) {
|
||||
self.cat_overloaded_place(expr, e_base, NoteNone)
|
||||
|
|
@ -1212,7 +1212,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
// that (where the `ref` on `x` is implied).
|
||||
op(cmt.clone(), pat);
|
||||
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => {
|
||||
let res = self.tables.qpath_res(qpath, pat.hir_id);
|
||||
let (cmt, expected_len) = match res {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
|
|||
return true
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(_, header, ..) if header.is_const() => {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ fn method_might_be_inlined(
|
|||
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
||||
return true
|
||||
}
|
||||
if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.node {
|
||||
if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.kind {
|
||||
if method_sig.header.is_const() {
|
||||
return true
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
let res = match expr.node {
|
||||
let res = match expr.kind {
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
Some(self.tables.qpath_res(qpath, expr.hir_id))
|
||||
}
|
||||
|
|
@ -157,14 +157,14 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
|
||||
match self.tcx.hir().find(hir_id) {
|
||||
Some(Node::Item(item)) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(..) =>
|
||||
item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
Some(Node::TraitItem(trait_method)) => {
|
||||
match trait_method.node {
|
||||
match trait_method.kind {
|
||||
hir::TraitItemKind::Const(_, ref default) => default.is_some(),
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) |
|
||||
|
|
@ -172,7 +172,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
Some(Node::ImplItem(impl_item)) => {
|
||||
match impl_item.node {
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(..) => true,
|
||||
hir::ImplItemKind::Method(..) => {
|
||||
let attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||
|
|
@ -187,7 +187,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
// type of the impl require inlining, this method
|
||||
// does too.
|
||||
let impl_hir_id = self.tcx.hir().as_local_hir_id(impl_did).unwrap();
|
||||
match self.tcx.hir().expect_item(impl_hir_id).node {
|
||||
match self.tcx.hir().expect_item(impl_hir_id).kind {
|
||||
hir::ItemKind::Impl(..) => {
|
||||
let generics = self.tcx.generics_of(impl_did);
|
||||
generics.requires_monomorphization(self.tcx)
|
||||
|
|
@ -225,7 +225,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
// If we are building an executable, only explicitly extern
|
||||
// types need to be exported.
|
||||
if let Node::Item(item) = *node {
|
||||
let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.node {
|
||||
let reachable = if let hir::ItemKind::Fn(_, header, ..) = item.kind {
|
||||
header.abi != Abi::Rust
|
||||
} else {
|
||||
false
|
||||
|
|
@ -249,7 +249,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
|
||||
match *node {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(.., body) => {
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
if item_might_be_inlined(self.tcx,
|
||||
|
|
@ -286,7 +286,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
Node::TraitItem(trait_method) => {
|
||||
match trait_method.node {
|
||||
match trait_method.kind {
|
||||
hir::TraitItemKind::Const(_, None) |
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
|
||||
// Keep going, nothing to get exported
|
||||
|
|
@ -299,7 +299,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
Node::ImplItem(impl_item) => {
|
||||
match impl_item.node {
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(_, body) => {
|
||||
self.visit_nested_body(body);
|
||||
}
|
||||
|
|
@ -313,7 +313,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
hir::ImplItemKind::TyAlias(_) => {}
|
||||
}
|
||||
}
|
||||
Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(.., body, _, _), .. }) => {
|
||||
Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(.., body, _, _), .. }) => {
|
||||
self.visit_nested_body(body);
|
||||
}
|
||||
// Nothing to recurse on for these
|
||||
|
|
@ -361,7 +361,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
|
|||
}
|
||||
|
||||
// We need only trait impls here, not inherent impls, and only non-exported ones
|
||||
if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node {
|
||||
if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.kind {
|
||||
if !self.access_levels.is_reachable(item.hir_id) {
|
||||
self.worklist.extend(impl_item_refs.iter().map(|ii_ref| ii_ref.id.hir_id));
|
||||
|
||||
|
|
|
|||
|
|
@ -796,7 +796,7 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
|
|||
// index information.)
|
||||
|
||||
for (i, statement) in blk.stmts.iter().enumerate() {
|
||||
match statement.node {
|
||||
match statement.kind {
|
||||
hir::StmtKind::Local(..) |
|
||||
hir::StmtKind::Item(..) => {
|
||||
// Each declaration introduces a subscope for bindings
|
||||
|
|
@ -850,7 +850,7 @@ fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir
|
|||
visitor.record_child_scope(Scope { id: pat.hir_id.local_id, data: ScopeData::Node });
|
||||
|
||||
// If this is a binding then record the lifetime of that binding.
|
||||
if let PatKind::Binding(..) = pat.node {
|
||||
if let PatKind::Binding(..) = pat.kind {
|
||||
record_var_lifetime(visitor, pat.hir_id.local_id, pat.span);
|
||||
}
|
||||
|
||||
|
|
@ -893,7 +893,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
|
|||
let mut terminating = |id: hir::ItemLocalId| {
|
||||
terminating_scopes.insert(id);
|
||||
};
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
// Conditional or repeating scopes are always terminating
|
||||
// scopes, meaning that temporaries cannot outlive them.
|
||||
// This ensures fixed size stacks.
|
||||
|
|
@ -996,7 +996,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
|
|||
// properly, we can't miss any types.
|
||||
|
||||
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
// Manually recurse over closures, because they are the only
|
||||
// case of nested bodies that share the parent environment.
|
||||
hir::ExprKind::Closure(.., body, _, _) => {
|
||||
|
|
@ -1053,7 +1053,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
|
|||
|
||||
debug!("resolve_expr post-increment {}, expr = {:?}", visitor.expr_and_pat_count, expr);
|
||||
|
||||
if let hir::ExprKind::Yield(_, source) = &expr.node {
|
||||
if let hir::ExprKind::Yield(_, source) = &expr.kind {
|
||||
// Mark this expr's scope and all parent scopes as containing `yield`.
|
||||
let mut scope = Scope { id: expr.hir_id.local_id, data: ScopeData::Node };
|
||||
loop {
|
||||
|
|
@ -1198,7 +1198,7 @@ fn resolve_local<'tcx>(
|
|||
// In the former case (the implicit ref version), the temporary is created by the
|
||||
// & expression, and its lifetime would be extended to the end of the block (due
|
||||
// to a different rule, not the below code).
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Binding(hir::BindingAnnotation::Ref, ..) |
|
||||
PatKind::Binding(hir::BindingAnnotation::RefMut, ..) => true,
|
||||
|
||||
|
|
@ -1240,7 +1240,7 @@ fn resolve_local<'tcx>(
|
|||
expr: &hir::Expr,
|
||||
blk_id: Option<Scope>,
|
||||
) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::AddrOf(_, ref subexpr) => {
|
||||
record_rvalue_scope_if_borrow_expr(visitor, &subexpr, blk_id);
|
||||
record_rvalue_scope(visitor, &subexpr, blk_id);
|
||||
|
|
@ -1300,7 +1300,7 @@ fn resolve_local<'tcx>(
|
|||
// outer expression.
|
||||
visitor.scope_tree.record_rvalue_scope(expr.hir_id.local_id, blk_scope);
|
||||
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::AddrOf(_, ref subexpr) |
|
||||
hir::ExprKind::Unary(hir::UnDeref, ref subexpr) |
|
||||
hir::ExprKind::Field(ref subexpr, _) |
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Fn(ref decl, _, ref generics, _) => {
|
||||
self.visit_early_late(None, decl, generics, |this| {
|
||||
intravisit::walk_item(this, item);
|
||||
|
|
@ -504,12 +504,12 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
| hir::ItemKind::Impl(_, _, _, ref generics, ..) => {
|
||||
// Impls permit `'_` to be used and it is equivalent to "some fresh lifetime name".
|
||||
// This is not true for other kinds of items.x
|
||||
let track_lifetime_uses = match item.node {
|
||||
let track_lifetime_uses = match item.kind {
|
||||
hir::ItemKind::Impl(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
// These kinds of items have only early-bound lifetime parameters.
|
||||
let mut index = if sub_items_have_self_param(&item.node) {
|
||||
let mut index = if sub_items_have_self_param(&item.kind) {
|
||||
1 // Self comes before lifetimes
|
||||
} else {
|
||||
0
|
||||
|
|
@ -541,7 +541,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ForeignItemKind::Fn(ref decl, _, ref generics) => {
|
||||
self.visit_early_late(None, decl, generics, |this| {
|
||||
intravisit::walk_foreign_item(this, item);
|
||||
|
|
@ -558,8 +558,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
|
||||
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
|
||||
debug!("visit_ty: id={:?} ty={:?}", ty.hir_id, ty);
|
||||
debug!("visit_ty: ty.node={:?}", ty.node);
|
||||
match ty.node {
|
||||
debug!("visit_ty: ty.kind={:?}", ty.kind);
|
||||
match ty.kind {
|
||||
hir::TyKind::BareFn(ref c) => {
|
||||
let next_early_index = self.next_early_index();
|
||||
let was_in_fn_syntax = self.is_in_fn_syntax;
|
||||
|
|
@ -637,8 +637,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
// `type MyAnonTy<'b> = impl MyTrait<'b>;`
|
||||
// ^ ^ this gets resolved in the scope of
|
||||
// the opaque_ty generics
|
||||
let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).node
|
||||
{
|
||||
let (generics, bounds) = match self.tcx.hir().expect_item(item_id.id).kind {
|
||||
// Named opaque `impl Trait` types are reached via `TyKind::Path`.
|
||||
// This arm is for `impl Trait` in the types of statics, constants and locals.
|
||||
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
|
||||
|
|
@ -778,7 +777,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
use self::hir::TraitItemKind::*;
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
Method(ref sig, _) => {
|
||||
let tcx = self.tcx;
|
||||
self.visit_early_late(
|
||||
|
|
@ -830,7 +829,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
use self::hir::ImplItemKind::*;
|
||||
match impl_item.node {
|
||||
match impl_item.kind {
|
||||
Method(ref sig, _) => {
|
||||
let tcx = self.tcx;
|
||||
self.visit_early_late(
|
||||
|
|
@ -1214,7 +1213,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
|
|||
}
|
||||
|
||||
fn expression_label(ex: &hir::Expr) -> Option<ast::Ident> {
|
||||
if let hir::ExprKind::Loop(_, Some(label), _) = ex.node {
|
||||
if let hir::ExprKind::Loop(_, Some(label), _) = ex.kind {
|
||||
Some(label.ident)
|
||||
} else {
|
||||
None
|
||||
|
|
@ -1263,7 +1262,7 @@ fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) {
|
|||
fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap<Vec<ObjectLifetimeDefault>> {
|
||||
let mut map = HirIdMap::default();
|
||||
for item in tcx.hir().krate().items.values() {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Struct(_, ref generics)
|
||||
| hir::ItemKind::Union(_, ref generics)
|
||||
| hir::ItemKind::Enum(_, ref generics)
|
||||
|
|
@ -1352,7 +1351,7 @@ fn object_lifetime_defaults_for_item(
|
|||
continue;
|
||||
}
|
||||
|
||||
let res = match data.bounded_ty.node {
|
||||
let res = match data.bounded_ty.kind {
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => path.res,
|
||||
_ => continue,
|
||||
};
|
||||
|
|
@ -1487,7 +1486,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
let mut elide_use = None;
|
||||
let mut find_arg_use_span = |inputs: &hir::HirVec<hir::Ty>| {
|
||||
for input in inputs {
|
||||
match input.node {
|
||||
match input.kind {
|
||||
hir::TyKind::Rptr(lt, _) => {
|
||||
if lt.name.ident() == name {
|
||||
// include the trailing whitespace between the lifetime and type names
|
||||
|
|
@ -1525,12 +1524,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
{
|
||||
match parent {
|
||||
Node::Item(item) => {
|
||||
if let hir::ItemKind::Fn(decl, _, _, _) = &item.node {
|
||||
if let hir::ItemKind::Fn(decl, _, _, _) = &item.kind {
|
||||
find_arg_use_span(&decl.inputs);
|
||||
}
|
||||
},
|
||||
Node::ImplItem(impl_item) => {
|
||||
if let hir::ImplItemKind::Method(sig, _) = &impl_item.node {
|
||||
if let hir::ImplItemKind::Method(sig, _) = &impl_item.kind {
|
||||
find_arg_use_span(&sig.decl.inputs);
|
||||
}
|
||||
}
|
||||
|
|
@ -1733,10 +1732,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
let mut index = 0;
|
||||
if let Some(parent_id) = parent_id {
|
||||
let parent = self.tcx.hir().expect_item(parent_id);
|
||||
if sub_items_have_self_param(&parent.node) {
|
||||
if sub_items_have_self_param(&parent.kind) {
|
||||
index += 1; // Self comes before lifetimes
|
||||
}
|
||||
match parent.node {
|
||||
match parent.kind {
|
||||
hir::ItemKind::Trait(_, _, ref generics, ..)
|
||||
| hir::ItemKind::Impl(_, _, _, ref generics, ..) => {
|
||||
index += generics.params.len() as u32;
|
||||
|
|
@ -1867,15 +1866,15 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
let fn_id = self.tcx.hir().body_owner(body_id);
|
||||
match self.tcx.hir().get(fn_id) {
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(..),
|
||||
kind: hir::ItemKind::Fn(..),
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(..),
|
||||
kind: hir::TraitItemKind::Method(..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&hir::ImplItem {
|
||||
node: hir::ImplItemKind::Method(..),
|
||||
kind: hir::ImplItemKind::Method(..),
|
||||
..
|
||||
}) => {
|
||||
let scope = self.tcx.hir().local_def_id(fn_id);
|
||||
|
|
@ -2165,18 +2164,18 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
let body = match self.tcx.hir().get(parent) {
|
||||
// `fn` definitions and methods.
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(.., body),
|
||||
kind: hir::ItemKind::Fn(.., body),
|
||||
..
|
||||
}) => Some(body),
|
||||
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(_, ref m),
|
||||
kind: hir::TraitItemKind::Method(_, ref m),
|
||||
..
|
||||
}) => {
|
||||
if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx
|
||||
.hir()
|
||||
.expect_item(self.tcx.hir().get_parent_item(parent))
|
||||
.node
|
||||
.kind
|
||||
{
|
||||
assoc_item_kind = trait_items
|
||||
.iter()
|
||||
|
|
@ -2190,13 +2189,13 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
Node::ImplItem(&hir::ImplItem {
|
||||
node: hir::ImplItemKind::Method(_, body),
|
||||
kind: hir::ImplItemKind::Method(_, body),
|
||||
..
|
||||
}) => {
|
||||
if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx
|
||||
.hir()
|
||||
.expect_item(self.tcx.hir().get_parent_item(parent))
|
||||
.node
|
||||
.kind
|
||||
{
|
||||
impl_self = Some(self_ty);
|
||||
assoc_item_kind = impl_items
|
||||
|
|
@ -2270,8 +2269,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'a hir::Ty) {
|
||||
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.node {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node
|
||||
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.kind {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.kind
|
||||
{
|
||||
if self.is_self_ty(path.res) {
|
||||
if let Some(lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
|
||||
|
|
@ -2286,7 +2285,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
|
||||
let mut visitor = SelfVisitor {
|
||||
map: self.map,
|
||||
impl_self: impl_self.map(|ty| &ty.node),
|
||||
impl_self: impl_self.map(|ty| &ty.kind),
|
||||
lifetime: Set1::Empty,
|
||||
};
|
||||
visitor.visit_ty(&inputs[0]);
|
||||
|
|
@ -2364,10 +2363,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &hir::Ty) {
|
||||
if let hir::TyKind::BareFn(_) = ty.node {
|
||||
if let hir::TyKind::BareFn(_) = ty.kind {
|
||||
self.outer_index.shift_in(1);
|
||||
}
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
hir::TyKind::TraitObject(ref bounds, ref lifetime) => {
|
||||
for bound in bounds {
|
||||
self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None);
|
||||
|
|
@ -2384,7 +2383,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
intravisit::walk_ty(self, ty);
|
||||
}
|
||||
}
|
||||
if let hir::TyKind::BareFn(_) = ty.node {
|
||||
if let hir::TyKind::BareFn(_) = ty.kind {
|
||||
self.outer_index.shift_out(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -2991,7 +2990,7 @@ fn insert_late_bound_lifetimes(
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'v hir::Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
hir::TyKind::Path(hir::QPath::Resolved(Some(_), _))
|
||||
| hir::TyKind::Path(hir::QPath::TypeRelative(..)) => {
|
||||
// ignore lifetimes appearing in associated type
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
|||
fn visit_item(&mut self, i: &'tcx Item) {
|
||||
let orig_in_trait_impl = self.in_trait_impl;
|
||||
let mut kind = AnnotationKind::Required;
|
||||
match i.node {
|
||||
match i.kind {
|
||||
// Inherent impls and foreign modules serve only as containers for other items,
|
||||
// they don't have their own stability. They still can be annotated as unstable
|
||||
// and propagate this unstability to children, but this annotation is completely
|
||||
|
|
@ -344,14 +344,14 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx Item) {
|
||||
match i.node {
|
||||
match i.kind {
|
||||
// Inherent impls and foreign modules serve only as containers for other items,
|
||||
// they don't have their own stability. They still can be annotated as unstable
|
||||
// and propagate this unstability to children, but this annotation is completely
|
||||
// optional. They inherit stability from their parents when unannotated.
|
||||
hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {}
|
||||
|
||||
_ => self.check_missing_stability(i.hir_id, i.span, i.node.descriptive_variant())
|
||||
_ => self.check_missing_stability(i.hir_id, i.span, i.kind.descriptive_variant())
|
||||
}
|
||||
|
||||
intravisit::walk_item(self, i)
|
||||
|
|
@ -382,7 +382,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem) {
|
||||
self.check_missing_stability(i.hir_id, i.span, i.node.descriptive_variant());
|
||||
self.check_missing_stability(i.hir_id, i.span, i.kind.descriptive_variant());
|
||||
intravisit::walk_foreign_item(self, i);
|
||||
}
|
||||
|
||||
|
|
@ -797,7 +797,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(_) => {
|
||||
// compiler-generated `extern crate` items have a dummy span.
|
||||
if item.span.is_dummy() { return }
|
||||
|
|
|
|||
|
|
@ -1879,11 +1879,11 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
|
|||
if meta_item.path.segments.len() != 1 {
|
||||
error!("argument key must be an identifier");
|
||||
}
|
||||
match &meta_item.node {
|
||||
match &meta_item.kind {
|
||||
MetaItemKind::List(..) => {
|
||||
error!(r#"expected `key` or `key="value"`"#);
|
||||
}
|
||||
MetaItemKind::NameValue(lit) if !lit.node.is_str() => {
|
||||
MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
|
||||
error!("argument value must be a string");
|
||||
}
|
||||
MetaItemKind::NameValue(..) | MetaItemKind::Word => {
|
||||
|
|
|
|||
|
|
@ -956,7 +956,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
let parent_node = self.tcx.hir().get_parent_node(hir_id);
|
||||
if let Some(Node::Local(ref local)) = self.tcx.hir().find(parent_node) {
|
||||
if let Some(ref expr) = local.init {
|
||||
if let hir::ExprKind::Index(_, _) = expr.node {
|
||||
if let hir::ExprKind::Index(_, _) = expr.kind {
|
||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
|
||||
err.span_suggestion(
|
||||
expr.span,
|
||||
|
|
@ -1001,7 +1001,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
Ok(EvaluationResult::EvaluatedToAmbig) => {
|
||||
if let Some(hir::Node::Item(hir::Item {
|
||||
ident,
|
||||
node: hir::ItemKind::Fn(.., body_id),
|
||||
kind: hir::ItemKind::Fn(.., body_id),
|
||||
..
|
||||
})) = self.tcx.hir().get_if_local(def_id) {
|
||||
let body = self.tcx.hir().body(*body_id);
|
||||
|
|
@ -1010,7 +1010,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
"{}({})",
|
||||
ident,
|
||||
body.params.iter()
|
||||
.map(|arg| match &arg.pat.node {
|
||||
.map(|arg| match &arg.pat.kind {
|
||||
hir::PatKind::Binding(_, _, ident, None)
|
||||
if ident.name != kw::SelfLower => ident.to_string(),
|
||||
_ => "_".to_string(),
|
||||
|
|
@ -1106,11 +1106,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||
let node = hir.find(parent_node);
|
||||
if let Some(hir::Node::Item(hir::Item {
|
||||
node: hir::ItemKind::Fn(decl, _, _, body_id),
|
||||
kind: hir::ItemKind::Fn(decl, _, _, body_id),
|
||||
..
|
||||
})) = node {
|
||||
let body = hir.body(*body_id);
|
||||
if let hir::ExprKind::Block(blk, _) = &body.value.node {
|
||||
if let hir::ExprKind::Block(blk, _) = &body.value.kind {
|
||||
if decl.output.span().overlaps(span) && blk.expr.is_none() &&
|
||||
"()" == &trait_ref.self_ty().to_string()
|
||||
{
|
||||
|
|
@ -1134,14 +1134,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec<ArgKind>) {
|
||||
match node {
|
||||
Node::Expr(&hir::Expr {
|
||||
node: hir::ExprKind::Closure(_, ref _decl, id, span, _),
|
||||
kind: hir::ExprKind::Closure(_, ref _decl, id, span, _),
|
||||
..
|
||||
}) => {
|
||||
(self.tcx.sess.source_map().def_span(span),
|
||||
self.tcx.hir().body(id).params.iter()
|
||||
.map(|arg| {
|
||||
if let hir::Pat {
|
||||
node: hir::PatKind::Tuple(ref args, _),
|
||||
kind: hir::PatKind::Tuple(ref args, _),
|
||||
span,
|
||||
..
|
||||
} = *arg.pat {
|
||||
|
|
@ -1163,21 +1163,21 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
Node::Item(&hir::Item {
|
||||
span,
|
||||
node: hir::ItemKind::Fn(ref decl, ..),
|
||||
kind: hir::ItemKind::Fn(ref decl, ..),
|
||||
..
|
||||
}) |
|
||||
Node::ImplItem(&hir::ImplItem {
|
||||
span,
|
||||
node: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
||||
kind: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
||||
..
|
||||
}) |
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
span,
|
||||
node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
||||
kind: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
||||
..
|
||||
}) => {
|
||||
(self.tcx.sess.source_map().def_span(span), decl.inputs.iter()
|
||||
.map(|arg| match arg.clone().node {
|
||||
.map(|arg| match arg.clone().kind {
|
||||
hir::TyKind::Tup(ref tys) => ArgKind::Tuple(
|
||||
Some(arg.span),
|
||||
vec![("_".to_owned(), "_".to_owned()); tys.len()]
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
match self.hir().as_local_hir_id(node_item_def_id) {
|
||||
Some(hir_id) => {
|
||||
let item = self.hir().expect_item(hir_id);
|
||||
if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.node {
|
||||
if let hir::ItemKind::Impl(_, _, defaultness, ..) = item.kind {
|
||||
defaultness.is_default()
|
||||
} else {
|
||||
false
|
||||
|
|
|
|||
|
|
@ -603,7 +603,7 @@ impl<'tcx> TypeckTables<'tcx> {
|
|||
pub fn is_method_call(&self, expr: &hir::Expr) -> bool {
|
||||
// Only paths and method calls/overloaded operators have
|
||||
// entries in type_dependent_defs, ignore the former here.
|
||||
if let hir::ExprKind::Path(_) = expr.node {
|
||||
if let hir::ExprKind::Path(_) = expr.kind {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1141,7 +1141,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
None => return Bound::Unbounded,
|
||||
};
|
||||
for meta in attr.meta_item_list().expect("rustc_layout_scalar_valid_range takes args") {
|
||||
match meta.literal().expect("attribute takes lit").node {
|
||||
match meta.literal().expect("attribute takes lit").kind {
|
||||
ast::LitKind::Int(a, _) => return Bound::Included(a),
|
||||
_ => span_bug!(attr.span, "rustc_layout_scalar_valid_range expects int arg"),
|
||||
}
|
||||
|
|
@ -1543,7 +1543,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let hir_id = self.hir().as_local_hir_id(scope_def_id).unwrap();
|
||||
match self.hir().get(hir_id) {
|
||||
Node::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Fn(..) => { /* `type_of_def_id()` will work */ }
|
||||
_ => {
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -3164,7 +3164,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> AssocItem {
|
|||
let parent_id = tcx.hir().get_parent_item(id);
|
||||
let parent_def_id = tcx.hir().local_def_id(parent_id);
|
||||
let parent_item = tcx.hir().expect_item(parent_id);
|
||||
match parent_item.node {
|
||||
match parent_item.kind {
|
||||
hir::ItemKind::Impl(.., ref impl_item_refs) => {
|
||||
if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.hir_id == id) {
|
||||
let assoc_item = tcx.associated_item_from_impl_item_ref(parent_def_id,
|
||||
|
|
@ -3189,7 +3189,7 @@ fn associated_item(tcx: TyCtxt<'_>, def_id: DefId) -> AssocItem {
|
|||
|
||||
span_bug!(parent_item.span,
|
||||
"unexpected parent of trait or impl item or item not found: {:?}",
|
||||
parent_item.node)
|
||||
parent_item.kind)
|
||||
}
|
||||
|
||||
#[derive(Clone, HashStable)]
|
||||
|
|
@ -3221,7 +3221,7 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> AdtSizedConstraint<'_
|
|||
fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
||||
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let item = tcx.hir().expect_item(id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
tcx.arena.alloc_from_iter(
|
||||
trait_item_refs.iter()
|
||||
|
|
@ -3262,7 +3262,7 @@ fn trait_of_item(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
|||
pub fn is_impl_trait_defn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
|
||||
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
|
||||
if let Node::Item(item) = tcx.hir().get(hir_id) {
|
||||
if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.node {
|
||||
if let hir::ItemKind::OpaqueTy(ref opaque_ty) = item.kind {
|
||||
return opaque_ty.impl_trait_fn;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ pub fn check_loans<'a, 'tcx>(
|
|||
let hir_id = bccx.tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let movable_generator = !match bccx.tcx.hir().get(hir_id) {
|
||||
Node::Expr(&hir::Expr {
|
||||
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
|
||||
kind: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
|
||||
..
|
||||
}) => true,
|
||||
_ => false,
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ pub enum LoanPathElem<'tcx> {
|
|||
fn closure_to_block(closure_id: LocalDefId, tcx: TyCtxt<'_>) -> HirId {
|
||||
let closure_id = tcx.hir().local_def_id_to_hir_id(closure_id);
|
||||
match tcx.hir().get(closure_id) {
|
||||
Node::Expr(expr) => match expr.node {
|
||||
Node::Expr(expr) => match expr.kind {
|
||||
hir::ExprKind::Closure(.., body_id, _, _) => {
|
||||
body_id.hir_id
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
|
||||
let exit = match stmt.node {
|
||||
let exit = match stmt.kind {
|
||||
hir::StmtKind::Local(ref local) => {
|
||||
let init_exit = self.opt_expr(&local.init, pred);
|
||||
self.pat(&local.pat, init_exit)
|
||||
|
|
@ -114,7 +114,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn pat(&mut self, pat: &hir::Pat, pred: CFGIndex) -> CFGIndex {
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Binding(.., None) |
|
||||
PatKind::Path(_) |
|
||||
PatKind::Lit(..) |
|
||||
|
|
@ -163,7 +163,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Block(ref blk, _) => {
|
||||
let blk_exit = self.block(&blk, pred);
|
||||
self.add_ast_node(expr.hir_id.local_id, &[blk_exit])
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ impl CodegenCx<'ll, 'tcx> {
|
|||
let llty = self.layout_of(ty).llvm_type(self);
|
||||
let (g, attrs) = match self.tcx.hir().get(id) {
|
||||
Node::Item(&hir::Item {
|
||||
ref attrs, span, node: hir::ItemKind::Static(..), ..
|
||||
ref attrs, span, kind: hir::ItemKind::Static(..), ..
|
||||
}) => {
|
||||
let sym_str = sym.as_str();
|
||||
if self.get_declared_value(&sym_str).is_some() {
|
||||
|
|
@ -249,7 +249,7 @@ impl CodegenCx<'ll, 'tcx> {
|
|||
}
|
||||
|
||||
Node::ForeignItem(&hir::ForeignItem {
|
||||
ref attrs, span, node: hir::ForeignItemKind::Static(..), ..
|
||||
ref attrs, span, kind: hir::ForeignItemKind::Static(..), ..
|
||||
}) => {
|
||||
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||
(check_and_apply_linkage(&self, &fn_attrs, ty, sym, span), attrs)
|
||||
|
|
|
|||
|
|
@ -94,14 +94,14 @@ fn reachable_non_generics_provider(
|
|||
|
||||
// Only consider nodes that actually have exported symbols.
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Static(..),
|
||||
kind: hir::ItemKind::Static(..),
|
||||
..
|
||||
}) |
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(..), ..
|
||||
kind: hir::ItemKind::Fn(..), ..
|
||||
}) |
|
||||
Node::ImplItem(&hir::ImplItem {
|
||||
node: hir::ImplItemKind::Method(..),
|
||||
kind: hir::ImplItemKind::Method(..),
|
||||
..
|
||||
}) => {
|
||||
let def_id = tcx.hir().local_def_id(hir_id);
|
||||
|
|
@ -367,7 +367,7 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel
|
|||
// Emscripten cannot export statics, so reduce their export level here
|
||||
if tcx.sess.target.target.options.is_like_emscripten {
|
||||
if let Some(Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Static(..),
|
||||
kind: hir::ItemKind::Static(..),
|
||||
..
|
||||
})) = tcx.hir().get_if_local(sym_def_id) {
|
||||
return SymbolExportLevel::Rust;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
|||
}
|
||||
MonoItem::GlobalAsm(hir_id) => {
|
||||
let item = cx.tcx().hir().expect_item(hir_id);
|
||||
if let hir::ItemKind::GlobalAsm(ref ga) = item.node {
|
||||
if let hir::ItemKind::GlobalAsm(ref ga) = item.kind {
|
||||
cx.codegen_global_asm(ga);
|
||||
} else {
|
||||
span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type")
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ impl RustcDefaultCalls {
|
|||
let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| {
|
||||
let gated_cfg = GatedCfg::gate(&ast::MetaItem {
|
||||
path: ast::Path::from_ident(ast::Ident::with_dummy_span(name)),
|
||||
node: ast::MetaItemKind::Word,
|
||||
kind: ast::MetaItemKind::Word,
|
||||
span: DUMMY_SP,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ impl DirtyCleanVisitor<'tcx> {
|
|||
let node = self.tcx.hir().get(item_id);
|
||||
let (name, labels) = match node {
|
||||
HirNode::Item(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// note: these are in the same order as hir::Item_;
|
||||
// FIXME(michaelwoerister): do commented out ones
|
||||
|
||||
|
|
@ -391,20 +391,20 @@ impl DirtyCleanVisitor<'tcx> {
|
|||
&format!(
|
||||
"clean/dirty auto-assertions not yet defined \
|
||||
for Node::Item.node={:?}",
|
||||
item.node
|
||||
item.kind
|
||||
)
|
||||
),
|
||||
}
|
||||
},
|
||||
HirNode::TraitItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Method(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT),
|
||||
TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT),
|
||||
TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT),
|
||||
}
|
||||
},
|
||||
HirNode::ImplItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ImplItemKind::Method(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL),
|
||||
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
|
||||
ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
|
|||
sym::bin
|
||||
];
|
||||
|
||||
if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().node {
|
||||
if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().kind {
|
||||
let span = spanned.span;
|
||||
let lev_candidate = find_best_match_for_name(
|
||||
crate_types.iter(),
|
||||
|
|
@ -738,7 +738,7 @@ impl<'a> ReplaceBodyWithLoop<'a> {
|
|||
fn should_ignore_fn(ret_ty: &ast::FnDecl) -> bool {
|
||||
if let ast::FunctionRetTy::Ty(ref ty) = ret_ty.output {
|
||||
fn involves_impl_trait(ty: &ast::Ty) -> bool {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
ast::TyKind::ImplTrait(..) => true,
|
||||
ast::TyKind::Slice(ref subty) |
|
||||
ast::TyKind::Array(ref subty, _) |
|
||||
|
|
@ -796,7 +796,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
|||
}
|
||||
|
||||
fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
|
||||
let is_const = match i.node {
|
||||
let is_const = match i.kind {
|
||||
ast::TraitItemKind::Const(..) => true,
|
||||
ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
|
||||
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
|
||||
|
|
@ -806,7 +806,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
|||
}
|
||||
|
||||
fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
|
||||
let is_const = match i.node {
|
||||
let is_const = match i.kind {
|
||||
ast::ImplItemKind::Const(..) => true,
|
||||
ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
|
||||
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
|
||||
|
|
@ -834,21 +834,21 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
|||
fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt {
|
||||
let expr = P(ast::Expr {
|
||||
id: sess.next_node_id(),
|
||||
node: ast::ExprKind::Block(P(b), None),
|
||||
kind: ast::ExprKind::Block(P(b), None),
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
attrs: ThinVec::new(),
|
||||
});
|
||||
|
||||
ast::Stmt {
|
||||
id: sess.next_node_id(),
|
||||
node: ast::StmtKind::Expr(expr),
|
||||
kind: ast::StmtKind::Expr(expr),
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
}
|
||||
}
|
||||
|
||||
let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess);
|
||||
let loop_expr = P(ast::Expr {
|
||||
node: ast::ExprKind::Loop(P(empty_block), None),
|
||||
kind: ast::ExprKind::Loop(P(empty_block), None),
|
||||
id: self.sess.next_node_id(),
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
attrs: ThinVec::new(),
|
||||
|
|
@ -857,7 +857,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
|||
let loop_stmt = ast::Stmt {
|
||||
id: self.sess.next_node_id(),
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
node: ast::StmtKind::Expr(loop_expr),
|
||||
kind: ast::StmtKind::Expr(loop_expr),
|
||||
};
|
||||
|
||||
if self.within_static_or_const {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ declare_lint_pass!(WhileTrue => [WHILE_TRUE]);
|
|||
|
||||
/// Traverse through any amount of parenthesis and return the first non-parens expression.
|
||||
fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr {
|
||||
while let ast::ExprKind::Paren(sub) = &expr.node {
|
||||
while let ast::ExprKind::Paren(sub) = &expr.kind {
|
||||
expr = sub;
|
||||
}
|
||||
expr
|
||||
|
|
@ -75,9 +75,9 @@ fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr {
|
|||
|
||||
impl EarlyLintPass for WhileTrue {
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
|
||||
if let ast::ExprKind::While(cond, ..) = &e.node {
|
||||
if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).node {
|
||||
if let ast::LitKind::Bool(true) = lit.node {
|
||||
if let ast::ExprKind::While(cond, ..) = &e.kind {
|
||||
if let ast::ExprKind::Lit(ref lit) = pierce_parens(cond).kind {
|
||||
if let ast::LitKind::Bool(true) = lit.kind {
|
||||
if !lit.span.from_expansion() {
|
||||
let msg = "denote infinite loops with `loop { ... }`";
|
||||
let condition_span = cx.sess.source_map().def_span(e.span);
|
||||
|
|
@ -117,7 +117,7 @@ impl BoxPointers {
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Fn(..) |
|
||||
hir::ItemKind::TyAlias(..) |
|
||||
hir::ItemKind::Enum(..) |
|
||||
|
|
@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
|
|||
}
|
||||
|
||||
// If it's a struct, we also have to check the fields' types
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Struct(ref struct_def, _) |
|
||||
hir::ItemKind::Union(ref struct_def, _) => {
|
||||
for struct_field in struct_def.fields() {
|
||||
|
|
@ -159,7 +159,7 @@ declare_lint_pass!(NonShorthandFieldPatterns => [NON_SHORTHAND_FIELD_PATTERNS]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
|
||||
fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) {
|
||||
if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.node {
|
||||
if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.kind {
|
||||
let variant = cx.tables.pat_ty(pat).ty_adt_def()
|
||||
.expect("struct pattern type is not an ADT")
|
||||
.variant_of_res(cx.tables.qpath_res(qpath, pat.hir_id));
|
||||
|
|
@ -173,7 +173,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
|
|||
// (Issue #49588)
|
||||
continue;
|
||||
}
|
||||
if let PatKind::Binding(_, _, ident, None) = fieldpat.pat.node {
|
||||
if let PatKind::Binding(_, _, ident, None) = fieldpat.pat.kind {
|
||||
if cx.tcx.find_field_index(ident, &variant) ==
|
||||
Some(cx.tcx.field_index(fieldpat.hir_id, cx.tables)) {
|
||||
let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS,
|
||||
|
|
@ -224,7 +224,7 @@ impl EarlyLintPass for UnsafeCode {
|
|||
}
|
||||
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
|
||||
if let ast::ExprKind::Block(ref blk, _) = e.node {
|
||||
if let ast::ExprKind::Block(ref blk, _) = e.kind {
|
||||
// Don't warn about generated blocks; that'll just pollute the output.
|
||||
if blk.rules == ast::BlockCheckMode::Unsafe(ast::UserProvided) {
|
||||
self.report_unsafe(cx, blk.span, "usage of an `unsafe` block");
|
||||
|
|
@ -233,7 +233,7 @@ impl EarlyLintPass for UnsafeCode {
|
|||
}
|
||||
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
ast::ItemKind::Trait(_, ast::Unsafety::Unsafe, ..) => {
|
||||
self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait")
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ impl EarlyLintPass for UnsafeCode {
|
|||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::TraitItem) {
|
||||
if let ast::TraitItemKind::Method(ref sig, None) = item.node {
|
||||
if let ast::TraitItemKind::Method(ref sig, None) = item.kind {
|
||||
if sig.header.unsafety == ast::Unsafety::Unsafe {
|
||||
self.report_unsafe(cx, item.span, "declaration of an `unsafe` method")
|
||||
}
|
||||
|
|
@ -391,7 +391,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
|||
}
|
||||
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
let desc = match it.node {
|
||||
let desc = match it.kind {
|
||||
hir::ItemKind::Fn(..) => "a function",
|
||||
hir::ItemKind::Mod(..) => "a module",
|
||||
hir::ItemKind::Enum(..) => "an enum",
|
||||
|
|
@ -440,7 +440,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
|||
return;
|
||||
}
|
||||
|
||||
let desc = match trait_item.node {
|
||||
let desc = match trait_item.kind {
|
||||
hir::TraitItemKind::Const(..) => "an associated constant",
|
||||
hir::TraitItemKind::Method(..) => "a trait method",
|
||||
hir::TraitItemKind::Type(..) => "an associated type",
|
||||
|
|
@ -459,7 +459,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
|||
return;
|
||||
}
|
||||
|
||||
let desc = match impl_item.node {
|
||||
let desc = match impl_item.kind {
|
||||
hir::ImplItemKind::Const(..) => "an associated constant",
|
||||
hir::ImplItemKind::Method(..) => "a method",
|
||||
hir::ImplItemKind::TyAlias(_) => "an associated type",
|
||||
|
|
@ -504,7 +504,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
|
|||
if !cx.access_levels.is_reachable(item.hir_id) {
|
||||
return;
|
||||
}
|
||||
let (def, ty) = match item.node {
|
||||
let (def, ty) = match item.kind {
|
||||
hir::ItemKind::Struct(_, ref ast_generics) => {
|
||||
if !ast_generics.params.is_empty() {
|
||||
return;
|
||||
|
|
@ -563,7 +563,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
|
|||
return;
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Union(..) |
|
||||
hir::ItemKind::Enum(..) => {}
|
||||
|
|
@ -611,10 +611,10 @@ declare_lint_pass!(
|
|||
|
||||
impl EarlyLintPass for AnonymousParameters {
|
||||
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::TraitItem) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
ast::TraitItemKind::Method(ref sig, _) => {
|
||||
for arg in sig.decl.inputs.iter() {
|
||||
match arg.pat.node {
|
||||
match arg.pat.kind {
|
||||
ast::PatKind::Ident(_, ident, None) => {
|
||||
if ident.name == kw::Invalid {
|
||||
let ty_snip = cx
|
||||
|
|
@ -766,13 +766,13 @@ impl UnusedDocComment {
|
|||
|
||||
impl EarlyLintPass for UnusedDocComment {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
|
||||
if let ast::ItemKind::Mac(..) = item.node {
|
||||
if let ast::ItemKind::Mac(..) = item.kind {
|
||||
self.warn_if_doc(cx, item.span, "macro expansions", true, &item.attrs);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) {
|
||||
let (kind, is_macro_expansion) = match stmt.node {
|
||||
let (kind, is_macro_expansion) = match stmt.kind {
|
||||
ast::StmtKind::Local(..) => ("statements", false),
|
||||
ast::StmtKind::Item(..) => ("inner items", false),
|
||||
ast::StmtKind::Mac(..) => ("macro expansions", true),
|
||||
|
|
@ -781,7 +781,7 @@ impl EarlyLintPass for UnusedDocComment {
|
|||
ast::StmtKind::Expr(..) => return,
|
||||
};
|
||||
|
||||
self.warn_if_doc(cx, stmt.span, kind, is_macro_expansion, stmt.node.attrs());
|
||||
self.warn_if_doc(cx, stmt.span, kind, is_macro_expansion, stmt.kind.attrs());
|
||||
}
|
||||
|
||||
fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &ast::Arm) {
|
||||
|
|
@ -809,7 +809,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
|
|||
return;
|
||||
}
|
||||
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::ExternCrate(..) => (),
|
||||
_ => return,
|
||||
};
|
||||
|
|
@ -849,7 +849,7 @@ declare_lint_pass!(InvalidNoMangleItems => [NO_MANGLE_CONST_ITEMS, NO_MANGLE_GEN
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Fn(.., ref generics, _) => {
|
||||
if let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, sym::no_mangle) {
|
||||
for param in &generics.params {
|
||||
|
|
@ -932,7 +932,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
|
|||
(cx: &LateContext<'a, 'tcx>,
|
||||
expr: &hir::Expr)
|
||||
-> Option<(Ty<'tcx>, Ty<'tcx>)> {
|
||||
let def = if let hir::ExprKind::Path(ref qpath) = expr.node {
|
||||
let def = if let hir::ExprKind::Path(ref qpath) = expr.kind {
|
||||
cx.tables.qpath_res(qpath, expr.hir_id)
|
||||
} else {
|
||||
return None;
|
||||
|
|
@ -992,7 +992,7 @@ declare_lint_pass!(
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
|
||||
fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
if let hir::ItemKind::Union(ref vdata, _) = item.node {
|
||||
if let hir::ItemKind::Union(ref vdata, _) = item.kind {
|
||||
for field in vdata.fields() {
|
||||
let field_ty = ctx.tcx.type_of(
|
||||
ctx.tcx.hir().local_def_id(field.hir_id));
|
||||
|
|
@ -1090,7 +1090,7 @@ impl TypeAliasBounds {
|
|||
match *qpath {
|
||||
hir::QPath::TypeRelative(ref ty, _) => {
|
||||
// If this is a type variable, we found a `T::Assoc`.
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => {
|
||||
match path.res {
|
||||
Res::Def(DefKind::TyParam, _) => true,
|
||||
|
|
@ -1137,7 +1137,7 @@ impl TypeAliasBounds {
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
|
||||
let (ty, type_alias_generics) = match item.node {
|
||||
let (ty, type_alias_generics) = match item.kind {
|
||||
hir::ItemKind::TyAlias(ref ty, ref generics) => (&*ty, generics),
|
||||
_ => return,
|
||||
};
|
||||
|
|
@ -1204,7 +1204,7 @@ fn check_const(cx: &LateContext<'_, '_>, body_id: hir::BodyId) {
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Const(_, body_id) => {
|
||||
check_const(cx, body_id);
|
||||
},
|
||||
|
|
@ -1321,7 +1321,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
|||
/// If `pat` is a `...` pattern, return the start and end of the range, as well as the span
|
||||
/// corresponding to the ellipsis.
|
||||
fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(&P<Expr>, &P<Expr>, Span)> {
|
||||
match &pat.node {
|
||||
match &pat.kind {
|
||||
PatKind::Range(a, b, Spanned { span, node: RangeEnd::Included(DotDotDot), .. }) => {
|
||||
Some((a, b, *span))
|
||||
}
|
||||
|
|
@ -1329,7 +1329,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
|||
}
|
||||
}
|
||||
|
||||
let (parenthesise, endpoints) = match &pat.node {
|
||||
let (parenthesise, endpoints) = match &pat.kind {
|
||||
PatKind::Ref(subpat, _) => (true, matches_ellipsis_pat(&subpat)),
|
||||
_ => (false, matches_ellipsis_pat(pat)),
|
||||
};
|
||||
|
|
@ -1395,7 +1395,7 @@ impl UnnameableTestItems {
|
|||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestItems {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if self.items_nameable {
|
||||
if let hir::ItemKind::Mod(..) = it.node {}
|
||||
if let hir::ItemKind::Mod(..) = it.kind {}
|
||||
else {
|
||||
self.items_nameable = false;
|
||||
self.boundary = it.hir_id;
|
||||
|
|
@ -1684,7 +1684,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
|
|||
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
||||
if let hir::ItemKind::Struct(_, ref hir_generics)
|
||||
| hir::ItemKind::Enum(_, ref hir_generics)
|
||||
| hir::ItemKind::Union(_, ref hir_generics) = item.node
|
||||
| hir::ItemKind::Union(_, ref hir_generics) = item.kind
|
||||
{
|
||||
let inferred_outlives = cx.tcx.inferred_outlives_of(def_id);
|
||||
if inferred_outlives.is_empty() {
|
||||
|
|
@ -1750,7 +1750,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
|
|||
hir::WherePredicate::BoundPredicate(predicate) => {
|
||||
// FIXME we can also infer bounds on associated types,
|
||||
// and should check for them here.
|
||||
match predicate.bounded_ty.node {
|
||||
match predicate.bounded_ty.kind {
|
||||
hir::TyKind::Path(hir::QPath::Resolved(
|
||||
None,
|
||||
ref path,
|
||||
|
|
@ -1812,7 +1812,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
|
|||
// generics, except for tuple struct, which have the `where`
|
||||
// after the fields of the struct.
|
||||
let full_where_span = if let hir::ItemKind::Struct(hir::VariantData::Tuple(..), _)
|
||||
= item.node
|
||||
= item.kind
|
||||
{
|
||||
where_span
|
||||
} else {
|
||||
|
|
@ -1900,7 +1900,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
|
|||
fn is_zero(expr: &hir::Expr) -> bool {
|
||||
use hir::ExprKind::*;
|
||||
use syntax::ast::LitKind::*;
|
||||
match &expr.node {
|
||||
match &expr.kind {
|
||||
Lit(lit) =>
|
||||
if let Int(i, _) = lit.node {
|
||||
i == 0
|
||||
|
|
@ -1923,8 +1923,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
|
|||
const TRANSMUTE_PATH: &[Symbol] =
|
||||
&[sym::core, sym::intrinsics, kw::Invalid, sym::transmute];
|
||||
|
||||
if let hir::ExprKind::Call(ref path_expr, ref args) = expr.node {
|
||||
if let hir::ExprKind::Path(ref qpath) = path_expr.node {
|
||||
if let hir::ExprKind::Call(ref path_expr, ref args) = expr.kind {
|
||||
if let hir::ExprKind::Path(ref qpath) = path_expr.kind {
|
||||
let def_id = cx.tables.qpath_res(qpath, path_expr.hir_id).opt_def_id()?;
|
||||
|
||||
if cx.match_def_path(def_id, ZEROED_PATH) {
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ impl EarlyLintPass for NonCamelCaseTypes {
|
|||
return;
|
||||
}
|
||||
|
||||
match it.node {
|
||||
match it.kind {
|
||||
ast::ItemKind::TyAlias(..) |
|
||||
ast::ItemKind::Enum(..) |
|
||||
ast::ItemKind::Struct(..) |
|
||||
|
|
@ -258,7 +258,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
|||
.and_then(|attr| attr.meta())
|
||||
.and_then(|meta| {
|
||||
meta.name_value_literal().and_then(|lit| {
|
||||
if let ast::LitKind::Str(name, ..) = lit.node {
|
||||
if let ast::LitKind::Str(name, ..) = lit.kind {
|
||||
// Discard the double quotes surrounding the literal.
|
||||
let sp = cx.sess().source_map().span_to_snippet(lit.span)
|
||||
.ok()
|
||||
|
|
@ -326,13 +326,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
|||
}
|
||||
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if let hir::ItemKind::Mod(_) = it.node {
|
||||
if let hir::ItemKind::Mod(_) = it.kind {
|
||||
self.check_snake_case(cx, "module", &it.ident);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem) {
|
||||
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.node {
|
||||
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.kind {
|
||||
self.check_snake_case(cx, "trait method", &item.ident);
|
||||
for param_name in pnames {
|
||||
self.check_snake_case(cx, "variable", param_name);
|
||||
|
|
@ -341,7 +341,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
|||
}
|
||||
|
||||
fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) {
|
||||
if let &PatKind::Binding(_, _, ident, _) = &p.node {
|
||||
if let &PatKind::Binding(_, _, ident, _) = &p.kind {
|
||||
self.check_snake_case(cx, "variable", &ident);
|
||||
}
|
||||
}
|
||||
|
|
@ -387,7 +387,7 @@ impl NonUpperCaseGlobals {
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ItemKind::Static(..) if !attr::contains_name(&it.attrs, sym::no_mangle) => {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "static variable", &it.ident);
|
||||
}
|
||||
|
|
@ -399,20 +399,20 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
|
|||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, ti: &hir::TraitItem) {
|
||||
if let hir::TraitItemKind::Const(..) = ti.node {
|
||||
if let hir::TraitItemKind::Const(..) = ti.kind {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ti.ident);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, ii: &hir::ImplItem) {
|
||||
if let hir::ImplItemKind::Const(..) = ii.node {
|
||||
if let hir::ImplItemKind::Const(..) = ii.kind {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) {
|
||||
// Lint for constants that look like binding identifiers (#7526)
|
||||
if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.node {
|
||||
if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.kind {
|
||||
if let Res::Def(DefKind::Const, _) = path.res {
|
||||
if path.segments.len() == 1 {
|
||||
NonUpperCaseGlobals::check_upper_case(
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ declare_lint_pass!(RedundantSemicolon => [REDUNDANT_SEMICOLON]);
|
|||
|
||||
impl EarlyLintPass for RedundantSemicolon {
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &Stmt) {
|
||||
if let StmtKind::Semi(expr) = &stmt.node {
|
||||
if let ExprKind::Tup(ref v) = &expr.node {
|
||||
if let StmtKind::Semi(expr) = &stmt.kind {
|
||||
if let ExprKind::Tup(ref v) = &expr.kind {
|
||||
if v.is_empty() {
|
||||
// Strings of excess semicolons are encoded as empty tuple expressions
|
||||
// during the parsing stage, so we check for empty tuple expressions
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
|
|||
) -> bool {
|
||||
// We only want to handle exclusive (`..`) ranges,
|
||||
// which are represented as `ExprKind::Struct`.
|
||||
if let ExprKind::Struct(_, eps, _) = &parent_expr.node {
|
||||
if let ExprKind::Struct(_, eps, _) = &parent_expr.kind {
|
||||
if eps.len() != 2 {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -279,7 +279,7 @@ fn lint_int_literal<'a, 'tcx>(
|
|||
|
||||
let par_id = cx.tcx.hir().get_parent_node(e.hir_id);
|
||||
if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) {
|
||||
if let hir::ExprKind::Struct(..) = par_e.node {
|
||||
if let hir::ExprKind::Struct(..) = par_e.kind {
|
||||
if is_range_literal(cx.sess(), par_e)
|
||||
&& lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t)
|
||||
{
|
||||
|
|
@ -318,7 +318,7 @@ fn lint_uint_literal<'a, 'tcx>(
|
|||
if lit_val < min || lit_val > max {
|
||||
let parent_id = cx.tcx.hir().get_parent_node(e.hir_id);
|
||||
if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) {
|
||||
match par_e.node {
|
||||
match par_e.kind {
|
||||
hir::ExprKind::Cast(..) => {
|
||||
if let ty::Char = cx.tables.expr_ty(par_e).kind {
|
||||
let mut err = cx.struct_span_lint(
|
||||
|
|
@ -400,7 +400,7 @@ fn lint_literal<'a, 'tcx>(
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx hir::Expr) {
|
||||
match e.node {
|
||||
match e.kind {
|
||||
hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
|
||||
// propagate negation, if the negation itself isn't negated
|
||||
if self.negated_expr_id != e.hir_id {
|
||||
|
|
@ -445,7 +445,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
|||
l: &hir::Expr,
|
||||
r: &hir::Expr)
|
||||
-> bool {
|
||||
let (lit, expr, swap) = match (&l.node, &r.node) {
|
||||
let (lit, expr, swap) = match (&l.kind, &r.kind) {
|
||||
(&hir::ExprKind::Lit(_), _) => (l, r, true),
|
||||
(_, &hir::ExprKind::Lit(_)) => (r, l, false),
|
||||
_ => return true,
|
||||
|
|
@ -456,7 +456,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
|||
match cx.tables.node_type(expr.hir_id).kind {
|
||||
ty::Int(int_ty) => {
|
||||
let (min, max) = int_ty_range(int_ty);
|
||||
let lit_val: i128 = match lit.node {
|
||||
let lit_val: i128 = match lit.kind {
|
||||
hir::ExprKind::Lit(ref li) => {
|
||||
match li.node {
|
||||
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
|
||||
|
|
@ -470,7 +470,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
|||
}
|
||||
ty::Uint(uint_ty) => {
|
||||
let (min, max) :(u128, u128) = uint_ty_range(uint_ty);
|
||||
let lit_val: u128 = match lit.node {
|
||||
let lit_val: u128 = match lit.kind {
|
||||
hir::ExprKind::Lit(ref li) => {
|
||||
match li.node {
|
||||
ast::LitKind::Int(v, _) => v,
|
||||
|
|
@ -978,7 +978,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
|
|||
if let Abi::Rust | Abi::RustCall | Abi::RustIntrinsic | Abi::PlatformIntrinsic = abi {
|
||||
// Don't worry about types in internal ABIs.
|
||||
} else {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
hir::ForeignItemKind::Fn(ref decl, _, _) => {
|
||||
vis.check_foreign_fn(it.hir_id, decl);
|
||||
}
|
||||
|
|
@ -995,7 +995,7 @@ declare_lint_pass!(VariantSizeDifferences => [VARIANT_SIZE_DIFFERENCES]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
|
||||
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
|
||||
if let hir::ItemKind::Enum(ref enum_definition, _) = it.node {
|
||||
if let hir::ItemKind::Enum(ref enum_definition, _) = it.kind {
|
||||
let item_def_id = cx.tcx.hir().local_def_id(it.hir_id);
|
||||
let t = cx.tcx.type_of(item_def_id);
|
||||
let ty = cx.tcx.erase_regions(&t);
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ declare_lint_pass!(UnusedResults => [UNUSED_MUST_USE, UNUSED_RESULTS]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
|
||||
let expr = match s.node {
|
||||
let expr = match s.kind {
|
||||
hir::StmtKind::Semi(ref expr) => &**expr,
|
||||
_ => return,
|
||||
};
|
||||
|
||||
if let hir::ExprKind::Ret(..) = expr.node {
|
||||
if let hir::ExprKind::Ret(..) = expr.kind {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -52,9 +52,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
|||
|
||||
let mut fn_warned = false;
|
||||
let mut op_warned = false;
|
||||
let maybe_def_id = match expr.node {
|
||||
let maybe_def_id = match expr.kind {
|
||||
hir::ExprKind::Call(ref callee, _) => {
|
||||
match callee.node {
|
||||
match callee.kind {
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
match cx.tables.qpath_res(qpath, callee.hir_id) {
|
||||
Res::Def(DefKind::Fn, def_id)
|
||||
|
|
@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
|||
return;
|
||||
}
|
||||
|
||||
let must_use_op = match expr.node {
|
||||
let must_use_op = match expr.kind {
|
||||
// Hardcoding operators here seemed more expedient than the
|
||||
// refactoring that would be needed to look up the `#[must_use]`
|
||||
// attribute which does exist on the comparison trait methods
|
||||
|
|
@ -193,7 +193,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
|||
}
|
||||
ty::Tuple(ref tys) => {
|
||||
let mut has_emitted = false;
|
||||
let spans = if let hir::ExprKind::Tup(comps) = &expr.node {
|
||||
let spans = if let hir::ExprKind::Tup(comps) = &expr.kind {
|
||||
debug_assert_eq!(comps.len(), tys.len());
|
||||
comps.iter().map(|e| e.span).collect()
|
||||
} else {
|
||||
|
|
@ -269,8 +269,8 @@ declare_lint_pass!(PathStatements => [PATH_STATEMENTS]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
|
||||
if let hir::StmtKind::Semi(ref expr) = s.node {
|
||||
if let hir::ExprKind::Path(_) = expr.node {
|
||||
if let hir::StmtKind::Semi(ref expr) = s.kind {
|
||||
if let hir::ExprKind::Path(_) = expr.kind {
|
||||
cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect");
|
||||
}
|
||||
}
|
||||
|
|
@ -363,7 +363,7 @@ declare_lint_pass!(UnusedParens => [UNUSED_PARENS]);
|
|||
impl UnusedParens {
|
||||
|
||||
fn is_expr_parens_necessary(inner: &ast::Expr, followed_by_block: bool) -> bool {
|
||||
followed_by_block && match inner.node {
|
||||
followed_by_block && match inner.kind {
|
||||
ast::ExprKind::Ret(_) | ast::ExprKind::Break(..) => true,
|
||||
_ => parser::contains_exterior_struct_lit(&inner),
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ impl UnusedParens {
|
|||
followed_by_block: bool,
|
||||
left_pos: Option<BytePos>,
|
||||
right_pos: Option<BytePos>) {
|
||||
match value.node {
|
||||
match value.kind {
|
||||
ast::ExprKind::Paren(ref inner) => {
|
||||
if !Self::is_expr_parens_necessary(inner, followed_by_block) &&
|
||||
value.attrs.is_empty() {
|
||||
|
|
@ -416,8 +416,8 @@ impl UnusedParens {
|
|||
) {
|
||||
use ast::{PatKind, BindingMode::ByValue, Mutability::Mutable};
|
||||
|
||||
if let PatKind::Paren(inner) = &value.node {
|
||||
match inner.node {
|
||||
if let PatKind::Paren(inner) = &value.kind {
|
||||
match inner.kind {
|
||||
// The lint visitor will visit each subpattern of `p`. We do not want to lint
|
||||
// any range pattern no matter where it occurs in the pattern. For something like
|
||||
// `&(a..=b)`, there is a recursive `check_pat` on `a` and `b`, but we will assume
|
||||
|
|
@ -501,7 +501,7 @@ impl UnusedParens {
|
|||
impl EarlyLintPass for UnusedParens {
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
|
||||
use syntax::ast::ExprKind::*;
|
||||
let (value, msg, followed_by_block, left_pos, right_pos) = match e.node {
|
||||
let (value, msg, followed_by_block, left_pos, right_pos) = match e.kind {
|
||||
Let(ref pat, ..) => {
|
||||
self.check_unused_parens_pat(cx, pat, false, false);
|
||||
return;
|
||||
|
|
@ -566,7 +566,7 @@ impl EarlyLintPass for UnusedParens {
|
|||
|
||||
fn check_pat(&mut self, cx: &EarlyContext<'_>, p: &ast::Pat) {
|
||||
use ast::{PatKind::*, Mutability};
|
||||
match &p.node {
|
||||
match &p.kind {
|
||||
// Do not lint on `(..)` as that will result in the other arms being useless.
|
||||
Paren(_)
|
||||
// The other cases do not contain sub-patterns.
|
||||
|
|
@ -587,7 +587,7 @@ impl EarlyLintPass for UnusedParens {
|
|||
}
|
||||
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
|
||||
if let ast::StmtKind::Local(ref local) = s.node {
|
||||
if let ast::StmtKind::Local(ref local) = s.kind {
|
||||
self.check_unused_parens_pat(cx, &local.pat, false, false);
|
||||
|
||||
if let Some(ref value) = local.init {
|
||||
|
|
@ -647,7 +647,7 @@ impl UnusedImportBraces {
|
|||
|
||||
impl EarlyLintPass for UnusedImportBraces {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
|
||||
if let ast::ItemKind::Use(ref use_tree) = item.node {
|
||||
if let ast::ItemKind::Use(ref use_tree) = item.kind {
|
||||
self.check_use_tree(cx, use_tree, item);
|
||||
}
|
||||
}
|
||||
|
|
@ -663,7 +663,7 @@ declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]);
|
|||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
|
||||
fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
|
||||
match e.node {
|
||||
match e.kind {
|
||||
hir::ExprKind::Box(_) => {}
|
||||
_ => return,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -999,7 +999,7 @@ impl<'a> CrateLoader<'a> {
|
|||
pub fn process_extern_crate(
|
||||
&mut self, item: &ast::Item, definitions: &Definitions,
|
||||
) -> CrateNum {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ItemKind::ExternCrate(orig_name) => {
|
||||
debug!("resolving extern crate stmt. ident: {} orig_name: {:?}",
|
||||
item.ident, orig_name);
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ impl cstore::CStore {
|
|||
id: ast::DUMMY_NODE_ID,
|
||||
span: local_span,
|
||||
attrs: attrs.iter().cloned().collect(),
|
||||
node: ast::ItemKind::MacroDef(ast::MacroDef {
|
||||
kind: ast::ItemKind::MacroDef(ast::MacroDef {
|
||||
tokens: body.into(),
|
||||
legacy: def.legacy,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -862,7 +862,7 @@ impl EncodeContext<'tcx> {
|
|||
let kind = match trait_item.kind {
|
||||
ty::AssocKind::Const => {
|
||||
let const_qualif =
|
||||
if let hir::TraitItemKind::Const(_, Some(body)) = ast_item.node {
|
||||
if let hir::TraitItemKind::Const(_, Some(body)) = ast_item.kind {
|
||||
self.const_qualif(0, body)
|
||||
} else {
|
||||
ConstQualif { mir: 0, ast_promotable: false }
|
||||
|
|
@ -875,7 +875,7 @@ impl EncodeContext<'tcx> {
|
|||
EntryKind::AssocConst(container, const_qualif, rendered_const)
|
||||
}
|
||||
ty::AssocKind::Method => {
|
||||
let fn_data = if let hir::TraitItemKind::Method(method_sig, m) = &ast_item.node {
|
||||
let fn_data = if let hir::TraitItemKind::Method(method_sig, m) = &ast_item.kind {
|
||||
let param_names = match *m {
|
||||
hir::TraitMethod::Required(ref names) => {
|
||||
self.encode_fn_param_names(names)
|
||||
|
|
@ -970,7 +970,7 @@ impl EncodeContext<'tcx> {
|
|||
|
||||
let kind = match impl_item.kind {
|
||||
ty::AssocKind::Const => {
|
||||
if let hir::ImplItemKind::Const(_, body_id) = ast_item.node {
|
||||
if let hir::ImplItemKind::Const(_, body_id) = ast_item.kind {
|
||||
let mir = self.tcx.at(ast_item.span).mir_const_qualif(def_id).0;
|
||||
|
||||
EntryKind::AssocConst(container,
|
||||
|
|
@ -981,7 +981,7 @@ impl EncodeContext<'tcx> {
|
|||
}
|
||||
}
|
||||
ty::AssocKind::Method => {
|
||||
let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node {
|
||||
let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.kind {
|
||||
FnData {
|
||||
asyncness: sig.header.asyncness,
|
||||
constness: sig.header.constness,
|
||||
|
|
@ -1001,21 +1001,20 @@ impl EncodeContext<'tcx> {
|
|||
ty::AssocKind::Type => EntryKind::AssocType(container)
|
||||
};
|
||||
|
||||
let mir =
|
||||
match ast_item.node {
|
||||
hir::ImplItemKind::Const(..) => true,
|
||||
hir::ImplItemKind::Method(ref sig, _) => {
|
||||
let generics = self.tcx.generics_of(def_id);
|
||||
let needs_inline = (generics.requires_monomorphization(self.tcx) ||
|
||||
tcx.codegen_fn_attrs(def_id).requests_inline()) &&
|
||||
!self.metadata_output_only();
|
||||
let is_const_fn = sig.header.constness == hir::Constness::Const;
|
||||
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
|
||||
needs_inline || is_const_fn || always_encode_mir
|
||||
},
|
||||
hir::ImplItemKind::OpaqueTy(..) |
|
||||
hir::ImplItemKind::TyAlias(..) => false,
|
||||
};
|
||||
let mir = match ast_item.kind {
|
||||
hir::ImplItemKind::Const(..) => true,
|
||||
hir::ImplItemKind::Method(ref sig, _) => {
|
||||
let generics = self.tcx.generics_of(def_id);
|
||||
let needs_inline = (generics.requires_monomorphization(self.tcx) ||
|
||||
tcx.codegen_fn_attrs(def_id).requests_inline()) &&
|
||||
!self.metadata_output_only();
|
||||
let is_const_fn = sig.header.constness == hir::Constness::Const;
|
||||
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
|
||||
needs_inline || is_const_fn || always_encode_mir
|
||||
},
|
||||
hir::ImplItemKind::OpaqueTy(..) |
|
||||
hir::ImplItemKind::TyAlias(..) => false,
|
||||
};
|
||||
|
||||
Entry {
|
||||
kind,
|
||||
|
|
@ -1047,7 +1046,7 @@ impl EncodeContext<'tcx> {
|
|||
self.tcx.dep_graph.with_ignore(|| {
|
||||
let body = self.tcx.hir().body(body_id);
|
||||
self.lazy(body.params.iter().map(|arg| {
|
||||
match arg.pat.node {
|
||||
match arg.pat.kind {
|
||||
PatKind::Binding(_, _, ident, _) => ident.name,
|
||||
_ => kw::Invalid,
|
||||
}
|
||||
|
|
@ -1118,7 +1117,7 @@ impl EncodeContext<'tcx> {
|
|||
|
||||
debug!("EncodeContext::encode_info_for_item({:?})", def_id);
|
||||
|
||||
let kind = match item.node {
|
||||
let kind = match item.kind {
|
||||
hir::ItemKind::Static(_, hir::MutMutable, _) => EntryKind::MutStatic,
|
||||
hir::ItemKind::Static(_, hir::MutImmutable, _) => EntryKind::ImmStatic,
|
||||
hir::ItemKind::Const(_, body_id) => {
|
||||
|
|
@ -1234,7 +1233,7 @@ impl EncodeContext<'tcx> {
|
|||
hir::ItemKind::Use(..) => bug!("cannot encode info for item {:?}", item),
|
||||
};
|
||||
|
||||
let mir = match item.node {
|
||||
let mir = match item.kind {
|
||||
hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => true,
|
||||
hir::ItemKind::Fn(_, header, ..) => {
|
||||
let generics = tcx.generics_of(def_id);
|
||||
|
|
@ -1253,7 +1252,7 @@ impl EncodeContext<'tcx> {
|
|||
visibility: self.lazy(ty::Visibility::from_hir(&item.vis, item.hir_id, tcx)),
|
||||
span: self.lazy(item.span),
|
||||
attributes: self.encode_attributes(&item.attrs),
|
||||
children: match item.node {
|
||||
children: match item.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => {
|
||||
self.lazy(fm.items
|
||||
.iter()
|
||||
|
|
@ -1287,7 +1286,7 @@ impl EncodeContext<'tcx> {
|
|||
stability: self.encode_stability(def_id),
|
||||
deprecation: self.encode_deprecation(def_id),
|
||||
|
||||
ty: match item.node {
|
||||
ty: match item.kind {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
|
|
@ -1300,14 +1299,14 @@ impl EncodeContext<'tcx> {
|
|||
_ => None,
|
||||
},
|
||||
inherent_impls: self.encode_inherent_implementations(def_id),
|
||||
variances: match item.node {
|
||||
variances: match item.kind {
|
||||
hir::ItemKind::Enum(..) |
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Union(..) |
|
||||
hir::ItemKind::Fn(..) => self.encode_variances_of(def_id),
|
||||
_ => Lazy::empty(),
|
||||
},
|
||||
generics: match item.node {
|
||||
generics: match item.kind {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
|
|
@ -1321,7 +1320,7 @@ impl EncodeContext<'tcx> {
|
|||
hir::ItemKind::TraitAlias(..) => Some(self.encode_generics(def_id)),
|
||||
_ => None,
|
||||
},
|
||||
predicates: match item.node {
|
||||
predicates: match item.kind {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
|
|
@ -1341,7 +1340,7 @@ impl EncodeContext<'tcx> {
|
|||
// so only encode it in that case as an efficiency
|
||||
// hack. (No reason not to expand it in the future if
|
||||
// necessary.)
|
||||
predicates_defined_on: match item.node {
|
||||
predicates_defined_on: match item.kind {
|
||||
hir::ItemKind::Trait(..) |
|
||||
hir::ItemKind::TraitAlias(..) => Some(self.encode_predicates_defined_on(def_id)),
|
||||
_ => None, // not *wrong* for other kinds of items, but not needed
|
||||
|
|
@ -1678,7 +1677,7 @@ impl EncodeContext<'tcx> {
|
|||
|
||||
debug!("EncodeContext::encode_info_for_foreign_item({:?})", def_id);
|
||||
|
||||
let kind = match nitem.node {
|
||||
let kind = match nitem.kind {
|
||||
hir::ForeignItemKind::Fn(_, ref names, _) => {
|
||||
let data = FnData {
|
||||
asyncness: hir::IsAsync::NotAsync,
|
||||
|
|
@ -1704,7 +1703,7 @@ impl EncodeContext<'tcx> {
|
|||
|
||||
ty: Some(self.encode_item_type(def_id)),
|
||||
inherent_impls: Lazy::empty(),
|
||||
variances: match nitem.node {
|
||||
variances: match nitem.kind {
|
||||
hir::ForeignItemKind::Fn(..) => self.encode_variances_of(def_id),
|
||||
_ => Lazy::empty(),
|
||||
},
|
||||
|
|
@ -1729,7 +1728,7 @@ impl Visitor<'tcx> for EncodeContext<'tcx> {
|
|||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
intravisit::walk_item(self, item);
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(_) |
|
||||
hir::ItemKind::Use(..) => {} // ignore these
|
||||
_ => self.record(def_id, EncodeContext::encode_info_for_item, (def_id, item)),
|
||||
|
|
@ -1800,7 +1799,7 @@ impl EncodeContext<'tcx> {
|
|||
}
|
||||
|
||||
fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
hir::TyKind::Array(_, ref length) => {
|
||||
let def_id = self.tcx.hir().local_def_id(length.hir_id);
|
||||
self.record(def_id, EncodeContext::encode_info_for_anon_const, def_id);
|
||||
|
|
@ -1810,7 +1809,7 @@ impl EncodeContext<'tcx> {
|
|||
}
|
||||
|
||||
fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Closure(..) => {
|
||||
let def_id = self.tcx.hir().local_def_id(expr.hir_id);
|
||||
self.record(def_id, EncodeContext::encode_info_for_closure, def_id);
|
||||
|
|
@ -1825,7 +1824,7 @@ impl EncodeContext<'tcx> {
|
|||
/// normally in the visitor walk.
|
||||
fn encode_addl_info_for_item(&mut self, item: &hir::Item) {
|
||||
let def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
|
|
@ -1894,7 +1893,7 @@ struct ImplVisitor<'tcx> {
|
|||
|
||||
impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemKind::Impl(..) = item.node {
|
||||
if let hir::ItemKind::Impl(..) = item.kind {
|
||||
let impl_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
if let Some(trait_ref) = self.tcx.impl_trait_ref(impl_id) {
|
||||
self.impls
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ struct Collector<'tcx> {
|
|||
|
||||
impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
let fm = match it.node {
|
||||
let fm = match it.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => fm,
|
||||
_ => return,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ struct Collector {
|
|||
|
||||
impl<'tcx> ItemLikeVisitor<'tcx> for Collector {
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
let fm = match it.node {
|
||||
let fm = match it.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => fm,
|
||||
_ => return,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ struct Collector<'tcx> {
|
|||
|
||||
impl ItemLikeVisitor<'tcx> for Collector<'tcx> {
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
let fm = match it.node {
|
||||
let fm = match it.kind {
|
||||
hir::ItemKind::ForeignMod(ref fm) => fm,
|
||||
_ => return,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1842,7 +1842,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
// Need to use the `rustc::ty` types to compare against the
|
||||
// `return_region`. Then use the `rustc::hir` type to get only
|
||||
// the lifetime span.
|
||||
if let hir::TyKind::Rptr(lifetime, _) = &fn_decl.inputs[index].node {
|
||||
if let hir::TyKind::Rptr(lifetime, _) = &fn_decl.inputs[index].kind {
|
||||
// With access to the lifetime, we can get
|
||||
// the span of it.
|
||||
arguments.push((*argument, lifetime.span));
|
||||
|
|
@ -1863,7 +1863,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let return_ty = *sig.output().skip_binder();
|
||||
let mut return_span = fn_decl.output.span();
|
||||
if let hir::FunctionRetTy::Return(ty) = &fn_decl.output {
|
||||
if let hir::TyKind::Rptr(lifetime, _) = ty.node {
|
||||
if let hir::TyKind::Rptr(lifetime, _) = ty.kind {
|
||||
return_span = lifetime.span;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -890,7 +890,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
def_id, target_place, places
|
||||
);
|
||||
let hir_id = self.infcx.tcx.hir().as_local_hir_id(def_id)?;
|
||||
let expr = &self.infcx.tcx.hir().expect_expr(hir_id).node;
|
||||
let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind;
|
||||
debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr);
|
||||
if let hir::ExprKind::Closure(
|
||||
.., args_span, _
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||
|
||||
let movable_generator = match tcx.hir().get(id) {
|
||||
Node::Expr(&hir::Expr {
|
||||
node: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
|
||||
kind: hir::ExprKind::Closure(.., Some(hir::GeneratorMovability::Static)),
|
||||
..
|
||||
}) => false,
|
||||
_ => true,
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
_,
|
||||
upvar_ident,
|
||||
_,
|
||||
) = pat.node
|
||||
) = pat.kind
|
||||
{
|
||||
err.span_suggestion(
|
||||
upvar_ident.span,
|
||||
|
|
@ -642,7 +642,7 @@ fn annotate_struct_field(
|
|||
if let hir::TyKind::Rptr(lifetime, hir::MutTy {
|
||||
mutbl: hir::Mutability::MutImmutable,
|
||||
ref ty
|
||||
}) = field.ty.node {
|
||||
}) = field.ty.kind {
|
||||
// Get the snippets in two parts - the named lifetime (if there is one) and
|
||||
// type being referenced, that way we can reconstruct the snippet without loss
|
||||
// of detail.
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
|
||||
if let DefiningTy::Closure(def_id, substs) = def_ty {
|
||||
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) =
|
||||
tcx.hir().expect_expr(mir_hir_id).node
|
||||
tcx.hir().expect_expr(mir_hir_id).kind
|
||||
{
|
||||
span
|
||||
} else {
|
||||
|
|
@ -425,7 +425,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
let mir_hir_id = infcx.tcx.hir().as_local_hir_id(mir_def_id)?;
|
||||
let fn_decl = infcx.tcx.hir().fn_decl_by_hir_id(mir_hir_id)?;
|
||||
let argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index];
|
||||
match argument_hir_ty.node {
|
||||
match argument_hir_ty.kind {
|
||||
// This indicates a variable with no type annotation, like
|
||||
// `|x|`... in that case, we can't highlight the type but
|
||||
// must highlight the variable.
|
||||
|
|
@ -527,7 +527,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
&mut vec![(argument_ty, argument_hir_ty)];
|
||||
|
||||
while let Some((ty, hir_ty)) = search_stack.pop() {
|
||||
match (&ty.kind, &hir_ty.node) {
|
||||
match (&ty.kind, &hir_ty.kind) {
|
||||
// Check if the `argument_ty` is `&'X ..` where `'X`
|
||||
// is the region we are looking for -- if so, and we have a `&T`
|
||||
// on the RHS, then we want to highlight the `&` like so:
|
||||
|
|
@ -758,7 +758,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
|
||||
let (return_span, mir_description) = match tcx.hir().get(mir_hir_id) {
|
||||
hir::Node::Expr(hir::Expr {
|
||||
node: hir::ExprKind::Closure(_, return_ty, _, span, gen_move),
|
||||
kind: hir::ExprKind::Closure(_, return_ty, _, span, gen_move),
|
||||
..
|
||||
}) => (
|
||||
match return_ty.output {
|
||||
|
|
@ -772,7 +772,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
},
|
||||
),
|
||||
hir::Node::ImplItem(hir::ImplItem {
|
||||
node: hir::ImplItemKind::Method(method_sig, _),
|
||||
kind: hir::ImplItemKind::Method(method_sig, _),
|
||||
..
|
||||
}) => (method_sig.decl.output.span(), ""),
|
||||
_ => (body.span, ""),
|
||||
|
|
@ -821,7 +821,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
|
||||
let yield_span = match tcx.hir().get(mir_hir_id) {
|
||||
hir::Node::Expr(hir::Expr {
|
||||
node: hir::ExprKind::Closure(_, _, _, span, _),
|
||||
kind: hir::ExprKind::Closure(_, _, _, span, _),
|
||||
..
|
||||
}) => (
|
||||
tcx.sess.source_map().end_point(*span)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
initializer,
|
||||
lint_level
|
||||
} => {
|
||||
let ignores_expr_result = if let PatternKind::Wild = *pattern.kind {
|
||||
let ignores_expr_result = if let PatKind::Wild = *pattern.kind {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
if let ExprKind::Block { body } = expr.kind {
|
||||
if let Some(tail_expr) = &body.expr {
|
||||
let mut expr = tail_expr;
|
||||
while let rustc::hir::ExprKind::Block(subblock, _label) = &expr.node {
|
||||
while let rustc::hir::ExprKind::Block(subblock, _label) = &expr.kind {
|
||||
if let Some(subtail_expr) = &subblock.expr {
|
||||
expr = subtail_expr
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -298,12 +298,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
pub(super) fn expr_into_pattern(
|
||||
&mut self,
|
||||
mut block: BasicBlock,
|
||||
irrefutable_pat: Pattern<'tcx>,
|
||||
irrefutable_pat: Pat<'tcx>,
|
||||
initializer: ExprRef<'tcx>,
|
||||
) -> BlockAnd<()> {
|
||||
match *irrefutable_pat.kind {
|
||||
// Optimize the case of `let x = ...` to write directly into `x`
|
||||
PatternKind::Binding {
|
||||
PatKind::Binding {
|
||||
mode: BindingMode::ByValue,
|
||||
var,
|
||||
subpattern: None,
|
||||
|
|
@ -336,9 +336,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// test works with uninitialized values in a rather
|
||||
// dubious way, so it may be that the test is kind of
|
||||
// broken.
|
||||
PatternKind::AscribeUserType {
|
||||
subpattern: Pattern {
|
||||
kind: box PatternKind::Binding {
|
||||
PatKind::AscribeUserType {
|
||||
subpattern: Pat {
|
||||
kind: box PatKind::Binding {
|
||||
mode: BindingMode::ByValue,
|
||||
var,
|
||||
subpattern: None,
|
||||
|
|
@ -414,7 +414,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
pub fn place_into_pattern(
|
||||
&mut self,
|
||||
block: BasicBlock,
|
||||
irrefutable_pat: Pattern<'tcx>,
|
||||
irrefutable_pat: Pat<'tcx>,
|
||||
initializer: &Place<'tcx>,
|
||||
set_match_place: bool,
|
||||
) -> BlockAnd<()> {
|
||||
|
|
@ -486,7 +486,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
&mut self,
|
||||
mut visibility_scope: Option<SourceScope>,
|
||||
scope_span: Span,
|
||||
pattern: &Pattern<'tcx>,
|
||||
pattern: &Pat<'tcx>,
|
||||
has_guard: ArmHasGuard,
|
||||
opt_match_place: Option<(Option<&Place<'tcx>>, Span)>,
|
||||
) -> Option<SourceScope> {
|
||||
|
|
@ -556,7 +556,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
|
||||
pub(super) fn visit_bindings(
|
||||
&mut self,
|
||||
pattern: &Pattern<'tcx>,
|
||||
pattern: &Pat<'tcx>,
|
||||
pattern_user_ty: UserTypeProjections,
|
||||
f: &mut impl FnMut(
|
||||
&mut Self,
|
||||
|
|
@ -571,7 +571,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
) {
|
||||
debug!("visit_bindings: pattern={:?} pattern_user_ty={:?}", pattern, pattern_user_ty);
|
||||
match *pattern.kind {
|
||||
PatternKind::Binding {
|
||||
PatKind::Binding {
|
||||
mutability,
|
||||
name,
|
||||
mode,
|
||||
|
|
@ -586,12 +586,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Array {
|
||||
PatKind::Array {
|
||||
ref prefix,
|
||||
ref slice,
|
||||
ref suffix,
|
||||
}
|
||||
| PatternKind::Slice {
|
||||
| PatKind::Slice {
|
||||
ref prefix,
|
||||
ref slice,
|
||||
ref suffix,
|
||||
|
|
@ -609,13 +609,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Constant { .. } | PatternKind::Range { .. } | PatternKind::Wild => {}
|
||||
PatKind::Constant { .. } | PatKind::Range { .. } | PatKind::Wild => {}
|
||||
|
||||
PatternKind::Deref { ref subpattern } => {
|
||||
PatKind::Deref { ref subpattern } => {
|
||||
self.visit_bindings(subpattern, pattern_user_ty.deref(), f);
|
||||
}
|
||||
|
||||
PatternKind::AscribeUserType {
|
||||
PatKind::AscribeUserType {
|
||||
ref subpattern,
|
||||
ascription: hair::pattern::Ascription {
|
||||
ref user_ty,
|
||||
|
|
@ -644,7 +644,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
self.visit_bindings(subpattern, subpattern_user_ty, f)
|
||||
}
|
||||
|
||||
PatternKind::Leaf { ref subpatterns } => {
|
||||
PatKind::Leaf { ref subpatterns } => {
|
||||
for subpattern in subpatterns {
|
||||
let subpattern_user_ty = pattern_user_ty.clone().leaf(subpattern.field);
|
||||
debug!("visit_bindings: subpattern_user_ty={:?}", subpattern_user_ty);
|
||||
|
|
@ -652,14 +652,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Variant { adt_def, substs: _, variant_index, ref subpatterns } => {
|
||||
PatKind::Variant { adt_def, substs: _, variant_index, ref subpatterns } => {
|
||||
for subpattern in subpatterns {
|
||||
let subpattern_user_ty = pattern_user_ty.clone().variant(
|
||||
adt_def, variant_index, subpattern.field);
|
||||
self.visit_bindings(&subpattern.pattern, subpattern_user_ty, f);
|
||||
}
|
||||
}
|
||||
PatternKind::Or { ref pats } => {
|
||||
PatKind::Or { ref pats } => {
|
||||
for pat in pats {
|
||||
self.visit_bindings(&pat, pattern_user_ty.clone(), f);
|
||||
}
|
||||
|
|
@ -708,7 +708,7 @@ struct Binding<'tcx> {
|
|||
struct Ascription<'tcx> {
|
||||
span: Span,
|
||||
source: Place<'tcx>,
|
||||
user_ty: PatternTypeProjection<'tcx>,
|
||||
user_ty: PatTyProj<'tcx>,
|
||||
variance: ty::Variance,
|
||||
}
|
||||
|
||||
|
|
@ -718,7 +718,7 @@ pub struct MatchPair<'pat, 'tcx> {
|
|||
place: Place<'tcx>,
|
||||
|
||||
// ... must match this pattern.
|
||||
pattern: &'pat Pattern<'tcx>,
|
||||
pattern: &'pat Pat<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
|
@ -760,7 +760,7 @@ enum TestKind<'tcx> {
|
|||
},
|
||||
|
||||
/// Test whether the value falls within an inclusive or exclusive range
|
||||
Range(PatternRange<'tcx>),
|
||||
Range(PatRange<'tcx>),
|
||||
|
||||
/// Test length of the slice is equal to len
|
||||
Len {
|
||||
|
|
@ -1339,7 +1339,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Pattern binding - used for `let` and function parameters as well.
|
||||
// Pat binding - used for `let` and function parameters as well.
|
||||
|
||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
/// Initializes each of the bindings from the candidate by
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
-> Result<(), MatchPair<'pat, 'tcx>> {
|
||||
let tcx = self.hir.tcx();
|
||||
match *match_pair.pattern.kind {
|
||||
PatternKind::AscribeUserType {
|
||||
PatKind::AscribeUserType {
|
||||
ref subpattern,
|
||||
ascription: hair::pattern::Ascription {
|
||||
variance,
|
||||
|
|
@ -79,12 +79,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
PatternKind::Wild => {
|
||||
PatKind::Wild => {
|
||||
// nothing left to do
|
||||
Ok(())
|
||||
}
|
||||
|
||||
PatternKind::Binding { name, mutability, mode, var, ty, ref subpattern } => {
|
||||
PatKind::Binding { name, mutability, mode, var, ty, ref subpattern } => {
|
||||
candidate.bindings.push(Binding {
|
||||
name,
|
||||
mutability,
|
||||
|
|
@ -103,12 +103,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
PatternKind::Constant { .. } => {
|
||||
PatKind::Constant { .. } => {
|
||||
// FIXME normalize patterns when possible
|
||||
Err(match_pair)
|
||||
}
|
||||
|
||||
PatternKind::Range(PatternRange { lo, hi, end }) => {
|
||||
PatKind::Range(PatRange { lo, hi, end }) => {
|
||||
let (range, bias) = match lo.ty.kind {
|
||||
ty::Char => {
|
||||
(Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0)
|
||||
|
|
@ -144,7 +144,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
Err(match_pair)
|
||||
}
|
||||
|
||||
PatternKind::Slice { ref prefix, ref slice, ref suffix } => {
|
||||
PatKind::Slice { ref prefix, ref slice, ref suffix } => {
|
||||
if prefix.is_empty() && slice.is_some() && suffix.is_empty() {
|
||||
// irrefutable
|
||||
self.prefix_slice_suffix(&mut candidate.match_pairs,
|
||||
|
|
@ -158,7 +158,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
|
||||
PatKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
|
||||
let irrefutable = adt_def.variants.iter_enumerated().all(|(i, v)| {
|
||||
i == variant_index || {
|
||||
self.hir.tcx().features().exhaustive_patterns &&
|
||||
|
|
@ -174,7 +174,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Array { ref prefix, ref slice, ref suffix } => {
|
||||
PatKind::Array { ref prefix, ref slice, ref suffix } => {
|
||||
self.prefix_slice_suffix(&mut candidate.match_pairs,
|
||||
&match_pair.place,
|
||||
prefix,
|
||||
|
|
@ -183,20 +183,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
PatternKind::Leaf { ref subpatterns } => {
|
||||
PatKind::Leaf { ref subpatterns } => {
|
||||
// tuple struct, match subpats (if any)
|
||||
candidate.match_pairs
|
||||
.extend(self.field_match_pairs(match_pair.place, subpatterns));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
PatternKind::Deref { ref subpattern } => {
|
||||
PatKind::Deref { ref subpattern } => {
|
||||
let place = match_pair.place.deref();
|
||||
candidate.match_pairs.push(MatchPair::new(place, subpattern));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
PatternKind::Or { .. } => {
|
||||
PatKind::Or { .. } => {
|
||||
Err(match_pair)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
/// It is a bug to call this with a simplifiable pattern.
|
||||
pub fn test<'pat>(&mut self, match_pair: &MatchPair<'pat, 'tcx>) -> Test<'tcx> {
|
||||
match *match_pair.pattern.kind {
|
||||
PatternKind::Variant { ref adt_def, substs: _, variant_index: _, subpatterns: _ } => {
|
||||
PatKind::Variant { ref adt_def, substs: _, variant_index: _, subpatterns: _ } => {
|
||||
Test {
|
||||
span: match_pair.pattern.span,
|
||||
kind: TestKind::Switch {
|
||||
|
|
@ -36,7 +36,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Constant { .. } if is_switch_ty(match_pair.pattern.ty) => {
|
||||
PatKind::Constant { .. } if is_switch_ty(match_pair.pattern.ty) => {
|
||||
// For integers, we use a `SwitchInt` match, which allows
|
||||
// us to handle more cases.
|
||||
Test {
|
||||
|
|
@ -52,7 +52,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Constant { value } => {
|
||||
PatKind::Constant { value } => {
|
||||
Test {
|
||||
span: match_pair.pattern.span,
|
||||
kind: TestKind::Eq {
|
||||
|
|
@ -62,7 +62,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Range(range) => {
|
||||
PatKind::Range(range) => {
|
||||
assert_eq!(range.lo.ty, match_pair.pattern.ty);
|
||||
assert_eq!(range.hi.ty, match_pair.pattern.ty);
|
||||
Test {
|
||||
|
|
@ -71,7 +71,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Slice { ref prefix, ref slice, ref suffix } => {
|
||||
PatKind::Slice { ref prefix, ref slice, ref suffix } => {
|
||||
let len = prefix.len() + suffix.len();
|
||||
let op = if slice.is_some() {
|
||||
BinOp::Ge
|
||||
|
|
@ -84,13 +84,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::AscribeUserType { .. } |
|
||||
PatternKind::Array { .. } |
|
||||
PatternKind::Wild |
|
||||
PatternKind::Or { .. } |
|
||||
PatternKind::Binding { .. } |
|
||||
PatternKind::Leaf { .. } |
|
||||
PatternKind::Deref { .. } => {
|
||||
PatKind::AscribeUserType { .. } |
|
||||
PatKind::Array { .. } |
|
||||
PatKind::Wild |
|
||||
PatKind::Or { .. } |
|
||||
PatKind::Binding { .. } |
|
||||
PatKind::Leaf { .. } |
|
||||
PatKind::Deref { .. } => {
|
||||
self.error_simplifyable(match_pair)
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
};
|
||||
|
||||
match *match_pair.pattern.kind {
|
||||
PatternKind::Constant { value } => {
|
||||
PatKind::Constant { value } => {
|
||||
indices.entry(value)
|
||||
.or_insert_with(|| {
|
||||
options.push(value.eval_bits(
|
||||
|
|
@ -120,22 +120,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
});
|
||||
true
|
||||
}
|
||||
PatternKind::Variant { .. } => {
|
||||
PatKind::Variant { .. } => {
|
||||
panic!("you should have called add_variants_to_switch instead!");
|
||||
}
|
||||
PatternKind::Range(range) => {
|
||||
PatKind::Range(range) => {
|
||||
// Check that none of the switch values are in the range.
|
||||
self.values_not_contained_in_range(range, indices)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
PatternKind::Slice { .. } |
|
||||
PatternKind::Array { .. } |
|
||||
PatternKind::Wild |
|
||||
PatternKind::Or { .. } |
|
||||
PatternKind::Binding { .. } |
|
||||
PatternKind::AscribeUserType { .. } |
|
||||
PatternKind::Leaf { .. } |
|
||||
PatternKind::Deref { .. } => {
|
||||
PatKind::Slice { .. } |
|
||||
PatKind::Array { .. } |
|
||||
PatKind::Wild |
|
||||
PatKind::Or { .. } |
|
||||
PatKind::Binding { .. } |
|
||||
PatKind::AscribeUserType { .. } |
|
||||
PatKind::Leaf { .. } |
|
||||
PatKind::Deref { .. } => {
|
||||
// don't know how to add these patterns to a switch
|
||||
false
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
};
|
||||
|
||||
match *match_pair.pattern.kind {
|
||||
PatternKind::Variant { adt_def: _ , variant_index, .. } => {
|
||||
PatKind::Variant { adt_def: _ , variant_index, .. } => {
|
||||
// We have a pattern testing for variant `variant_index`
|
||||
// set the corresponding index to true
|
||||
variants.insert(variant_index);
|
||||
|
|
@ -283,7 +283,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
TestKind::Range(PatternRange { ref lo, ref hi, ref end }) => {
|
||||
TestKind::Range(PatRange { ref lo, ref hi, ref end }) => {
|
||||
let lower_bound_success = self.cfg.start_new_block();
|
||||
let target_blocks = make_target_blocks(self);
|
||||
|
||||
|
|
@ -533,7 +533,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// If we are performing a variant switch, then this
|
||||
// informs variant patterns, but nothing else.
|
||||
(&TestKind::Switch { adt_def: tested_adt_def, .. },
|
||||
&PatternKind::Variant { adt_def, variant_index, ref subpatterns, .. }) => {
|
||||
&PatKind::Variant { adt_def, variant_index, ref subpatterns, .. }) => {
|
||||
assert_eq!(adt_def, tested_adt_def);
|
||||
self.candidate_after_variant_switch(match_pair_index,
|
||||
adt_def,
|
||||
|
|
@ -548,10 +548,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// If we are performing a switch over integers, then this informs integer
|
||||
// equality, but nothing else.
|
||||
//
|
||||
// FIXME(#29623) we could use PatternKind::Range to rule
|
||||
// FIXME(#29623) we could use PatKind::Range to rule
|
||||
// things out here, in some cases.
|
||||
(&TestKind::SwitchInt { switch_ty: _, options: _, ref indices },
|
||||
&PatternKind::Constant { ref value })
|
||||
&PatKind::Constant { ref value })
|
||||
if is_switch_ty(match_pair.pattern.ty) => {
|
||||
let index = indices[value];
|
||||
self.candidate_without_match_pair(match_pair_index, candidate);
|
||||
|
|
@ -559,7 +559,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
(&TestKind::SwitchInt { switch_ty: _, ref options, ref indices },
|
||||
&PatternKind::Range(range)) => {
|
||||
&PatKind::Range(range)) => {
|
||||
let not_contained = self
|
||||
.values_not_contained_in_range(range, indices)
|
||||
.unwrap_or(false);
|
||||
|
|
@ -577,7 +577,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
(&TestKind::SwitchInt { .. }, _) => None,
|
||||
|
||||
(&TestKind::Len { len: test_len, op: BinOp::Eq },
|
||||
&PatternKind::Slice { ref prefix, ref slice, ref suffix }) => {
|
||||
&PatKind::Slice { ref prefix, ref slice, ref suffix }) => {
|
||||
let pat_len = (prefix.len() + suffix.len()) as u64;
|
||||
match (test_len.cmp(&pat_len), slice) {
|
||||
(Ordering::Equal, &None) => {
|
||||
|
|
@ -610,7 +610,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
(&TestKind::Len { len: test_len, op: BinOp::Ge },
|
||||
&PatternKind::Slice { ref prefix, ref slice, ref suffix }) => {
|
||||
&PatKind::Slice { ref prefix, ref slice, ref suffix }) => {
|
||||
// the test is `$actual_len >= test_len`
|
||||
let pat_len = (prefix.len() + suffix.len()) as u64;
|
||||
match (test_len.cmp(&pat_len), slice) {
|
||||
|
|
@ -644,7 +644,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
(&TestKind::Range(test),
|
||||
&PatternKind::Range(pat)) => {
|
||||
&PatKind::Range(pat)) => {
|
||||
if test == pat {
|
||||
self.candidate_without_match_pair(
|
||||
match_pair_index,
|
||||
|
|
@ -683,7 +683,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
(&TestKind::Range(range), &PatternKind::Constant { value }) => {
|
||||
(&TestKind::Range(range), &PatKind::Constant { value }) => {
|
||||
if self.const_range_contains(range, value) == Some(false) {
|
||||
// `value` is not contained in the testing range,
|
||||
// so `value` can be matched only if this test fails.
|
||||
|
|
@ -722,9 +722,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
fn candidate_after_slice_test<'pat>(&mut self,
|
||||
match_pair_index: usize,
|
||||
candidate: &mut Candidate<'pat, 'tcx>,
|
||||
prefix: &'pat [Pattern<'tcx>],
|
||||
opt_slice: Option<&'pat Pattern<'tcx>>,
|
||||
suffix: &'pat [Pattern<'tcx>]) {
|
||||
prefix: &'pat [Pat<'tcx>],
|
||||
opt_slice: Option<&'pat Pat<'tcx>>,
|
||||
suffix: &'pat [Pat<'tcx>]) {
|
||||
let removed_place = candidate.match_pairs.remove(match_pair_index).place;
|
||||
self.prefix_slice_suffix(
|
||||
&mut candidate.match_pairs,
|
||||
|
|
@ -739,7 +739,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
match_pair_index: usize,
|
||||
adt_def: &'tcx ty::AdtDef,
|
||||
variant_index: VariantIdx,
|
||||
subpatterns: &'pat [FieldPattern<'tcx>],
|
||||
subpatterns: &'pat [FieldPat<'tcx>],
|
||||
candidate: &mut Candidate<'pat, 'tcx>,
|
||||
) {
|
||||
let match_pair = candidate.match_pairs.remove(match_pair_index);
|
||||
|
|
@ -771,7 +771,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
|
||||
fn const_range_contains(
|
||||
&self,
|
||||
range: PatternRange<'tcx>,
|
||||
range: PatRange<'tcx>,
|
||||
value: &'tcx ty::Const<'tcx>,
|
||||
) -> Option<bool> {
|
||||
use std::cmp::Ordering::*;
|
||||
|
|
@ -790,7 +790,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
|
||||
fn values_not_contained_in_range(
|
||||
&self,
|
||||
range: PatternRange<'tcx>,
|
||||
range: PatRange<'tcx>,
|
||||
indices: &FxHashMap<&'tcx ty::Const<'tcx>, usize>,
|
||||
) -> Option<bool> {
|
||||
for &val in indices.keys() {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::convert::TryInto;
|
|||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
pub fn field_match_pairs<'pat>(&mut self,
|
||||
place: Place<'tcx>,
|
||||
subpatterns: &'pat [FieldPattern<'tcx>])
|
||||
subpatterns: &'pat [FieldPat<'tcx>])
|
||||
-> Vec<MatchPair<'pat, 'tcx>> {
|
||||
subpatterns.iter()
|
||||
.map(|fieldpat| {
|
||||
|
|
@ -22,9 +22,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
pub fn prefix_slice_suffix<'pat>(&mut self,
|
||||
match_pairs: &mut Vec<MatchPair<'pat, 'tcx>>,
|
||||
place: &Place<'tcx>,
|
||||
prefix: &'pat [Pattern<'tcx>],
|
||||
opt_slice: Option<&'pat Pattern<'tcx>>,
|
||||
suffix: &'pat [Pattern<'tcx>]) {
|
||||
prefix: &'pat [Pat<'tcx>],
|
||||
opt_slice: Option<&'pat Pat<'tcx>>,
|
||||
suffix: &'pat [Pat<'tcx>]) {
|
||||
let min_length = prefix.len() + suffix.len();
|
||||
let min_length = min_length.try_into().unwrap();
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
|
||||
pub fn new(place: Place<'tcx>, pattern: &'pat Pattern<'tcx>) -> MatchPair<'pat, 'tcx> {
|
||||
pub fn new(place: Place<'tcx>, pattern: &'pat Pat<'tcx>) -> MatchPair<'pat, 'tcx> {
|
||||
MatchPair {
|
||||
place,
|
||||
pattern,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::build;
|
||||
use crate::build::scope::DropKind;
|
||||
use crate::hair::cx::Cx;
|
||||
use crate::hair::{LintLevel, BindingMode, PatternKind};
|
||||
use crate::hair::{LintLevel, BindingMode, PatKind};
|
||||
use crate::transform::MirSource;
|
||||
use crate::util as mir_util;
|
||||
use rustc::hir;
|
||||
|
|
@ -27,17 +27,17 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
|||
|
||||
// Figure out what primary body this item has.
|
||||
let (body_id, return_ty_span) = match tcx.hir().get(id) {
|
||||
Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
||||
| Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
||||
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(_, decl, body_id, _, _), .. })
|
||||
| Node::Item(hir::Item { kind: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
||||
| Node::ImplItem(
|
||||
hir::ImplItem {
|
||||
node: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id),
|
||||
kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id),
|
||||
..
|
||||
}
|
||||
)
|
||||
| Node::TraitItem(
|
||||
hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(
|
||||
kind: hir::TraitItemKind::Method(
|
||||
hir::MethodSig { decl, .. },
|
||||
hir::TraitMethod::Provided(body_id),
|
||||
),
|
||||
|
|
@ -46,11 +46,11 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
|||
) => {
|
||||
(*body_id, decl.output.span())
|
||||
}
|
||||
Node::Item(hir::Item { node: hir::ItemKind::Static(ty, _, body_id), .. })
|
||||
| Node::Item(hir::Item { node: hir::ItemKind::Const(ty, body_id), .. })
|
||||
| Node::ImplItem(hir::ImplItem { node: hir::ImplItemKind::Const(ty, body_id), .. })
|
||||
Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. })
|
||||
| Node::Item(hir::Item { kind: hir::ItemKind::Const(ty, body_id), .. })
|
||||
| Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, body_id), .. })
|
||||
| Node::TraitItem(
|
||||
hir::TraitItem { node: hir::TraitItemKind::Const(ty, Some(body_id)), .. }
|
||||
hir::TraitItem { kind: hir::TraitItemKind::Const(ty, Some(body_id)), .. }
|
||||
) => {
|
||||
(*body_id, ty.span)
|
||||
}
|
||||
|
|
@ -559,7 +559,7 @@ where
|
|||
};
|
||||
let mut mutability = Mutability::Not;
|
||||
if let Some(Node::Binding(pat)) = tcx_hir.find(var_hir_id) {
|
||||
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
|
||||
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
|
||||
debuginfo.debug_name = ident.name;
|
||||
if let Some(&bm) = hir.tables.pat_binding_modes().get(pat.hir_id) {
|
||||
if bm == ty::BindByValue(hir::MutMutable) {
|
||||
|
|
@ -827,7 +827,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
self.set_correct_source_scope_for_arg(arg.hir_id, original_source_scope, span);
|
||||
match *pattern.kind {
|
||||
// Don't introduce extra copies for simple bindings
|
||||
PatternKind::Binding {
|
||||
PatKind::Binding {
|
||||
mutability,
|
||||
var,
|
||||
mode: BindingMode::ByValue,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ fn mirror_stmts<'a, 'tcx>(
|
|||
for (index, stmt) in stmts.iter().enumerate() {
|
||||
let hir_id = stmt.hir_id;
|
||||
let opt_dxn_ext = cx.region_scope_tree.opt_destruction_scope(hir_id.local_id);
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
hir::StmtKind::Expr(ref expr) |
|
||||
hir::StmtKind::Semi(ref expr) => {
|
||||
result.push(StmtRef::Mirror(Box::new(Stmt {
|
||||
|
|
@ -78,12 +78,12 @@ fn mirror_stmts<'a, 'tcx>(
|
|||
if let Some(ty) = &local.ty {
|
||||
if let Some(&user_ty) = cx.tables.user_provided_types().get(ty.hir_id) {
|
||||
debug!("mirror_stmts: user_ty={:?}", user_ty);
|
||||
pattern = Pattern {
|
||||
pattern = Pat {
|
||||
ty: pattern.ty,
|
||||
span: pattern.span,
|
||||
kind: Box::new(PatternKind::AscribeUserType {
|
||||
kind: Box::new(PatKind::AscribeUserType {
|
||||
ascription: hair::pattern::Ascription {
|
||||
user_ty: PatternTypeProjection::from_user_type(user_ty),
|
||||
user_ty: PatTyProj::from_user_type(user_ty),
|
||||
user_ty_span: ty.span,
|
||||
variance: ty::Variance::Covariant,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
let expr_ty = cx.tables().expr_ty(expr);
|
||||
let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id);
|
||||
|
||||
let kind = match expr.node {
|
||||
let kind = match expr.kind {
|
||||
// Here comes the interesting stuff:
|
||||
hir::ExprKind::MethodCall(_, method_span, ref args) => {
|
||||
// Rewrite a.b(c) into UFCS form like Trait::b(a, c)
|
||||
|
|
@ -247,7 +247,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
}
|
||||
} else {
|
||||
let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) =
|
||||
fun.node
|
||||
fun.kind
|
||||
{
|
||||
// Tuple-like ADTs are represented as ExprKind::Call. We convert them here.
|
||||
expr_ty.ty_adt_def().and_then(|adt_def| {
|
||||
|
|
@ -427,7 +427,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
if cx.tables().is_method_call(expr) {
|
||||
overloaded_operator(cx, expr, vec![arg.to_ref()])
|
||||
} else {
|
||||
if let hir::ExprKind::Lit(ref lit) = arg.node {
|
||||
if let hir::ExprKind::Lit(ref lit) = arg.kind {
|
||||
ExprKind::Literal {
|
||||
literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true),
|
||||
user_ty: None,
|
||||
|
|
@ -639,7 +639,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
|
|||
// }
|
||||
// The correct solution would be to add symbolic computations to miri,
|
||||
// so we wouldn't have to compute and store the actual value
|
||||
let var = if let hir::ExprKind::Path(ref qpath) = source.node {
|
||||
let var = if let hir::ExprKind::Path(ref qpath) = source.kind {
|
||||
let res = cx.tables().qpath_res(qpath, source.hir_id);
|
||||
cx
|
||||
.tables()
|
||||
|
|
|
|||
|
|
@ -153,16 +153,13 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
|
||||
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pat<'tcx> {
|
||||
let tcx = self.tcx.global_tcx();
|
||||
let p = match tcx.hir().get(p.hir_id) {
|
||||
Node::Pat(p) | Node::Binding(p) => p,
|
||||
node => bug!("pattern became {:?}", node)
|
||||
};
|
||||
Pattern::from_hir(tcx,
|
||||
self.param_env.and(self.identity_substs),
|
||||
self.tables(),
|
||||
p)
|
||||
Pat::from_hir(tcx, self.param_env.and(self.identity_substs), self.tables(), p)
|
||||
}
|
||||
|
||||
pub fn trait_method(&mut self,
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ pub mod cx;
|
|||
mod constant;
|
||||
|
||||
pub mod pattern;
|
||||
pub use self::pattern::{BindingMode, Pattern, PatternKind, PatternRange, FieldPattern};
|
||||
pub(crate) use self::pattern::PatternTypeProjection;
|
||||
pub use self::pattern::{BindingMode, Pat, PatKind, PatRange, FieldPat};
|
||||
pub(crate) use self::pattern::PatTyProj;
|
||||
|
||||
mod util;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ pub enum StmtKind<'tcx> {
|
|||
/// `let <PAT> = ...`
|
||||
///
|
||||
/// if a type is included, it is added as an ascription pattern
|
||||
pattern: Pattern<'tcx>,
|
||||
pattern: Pat<'tcx>,
|
||||
|
||||
/// let pat: ty = <INIT> ...
|
||||
initializer: Option<ExprRef<'tcx>>,
|
||||
|
|
@ -293,7 +293,7 @@ pub struct FruInfo<'tcx> {
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Arm<'tcx> {
|
||||
pub pattern: Pattern<'tcx>,
|
||||
pub pattern: Pat<'tcx>,
|
||||
pub guard: Option<Guard<'tcx>>,
|
||||
pub body: ExprRef<'tcx>,
|
||||
pub lint_level: LintLevel,
|
||||
|
|
@ -304,9 +304,9 @@ pub struct Arm<'tcx> {
|
|||
impl Arm<'tcx> {
|
||||
// HACK(or_patterns; Centril | dlrobertson): Remove this and
|
||||
// correctly handle each case in which this method is used.
|
||||
pub fn top_pats_hack(&self) -> &[Pattern<'tcx>] {
|
||||
pub fn top_pats_hack(&self) -> &[Pat<'tcx>] {
|
||||
match &*self.pattern.kind {
|
||||
PatternKind::Or { pats } => pats,
|
||||
PatKind::Or { pats } => pats,
|
||||
_ => std::slice::from_ref(&self.pattern),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ use self::WitnessPreference::*;
|
|||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
|
||||
use super::{FieldPattern, Pattern, PatternKind, PatternRange};
|
||||
use super::{FieldPat, Pat, PatKind, PatRange};
|
||||
use super::{PatternFoldable, PatternFolder, compare_const_vals};
|
||||
|
||||
use rustc::hir::def_id::DefId;
|
||||
|
|
@ -188,9 +188,7 @@ use std::ops::RangeInclusive;
|
|||
use std::u128;
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pattern<'tcx>)
|
||||
-> &'a Pattern<'tcx>
|
||||
{
|
||||
pub fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pat<'tcx>) -> &'a Pat<'tcx> {
|
||||
cx.pattern_arena.alloc(LiteralExpander { tcx: cx.tcx }.fold_pattern(&pat))
|
||||
}
|
||||
|
||||
|
|
@ -243,24 +241,24 @@ impl LiteralExpander<'tcx> {
|
|||
}
|
||||
|
||||
impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
|
||||
fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> {
|
||||
fn fold_pattern(&mut self, pat: &Pat<'tcx>) -> Pat<'tcx> {
|
||||
debug!("fold_pattern {:?} {:?} {:?}", pat, pat.ty.kind, pat.kind);
|
||||
match (&pat.ty.kind, &*pat.kind) {
|
||||
(
|
||||
&ty::Ref(_, rty, _),
|
||||
&PatternKind::Constant { value: Const {
|
||||
&PatKind::Constant { value: Const {
|
||||
val,
|
||||
ty: ty::TyS { kind: ty::Ref(_, crty, _), .. },
|
||||
} },
|
||||
) => {
|
||||
Pattern {
|
||||
Pat {
|
||||
ty: pat.ty,
|
||||
span: pat.span,
|
||||
kind: box PatternKind::Deref {
|
||||
subpattern: Pattern {
|
||||
kind: box PatKind::Deref {
|
||||
subpattern: Pat {
|
||||
ty: rty,
|
||||
span: pat.span,
|
||||
kind: box PatternKind::Constant { value: self.tcx.mk_const(Const {
|
||||
kind: box PatKind::Constant { value: self.tcx.mk_const(Const {
|
||||
val: self.fold_const_value_deref(*val, rty, crty),
|
||||
ty: rty,
|
||||
}) },
|
||||
|
|
@ -268,7 +266,7 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
(_, &PatternKind::Binding { subpattern: Some(ref s), .. }) => {
|
||||
(_, &PatKind::Binding { subpattern: Some(ref s), .. }) => {
|
||||
s.fold_with(self)
|
||||
}
|
||||
_ => pat.super_fold_with(self)
|
||||
|
|
@ -276,10 +274,10 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Pattern<'tcx> {
|
||||
impl<'tcx> Pat<'tcx> {
|
||||
fn is_wildcard(&self) -> bool {
|
||||
match *self.kind {
|
||||
PatternKind::Binding { subpattern: None, .. } | PatternKind::Wild =>
|
||||
PatKind::Binding { subpattern: None, .. } | PatKind::Wild =>
|
||||
true,
|
||||
_ => false
|
||||
}
|
||||
|
|
@ -288,14 +286,14 @@ impl<'tcx> Pattern<'tcx> {
|
|||
|
||||
/// A 2D matrix. Nx1 matrices are very common, which is why `SmallVec[_; 2]`
|
||||
/// works well for each row.
|
||||
pub struct Matrix<'p, 'tcx>(Vec<SmallVec<[&'p Pattern<'tcx>; 2]>>);
|
||||
pub struct Matrix<'p, 'tcx>(Vec<SmallVec<[&'p Pat<'tcx>; 2]>>);
|
||||
|
||||
impl<'p, 'tcx> Matrix<'p, 'tcx> {
|
||||
pub fn empty() -> Self {
|
||||
Matrix(vec![])
|
||||
}
|
||||
|
||||
pub fn push(&mut self, row: SmallVec<[&'p Pattern<'tcx>; 2]>) {
|
||||
pub fn push(&mut self, row: SmallVec<[&'p Pat<'tcx>; 2]>) {
|
||||
self.0.push(row)
|
||||
}
|
||||
}
|
||||
|
|
@ -344,9 +342,9 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'p, 'tcx> FromIterator<SmallVec<[&'p Pattern<'tcx>; 2]>> for Matrix<'p, 'tcx> {
|
||||
impl<'p, 'tcx> FromIterator<SmallVec<[&'p Pat<'tcx>; 2]>> for Matrix<'p, 'tcx> {
|
||||
fn from_iter<T>(iter: T) -> Self
|
||||
where T: IntoIterator<Item=SmallVec<[&'p Pattern<'tcx>; 2]>>
|
||||
where T: IntoIterator<Item=SmallVec<[&'p Pat<'tcx>; 2]>>
|
||||
{
|
||||
Matrix(iter.into_iter().collect())
|
||||
}
|
||||
|
|
@ -362,8 +360,8 @@ pub struct MatchCheckCtxt<'a, 'tcx> {
|
|||
/// statement.
|
||||
pub module: DefId,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
pub pattern_arena: &'a TypedArena<Pattern<'tcx>>,
|
||||
pub byte_array_map: FxHashMap<*const Pattern<'tcx>, Vec<&'a Pattern<'tcx>>>,
|
||||
pub pattern_arena: &'a TypedArena<Pat<'tcx>>,
|
||||
pub byte_array_map: FxHashMap<*const Pat<'tcx>, Vec<&'a Pat<'tcx>>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
|
||||
|
|
@ -395,9 +393,9 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_non_exhaustive_variant<'p>(&self, pattern: &'p Pattern<'tcx>) -> bool {
|
||||
fn is_non_exhaustive_variant<'p>(&self, pattern: &'p Pat<'tcx>) -> bool {
|
||||
match *pattern.kind {
|
||||
PatternKind::Variant { adt_def, variant_index, .. } => {
|
||||
PatKind::Variant { adt_def, variant_index, .. } => {
|
||||
let ref variant = adt_def.variants[variant_index];
|
||||
variant.is_field_list_non_exhaustive()
|
||||
}
|
||||
|
|
@ -476,7 +474,7 @@ pub enum WitnessPreference {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct PatternContext<'tcx> {
|
||||
struct PatCtxt<'tcx> {
|
||||
ty: Ty<'tcx>,
|
||||
max_slice_length: u64,
|
||||
}
|
||||
|
|
@ -514,10 +512,10 @@ struct PatternContext<'tcx> {
|
|||
///
|
||||
/// The final `Pair(Some(_), true)` is then the resulting witness.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Witness<'tcx>(Vec<Pattern<'tcx>>);
|
||||
pub struct Witness<'tcx>(Vec<Pat<'tcx>>);
|
||||
|
||||
impl<'tcx> Witness<'tcx> {
|
||||
pub fn single_pattern(self) -> Pattern<'tcx> {
|
||||
pub fn single_pattern(self) -> Pat<'tcx> {
|
||||
assert_eq!(self.0.len(), 1);
|
||||
self.0.into_iter().next().unwrap()
|
||||
}
|
||||
|
|
@ -531,10 +529,10 @@ impl<'tcx> Witness<'tcx> {
|
|||
{
|
||||
let sub_pattern_tys = constructor_sub_pattern_tys(cx, ctor, ty);
|
||||
self.0.extend(sub_pattern_tys.into_iter().map(|ty| {
|
||||
Pattern {
|
||||
Pat {
|
||||
ty,
|
||||
span: DUMMY_SP,
|
||||
kind: box PatternKind::Wild,
|
||||
kind: box PatKind::Wild,
|
||||
}
|
||||
}));
|
||||
self.apply_constructor(cx, ctor, ty)
|
||||
|
|
@ -569,7 +567,7 @@ impl<'tcx> Witness<'tcx> {
|
|||
ty::Adt(..) |
|
||||
ty::Tuple(..) => {
|
||||
let pats = pats.enumerate().map(|(i, p)| {
|
||||
FieldPattern {
|
||||
FieldPat {
|
||||
field: Field::new(i),
|
||||
pattern: p
|
||||
}
|
||||
|
|
@ -577,26 +575,26 @@ impl<'tcx> Witness<'tcx> {
|
|||
|
||||
if let ty::Adt(adt, substs) = ty.kind {
|
||||
if adt.is_enum() {
|
||||
PatternKind::Variant {
|
||||
PatKind::Variant {
|
||||
adt_def: adt,
|
||||
substs,
|
||||
variant_index: ctor.variant_index_for_adt(cx, adt),
|
||||
subpatterns: pats
|
||||
}
|
||||
} else {
|
||||
PatternKind::Leaf { subpatterns: pats }
|
||||
PatKind::Leaf { subpatterns: pats }
|
||||
}
|
||||
} else {
|
||||
PatternKind::Leaf { subpatterns: pats }
|
||||
PatKind::Leaf { subpatterns: pats }
|
||||
}
|
||||
}
|
||||
|
||||
ty::Ref(..) => {
|
||||
PatternKind::Deref { subpattern: pats.nth(0).unwrap() }
|
||||
PatKind::Deref { subpattern: pats.nth(0).unwrap() }
|
||||
}
|
||||
|
||||
ty::Slice(_) | ty::Array(..) => {
|
||||
PatternKind::Slice {
|
||||
PatKind::Slice {
|
||||
prefix: pats.collect(),
|
||||
slice: None,
|
||||
suffix: vec![]
|
||||
|
|
@ -605,19 +603,19 @@ impl<'tcx> Witness<'tcx> {
|
|||
|
||||
_ => {
|
||||
match *ctor {
|
||||
ConstantValue(value) => PatternKind::Constant { value },
|
||||
ConstantRange(lo, hi, ty, end) => PatternKind::Range(PatternRange {
|
||||
ConstantValue(value) => PatKind::Constant { value },
|
||||
ConstantRange(lo, hi, ty, end) => PatKind::Range(PatRange {
|
||||
lo: ty::Const::from_bits(cx.tcx, lo, ty::ParamEnv::empty().and(ty)),
|
||||
hi: ty::Const::from_bits(cx.tcx, hi, ty::ParamEnv::empty().and(ty)),
|
||||
end,
|
||||
}),
|
||||
_ => PatternKind::Wild,
|
||||
_ => PatKind::Wild,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.0.push(Pattern {
|
||||
self.0.push(Pat {
|
||||
ty,
|
||||
span: DUMMY_SP,
|
||||
kind: Box::new(pat),
|
||||
|
|
@ -636,7 +634,7 @@ impl<'tcx> Witness<'tcx> {
|
|||
/// `Option<!>`, we do not include `Some(_)` in the returned list of constructors.
|
||||
fn all_constructors<'a, 'tcx>(
|
||||
cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
pcx: PatternContext<'tcx>,
|
||||
pcx: PatCtxt<'tcx>,
|
||||
) -> Vec<Constructor<'tcx>> {
|
||||
debug!("all_constructors({:?})", pcx.ty);
|
||||
let ctors = match pcx.ty.kind {
|
||||
|
|
@ -710,7 +708,7 @@ fn all_constructors<'a, 'tcx>(
|
|||
|
||||
fn max_slice_length<'p, 'a, 'tcx, I>(cx: &mut MatchCheckCtxt<'a, 'tcx>, patterns: I) -> u64
|
||||
where
|
||||
I: Iterator<Item = &'p Pattern<'tcx>>,
|
||||
I: Iterator<Item = &'p Pat<'tcx>>,
|
||||
'tcx: 'p,
|
||||
{
|
||||
// The exhaustiveness-checking paper does not include any details on
|
||||
|
|
@ -783,7 +781,7 @@ where
|
|||
|
||||
for row in patterns {
|
||||
match *row.kind {
|
||||
PatternKind::Constant { value } => {
|
||||
PatKind::Constant { value } => {
|
||||
// extract the length of an array/slice from a constant
|
||||
match (value.val, &value.ty.kind) {
|
||||
(_, ty::Array(_, n)) => max_fixed_len = cmp::max(
|
||||
|
|
@ -797,11 +795,11 @@ where
|
|||
_ => {},
|
||||
}
|
||||
}
|
||||
PatternKind::Slice { ref prefix, slice: None, ref suffix } => {
|
||||
PatKind::Slice { ref prefix, slice: None, ref suffix } => {
|
||||
let fixed_len = prefix.len() as u64 + suffix.len() as u64;
|
||||
max_fixed_len = cmp::max(max_fixed_len, fixed_len);
|
||||
}
|
||||
PatternKind::Slice { ref prefix, slice: Some(_), ref suffix } => {
|
||||
PatKind::Slice { ref prefix, slice: Some(_), ref suffix } => {
|
||||
max_prefix_len = cmp::max(max_prefix_len, prefix.len() as u64);
|
||||
max_suffix_len = cmp::max(max_suffix_len, suffix.len() as u64);
|
||||
}
|
||||
|
|
@ -874,18 +872,18 @@ impl<'tcx> IntRange<'tcx> {
|
|||
fn from_pat(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
mut pat: &Pattern<'tcx>,
|
||||
mut pat: &Pat<'tcx>,
|
||||
) -> Option<IntRange<'tcx>> {
|
||||
let range = loop {
|
||||
match pat.kind {
|
||||
box PatternKind::Constant { value } => break ConstantValue(value),
|
||||
box PatternKind::Range(PatternRange { lo, hi, end }) => break ConstantRange(
|
||||
box PatKind::Constant { value } => break ConstantValue(value),
|
||||
box PatKind::Range(PatRange { lo, hi, end }) => break ConstantRange(
|
||||
lo.eval_bits(tcx, param_env, lo.ty),
|
||||
hi.eval_bits(tcx, param_env, hi.ty),
|
||||
lo.ty,
|
||||
end,
|
||||
),
|
||||
box PatternKind::AscribeUserType { ref subpattern, .. } => {
|
||||
box PatKind::AscribeUserType { ref subpattern, .. } => {
|
||||
pat = subpattern;
|
||||
},
|
||||
_ => return None,
|
||||
|
|
@ -1058,7 +1056,7 @@ fn compute_missing_ctors<'tcx>(
|
|||
/// inputs that will match `v` but not any of the sets in `m`.
|
||||
///
|
||||
/// All the patterns at each column of the `matrix ++ v` matrix must
|
||||
/// have the same type, except that wildcard (PatternKind::Wild) patterns
|
||||
/// have the same type, except that wildcard (PatKind::Wild) patterns
|
||||
/// with type `TyErr` are also allowed, even if the "type of the column"
|
||||
/// is not `TyErr`. That is used to represent private fields, as using their
|
||||
/// real type would assert that they are inhabited.
|
||||
|
|
@ -1070,7 +1068,7 @@ fn compute_missing_ctors<'tcx>(
|
|||
pub fn is_useful<'p, 'a, 'tcx>(
|
||||
cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
matrix: &Matrix<'p, 'tcx>,
|
||||
v: &[&Pattern<'tcx>],
|
||||
v: &[&Pat<'tcx>],
|
||||
witness: WitnessPreference,
|
||||
) -> Usefulness<'tcx> {
|
||||
let &Matrix(ref rows) = matrix;
|
||||
|
|
@ -1094,7 +1092,7 @@ pub fn is_useful<'p, 'a, 'tcx>(
|
|||
|
||||
assert!(rows.iter().all(|r| r.len() == v.len()));
|
||||
|
||||
let pcx = PatternContext {
|
||||
let pcx = PatCtxt {
|
||||
// TyErr is used to represent the type of wildcard patterns matching
|
||||
// against inaccessible (private) fields of structs, so that we won't
|
||||
// be able to observe whether the types of the struct's fields are
|
||||
|
|
@ -1247,10 +1245,10 @@ pub fn is_useful<'p, 'a, 'tcx>(
|
|||
// All constructors are unused. Add wild patterns
|
||||
// rather than each individual constructor.
|
||||
pats.into_iter().map(|mut witness| {
|
||||
witness.0.push(Pattern {
|
||||
witness.0.push(Pat {
|
||||
ty: pcx.ty,
|
||||
span: DUMMY_SP,
|
||||
kind: box PatternKind::Wild,
|
||||
kind: box PatKind::Wild,
|
||||
});
|
||||
witness
|
||||
}).collect()
|
||||
|
|
@ -1285,7 +1283,7 @@ pub fn is_useful<'p, 'a, 'tcx>(
|
|||
fn is_useful_specialized<'p, 'a, 'tcx>(
|
||||
cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
&Matrix(ref m): &Matrix<'p, 'tcx>,
|
||||
v: &[&Pattern<'tcx>],
|
||||
v: &[&Pat<'tcx>],
|
||||
ctor: Constructor<'tcx>,
|
||||
lty: Ty<'tcx>,
|
||||
witness: WitnessPreference,
|
||||
|
|
@ -1293,10 +1291,10 @@ fn is_useful_specialized<'p, 'a, 'tcx>(
|
|||
debug!("is_useful_specialized({:#?}, {:#?}, {:?})", v, ctor, lty);
|
||||
let sub_pat_tys = constructor_sub_pattern_tys(cx, &ctor, lty);
|
||||
let wild_patterns_owned: Vec<_> = sub_pat_tys.iter().map(|ty| {
|
||||
Pattern {
|
||||
Pat {
|
||||
ty,
|
||||
span: DUMMY_SP,
|
||||
kind: box PatternKind::Wild,
|
||||
kind: box PatKind::Wild,
|
||||
}
|
||||
}).collect();
|
||||
let wild_patterns: Vec<_> = wild_patterns_owned.iter().collect();
|
||||
|
|
@ -1325,33 +1323,33 @@ fn is_useful_specialized<'p, 'a, 'tcx>(
|
|||
///
|
||||
/// Returns `None` in case of a catch-all, which can't be specialized.
|
||||
fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>,
|
||||
pat: &Pattern<'tcx>,
|
||||
pcx: PatternContext<'tcx>)
|
||||
pat: &Pat<'tcx>,
|
||||
pcx: PatCtxt<'tcx>)
|
||||
-> Option<Vec<Constructor<'tcx>>>
|
||||
{
|
||||
match *pat.kind {
|
||||
PatternKind::AscribeUserType { ref subpattern, .. } =>
|
||||
PatKind::AscribeUserType { ref subpattern, .. } =>
|
||||
pat_constructors(cx, subpattern, pcx),
|
||||
PatternKind::Binding { .. } | PatternKind::Wild => None,
|
||||
PatternKind::Leaf { .. } | PatternKind::Deref { .. } => Some(vec![Single]),
|
||||
PatternKind::Variant { adt_def, variant_index, .. } => {
|
||||
PatKind::Binding { .. } | PatKind::Wild => None,
|
||||
PatKind::Leaf { .. } | PatKind::Deref { .. } => Some(vec![Single]),
|
||||
PatKind::Variant { adt_def, variant_index, .. } => {
|
||||
Some(vec![Variant(adt_def.variants[variant_index].def_id)])
|
||||
}
|
||||
PatternKind::Constant { value } => Some(vec![ConstantValue(value)]),
|
||||
PatternKind::Range(PatternRange { lo, hi, end }) =>
|
||||
PatKind::Constant { value } => Some(vec![ConstantValue(value)]),
|
||||
PatKind::Range(PatRange { lo, hi, end }) =>
|
||||
Some(vec![ConstantRange(
|
||||
lo.eval_bits(cx.tcx, cx.param_env, lo.ty),
|
||||
hi.eval_bits(cx.tcx, cx.param_env, hi.ty),
|
||||
lo.ty,
|
||||
end,
|
||||
)]),
|
||||
PatternKind::Array { .. } => match pcx.ty.kind {
|
||||
PatKind::Array { .. } => match pcx.ty.kind {
|
||||
ty::Array(_, length) => Some(vec![
|
||||
Slice(length.eval_usize(cx.tcx, cx.param_env))
|
||||
]),
|
||||
_ => span_bug!(pat.span, "bad ty {:?} for array pattern", pcx.ty)
|
||||
},
|
||||
PatternKind::Slice { ref prefix, ref slice, ref suffix } => {
|
||||
PatKind::Slice { ref prefix, ref slice, ref suffix } => {
|
||||
let pat_len = prefix.len() as u64 + suffix.len() as u64;
|
||||
if slice.is_some() {
|
||||
Some((pat_len..pcx.max_slice_length+1).map(Slice).collect())
|
||||
|
|
@ -1359,7 +1357,7 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>,
|
|||
Some(vec![Slice(pat_len)])
|
||||
}
|
||||
}
|
||||
PatternKind::Or { .. } => {
|
||||
PatKind::Or { .. } => {
|
||||
bug!("support for or-patterns has not been fully implemented yet.");
|
||||
}
|
||||
}
|
||||
|
|
@ -1446,9 +1444,9 @@ fn slice_pat_covered_by_const<'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
_span: Span,
|
||||
const_val: &'tcx ty::Const<'tcx>,
|
||||
prefix: &[Pattern<'tcx>],
|
||||
slice: &Option<Pattern<'tcx>>,
|
||||
suffix: &[Pattern<'tcx>],
|
||||
prefix: &[Pat<'tcx>],
|
||||
slice: &Option<Pat<'tcx>>,
|
||||
suffix: &[Pat<'tcx>],
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> Result<bool, ErrorReported> {
|
||||
let data: &[u8] = match (const_val.val, &const_val.ty.kind) {
|
||||
|
|
@ -1481,7 +1479,7 @@ fn slice_pat_covered_by_const<'tcx>(
|
|||
data[data.len()-suffix.len()..].iter().zip(suffix))
|
||||
{
|
||||
match pat.kind {
|
||||
box PatternKind::Constant { value } => {
|
||||
box PatKind::Constant { value } => {
|
||||
let b = value.eval_bits(tcx, param_env, pat.ty);
|
||||
assert_eq!(b as u8 as u128, b);
|
||||
if b as u8 != *ch {
|
||||
|
|
@ -1625,8 +1623,8 @@ fn constructor_intersects_pattern<'p, 'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
ctor: &Constructor<'tcx>,
|
||||
pat: &'p Pattern<'tcx>,
|
||||
) -> Option<SmallVec<[&'p Pattern<'tcx>; 2]>> {
|
||||
pat: &'p Pat<'tcx>,
|
||||
) -> Option<SmallVec<[&'p Pat<'tcx>; 2]>> {
|
||||
if should_treat_range_exhaustively(tcx, ctor) {
|
||||
match (IntRange::from_ctor(tcx, param_env, ctor), IntRange::from_pat(tcx, param_env, pat)) {
|
||||
(Some(ctor), Some(pat)) => {
|
||||
|
|
@ -1654,11 +1652,11 @@ fn constructor_covered_by_range<'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
ctor: &Constructor<'tcx>,
|
||||
pat: &Pattern<'tcx>,
|
||||
pat: &Pat<'tcx>,
|
||||
) -> Result<bool, ErrorReported> {
|
||||
let (from, to, end, ty) = match pat.kind {
|
||||
box PatternKind::Constant { value } => (value, value, RangeEnd::Included, value.ty),
|
||||
box PatternKind::Range(PatternRange { lo, hi, end }) => (lo, hi, end, lo.ty),
|
||||
box PatKind::Constant { value } => (value, value, RangeEnd::Included, value.ty),
|
||||
box PatKind::Range(PatRange { lo, hi, end }) => (lo, hi, end, lo.ty),
|
||||
_ => bug!("`constructor_covered_by_range` called with {:?}", pat),
|
||||
};
|
||||
trace!("constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}", ctor, from, to, ty);
|
||||
|
|
@ -1714,9 +1712,9 @@ fn constructor_covered_by_range<'tcx>(
|
|||
}
|
||||
|
||||
fn patterns_for_variant<'p, 'tcx>(
|
||||
subpatterns: &'p [FieldPattern<'tcx>],
|
||||
wild_patterns: &[&'p Pattern<'tcx>])
|
||||
-> SmallVec<[&'p Pattern<'tcx>; 2]>
|
||||
subpatterns: &'p [FieldPat<'tcx>],
|
||||
wild_patterns: &[&'p Pat<'tcx>])
|
||||
-> SmallVec<[&'p Pat<'tcx>; 2]>
|
||||
{
|
||||
let mut result = SmallVec::from_slice(wild_patterns);
|
||||
|
||||
|
|
@ -1738,37 +1736,37 @@ fn patterns_for_variant<'p, 'tcx>(
|
|||
/// fields filled with wild patterns.
|
||||
fn specialize<'p, 'a: 'p, 'tcx>(
|
||||
cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
r: &[&'p Pattern<'tcx>],
|
||||
r: &[&'p Pat<'tcx>],
|
||||
constructor: &Constructor<'tcx>,
|
||||
wild_patterns: &[&'p Pattern<'tcx>],
|
||||
) -> Option<SmallVec<[&'p Pattern<'tcx>; 2]>> {
|
||||
wild_patterns: &[&'p Pat<'tcx>],
|
||||
) -> Option<SmallVec<[&'p Pat<'tcx>; 2]>> {
|
||||
let pat = &r[0];
|
||||
|
||||
let head = match *pat.kind {
|
||||
PatternKind::AscribeUserType { ref subpattern, .. } => {
|
||||
PatKind::AscribeUserType { ref subpattern, .. } => {
|
||||
specialize(cx, ::std::slice::from_ref(&subpattern), constructor, wild_patterns)
|
||||
}
|
||||
|
||||
PatternKind::Binding { .. } | PatternKind::Wild => {
|
||||
PatKind::Binding { .. } | PatKind::Wild => {
|
||||
Some(SmallVec::from_slice(wild_patterns))
|
||||
}
|
||||
|
||||
PatternKind::Variant { adt_def, variant_index, ref subpatterns, .. } => {
|
||||
PatKind::Variant { adt_def, variant_index, ref subpatterns, .. } => {
|
||||
let ref variant = adt_def.variants[variant_index];
|
||||
Some(Variant(variant.def_id))
|
||||
.filter(|variant_constructor| variant_constructor == constructor)
|
||||
.map(|_| patterns_for_variant(subpatterns, wild_patterns))
|
||||
}
|
||||
|
||||
PatternKind::Leaf { ref subpatterns } => {
|
||||
PatKind::Leaf { ref subpatterns } => {
|
||||
Some(patterns_for_variant(subpatterns, wild_patterns))
|
||||
}
|
||||
|
||||
PatternKind::Deref { ref subpattern } => {
|
||||
PatKind::Deref { ref subpattern } => {
|
||||
Some(smallvec![subpattern])
|
||||
}
|
||||
|
||||
PatternKind::Constant { value } => {
|
||||
PatKind::Constant { value } => {
|
||||
match *constructor {
|
||||
Slice(..) => {
|
||||
// we extract an `Option` for the pointer because slices of zero elements don't
|
||||
|
|
@ -1827,10 +1825,10 @@ fn specialize<'p, 'a: 'p, 'tcx>(
|
|||
).ok()?;
|
||||
let scalar = scalar.not_undef().ok()?;
|
||||
let value = ty::Const::from_scalar(cx.tcx, scalar, ty);
|
||||
let pattern = Pattern {
|
||||
let pattern = Pat {
|
||||
ty,
|
||||
span: pat.span,
|
||||
kind: box PatternKind::Constant { value },
|
||||
kind: box PatKind::Constant { value },
|
||||
};
|
||||
Some(&*cx.pattern_arena.alloc(pattern))
|
||||
}).collect()
|
||||
|
|
@ -1847,15 +1845,15 @@ fn specialize<'p, 'a: 'p, 'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Range { .. } => {
|
||||
PatKind::Range { .. } => {
|
||||
// If the constructor is a:
|
||||
// Single value: add a row if the pattern contains the constructor.
|
||||
// Range: add a row if the constructor intersects the pattern.
|
||||
constructor_intersects_pattern(cx.tcx, cx.param_env, constructor, pat)
|
||||
}
|
||||
|
||||
PatternKind::Array { ref prefix, ref slice, ref suffix } |
|
||||
PatternKind::Slice { ref prefix, ref slice, ref suffix } => {
|
||||
PatKind::Array { ref prefix, ref slice, ref suffix } |
|
||||
PatKind::Slice { ref prefix, ref slice, ref suffix } => {
|
||||
match *constructor {
|
||||
Slice(..) => {
|
||||
let pat_len = prefix.len() + suffix.len();
|
||||
|
|
@ -1888,7 +1886,7 @@ fn specialize<'p, 'a: 'p, 'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Or { .. } => {
|
||||
PatKind::Or { .. } => {
|
||||
bug!("support for or-patterns has not been fully implemented yet.");
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use super::_match::{MatchCheckCtxt, Matrix, expand_pattern, is_useful};
|
|||
use super::_match::Usefulness::*;
|
||||
use super::_match::WitnessPreference::*;
|
||||
|
||||
use super::{Pattern, PatternContext, PatternError, PatternKind};
|
||||
use super::{PatCtxt, PatternError, PatKind};
|
||||
|
||||
use rustc::middle::borrowck::SignalledError;
|
||||
use rustc::session::Session;
|
||||
|
|
@ -14,7 +14,7 @@ use rustc_errors::{Applicability, DiagnosticBuilder};
|
|||
use rustc::hir::def::*;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir::{self, Pat, PatKind};
|
||||
use rustc::hir::{self, Pat};
|
||||
|
||||
use smallvec::smallvec;
|
||||
use std::slice;
|
||||
|
|
@ -59,7 +59,7 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> {
|
|||
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
|
||||
intravisit::walk_expr(self, ex);
|
||||
|
||||
if let hir::ExprKind::Match(ref scrut, ref arms, source) = ex.node {
|
||||
if let hir::ExprKind::Match(ref scrut, ref arms, source) = ex.kind {
|
||||
self.check_match(scrut, arms, source);
|
||||
}
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl PatternContext<'_, '_> {
|
||||
impl PatCtxt<'_, '_> {
|
||||
fn report_inlining_errors(&self, pat_span: Span) {
|
||||
for error in &self.errors {
|
||||
match *error {
|
||||
|
|
@ -152,7 +152,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
|
|||
|
||||
let inlined_arms : Vec<(Vec<_>, _)> = arms.iter().map(|arm| (
|
||||
arm.top_pats_hack().iter().map(|pat| {
|
||||
let mut patcx = PatternContext::new(self.tcx,
|
||||
let mut patcx = PatCtxt::new(self.tcx,
|
||||
self.param_env.and(self.identity_substs),
|
||||
self.tables);
|
||||
patcx.include_lint_checks();
|
||||
|
|
@ -249,7 +249,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
|
|||
fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
|
||||
let module = self.tcx.hir().get_module_parent(pat.hir_id);
|
||||
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
|
||||
let mut patcx = PatternContext::new(self.tcx,
|
||||
let mut patcx = PatCtxt::new(self.tcx,
|
||||
self.param_env.and(self.identity_substs),
|
||||
self.tables);
|
||||
patcx.include_lint_checks();
|
||||
|
|
@ -270,8 +270,8 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
|
|||
"refutable pattern in {}: {} not covered",
|
||||
origin, joined_patterns
|
||||
);
|
||||
err.span_label(pat.span, match &pat.node {
|
||||
PatKind::Path(hir::QPath::Resolved(None, path))
|
||||
err.span_label(pat.span, match &pat.kind {
|
||||
hir::PatKind::Path(hir::QPath::Resolved(None, path))
|
||||
if path.segments.len() == 1 && path.segments[0].args.is_none() => {
|
||||
format!("interpreted as {} {} pattern, not new variable",
|
||||
path.res.article(), path.res.descr())
|
||||
|
|
@ -286,7 +286,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
|
|||
|
||||
fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pat) {
|
||||
pat.walk(|p| {
|
||||
if let PatKind::Binding(_, _, ident, None) = p.node {
|
||||
if let hir::PatKind::Binding(_, _, ident, None) = p.kind {
|
||||
if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) {
|
||||
if bm != ty::BindByValue(hir::MutImmutable) {
|
||||
// Nothing to check.
|
||||
|
|
@ -321,11 +321,11 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pa
|
|||
|
||||
/// Checks for common cases of "catchall" patterns that may not be intended as such.
|
||||
fn pat_is_catchall(pat: &Pat) -> bool {
|
||||
match pat.node {
|
||||
PatKind::Binding(.., None) => true,
|
||||
PatKind::Binding(.., Some(ref s)) => pat_is_catchall(s),
|
||||
PatKind::Ref(ref s, _) => pat_is_catchall(s),
|
||||
PatKind::Tuple(ref v, _) => v.iter().all(|p| {
|
||||
match pat.kind {
|
||||
hir::PatKind::Binding(.., None) => true,
|
||||
hir::PatKind::Binding(.., Some(ref s)) => pat_is_catchall(s),
|
||||
hir::PatKind::Ref(ref s, _) => pat_is_catchall(s),
|
||||
hir::PatKind::Tuple(ref v, _) => v.iter().all(|p| {
|
||||
pat_is_catchall(&p)
|
||||
}),
|
||||
_ => false
|
||||
|
|
@ -335,7 +335,7 @@ fn pat_is_catchall(pat: &Pat) -> bool {
|
|||
// Check for unreachable patterns
|
||||
fn check_arms<'tcx>(
|
||||
cx: &mut MatchCheckCtxt<'_, 'tcx>,
|
||||
arms: &[(Vec<(&Pattern<'tcx>, &hir::Pat)>, Option<&hir::Expr>)],
|
||||
arms: &[(Vec<(&super::Pat<'tcx>, &hir::Pat)>, Option<&hir::Expr>)],
|
||||
source: hir::MatchSource,
|
||||
) {
|
||||
let mut seen = Matrix::empty();
|
||||
|
|
@ -420,8 +420,8 @@ fn check_not_useful(
|
|||
cx: &mut MatchCheckCtxt<'_, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
matrix: &Matrix<'_, 'tcx>,
|
||||
) -> Result<(), Vec<Pattern<'tcx>>> {
|
||||
let wild_pattern = Pattern { ty, span: DUMMY_SP, kind: box PatternKind::Wild };
|
||||
) -> Result<(), Vec<super::Pat<'tcx>>> {
|
||||
let wild_pattern = super::Pat { ty, span: DUMMY_SP, kind: box PatKind::Wild };
|
||||
match is_useful(cx, matrix, &[&wild_pattern], ConstructWitness) {
|
||||
NotUseful => Ok(()), // This is good, wildcard pattern isn't reachable.
|
||||
UsefulWithWitness(pats) => Err(if pats.is_empty() {
|
||||
|
|
@ -458,7 +458,7 @@ fn check_exhaustive<'tcx>(
|
|||
.emit();
|
||||
}
|
||||
|
||||
fn joined_uncovered_patterns(witnesses: &[Pattern<'_>]) -> String {
|
||||
fn joined_uncovered_patterns(witnesses: &[super::Pat<'_>]) -> String {
|
||||
const LIMIT: usize = 3;
|
||||
match witnesses {
|
||||
[] => bug!(),
|
||||
|
|
@ -475,7 +475,7 @@ fn joined_uncovered_patterns(witnesses: &[Pattern<'_>]) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn pattern_not_convered_label(witnesses: &[Pattern<'_>], joined_patterns: &str) -> String {
|
||||
fn pattern_not_convered_label(witnesses: &[super::Pat<'_>], joined_patterns: &str) -> String {
|
||||
format!("pattern{} {} not covered", rustc_errors::pluralise!(witnesses.len()), joined_patterns)
|
||||
}
|
||||
|
||||
|
|
@ -484,7 +484,7 @@ fn adt_defined_here(
|
|||
cx: &MatchCheckCtxt<'_, '_>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
ty: Ty<'_>,
|
||||
witnesses: &[Pattern<'_>],
|
||||
witnesses: &[super::Pat<'_>],
|
||||
) {
|
||||
let ty = ty.peel_refs();
|
||||
if let ty::Adt(def, _) = ty.kind {
|
||||
|
|
@ -500,13 +500,13 @@ fn adt_defined_here(
|
|||
}
|
||||
}
|
||||
|
||||
fn maybe_point_at_variant(ty: Ty<'_>, patterns: &[Pattern<'_>]) -> Vec<Span> {
|
||||
fn maybe_point_at_variant(ty: Ty<'_>, patterns: &[super::Pat<'_>]) -> Vec<Span> {
|
||||
let mut covered = vec![];
|
||||
if let ty::Adt(def, _) = ty.kind {
|
||||
// Don't point at variants that have already been covered due to other patterns to avoid
|
||||
// visual clutter.
|
||||
for pattern in patterns {
|
||||
use PatternKind::{AscribeUserType, Deref, Variant, Or, Leaf};
|
||||
use PatKind::{AscribeUserType, Deref, Variant, Or, Leaf};
|
||||
match &*pattern.kind {
|
||||
AscribeUserType { subpattern, .. } | Deref { subpattern } => {
|
||||
covered.extend(maybe_point_at_variant(ty, slice::from_ref(&subpattern)));
|
||||
|
|
@ -568,7 +568,7 @@ fn check_legality_of_move_bindings(cx: &mut MatchVisitor<'_, '_>, has_guard: boo
|
|||
};
|
||||
|
||||
pat.walk(|p| {
|
||||
if let PatKind::Binding(.., sub) = &p.node {
|
||||
if let hir::PatKind::Binding(.., sub) = &p.kind {
|
||||
if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) {
|
||||
if let ty::BindByValue(..) = bm {
|
||||
let pat_ty = cx.tables.node_type(p.hir_id);
|
||||
|
|
@ -618,8 +618,8 @@ impl<'v> Visitor<'v> for AtBindingPatternVisitor<'_, '_, '_> {
|
|||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &Pat) {
|
||||
match pat.node {
|
||||
PatKind::Binding(.., ref subpat) => {
|
||||
match pat.kind {
|
||||
hir::PatKind::Binding(.., ref subpat) => {
|
||||
if !self.bindings_allowed {
|
||||
struct_span_err!(self.cx.tcx.sess, pat.span, E0303,
|
||||
"pattern bindings are not allowed after an `@`")
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use rustc::ty::{self, Region, TyCtxt, AdtDef, Ty, UserType, DefIdTree};
|
|||
use rustc::ty::{CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations};
|
||||
use rustc::ty::subst::{SubstsRef, GenericArg};
|
||||
use rustc::ty::layout::{VariantIdx, Size};
|
||||
use rustc::hir::{self, PatKind, RangeEnd};
|
||||
use rustc::hir::{self, RangeEnd};
|
||||
use rustc::hir::def::{CtorOf, Res, DefKind, CtorKind};
|
||||
use rustc::hir::pat_util::EnumerateAndAdjustIterator;
|
||||
use rustc::hir::ptr::P;
|
||||
|
|
@ -48,25 +48,25 @@ pub enum BindingMode {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FieldPattern<'tcx> {
|
||||
pub struct FieldPat<'tcx> {
|
||||
pub field: Field,
|
||||
pub pattern: Pattern<'tcx>,
|
||||
pub pattern: Pat<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Pattern<'tcx> {
|
||||
pub struct Pat<'tcx> {
|
||||
pub ty: Ty<'tcx>,
|
||||
pub span: Span,
|
||||
pub kind: Box<PatternKind<'tcx>>,
|
||||
pub kind: Box<PatKind<'tcx>>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub struct PatternTypeProjection<'tcx> {
|
||||
pub struct PatTyProj<'tcx> {
|
||||
pub user_ty: CanonicalUserType<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> PatternTypeProjection<'tcx> {
|
||||
impl<'tcx> PatTyProj<'tcx> {
|
||||
pub(crate) fn from_user_type(user_annotation: CanonicalUserType<'tcx>) -> Self {
|
||||
Self {
|
||||
user_ty: user_annotation,
|
||||
|
|
@ -92,7 +92,7 @@ impl<'tcx> PatternTypeProjection<'tcx> {
|
|||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub struct Ascription<'tcx> {
|
||||
pub user_ty: PatternTypeProjection<'tcx>,
|
||||
pub user_ty: PatTyProj<'tcx>,
|
||||
/// Variance to use when relating the type `user_ty` to the **type of the value being
|
||||
/// matched**. Typically, this is `Variance::Covariant`, since the value being matched must
|
||||
/// have a type that is some subtype of the ascribed type.
|
||||
|
|
@ -116,12 +116,12 @@ pub struct Ascription<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum PatternKind<'tcx> {
|
||||
pub enum PatKind<'tcx> {
|
||||
Wild,
|
||||
|
||||
AscribeUserType {
|
||||
ascription: Ascription<'tcx>,
|
||||
subpattern: Pattern<'tcx>,
|
||||
subpattern: Pat<'tcx>,
|
||||
},
|
||||
|
||||
/// `x`, `ref x`, `x @ P`, etc.
|
||||
|
|
@ -131,7 +131,7 @@ pub enum PatternKind<'tcx> {
|
|||
mode: BindingMode,
|
||||
var: hir::HirId,
|
||||
ty: Ty<'tcx>,
|
||||
subpattern: Option<Pattern<'tcx>>,
|
||||
subpattern: Option<Pat<'tcx>>,
|
||||
},
|
||||
|
||||
/// `Foo(...)` or `Foo{...}` or `Foo`, where `Foo` is a variant name from an ADT with
|
||||
|
|
@ -140,57 +140,57 @@ pub enum PatternKind<'tcx> {
|
|||
adt_def: &'tcx AdtDef,
|
||||
substs: SubstsRef<'tcx>,
|
||||
variant_index: VariantIdx,
|
||||
subpatterns: Vec<FieldPattern<'tcx>>,
|
||||
subpatterns: Vec<FieldPat<'tcx>>,
|
||||
},
|
||||
|
||||
/// `(...)`, `Foo(...)`, `Foo{...}`, or `Foo`, where `Foo` is a variant name from an ADT with
|
||||
/// a single variant.
|
||||
Leaf {
|
||||
subpatterns: Vec<FieldPattern<'tcx>>,
|
||||
subpatterns: Vec<FieldPat<'tcx>>,
|
||||
},
|
||||
|
||||
/// `box P`, `&P`, `&mut P`, etc.
|
||||
Deref {
|
||||
subpattern: Pattern<'tcx>,
|
||||
subpattern: Pat<'tcx>,
|
||||
},
|
||||
|
||||
Constant {
|
||||
value: &'tcx ty::Const<'tcx>,
|
||||
},
|
||||
|
||||
Range(PatternRange<'tcx>),
|
||||
Range(PatRange<'tcx>),
|
||||
|
||||
/// Matches against a slice, checking the length and extracting elements.
|
||||
/// irrefutable when there is a slice pattern and both `prefix` and `suffix` are empty.
|
||||
/// e.g., `&[ref xs @ ..]`.
|
||||
Slice {
|
||||
prefix: Vec<Pattern<'tcx>>,
|
||||
slice: Option<Pattern<'tcx>>,
|
||||
suffix: Vec<Pattern<'tcx>>,
|
||||
prefix: Vec<Pat<'tcx>>,
|
||||
slice: Option<Pat<'tcx>>,
|
||||
suffix: Vec<Pat<'tcx>>,
|
||||
},
|
||||
|
||||
/// Fixed match against an array; irrefutable.
|
||||
Array {
|
||||
prefix: Vec<Pattern<'tcx>>,
|
||||
slice: Option<Pattern<'tcx>>,
|
||||
suffix: Vec<Pattern<'tcx>>,
|
||||
prefix: Vec<Pat<'tcx>>,
|
||||
slice: Option<Pat<'tcx>>,
|
||||
suffix: Vec<Pat<'tcx>>,
|
||||
},
|
||||
|
||||
/// An or-pattern, e.g. `p | q`.
|
||||
/// Invariant: `pats.len() >= 2`.
|
||||
Or {
|
||||
pats: Vec<Pattern<'tcx>>,
|
||||
pats: Vec<Pat<'tcx>>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub struct PatternRange<'tcx> {
|
||||
pub struct PatRange<'tcx> {
|
||||
pub lo: &'tcx ty::Const<'tcx>,
|
||||
pub hi: &'tcx ty::Const<'tcx>,
|
||||
pub end: RangeEnd,
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Display for Pattern<'tcx> {
|
||||
impl<'tcx> fmt::Display for Pat<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// Printing lists is a chore.
|
||||
let mut first = true;
|
||||
|
|
@ -205,10 +205,10 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
let mut start_or_comma = || start_or_continue(", ");
|
||||
|
||||
match *self.kind {
|
||||
PatternKind::Wild => write!(f, "_"),
|
||||
PatternKind::AscribeUserType { ref subpattern, .. } =>
|
||||
PatKind::Wild => write!(f, "_"),
|
||||
PatKind::AscribeUserType { ref subpattern, .. } =>
|
||||
write!(f, "{}: _", subpattern),
|
||||
PatternKind::Binding { mutability, name, mode, ref subpattern, .. } => {
|
||||
PatKind::Binding { mutability, name, mode, ref subpattern, .. } => {
|
||||
let is_mut = match mode {
|
||||
BindingMode::ByValue => mutability == Mutability::Mut,
|
||||
BindingMode::ByRef(bk) => {
|
||||
|
|
@ -225,10 +225,10 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
PatternKind::Variant { ref subpatterns, .. } |
|
||||
PatternKind::Leaf { ref subpatterns } => {
|
||||
PatKind::Variant { ref subpatterns, .. } |
|
||||
PatKind::Leaf { ref subpatterns } => {
|
||||
let variant = match *self.kind {
|
||||
PatternKind::Variant { adt_def, variant_index, .. } => {
|
||||
PatKind::Variant { adt_def, variant_index, .. } => {
|
||||
Some(&adt_def.variants[variant_index])
|
||||
}
|
||||
_ => if let ty::Adt(adt, _) = self.ty.kind {
|
||||
|
|
@ -252,7 +252,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
|
||||
let mut printed = 0;
|
||||
for p in subpatterns {
|
||||
if let PatternKind::Wild = *p.pattern.kind {
|
||||
if let PatKind::Wild = *p.pattern.kind {
|
||||
continue;
|
||||
}
|
||||
let name = variant.fields[p.field.index()].ident;
|
||||
|
|
@ -294,7 +294,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
PatternKind::Deref { ref subpattern } => {
|
||||
PatKind::Deref { ref subpattern } => {
|
||||
match self.ty.kind {
|
||||
ty::Adt(def, _) if def.is_box() => write!(f, "box ")?,
|
||||
ty::Ref(_, _, mutbl) => {
|
||||
|
|
@ -307,10 +307,10 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
}
|
||||
write!(f, "{}", subpattern)
|
||||
}
|
||||
PatternKind::Constant { value } => {
|
||||
PatKind::Constant { value } => {
|
||||
write!(f, "{}", value)
|
||||
}
|
||||
PatternKind::Range(PatternRange { lo, hi, end }) => {
|
||||
PatKind::Range(PatRange { lo, hi, end }) => {
|
||||
write!(f, "{}", lo)?;
|
||||
match end {
|
||||
RangeEnd::Included => write!(f, "..=")?,
|
||||
|
|
@ -318,8 +318,8 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
}
|
||||
write!(f, "{}", hi)
|
||||
}
|
||||
PatternKind::Slice { ref prefix, ref slice, ref suffix } |
|
||||
PatternKind::Array { ref prefix, ref slice, ref suffix } => {
|
||||
PatKind::Slice { ref prefix, ref slice, ref suffix } |
|
||||
PatKind::Array { ref prefix, ref slice, ref suffix } => {
|
||||
write!(f, "[")?;
|
||||
for p in prefix {
|
||||
write!(f, "{}{}", start_or_comma(), p)?;
|
||||
|
|
@ -327,7 +327,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
if let Some(ref slice) = *slice {
|
||||
write!(f, "{}", start_or_comma())?;
|
||||
match *slice.kind {
|
||||
PatternKind::Wild => {}
|
||||
PatKind::Wild => {}
|
||||
_ => write!(f, "{}", slice)?
|
||||
}
|
||||
write!(f, "..")?;
|
||||
|
|
@ -337,7 +337,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
}
|
||||
write!(f, "]")
|
||||
}
|
||||
PatternKind::Or { ref pats } => {
|
||||
PatKind::Or { ref pats } => {
|
||||
for pat in pats {
|
||||
write!(f, "{}{}", start_or_continue(" | "), pat)?;
|
||||
}
|
||||
|
|
@ -347,7 +347,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct PatternContext<'a, 'tcx> {
|
||||
pub struct PatCtxt<'a, 'tcx> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
pub param_env: ty::ParamEnv<'tcx>,
|
||||
pub tables: &'a ty::TypeckTables<'tcx>,
|
||||
|
|
@ -356,31 +356,31 @@ pub struct PatternContext<'a, 'tcx> {
|
|||
include_lint_checks: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Pattern<'tcx> {
|
||||
impl<'a, 'tcx> Pat<'tcx> {
|
||||
pub fn from_hir(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
pat: &'tcx hir::Pat,
|
||||
) -> Self {
|
||||
let mut pcx = PatternContext::new(tcx, param_env_and_substs, tables);
|
||||
let mut pcx = PatCtxt::new(tcx, param_env_and_substs, tables);
|
||||
let result = pcx.lower_pattern(pat);
|
||||
if !pcx.errors.is_empty() {
|
||||
let msg = format!("encountered errors lowering pattern: {:?}", pcx.errors);
|
||||
tcx.sess.delay_span_bug(pat.span, &msg);
|
||||
}
|
||||
debug!("Pattern::from_hir({:?}) = {:?}", pat, result);
|
||||
debug!("Pat::from_hir({:?}) = {:?}", pat, result);
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||
impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||
pub fn new(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
) -> Self {
|
||||
PatternContext {
|
||||
PatCtxt {
|
||||
tcx,
|
||||
param_env: param_env_and_substs.param_env,
|
||||
tables,
|
||||
|
|
@ -395,7 +395,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn lower_pattern(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {
|
||||
pub fn lower_pattern(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> {
|
||||
// When implicit dereferences have been inserted in this pattern, the unadjusted lowered
|
||||
// pattern has the type that results *after* dereferencing. For example, in this code:
|
||||
//
|
||||
|
|
@ -412,7 +412,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
// `vec![&&Option<i32>, &Option<i32>]`.
|
||||
//
|
||||
// Applying the adjustments, we want to instead output `&&Some(n)` (as a HAIR pattern). So
|
||||
// we wrap the unadjusted pattern in `PatternKind::Deref` repeatedly, consuming the
|
||||
// we wrap the unadjusted pattern in `PatKind::Deref` repeatedly, consuming the
|
||||
// adjustments in *reverse order* (last-in-first-out, so that the last `Deref` inserted
|
||||
// gets the least-dereferenced type).
|
||||
let unadjusted_pat = self.lower_pattern_unadjusted(pat);
|
||||
|
|
@ -424,10 +424,10 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
.rev()
|
||||
.fold(unadjusted_pat, |pat, ref_ty| {
|
||||
debug!("{:?}: wrapping pattern with type {:?}", pat, ref_ty);
|
||||
Pattern {
|
||||
Pat {
|
||||
span: pat.span,
|
||||
ty: ref_ty,
|
||||
kind: Box::new(PatternKind::Deref { subpattern: pat }),
|
||||
kind: Box::new(PatKind::Deref { subpattern: pat }),
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
@ -436,30 +436,30 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
fn lower_range_expr(
|
||||
&mut self,
|
||||
expr: &'tcx hir::Expr,
|
||||
) -> (PatternKind<'tcx>, Option<Ascription<'tcx>>) {
|
||||
) -> (PatKind<'tcx>, Option<Ascription<'tcx>>) {
|
||||
match self.lower_lit(expr) {
|
||||
PatternKind::AscribeUserType {
|
||||
PatKind::AscribeUserType {
|
||||
ascription: lo_ascription,
|
||||
subpattern: Pattern { kind: box kind, .. },
|
||||
subpattern: Pat { kind: box kind, .. },
|
||||
} => (kind, Some(lo_ascription)),
|
||||
kind => (kind, None),
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {
|
||||
fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pat<'tcx> {
|
||||
let mut ty = self.tables.node_type(pat.hir_id);
|
||||
|
||||
let kind = match pat.node {
|
||||
PatKind::Wild => PatternKind::Wild,
|
||||
let kind = match pat.kind {
|
||||
hir::PatKind::Wild => PatKind::Wild,
|
||||
|
||||
PatKind::Lit(ref value) => self.lower_lit(value),
|
||||
hir::PatKind::Lit(ref value) => self.lower_lit(value),
|
||||
|
||||
PatKind::Range(ref lo_expr, ref hi_expr, end) => {
|
||||
hir::PatKind::Range(ref lo_expr, ref hi_expr, end) => {
|
||||
let (lo, lo_ascription) = self.lower_range_expr(lo_expr);
|
||||
let (hi, hi_ascription) = self.lower_range_expr(hi_expr);
|
||||
|
||||
let mut kind = match (lo, hi) {
|
||||
(PatternKind::Constant { value: lo }, PatternKind::Constant { value: hi }) => {
|
||||
(PatKind::Constant { value: lo }, PatKind::Constant { value: hi }) => {
|
||||
assert_eq!(lo.ty, ty);
|
||||
assert_eq!(hi.ty, ty);
|
||||
let cmp = compare_const_vals(
|
||||
|
|
@ -471,7 +471,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
);
|
||||
match (end, cmp) {
|
||||
(RangeEnd::Excluded, Some(Ordering::Less)) =>
|
||||
PatternKind::Range(PatternRange { lo, hi, end }),
|
||||
PatKind::Range(PatRange { lo, hi, end }),
|
||||
(RangeEnd::Excluded, _) => {
|
||||
span_err!(
|
||||
self.tcx.sess,
|
||||
|
|
@ -479,13 +479,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
E0579,
|
||||
"lower range bound must be less than upper",
|
||||
);
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
}
|
||||
(RangeEnd::Included, Some(Ordering::Equal)) => {
|
||||
PatternKind::Constant { value: lo }
|
||||
PatKind::Constant { value: lo }
|
||||
}
|
||||
(RangeEnd::Included, Some(Ordering::Less)) => {
|
||||
PatternKind::Range(PatternRange { lo, hi, end })
|
||||
PatKind::Range(PatRange { lo, hi, end })
|
||||
}
|
||||
(RangeEnd::Included, _) => {
|
||||
let mut err = struct_span_err!(
|
||||
|
|
@ -506,7 +506,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
to be less than or equal to the end of the range.");
|
||||
}
|
||||
err.emit();
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -519,7 +519,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
),
|
||||
);
|
||||
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -528,9 +528,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
// constants somewhere. Have them on the range pattern.
|
||||
for ascription in &[lo_ascription, hi_ascription] {
|
||||
if let Some(ascription) = ascription {
|
||||
kind = PatternKind::AscribeUserType {
|
||||
kind = PatKind::AscribeUserType {
|
||||
ascription: *ascription,
|
||||
subpattern: Pattern { span: pat.span, ty, kind: Box::new(kind), },
|
||||
subpattern: Pat { span: pat.span, ty, kind: Box::new(kind), },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -538,20 +538,20 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
kind
|
||||
}
|
||||
|
||||
PatKind::Path(ref qpath) => {
|
||||
hir::PatKind::Path(ref qpath) => {
|
||||
return self.lower_path(qpath, pat.hir_id, pat.span);
|
||||
}
|
||||
|
||||
PatKind::Ref(ref subpattern, _) |
|
||||
PatKind::Box(ref subpattern) => {
|
||||
PatternKind::Deref { subpattern: self.lower_pattern(subpattern) }
|
||||
hir::PatKind::Ref(ref subpattern, _) |
|
||||
hir::PatKind::Box(ref subpattern) => {
|
||||
PatKind::Deref { subpattern: self.lower_pattern(subpattern) }
|
||||
}
|
||||
|
||||
PatKind::Slice(ref prefix, ref slice, ref suffix) => {
|
||||
hir::PatKind::Slice(ref prefix, ref slice, ref suffix) => {
|
||||
match ty.kind {
|
||||
ty::Ref(_, ty, _) =>
|
||||
PatternKind::Deref {
|
||||
subpattern: Pattern {
|
||||
PatKind::Deref {
|
||||
subpattern: Pat {
|
||||
ty,
|
||||
span: pat.span,
|
||||
kind: Box::new(self.slice_or_array_pattern(
|
||||
|
|
@ -562,7 +562,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
ty::Array(..) =>
|
||||
self.slice_or_array_pattern(pat.span, ty, prefix, slice, suffix),
|
||||
ty::Error => { // Avoid ICE
|
||||
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
||||
return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) };
|
||||
}
|
||||
_ =>
|
||||
span_bug!(
|
||||
|
|
@ -572,32 +572,32 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatKind::Tuple(ref subpatterns, ddpos) => {
|
||||
hir::PatKind::Tuple(ref subpatterns, ddpos) => {
|
||||
match ty.kind {
|
||||
ty::Tuple(ref tys) => {
|
||||
let subpatterns =
|
||||
subpatterns.iter()
|
||||
.enumerate_and_adjust(tys.len(), ddpos)
|
||||
.map(|(i, subpattern)| FieldPattern {
|
||||
.map(|(i, subpattern)| FieldPat {
|
||||
field: Field::new(i),
|
||||
pattern: self.lower_pattern(subpattern)
|
||||
})
|
||||
.collect();
|
||||
|
||||
PatternKind::Leaf { subpatterns }
|
||||
PatKind::Leaf { subpatterns }
|
||||
}
|
||||
ty::Error => { // Avoid ICE (#50577)
|
||||
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
||||
return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) };
|
||||
}
|
||||
_ => span_bug!(pat.span, "unexpected type for tuple pattern: {:?}", ty),
|
||||
}
|
||||
}
|
||||
|
||||
PatKind::Binding(_, id, ident, ref sub) => {
|
||||
hir::PatKind::Binding(_, id, ident, ref sub) => {
|
||||
let var_ty = self.tables.node_type(pat.hir_id);
|
||||
if let ty::Error = var_ty.kind {
|
||||
// Avoid ICE
|
||||
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
||||
return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) };
|
||||
};
|
||||
let bm = *self.tables.pat_binding_modes().get(pat.hir_id)
|
||||
.expect("missing binding mode");
|
||||
|
|
@ -624,7 +624,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatternKind::Binding {
|
||||
PatKind::Binding {
|
||||
mutability,
|
||||
mode,
|
||||
name: ident.name,
|
||||
|
|
@ -634,12 +634,12 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatKind::TupleStruct(ref qpath, ref subpatterns, ddpos) => {
|
||||
hir::PatKind::TupleStruct(ref qpath, ref subpatterns, ddpos) => {
|
||||
let res = self.tables.qpath_res(qpath, pat.hir_id);
|
||||
let adt_def = match ty.kind {
|
||||
ty::Adt(adt_def, _) => adt_def,
|
||||
ty::Error => { // Avoid ICE (#50585)
|
||||
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
||||
return Pat { span: pat.span, ty, kind: Box::new(PatKind::Wild) };
|
||||
}
|
||||
_ => span_bug!(pat.span,
|
||||
"tuple struct pattern not applied to an ADT {:?}",
|
||||
|
|
@ -650,7 +650,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
let subpatterns =
|
||||
subpatterns.iter()
|
||||
.enumerate_and_adjust(variant_def.fields.len(), ddpos)
|
||||
.map(|(i, field)| FieldPattern {
|
||||
.map(|(i, field)| FieldPat {
|
||||
field: Field::new(i),
|
||||
pattern: self.lower_pattern(field),
|
||||
})
|
||||
|
|
@ -659,12 +659,12 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
self.lower_variant_or_leaf(res, pat.hir_id, pat.span, ty, subpatterns)
|
||||
}
|
||||
|
||||
PatKind::Struct(ref qpath, ref fields, _) => {
|
||||
hir::PatKind::Struct(ref qpath, ref fields, _) => {
|
||||
let res = self.tables.qpath_res(qpath, pat.hir_id);
|
||||
let subpatterns =
|
||||
fields.iter()
|
||||
.map(|field| {
|
||||
FieldPattern {
|
||||
FieldPat {
|
||||
field: Field::new(self.tcx.field_index(field.hir_id,
|
||||
self.tables)),
|
||||
pattern: self.lower_pattern(&field.pat),
|
||||
|
|
@ -675,35 +675,35 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
self.lower_variant_or_leaf(res, pat.hir_id, pat.span, ty, subpatterns)
|
||||
}
|
||||
|
||||
PatKind::Or(ref pats) => {
|
||||
PatternKind::Or {
|
||||
hir::PatKind::Or(ref pats) => {
|
||||
PatKind::Or {
|
||||
pats: pats.iter().map(|p| self.lower_pattern(p)).collect(),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Pattern {
|
||||
Pat {
|
||||
span: pat.span,
|
||||
ty,
|
||||
kind: Box::new(kind),
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_patterns(&mut self, pats: &'tcx [P<hir::Pat>]) -> Vec<Pattern<'tcx>> {
|
||||
fn lower_patterns(&mut self, pats: &'tcx [P<hir::Pat>]) -> Vec<Pat<'tcx>> {
|
||||
pats.iter().map(|p| self.lower_pattern(p)).collect()
|
||||
}
|
||||
|
||||
fn lower_opt_pattern(&mut self, pat: &'tcx Option<P<hir::Pat>>) -> Option<Pattern<'tcx>>
|
||||
fn lower_opt_pattern(&mut self, pat: &'tcx Option<P<hir::Pat>>) -> Option<Pat<'tcx>>
|
||||
{
|
||||
pat.as_ref().map(|p| self.lower_pattern(p))
|
||||
}
|
||||
|
||||
fn flatten_nested_slice_patterns(
|
||||
&mut self,
|
||||
prefix: Vec<Pattern<'tcx>>,
|
||||
slice: Option<Pattern<'tcx>>,
|
||||
suffix: Vec<Pattern<'tcx>>)
|
||||
-> (Vec<Pattern<'tcx>>, Option<Pattern<'tcx>>, Vec<Pattern<'tcx>>)
|
||||
prefix: Vec<Pat<'tcx>>,
|
||||
slice: Option<Pat<'tcx>>,
|
||||
suffix: Vec<Pat<'tcx>>)
|
||||
-> (Vec<Pat<'tcx>>, Option<Pat<'tcx>>, Vec<Pat<'tcx>>)
|
||||
{
|
||||
let orig_slice = match slice {
|
||||
Some(orig_slice) => orig_slice,
|
||||
|
|
@ -715,8 +715,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
// dance because of intentional borrow-checker stupidity.
|
||||
let kind = *orig_slice.kind;
|
||||
match kind {
|
||||
PatternKind::Slice { prefix, slice, mut suffix } |
|
||||
PatternKind::Array { prefix, slice, mut suffix } => {
|
||||
PatKind::Slice { prefix, slice, mut suffix } |
|
||||
PatKind::Array { prefix, slice, mut suffix } => {
|
||||
let mut orig_prefix = orig_prefix;
|
||||
|
||||
orig_prefix.extend(prefix);
|
||||
|
|
@ -725,7 +725,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
(orig_prefix, slice, suffix)
|
||||
}
|
||||
_ => {
|
||||
(orig_prefix, Some(Pattern {
|
||||
(orig_prefix, Some(Pat {
|
||||
kind: box kind, ..orig_slice
|
||||
}), orig_suffix)
|
||||
}
|
||||
|
|
@ -739,7 +739,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
prefix: &'tcx [P<hir::Pat>],
|
||||
slice: &'tcx Option<P<hir::Pat>>,
|
||||
suffix: &'tcx [P<hir::Pat>])
|
||||
-> PatternKind<'tcx>
|
||||
-> PatKind<'tcx>
|
||||
{
|
||||
let prefix = self.lower_patterns(prefix);
|
||||
let slice = self.lower_opt_pattern(slice);
|
||||
|
|
@ -750,14 +750,14 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
match ty.kind {
|
||||
ty::Slice(..) => {
|
||||
// matching a slice or fixed-length array
|
||||
PatternKind::Slice { prefix: prefix, slice: slice, suffix: suffix }
|
||||
PatKind::Slice { prefix: prefix, slice: slice, suffix: suffix }
|
||||
}
|
||||
|
||||
ty::Array(_, len) => {
|
||||
// fixed-length array
|
||||
let len = len.eval_usize(self.tcx, self.param_env);
|
||||
assert!(len >= prefix.len() as u64 + suffix.len() as u64);
|
||||
PatternKind::Array { prefix: prefix, slice: slice, suffix: suffix }
|
||||
PatKind::Array { prefix: prefix, slice: slice, suffix: suffix }
|
||||
}
|
||||
|
||||
_ => {
|
||||
|
|
@ -772,8 +772,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
hir_id: hir::HirId,
|
||||
span: Span,
|
||||
ty: Ty<'tcx>,
|
||||
subpatterns: Vec<FieldPattern<'tcx>>,
|
||||
) -> PatternKind<'tcx> {
|
||||
subpatterns: Vec<FieldPat<'tcx>>,
|
||||
) -> PatKind<'tcx> {
|
||||
let res = match res {
|
||||
Res::Def(DefKind::Ctor(CtorOf::Variant, ..), variant_ctor_id) => {
|
||||
let variant_id = self.tcx.parent(variant_ctor_id).unwrap();
|
||||
|
|
@ -791,18 +791,18 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
ty::Adt(_, substs) |
|
||||
ty::FnDef(_, substs) => substs,
|
||||
ty::Error => { // Avoid ICE (#50585)
|
||||
return PatternKind::Wild;
|
||||
return PatKind::Wild;
|
||||
}
|
||||
_ => bug!("inappropriate type for def: {:?}", ty),
|
||||
};
|
||||
PatternKind::Variant {
|
||||
PatKind::Variant {
|
||||
adt_def,
|
||||
substs,
|
||||
variant_index: adt_def.variant_index_with_id(variant_id),
|
||||
subpatterns,
|
||||
}
|
||||
} else {
|
||||
PatternKind::Leaf { subpatterns }
|
||||
PatKind::Leaf { subpatterns }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -813,25 +813,25 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
| Res::Def(DefKind::AssocTy, _)
|
||||
| Res::SelfTy(..)
|
||||
| Res::SelfCtor(..) => {
|
||||
PatternKind::Leaf { subpatterns }
|
||||
PatKind::Leaf { subpatterns }
|
||||
}
|
||||
|
||||
_ => {
|
||||
self.errors.push(PatternError::NonConstPath(span));
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) {
|
||||
debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span);
|
||||
kind = PatternKind::AscribeUserType {
|
||||
subpattern: Pattern {
|
||||
kind = PatKind::AscribeUserType {
|
||||
subpattern: Pat {
|
||||
span,
|
||||
ty,
|
||||
kind: Box::new(kind),
|
||||
},
|
||||
ascription: Ascription {
|
||||
user_ty: PatternTypeProjection::from_user_type(user_ty),
|
||||
user_ty: PatTyProj::from_user_type(user_ty),
|
||||
user_ty_span: span,
|
||||
variance: ty::Variance::Covariant,
|
||||
},
|
||||
|
|
@ -848,7 +848,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
qpath: &hir::QPath,
|
||||
id: hir::HirId,
|
||||
span: Span)
|
||||
-> Pattern<'tcx> {
|
||||
-> Pat<'tcx> {
|
||||
let ty = self.tables.node_type(id);
|
||||
let res = self.tables.qpath_res(qpath, id);
|
||||
let is_associated_const = match res {
|
||||
|
|
@ -878,11 +878,11 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
|
||||
let user_provided_types = self.tables().user_provided_types();
|
||||
return if let Some(u_ty) = user_provided_types.get(id) {
|
||||
let user_ty = PatternTypeProjection::from_user_type(*u_ty);
|
||||
Pattern {
|
||||
let user_ty = PatTyProj::from_user_type(*u_ty);
|
||||
Pat {
|
||||
span,
|
||||
kind: Box::new(
|
||||
PatternKind::AscribeUserType {
|
||||
PatKind::AscribeUserType {
|
||||
subpattern: pattern,
|
||||
ascription: Ascription {
|
||||
/// Note that use `Contravariant` here. See the
|
||||
|
|
@ -904,7 +904,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
span,
|
||||
"could not evaluate constant pattern",
|
||||
);
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -914,14 +914,14 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
} else {
|
||||
PatternError::StaticInPattern(span)
|
||||
});
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
},
|
||||
}
|
||||
}
|
||||
_ => self.lower_variant_or_leaf(res, id, span, ty, vec![]),
|
||||
};
|
||||
|
||||
Pattern {
|
||||
Pat {
|
||||
span,
|
||||
ty,
|
||||
kind: Box::new(kind),
|
||||
|
|
@ -932,8 +932,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
/// The special case for negation exists to allow things like `-128_i8`
|
||||
/// which would overflow if we tried to evaluate `128_i8` and then negate
|
||||
/// afterwards.
|
||||
fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatternKind<'tcx> {
|
||||
match expr.node {
|
||||
fn lower_lit(&mut self, expr: &'tcx hir::Expr) -> PatKind<'tcx> {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Lit(ref lit) => {
|
||||
let ty = self.tables.expr_ty(expr);
|
||||
match lit_to_const(&lit.node, self.tcx, ty, false) {
|
||||
|
|
@ -946,15 +946,15 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
},
|
||||
Err(LitToConstError::UnparseableFloat) => {
|
||||
self.errors.push(PatternError::FloatBug);
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
},
|
||||
Err(LitToConstError::Reported) => PatternKind::Wild,
|
||||
Err(LitToConstError::Reported) => PatKind::Wild,
|
||||
}
|
||||
},
|
||||
hir::ExprKind::Path(ref qpath) => *self.lower_path(qpath, expr.hir_id, expr.span).kind,
|
||||
hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
|
||||
let ty = self.tables.expr_ty(expr);
|
||||
let lit = match expr.node {
|
||||
let lit = match expr.kind {
|
||||
hir::ExprKind::Lit(ref lit) => lit,
|
||||
_ => span_bug!(expr.span, "not a literal: {:?}", expr),
|
||||
};
|
||||
|
|
@ -968,9 +968,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
},
|
||||
Err(LitToConstError::UnparseableFloat) => {
|
||||
self.errors.push(PatternError::FloatBug);
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
},
|
||||
Err(LitToConstError::Reported) => PatternKind::Wild,
|
||||
Err(LitToConstError::Reported) => PatKind::Wild,
|
||||
}
|
||||
}
|
||||
_ => span_bug!(expr.span, "not a literal: {:?}", expr),
|
||||
|
|
@ -986,7 +986,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
cv: &'tcx ty::Const<'tcx>,
|
||||
id: hir::HirId,
|
||||
span: Span,
|
||||
) -> Pattern<'tcx> {
|
||||
) -> Pat<'tcx> {
|
||||
// This method is just a warpper handling a validity check; the heavy lifting is
|
||||
// performed by the recursive const_to_pat_inner method, which is not meant to be
|
||||
// invoked except by this method.
|
||||
|
|
@ -1057,7 +1057,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
// value, so that we will not subsequently issue an irrelevant
|
||||
// lint for the same const value.
|
||||
saw_const_match_error: &mut bool,
|
||||
) -> Pattern<'tcx> {
|
||||
) -> Pat<'tcx> {
|
||||
|
||||
let mut adt_subpattern = |i, variant_opt| {
|
||||
let field = Field::new(i);
|
||||
|
|
@ -1069,7 +1069,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
let mut adt_subpatterns = |n, variant_opt| {
|
||||
(0..n).map(|i| {
|
||||
let field = Field::new(i);
|
||||
FieldPattern {
|
||||
FieldPat {
|
||||
field,
|
||||
pattern: adt_subpattern(i, variant_opt),
|
||||
}
|
||||
|
|
@ -1085,7 +1085,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
span,
|
||||
"floating-point types cannot be used in patterns",
|
||||
);
|
||||
PatternKind::Constant {
|
||||
PatKind::Constant {
|
||||
value: cv,
|
||||
}
|
||||
}
|
||||
|
|
@ -1093,7 +1093,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
// Matching on union fields is unsafe, we can't hide it in constants
|
||||
*saw_const_match_error = true;
|
||||
self.tcx.sess.span_err(span, "cannot use unions in constant patterns");
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
}
|
||||
// keep old code until future-compat upgraded to errors.
|
||||
ty::Adt(adt_def, _) if !self.tcx.has_attr(adt_def.did, sym::structural_match) => {
|
||||
|
|
@ -1106,13 +1106,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
);
|
||||
*saw_const_match_error = true;
|
||||
self.tcx.sess.span_err(span, &msg);
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
}
|
||||
// keep old code until future-compat upgraded to errors.
|
||||
ty::Ref(_, ty::TyS { kind: ty::Adt(adt_def, _), .. }, _)
|
||||
if !self.tcx.has_attr(adt_def.did, sym::structural_match) => {
|
||||
// HACK(estebank): Side-step ICE #53708, but anything other than erroring here
|
||||
// would be wrong. Returnging `PatternKind::Wild` is not technically correct.
|
||||
// would be wrong. Returnging `PatKind::Wild` is not technically correct.
|
||||
let path = self.tcx.def_path_str(adt_def.did);
|
||||
let msg = format!(
|
||||
"to use a constant of type `{}` in a pattern, \
|
||||
|
|
@ -1122,7 +1122,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
);
|
||||
*saw_const_match_error = true;
|
||||
self.tcx.sess.span_err(span, &msg);
|
||||
PatternKind::Wild
|
||||
PatKind::Wild
|
||||
}
|
||||
ty::Adt(adt_def, substs) if adt_def.is_enum() => {
|
||||
let variant_index = const_variant_index(self.tcx, self.param_env, cv);
|
||||
|
|
@ -1130,7 +1130,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
adt_def.variants[variant_index].fields.len(),
|
||||
Some(variant_index),
|
||||
);
|
||||
PatternKind::Variant {
|
||||
PatKind::Variant {
|
||||
adt_def,
|
||||
substs,
|
||||
variant_index,
|
||||
|
|
@ -1139,17 +1139,17 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
}
|
||||
ty::Adt(adt_def, _) => {
|
||||
let struct_var = adt_def.non_enum_variant();
|
||||
PatternKind::Leaf {
|
||||
PatKind::Leaf {
|
||||
subpatterns: adt_subpatterns(struct_var.fields.len(), None),
|
||||
}
|
||||
}
|
||||
ty::Tuple(fields) => {
|
||||
PatternKind::Leaf {
|
||||
PatKind::Leaf {
|
||||
subpatterns: adt_subpatterns(fields.len(), None),
|
||||
}
|
||||
}
|
||||
ty::Array(_, n) => {
|
||||
PatternKind::Array {
|
||||
PatKind::Array {
|
||||
prefix: (0..n.eval_usize(self.tcx, self.param_env))
|
||||
.map(|i| adt_subpattern(i as usize, None))
|
||||
.collect(),
|
||||
|
|
@ -1158,13 +1158,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
PatternKind::Constant {
|
||||
PatKind::Constant {
|
||||
value: cv,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Pattern {
|
||||
Pat {
|
||||
span,
|
||||
ty: cv.ty,
|
||||
kind: Box::new(kind),
|
||||
|
|
@ -1293,7 +1293,7 @@ fn search_for_adt_without_structural_match<'tcx>(tcx: TyCtxt<'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
impl UserAnnotatedTyHelpers<'tcx> for PatternContext<'_, 'tcx> {
|
||||
impl UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
|
@ -1313,11 +1313,11 @@ pub trait PatternFoldable<'tcx> : Sized {
|
|||
}
|
||||
|
||||
pub trait PatternFolder<'tcx> : Sized {
|
||||
fn fold_pattern(&mut self, pattern: &Pattern<'tcx>) -> Pattern<'tcx> {
|
||||
fn fold_pattern(&mut self, pattern: &Pat<'tcx>) -> Pat<'tcx> {
|
||||
pattern.super_fold_with(self)
|
||||
}
|
||||
|
||||
fn fold_pattern_kind(&mut self, kind: &PatternKind<'tcx>) -> PatternKind<'tcx> {
|
||||
fn fold_pattern_kind(&mut self, kind: &PatKind<'tcx>) -> PatKind<'tcx> {
|
||||
kind.super_fold_with(self)
|
||||
}
|
||||
}
|
||||
|
|
@ -1358,25 +1358,25 @@ CloneImpls!{ <'tcx>
|
|||
Span, Field, Mutability, ast::Name, hir::HirId, usize, ty::Const<'tcx>,
|
||||
Region<'tcx>, Ty<'tcx>, BindingMode, &'tcx AdtDef,
|
||||
SubstsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>,
|
||||
UserTypeProjection, PatternTypeProjection<'tcx>
|
||||
UserTypeProjection, PatTyProj<'tcx>
|
||||
}
|
||||
|
||||
impl<'tcx> PatternFoldable<'tcx> for FieldPattern<'tcx> {
|
||||
impl<'tcx> PatternFoldable<'tcx> for FieldPat<'tcx> {
|
||||
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||
FieldPattern {
|
||||
FieldPat {
|
||||
field: self.field.fold_with(folder),
|
||||
pattern: self.pattern.fold_with(folder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> PatternFoldable<'tcx> for Pattern<'tcx> {
|
||||
impl<'tcx> PatternFoldable<'tcx> for Pat<'tcx> {
|
||||
fn fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||
folder.fold_pattern(self)
|
||||
}
|
||||
|
||||
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||
Pattern {
|
||||
Pat {
|
||||
ty: self.ty.fold_with(folder),
|
||||
span: self.span.fold_with(folder),
|
||||
kind: self.kind.fold_with(folder)
|
||||
|
|
@ -1384,22 +1384,22 @@ impl<'tcx> PatternFoldable<'tcx> for Pattern<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> {
|
||||
impl<'tcx> PatternFoldable<'tcx> for PatKind<'tcx> {
|
||||
fn fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||
folder.fold_pattern_kind(self)
|
||||
}
|
||||
|
||||
fn super_fold_with<F: PatternFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||
match *self {
|
||||
PatternKind::Wild => PatternKind::Wild,
|
||||
PatternKind::AscribeUserType {
|
||||
PatKind::Wild => PatKind::Wild,
|
||||
PatKind::AscribeUserType {
|
||||
ref subpattern,
|
||||
ascription: Ascription {
|
||||
variance,
|
||||
ref user_ty,
|
||||
user_ty_span,
|
||||
},
|
||||
} => PatternKind::AscribeUserType {
|
||||
} => PatKind::AscribeUserType {
|
||||
subpattern: subpattern.fold_with(folder),
|
||||
ascription: Ascription {
|
||||
user_ty: user_ty.fold_with(folder),
|
||||
|
|
@ -1407,14 +1407,14 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> {
|
|||
user_ty_span,
|
||||
},
|
||||
},
|
||||
PatternKind::Binding {
|
||||
PatKind::Binding {
|
||||
mutability,
|
||||
name,
|
||||
mode,
|
||||
var,
|
||||
ty,
|
||||
ref subpattern,
|
||||
} => PatternKind::Binding {
|
||||
} => PatKind::Binding {
|
||||
mutability: mutability.fold_with(folder),
|
||||
name: name.fold_with(folder),
|
||||
mode: mode.fold_with(folder),
|
||||
|
|
@ -1422,52 +1422,52 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> {
|
|||
ty: ty.fold_with(folder),
|
||||
subpattern: subpattern.fold_with(folder),
|
||||
},
|
||||
PatternKind::Variant {
|
||||
PatKind::Variant {
|
||||
adt_def,
|
||||
substs,
|
||||
variant_index,
|
||||
ref subpatterns,
|
||||
} => PatternKind::Variant {
|
||||
} => PatKind::Variant {
|
||||
adt_def: adt_def.fold_with(folder),
|
||||
substs: substs.fold_with(folder),
|
||||
variant_index,
|
||||
subpatterns: subpatterns.fold_with(folder)
|
||||
},
|
||||
PatternKind::Leaf {
|
||||
PatKind::Leaf {
|
||||
ref subpatterns,
|
||||
} => PatternKind::Leaf {
|
||||
} => PatKind::Leaf {
|
||||
subpatterns: subpatterns.fold_with(folder),
|
||||
},
|
||||
PatternKind::Deref {
|
||||
PatKind::Deref {
|
||||
ref subpattern,
|
||||
} => PatternKind::Deref {
|
||||
} => PatKind::Deref {
|
||||
subpattern: subpattern.fold_with(folder),
|
||||
},
|
||||
PatternKind::Constant {
|
||||
PatKind::Constant {
|
||||
value
|
||||
} => PatternKind::Constant {
|
||||
} => PatKind::Constant {
|
||||
value,
|
||||
},
|
||||
PatternKind::Range(range) => PatternKind::Range(range),
|
||||
PatternKind::Slice {
|
||||
PatKind::Range(range) => PatKind::Range(range),
|
||||
PatKind::Slice {
|
||||
ref prefix,
|
||||
ref slice,
|
||||
ref suffix,
|
||||
} => PatternKind::Slice {
|
||||
} => PatKind::Slice {
|
||||
prefix: prefix.fold_with(folder),
|
||||
slice: slice.fold_with(folder),
|
||||
suffix: suffix.fold_with(folder)
|
||||
},
|
||||
PatternKind::Array {
|
||||
PatKind::Array {
|
||||
ref prefix,
|
||||
ref slice,
|
||||
ref suffix
|
||||
} => PatternKind::Array {
|
||||
} => PatKind::Array {
|
||||
prefix: prefix.fold_with(folder),
|
||||
slice: slice.fold_with(folder),
|
||||
suffix: suffix.fold_with(folder)
|
||||
},
|
||||
PatternKind::Or { ref pats } => PatternKind::Or { pats: pats.fold_with(folder) },
|
||||
PatKind::Or { ref pats } => PatKind::Or { pats: pats.fold_with(folder) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M
|
|||
if let Some((&var_hir_id, _)) = upvars.get_index(field) {
|
||||
let node = self.ecx.tcx.hir().get(var_hir_id);
|
||||
if let hir::Node::Binding(pat) = node {
|
||||
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
|
||||
if let hir::PatKind::Binding(_, _, ident, _) = pat.kind {
|
||||
name = Some(ident.name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -981,7 +981,7 @@ struct RootCollector<'a, 'tcx> {
|
|||
|
||||
impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
|
||||
fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::ExternCrate(..) |
|
||||
hir::ItemKind::Use(..) |
|
||||
hir::ItemKind::ForeignMod(..) |
|
||||
|
|
@ -1058,7 +1058,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
|
||||
match ii.node {
|
||||
match ii.kind {
|
||||
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
|
||||
let def_id = self.tcx.hir().local_def_id(ii.hir_id);
|
||||
self.push_if_root(def_id);
|
||||
|
|
@ -1141,7 +1141,7 @@ fn create_mono_items_for_default_impls<'tcx>(
|
|||
item: &'tcx hir::Item,
|
||||
output: &mut Vec<MonoItem<'tcx>>,
|
||||
) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Impl(_, _, _, ref generics, .., ref impl_item_refs) => {
|
||||
for param in &generics.params {
|
||||
match param.kind {
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ fn is_enclosed(
|
|||
if used_unsafe.contains(&parent_id) {
|
||||
Some(("block".to_string(), parent_id))
|
||||
} else if let Some(Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Fn(_, header, _, _),
|
||||
kind: hir::ItemKind::Fn(_, header, _, _),
|
||||
..
|
||||
})) = tcx.hir().find(parent_id) {
|
||||
match header.unsafety {
|
||||
|
|
|
|||
|
|
@ -1768,7 +1768,7 @@ fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<FxHashSet<usize
|
|||
let attr = attrs.iter().find(|a| a.check_name(sym::rustc_args_required_const))?;
|
||||
let mut ret = FxHashSet::default();
|
||||
for meta in attr.meta_item_list()? {
|
||||
match meta.literal()?.node {
|
||||
match meta.literal()?.kind {
|
||||
LitKind::Int(a, _) => { ret.insert(a as usize); }
|
||||
_ => return None,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ impl<'a> AstValidator<'a> {
|
|||
// rust-lang/rust#57979: bug in old `visit_generic_args` called
|
||||
// `walk_ty` rather than `visit_ty`, skipping outer `impl Trait`
|
||||
// if it happened to occur at `ty`.
|
||||
if let TyKind::ImplTrait(..) = ty.node {
|
||||
if let TyKind::ImplTrait(..) = ty.kind {
|
||||
self.warning_period_57979_didnt_record_next_impl_trait = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ impl<'a> AstValidator<'a> {
|
|||
// rust-lang/rust#57979: bug in old `visit_generic_args` called
|
||||
// `walk_ty` rather than `visit_ty`, skippping outer `impl Trait`
|
||||
// if it happened to occur at `ty`.
|
||||
if let TyKind::ImplTrait(..) = ty.node {
|
||||
if let TyKind::ImplTrait(..) = ty.kind {
|
||||
self.warning_period_57979_didnt_record_next_impl_trait = true;
|
||||
}
|
||||
self.visit_ty(ty);
|
||||
|
|
@ -149,7 +149,7 @@ impl<'a> AstValidator<'a> {
|
|||
|
||||
// Mirrors `visit::walk_ty`, but tracks relevant state.
|
||||
fn walk_ty(&mut self, t: &'a Ty) {
|
||||
match t.node {
|
||||
match t.kind {
|
||||
TyKind::ImplTrait(..) => {
|
||||
let outer_impl_trait = self.outer_impl_trait(t.span);
|
||||
self.with_impl_trait(Some(outer_impl_trait), |this| visit::walk_ty(this, t))
|
||||
|
|
@ -231,7 +231,7 @@ impl<'a> AstValidator<'a> {
|
|||
|
||||
fn check_decl_no_pat<ReportFn: Fn(Span, bool)>(&self, decl: &FnDecl, report_err: ReportFn) {
|
||||
for arg in &decl.inputs {
|
||||
match arg.pat.node {
|
||||
match arg.pat.kind {
|
||||
PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), _, None) |
|
||||
PatKind::Wild => {}
|
||||
PatKind::Ident(BindingMode::ByValue(Mutability::Mutable), _, None) =>
|
||||
|
|
@ -286,11 +286,11 @@ impl<'a> AstValidator<'a> {
|
|||
// m!(S);
|
||||
// ```
|
||||
fn check_expr_within_pat(&self, expr: &Expr, allow_paths: bool) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
ExprKind::Lit(..) | ExprKind::Err => {}
|
||||
ExprKind::Path(..) if allow_paths => {}
|
||||
ExprKind::Unary(UnOp::Neg, ref inner)
|
||||
if match inner.node { ExprKind::Lit(_) => true, _ => false } => {}
|
||||
if match inner.kind { ExprKind::Lit(_) => true, _ => false } => {}
|
||||
_ => self.err_handler().span_err(expr.span, "arbitrary expressions aren't allowed \
|
||||
in patterns")
|
||||
}
|
||||
|
|
@ -442,7 +442,7 @@ fn validate_generics_order<'a>(
|
|||
|
||||
impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
fn visit_expr(&mut self, expr: &'a Expr) {
|
||||
match &expr.node {
|
||||
match &expr.kind {
|
||||
ExprKind::Closure(_, _, _, fn_decl, _, _) => {
|
||||
self.check_fn_decl(fn_decl);
|
||||
}
|
||||
|
|
@ -456,7 +456,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'a Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
TyKind::BareFn(ref bfty) => {
|
||||
self.check_fn_decl(&bfty.decl);
|
||||
self.check_decl_no_pat(&bfty.decl, |span, _| {
|
||||
|
|
@ -538,10 +538,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
self.has_proc_macro_decls = true;
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Impl(unsafety, polarity, _, _, Some(..), ref ty, ref impl_items) => {
|
||||
self.invalid_visibility(&item.vis, None);
|
||||
if let TyKind::Err = ty.node {
|
||||
if let TyKind::Err = ty.kind {
|
||||
self.err_handler()
|
||||
.struct_span_err(item.span, "`impl Trait for .. {}` is an obsolete syntax")
|
||||
.help("use `auto trait Trait {}` instead").emit();
|
||||
|
|
@ -551,7 +551,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
for impl_item in impl_items {
|
||||
self.invalid_visibility(&impl_item.vis, None);
|
||||
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
|
||||
if let ImplItemKind::Method(ref sig, _) = impl_item.kind {
|
||||
self.check_trait_fn_not_const(sig.header.constness);
|
||||
self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node);
|
||||
}
|
||||
|
|
@ -628,7 +628,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
self.no_questions_in_bounds(bounds, "supertraits", true);
|
||||
for trait_item in trait_items {
|
||||
if let TraitItemKind::Method(ref sig, ref block) = trait_item.node {
|
||||
if let TraitItemKind::Method(ref sig, ref block) = trait_item.kind {
|
||||
self.check_fn_decl(&sig.decl);
|
||||
self.check_trait_fn_not_async(trait_item.span, sig.header.asyncness.node);
|
||||
self.check_trait_fn_not_const(sig.header.constness);
|
||||
|
|
@ -682,7 +682,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
|
||||
match fi.node {
|
||||
match fi.kind {
|
||||
ForeignItemKind::Fn(ref decl, _) => {
|
||||
self.check_fn_decl(decl);
|
||||
self.check_decl_no_pat(decl, |span, _| {
|
||||
|
|
@ -786,7 +786,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &'a Pat) {
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Lit(ref expr) => {
|
||||
self.check_expr_within_pat(expr, false);
|
||||
}
|
||||
|
|
@ -832,11 +832,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
|
||||
match ii.node {
|
||||
ImplItemKind::Method(ref sig, _) => {
|
||||
self.check_fn_decl(&sig.decl);
|
||||
}
|
||||
_ => {}
|
||||
if let ImplItemKind::Method(ref sig, _) = ii.kind {
|
||||
self.check_fn_decl(&sig.decl);
|
||||
}
|
||||
visit::walk_impl_item(self, ii);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl ItemLikeVisitor<'tcx> for VarianceTest<'tcx> {
|
|||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let item_def_id = self.tcx.hir().local_def_id(item.hir_id);
|
||||
|
||||
if let ItemKind::TyAlias(..) = item.node {
|
||||
if let ItemKind::TyAlias(..) = item.kind {
|
||||
for attr in self.tcx.get_attrs(item_def_id).iter() {
|
||||
if attr.check_name(sym::rustc_layout) {
|
||||
self.dump_layout_of(item_def_id, item, attr);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &'hir hir::Expr) {
|
||||
match e.node {
|
||||
match e.kind {
|
||||
hir::ExprKind::Loop(ref b, _, source) => {
|
||||
self.with_context(Loop(source), |v| v.visit_block(&b));
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
|||
let loop_kind = if loop_id == hir::DUMMY_HIR_ID {
|
||||
None
|
||||
} else {
|
||||
Some(match self.hir_map.expect_expr(loop_id).node {
|
||||
Some(match self.hir_map.expect_expr(loop_id).kind {
|
||||
hir::ExprKind::Loop(_, _, source) => source,
|
||||
ref r => span_bug!(e.span,
|
||||
"break label resolved to a non-loop: {:?}", r),
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability {
|
||||
match stmt.node {
|
||||
match stmt.kind {
|
||||
hir::StmtKind::Local(ref local) => {
|
||||
if self.remove_mut_rvalue_borrow(&local.pat) {
|
||||
if let Some(init) = &local.init {
|
||||
|
|
@ -280,7 +280,7 @@ fn check_expr_kind<'a, 'tcx>(
|
|||
_ => Promotable
|
||||
};
|
||||
|
||||
let node_result = match e.node {
|
||||
let kind_result = match e.kind {
|
||||
hir::ExprKind::Box(ref expr) => {
|
||||
let _ = v.check_expr(&expr);
|
||||
NotPromotable
|
||||
|
|
@ -376,7 +376,7 @@ fn check_expr_kind<'a, 'tcx>(
|
|||
}
|
||||
let mut callee = &**callee;
|
||||
loop {
|
||||
callee = match callee.node {
|
||||
callee = match callee.kind {
|
||||
hir::ExprKind::Block(ref block, _) => match block.expr {
|
||||
Some(ref tail) => &tail,
|
||||
None => break
|
||||
|
|
@ -385,7 +385,7 @@ fn check_expr_kind<'a, 'tcx>(
|
|||
};
|
||||
}
|
||||
// The callee is an arbitrary expression, it doesn't necessarily have a definition.
|
||||
let def = if let hir::ExprKind::Path(ref qpath) = callee.node {
|
||||
let def = if let hir::ExprKind::Path(ref qpath) = callee.kind {
|
||||
v.tables.qpath_res(qpath, callee.hir_id)
|
||||
} else {
|
||||
Res::Err
|
||||
|
|
@ -553,7 +553,7 @@ fn check_expr_kind<'a, 'tcx>(
|
|||
NotPromotable
|
||||
}
|
||||
};
|
||||
ty_result & node_result
|
||||
ty_result & kind_result
|
||||
}
|
||||
|
||||
/// Checks the adjustments of an expression.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ struct RegistrarFinder {
|
|||
|
||||
impl<'v> ItemLikeVisitor<'v> for RegistrarFinder {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
if let hir::ItemKind::Fn(..) = item.node {
|
||||
if let hir::ItemKind::Fn(..) = item.kind {
|
||||
if attr::contains_name(&item.attrs, sym::plugin_registrar) {
|
||||
self.registrars.push((item.hir_id, item.span));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ fn def_id_visibility<'tcx>(
|
|||
}
|
||||
Node::ImplItem(impl_item) => {
|
||||
match tcx.hir().get(tcx.hir().get_parent_item(hir_id)) {
|
||||
Node::Item(item) => match &item.node {
|
||||
Node::Item(item) => match &item.kind {
|
||||
hir::ItemKind::Impl(.., None, _, _) => &impl_item.vis,
|
||||
hir::ItemKind::Impl(.., Some(trait_ref), _, _)
|
||||
=> return def_id_visibility(tcx, trait_ref.path.res.def_id()),
|
||||
|
|
@ -572,7 +572,7 @@ impl EmbargoVisitor<'tcx> {
|
|||
if let ty::Visibility::Public = vis {
|
||||
let item = self.tcx.hir().expect_item(hir_id);
|
||||
if let hir::ItemKind::Struct(ref struct_def, _)
|
||||
| hir::ItemKind::Union(ref struct_def, _) = item.node
|
||||
| hir::ItemKind::Union(ref struct_def, _) = item.kind
|
||||
{
|
||||
for field in struct_def.fields() {
|
||||
let field_vis = ty::Visibility::from_hir(
|
||||
|
|
@ -630,12 +630,12 @@ impl EmbargoVisitor<'tcx> {
|
|||
.and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id))
|
||||
.map(|module_hir_id| self.tcx.hir().expect_item(module_hir_id))
|
||||
{
|
||||
if let hir::ItemKind::Mod(m) = &item.node {
|
||||
if let hir::ItemKind::Mod(m) = &item.kind {
|
||||
for item_id in m.item_ids.as_ref() {
|
||||
let item = self.tcx.hir().expect_item(item_id.id);
|
||||
let def_id = self.tcx.hir().local_def_id(item_id.id);
|
||||
if !self.tcx.hygienic_eq(segment.ident, item.ident, def_id) { continue; }
|
||||
if let hir::ItemKind::Use(..) = item.node {
|
||||
if let hir::ItemKind::Use(..) = item.kind {
|
||||
self.update(item.hir_id, Some(AccessLevel::Exported));
|
||||
}
|
||||
}
|
||||
|
|
@ -653,7 +653,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let inherited_item_level = match item.node {
|
||||
let inherited_item_level = match item.kind {
|
||||
hir::ItemKind::Impl(..) =>
|
||||
Option::<AccessLevel>::of_impl(item.hir_id, self.tcx, &self.access_levels),
|
||||
// Foreign modules inherit level from parents.
|
||||
|
|
@ -673,7 +673,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
|||
let item_level = self.update(item.hir_id, inherited_item_level);
|
||||
|
||||
// Update levels of nested things.
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::ItemKind::Enum(ref def, _) => {
|
||||
for variant in &def.variants {
|
||||
let variant_level = self.update(variant.id, item_level);
|
||||
|
|
@ -727,7 +727,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
|||
}
|
||||
|
||||
// Mark all items in interfaces of reachable items as reachable.
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// The interface is empty.
|
||||
hir::ItemKind::ExternCrate(..) => {}
|
||||
// All nested items are checked by `visit_item`.
|
||||
|
|
@ -1028,7 +1028,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Struct(ref qpath, ref fields, ref base) => {
|
||||
let res = self.tables.qpath_res(qpath, expr.hir_id);
|
||||
let adt = self.tables.expr_ty(expr).ty_adt_def().unwrap();
|
||||
|
|
@ -1062,7 +1062,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Struct(ref qpath, ref fields, _) => {
|
||||
let res = self.tables.qpath_res(qpath, pat.hir_id);
|
||||
let adt = self.tables.pat_ty(pat).ty_adt_def().unwrap();
|
||||
|
|
@ -1197,7 +1197,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
|
|||
// Do not check nested expressions if the error already happened.
|
||||
return;
|
||||
}
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
hir::ExprKind::Assign(.., ref rhs) | hir::ExprKind::Match(ref rhs, ..) => {
|
||||
// Do not report duplicate errors for `x = y` and `match x { ... }`.
|
||||
if self.check_expr_pat_type(rhs.hir_id, rhs.span) {
|
||||
|
|
@ -1389,14 +1389,14 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &hir::Ty) {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = ty.node {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = ty.kind {
|
||||
if self.inner.path_is_private_type(path) {
|
||||
self.contains_private = true;
|
||||
// Found what we're looking for, so let's stop working.
|
||||
return
|
||||
}
|
||||
}
|
||||
if let hir::TyKind::Path(_) = ty.node {
|
||||
if let hir::TyKind::Path(_) = ty.kind {
|
||||
if self.at_outer_type {
|
||||
self.outer_type_is_public_path = true;
|
||||
}
|
||||
|
|
@ -1417,7 +1417,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// Contents of a private mod can be re-exported, so we need
|
||||
// to check internals.
|
||||
hir::ItemKind::Mod(_) => {}
|
||||
|
|
@ -1489,7 +1489,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
impl_item_refs.iter()
|
||||
.any(|impl_item_ref| {
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
match impl_item.node {
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..) => {
|
||||
self.access_levels.is_reachable(
|
||||
|
|
@ -1515,7 +1515,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
// don't erroneously report errors for private
|
||||
// types in private items.
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
match impl_item.node {
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(..) |
|
||||
hir::ImplItemKind::Method(..)
|
||||
if self.item_is_public(&impl_item.hir_id, &impl_item.vis) =>
|
||||
|
|
@ -1548,7 +1548,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
// Those in 3. are warned with this call.
|
||||
for impl_item_ref in impl_item_refs {
|
||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||
if let hir::ImplItemKind::TyAlias(ref ty) = impl_item.node {
|
||||
if let hir::ImplItemKind::TyAlias(ref ty) = impl_item.kind {
|
||||
self.visit_ty(ty);
|
||||
}
|
||||
}
|
||||
|
|
@ -1628,7 +1628,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_ty(&mut self, t: &'tcx hir::Ty) {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.node {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.kind {
|
||||
if self.path_is_private_type(path) {
|
||||
self.old_error_set.insert(t.hir_id);
|
||||
}
|
||||
|
|
@ -1853,7 +1853,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
|||
let tcx = self.tcx;
|
||||
let item_visibility = ty::Visibility::from_hir(&item.vis, item.hir_id, tcx);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
// Crates are always public.
|
||||
hir::ItemKind::ExternCrate(..) => {}
|
||||
// All nested items are checked by `visit_item`.
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
|
||||
fn block_needs_anonymous_module(&mut self, block: &Block) -> bool {
|
||||
// If any statements are items, we need to create an anonymous module
|
||||
block.stmts.iter().any(|statement| match statement.node {
|
||||
block.stmts.iter().any(|statement| match statement.kind {
|
||||
StmtKind::Item(_) | StmtKind::Mac(_) => true,
|
||||
_ => false,
|
||||
})
|
||||
|
|
@ -588,7 +588,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
let sp = item.span;
|
||||
let vis = self.resolve_visibility(&item.vis);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Use(ref use_tree) => {
|
||||
self.build_reduced_graph_for_use_tree(
|
||||
// This particular use tree
|
||||
|
|
@ -813,7 +813,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
|
||||
/// Constructs the reduced graph for one foreign item.
|
||||
fn build_reduced_graph_for_foreign_item(&mut self, item: &ForeignItem) {
|
||||
let (res, ns) = match item.node {
|
||||
let (res, ns) = match item.kind {
|
||||
ForeignItemKind::Fn(..) => {
|
||||
(Res::Def(DefKind::Fn, self.r.definitions.local_def_id(item.id)), ValueNS)
|
||||
}
|
||||
|
|
@ -936,7 +936,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
span_err!(self.r.session, item.span, E0468,
|
||||
"an `extern crate` loading macros must be at the crate root");
|
||||
}
|
||||
if let ItemKind::ExternCrate(Some(orig_name)) = item.node {
|
||||
if let ItemKind::ExternCrate(Some(orig_name)) = item.kind {
|
||||
if orig_name == kw::SelfLower {
|
||||
self.r.session.span_err(attr.span,
|
||||
"`macro_use` is not supported on `extern crate self`");
|
||||
|
|
@ -944,7 +944,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
}
|
||||
let ill_formed = |span| span_err!(self.r.session, span, E0466, "bad macro import");
|
||||
match attr.meta() {
|
||||
Some(meta) => match meta.node {
|
||||
Some(meta) => match meta.kind {
|
||||
MetaItemKind::Word => {
|
||||
import_all = Some(meta.span);
|
||||
break;
|
||||
|
|
@ -1064,7 +1064,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
fn define_macro(&mut self, item: &ast::Item) -> LegacyScope<'a> {
|
||||
let parent_scope = &self.parent_scope;
|
||||
let expansion = parent_scope.expansion;
|
||||
let (ext, ident, span, is_legacy) = match &item.node {
|
||||
let (ext, ident, span, is_legacy) = match &item.kind {
|
||||
ItemKind::MacroDef(def) => {
|
||||
let ext = Lrc::new(self.r.compile_macro(item, self.r.session.edition()));
|
||||
(ext, item.ident, item.span, def.legacy)
|
||||
|
|
@ -1122,7 +1122,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
macro_rules! method {
|
||||
($visit:ident: $ty:ty, $invoc:path, $walk:ident) => {
|
||||
fn $visit(&mut self, node: &'b $ty) {
|
||||
if let $invoc(..) = node.node {
|
||||
if let $invoc(..) = node.kind {
|
||||
self.visit_invoc(node.id);
|
||||
} else {
|
||||
visit::$walk(self, node);
|
||||
|
|
@ -1138,7 +1138,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
|||
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty);
|
||||
|
||||
fn visit_item(&mut self, item: &'b Item) {
|
||||
let macro_use = match item.node {
|
||||
let macro_use = match item.kind {
|
||||
ItemKind::MacroDef(..) => {
|
||||
self.parent_scope.legacy = self.define_macro(item);
|
||||
return
|
||||
|
|
@ -1161,7 +1161,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
|||
}
|
||||
|
||||
fn visit_stmt(&mut self, stmt: &'b ast::Stmt) {
|
||||
if let ast::StmtKind::Mac(..) = stmt.node {
|
||||
if let ast::StmtKind::Mac(..) = stmt.kind {
|
||||
self.parent_scope.legacy = self.visit_invoc(stmt.id);
|
||||
} else {
|
||||
visit::walk_stmt(self, stmt);
|
||||
|
|
@ -1169,7 +1169,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
|||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, foreign_item: &'b ForeignItem) {
|
||||
if let ForeignItemKind::Macro(_) = foreign_item.node {
|
||||
if let ForeignItemKind::Macro(_) = foreign_item.kind {
|
||||
self.visit_invoc(foreign_item.id);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1190,14 +1190,14 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
|||
fn visit_trait_item(&mut self, item: &'b TraitItem) {
|
||||
let parent = self.parent_scope.module;
|
||||
|
||||
if let TraitItemKind::Macro(_) = item.node {
|
||||
if let TraitItemKind::Macro(_) = item.kind {
|
||||
self.visit_invoc(item.id);
|
||||
return
|
||||
}
|
||||
|
||||
// Add the item to the trait info.
|
||||
let item_def_id = self.r.definitions.local_def_id(item.id);
|
||||
let (res, ns) = match item.node {
|
||||
let (res, ns) = match item.kind {
|
||||
TraitItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
|
||||
TraitItemKind::Method(ref sig, _) => {
|
||||
if sig.decl.has_self() {
|
||||
|
|
@ -1219,7 +1219,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
|||
fn visit_token(&mut self, t: Token) {
|
||||
if let token::Interpolated(nt) = t.kind {
|
||||
if let token::NtExpr(ref expr) = *nt {
|
||||
if let ast::ExprKind::Mac(..) = expr.node {
|
||||
if let ast::ExprKind::Mac(..) = expr.kind {
|
||||
self.visit_invoc(expr.id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ impl<'a, 'b> Visitor<'a> for UnusedImportCheckVisitor<'a, 'b> {
|
|||
// whether they're used or not. Also ignore imports with a dummy span
|
||||
// because this means that they were generated in some fashion by the
|
||||
// compiler and we don't need to consider them.
|
||||
if let ast::ItemKind::Use(..) = item.node {
|
||||
if let ast::ItemKind::Use(..) = item.kind {
|
||||
if item.vis.node.is_pub() || item.span.is_dummy() {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ impl<'a> PathSource<'a> {
|
|||
ValueNS => "method or associated constant",
|
||||
MacroNS => bug!("associated macro"),
|
||||
},
|
||||
PathSource::Expr(parent) => match parent.map(|p| &p.node) {
|
||||
PathSource::Expr(parent) => match parent.map(|p| &p.kind) {
|
||||
// "function" here means "anything callable" rather than `DefKind::Fn`,
|
||||
// this is not precise but usually more helpful than just "value".
|
||||
Some(&ExprKind::Call(..)) => "function",
|
||||
|
|
@ -384,7 +384,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
|
|||
self.resolve_local(local);
|
||||
}
|
||||
fn visit_ty(&mut self, ty: &'tcx Ty) {
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
TyKind::Path(ref qself, ref path) => {
|
||||
self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type);
|
||||
}
|
||||
|
|
@ -406,7 +406,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LateResolutionVisitor<'a, '_> {
|
|||
visit::walk_poly_trait_ref(self, tref, m);
|
||||
}
|
||||
fn visit_foreign_item(&mut self, foreign_item: &'tcx ForeignItem) {
|
||||
let generic_params = match foreign_item.node {
|
||||
let generic_params = match foreign_item.kind {
|
||||
ForeignItemKind::Fn(_, ref generics) => {
|
||||
HasGenericParams(generics, ItemRibKind)
|
||||
}
|
||||
|
|
@ -700,9 +700,9 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
|
||||
fn resolve_item(&mut self, item: &Item) {
|
||||
let name = item.ident.name;
|
||||
debug!("(resolving item) resolving {} ({:?})", name, item.node);
|
||||
debug!("(resolving item) resolving {} ({:?})", name, item.kind);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::TyAlias(_, ref generics) |
|
||||
ItemKind::OpaqueTy(_, ref generics) |
|
||||
ItemKind::Fn(_, _, ref generics, _) => {
|
||||
|
|
@ -740,7 +740,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
AssocItemRibKind,
|
||||
);
|
||||
this.with_generic_param_rib(generic_params, |this| {
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
TraitItemKind::Const(ref ty, ref default) => {
|
||||
this.visit_ty(ty);
|
||||
|
||||
|
|
@ -938,7 +938,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
) -> T {
|
||||
let trait_assoc_types = replace(
|
||||
&mut self.current_trait_assoc_types,
|
||||
trait_items.iter().filter_map(|item| match &item.node {
|
||||
trait_items.iter().filter_map(|item| match &item.kind {
|
||||
TraitItemKind::Type(bounds, _) if bounds.len() == 0 => Some(item.ident),
|
||||
_ => None,
|
||||
}).collect(),
|
||||
|
|
@ -1035,7 +1035,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
AssocItemRibKind);
|
||||
this.with_generic_param_rib(generic_params, |this| {
|
||||
use crate::ResolutionError::*;
|
||||
match impl_item.node {
|
||||
match impl_item.kind {
|
||||
ImplItemKind::Const(..) => {
|
||||
debug!(
|
||||
"resolve_implementation ImplItemKind::Const",
|
||||
|
|
@ -1146,7 +1146,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
let mut binding_map = FxHashMap::default();
|
||||
|
||||
pat.walk(&mut |pat| {
|
||||
match pat.node {
|
||||
match pat.kind {
|
||||
PatKind::Ident(binding_mode, ident, ref sub_pat)
|
||||
if sub_pat.is_some() || self.is_base_res_local(pat.id) =>
|
||||
{
|
||||
|
|
@ -1246,7 +1246,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
|
||||
/// Check the consistency of the outermost or-patterns.
|
||||
fn check_consistent_bindings_top(&mut self, pat: &Pat) {
|
||||
pat.walk(&mut |pat| match pat.node {
|
||||
pat.walk(&mut |pat| match pat.kind {
|
||||
PatKind::Or(ref ps) => {
|
||||
self.check_consistent_bindings(ps);
|
||||
false
|
||||
|
|
@ -1308,8 +1308,8 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
) {
|
||||
// Visit all direct subpatterns of this pattern.
|
||||
pat.walk(&mut |pat| {
|
||||
debug!("resolve_pattern pat={:?} node={:?}", pat, pat.node);
|
||||
match pat.node {
|
||||
debug!("resolve_pattern pat={:?} node={:?}", pat, pat.kind);
|
||||
match pat.kind {
|
||||
PatKind::Ident(bmode, ident, ref sub) => {
|
||||
// First try to resolve the identifier as some existing entity,
|
||||
// then fall back to a fresh binding.
|
||||
|
|
@ -1804,8 +1804,8 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
|
||||
// Descend into the block.
|
||||
for stmt in &block.stmts {
|
||||
if let StmtKind::Item(ref item) = stmt.node {
|
||||
if let ItemKind::MacroDef(..) = item.node {
|
||||
if let StmtKind::Item(ref item) = stmt.kind {
|
||||
if let ItemKind::MacroDef(..) = item.kind {
|
||||
num_macro_definition_ribs += 1;
|
||||
let res = self.r.definitions.local_def_id(item.id);
|
||||
self.ribs[ValueNS].push(Rib::new(MacroDefinition(res)));
|
||||
|
|
@ -1836,7 +1836,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
self.record_candidate_traits_for_expr_if_necessary(expr);
|
||||
|
||||
// Next, resolve the node.
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
ExprKind::Path(ref qself, ref path) => {
|
||||
self.smart_resolve_path(expr.id, qself.as_ref(), path, PathSource::Expr(parent));
|
||||
visit::walk_expr(self, expr);
|
||||
|
|
@ -1968,7 +1968,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
|||
}
|
||||
|
||||
fn record_candidate_traits_for_expr_if_necessary(&mut self, expr: &Expr) {
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
ExprKind::Field(_, ident) => {
|
||||
// FIXME(#6890): Even though you can't treat a method like a
|
||||
// field, we need to add any trait methods we find that match
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ impl<'a> LateResolutionVisitor<'a, '_> {
|
|||
let ns = source.namespace();
|
||||
let is_expected = &|res| source.is_expected(res);
|
||||
|
||||
let path_sep = |err: &mut DiagnosticBuilder<'_>, expr: &Expr| match expr.node {
|
||||
let path_sep = |err: &mut DiagnosticBuilder<'_>, expr: &Expr| match expr.kind {
|
||||
ExprKind::Field(_, ident) => {
|
||||
err.span_suggestion(
|
||||
expr.span,
|
||||
|
|
@ -472,7 +472,7 @@ impl<'a> LateResolutionVisitor<'a, '_> {
|
|||
where FilterFn: Fn(Res) -> bool
|
||||
{
|
||||
fn extract_node_id(t: &Ty) -> Option<NodeId> {
|
||||
match t.node {
|
||||
match t.kind {
|
||||
TyKind::Path(None, _) => Some(t.id),
|
||||
TyKind::Rptr(_, ref mut_ty) => extract_node_id(&mut_ty.ty),
|
||||
// This doesn't handle the remaining `Ty` variants as they are not
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ impl<'tcx> Visitor<'tcx> for UsePlacementFinder {
|
|||
}
|
||||
// find a use statement
|
||||
for item in &module.items {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ItemKind::Use(..) => {
|
||||
// don't suggest placing a use before the prelude
|
||||
// import or other generated ones
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
|||
}
|
||||
|
||||
if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output {
|
||||
if let ast::TyKind::ImplTrait(..) = ret_ty.node {
|
||||
if let ast::TyKind::ImplTrait(..) = ret_ty.kind {
|
||||
// FIXME: Opaque type desugaring prevents us from easily
|
||||
// processing trait bounds. See `visit_ty` for more details.
|
||||
} else {
|
||||
|
|
@ -472,13 +472,13 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
|||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
|
||||
let kind = match item.node {
|
||||
let kind = match item.kind {
|
||||
ast::ItemKind::Struct(_, _) => DefKind::Struct,
|
||||
ast::ItemKind::Union(_, _) => DefKind::Union,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let (value, fields) = match item.node {
|
||||
let (value, fields) = match item.kind {
|
||||
ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, ..), ..) |
|
||||
ast::ItemKind::Union(ast::VariantData::Struct(ref fields, ..), ..) => {
|
||||
let include_priv_fields = !self.save_ctxt.config.pub_only;
|
||||
|
|
@ -864,7 +864,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
|||
}
|
||||
|
||||
fn process_pat(&mut self, p: &'l ast::Pat) {
|
||||
match p.node {
|
||||
match p.kind {
|
||||
PatKind::Struct(ref _path, ref fields, _) => {
|
||||
// FIXME do something with _path?
|
||||
let hir_id = self.tcx.hir().node_to_hir_id(p.id);
|
||||
|
|
@ -1007,7 +1007,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
|||
fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId) {
|
||||
self.process_macro_use(trait_item.span);
|
||||
let vis_span = trait_item.span.shrink_to_lo();
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
ast::TraitItemKind::Const(ref ty, ref expr) => {
|
||||
self.process_assoc_const(
|
||||
trait_item.id,
|
||||
|
|
@ -1078,7 +1078,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
|||
|
||||
fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) {
|
||||
self.process_macro_use(impl_item.span);
|
||||
match impl_item.node {
|
||||
match impl_item.kind {
|
||||
ast::ImplItemKind::Const(ref ty, ref expr) => {
|
||||
self.process_assoc_const(
|
||||
impl_item.id,
|
||||
|
|
@ -1276,7 +1276,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
|
|||
fn visit_item(&mut self, item: &'l ast::Item) {
|
||||
use syntax::ast::ItemKind::*;
|
||||
self.process_macro_use(item.span);
|
||||
match item.node {
|
||||
match item.kind {
|
||||
Use(ref use_tree) => {
|
||||
let prefix = ast::Path {
|
||||
segments: vec![],
|
||||
|
|
@ -1421,7 +1421,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
|
|||
|
||||
fn visit_ty(&mut self, t: &'l ast::Ty) {
|
||||
self.process_macro_use(t.span);
|
||||
match t.node {
|
||||
match t.kind {
|
||||
ast::TyKind::Path(_, ref path) => {
|
||||
if generated_code(t.span) {
|
||||
return;
|
||||
|
|
@ -1461,9 +1461,9 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, ex: &'l ast::Expr) {
|
||||
debug!("visit_expr {:?}", ex.node);
|
||||
debug!("visit_expr {:?}", ex.kind);
|
||||
self.process_macro_use(ex.span);
|
||||
match ex.node {
|
||||
match ex.kind {
|
||||
ast::ExprKind::Struct(ref path, ref fields, ref base) => {
|
||||
let expr_hir_id = self.save_ctxt.tcx.hir().node_to_hir_id(ex.id);
|
||||
let hir_expr = self.save_ctxt.tcx.hir().expect_expr(expr_hir_id);
|
||||
|
|
@ -1509,7 +1509,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
|
|||
}
|
||||
ast::ExprKind::ForLoop(ref pattern, ref subexpression, ref block, _) => {
|
||||
self.process_var_decl(pattern);
|
||||
debug!("for loop, walk sub-expr: {:?}", subexpression.node);
|
||||
debug!("for loop, walk sub-expr: {:?}", subexpression.kind);
|
||||
self.visit_expr(subexpression);
|
||||
visit::walk_block(self, block);
|
||||
}
|
||||
|
|
@ -1570,7 +1570,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
|
|||
let hir_id = self.tcx.hir().node_to_hir_id(item.id);
|
||||
let access = access_from!(self.save_ctxt, item, hir_id);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ForeignItemKind::Fn(ref decl, ref generics) => {
|
||||
if let Some(fn_data) = self.save_ctxt.get_extern_item_data(item) {
|
||||
down_cast_data!(fn_data, DefData, item.span);
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ForeignItemKind::Fn(ref decl, ref generics) => {
|
||||
filter!(self.span_utils, item.ident.span);
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::ItemKind::Fn(ref decl, .., ref generics, _) => {
|
||||
let qualname = format!("::{}",
|
||||
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id)));
|
||||
|
|
@ -301,7 +301,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
}))
|
||||
}
|
||||
ast::ItemKind::Impl(.., ref trait_ref, ref typ, ref impls) => {
|
||||
if let ast::TyKind::Path(None, ref path) = typ.node {
|
||||
if let ast::TyKind::Path(None, ref path) = typ.kind {
|
||||
// Common case impl for a struct or something basic.
|
||||
if generated_code(path.span) {
|
||||
return None;
|
||||
|
|
@ -396,7 +396,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
let (qualname, parent_scope, decl_id, docs, attributes) =
|
||||
match self.tcx.impl_of_method(self.tcx.hir().local_def_id_from_node_id(id)) {
|
||||
Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
|
||||
Some(Node::Item(item)) => match item.node {
|
||||
Some(Node::Item(item)) => match item.kind {
|
||||
hir::ItemKind::Impl(.., ref ty, _) => {
|
||||
let mut qualname = String::from("<");
|
||||
qualname.push_str(&self.tcx.hir().hir_to_pretty_string(ty.hir_id));
|
||||
|
|
@ -518,7 +518,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
if ty.is_none() || ty.unwrap().kind == ty::Error {
|
||||
return None;
|
||||
}
|
||||
match expr.node {
|
||||
match expr.kind {
|
||||
ast::ExprKind::Field(ref sub_ex, ident) => {
|
||||
let sub_ex_hir_id = self.tcx.hir().node_to_hir_id(sub_ex.id);
|
||||
let hir_node = match self.tcx.hir().find(sub_ex_hir_id) {
|
||||
|
|
@ -612,7 +612,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
Node::TraitRef(tr) => tr.path.res,
|
||||
|
||||
Node::Item(&hir::Item {
|
||||
node: hir::ItemKind::Use(ref path, _),
|
||||
kind: hir::ItemKind::Use(ref path, _),
|
||||
..
|
||||
}) |
|
||||
Node::Visibility(&Spanned {
|
||||
|
|
@ -629,37 +629,37 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
|||
}
|
||||
|
||||
Node::Expr(&hir::Expr {
|
||||
node: hir::ExprKind::Struct(ref qpath, ..),
|
||||
kind: hir::ExprKind::Struct(ref qpath, ..),
|
||||
..
|
||||
}) => {
|
||||
self.tables.qpath_res(qpath, hir_id)
|
||||
}
|
||||
|
||||
Node::Expr(&hir::Expr {
|
||||
node: hir::ExprKind::Path(ref qpath),
|
||||
kind: hir::ExprKind::Path(ref qpath),
|
||||
..
|
||||
}) |
|
||||
Node::Pat(&hir::Pat {
|
||||
node: hir::PatKind::Path(ref qpath),
|
||||
kind: hir::PatKind::Path(ref qpath),
|
||||
..
|
||||
}) |
|
||||
Node::Pat(&hir::Pat {
|
||||
node: hir::PatKind::Struct(ref qpath, ..),
|
||||
kind: hir::PatKind::Struct(ref qpath, ..),
|
||||
..
|
||||
}) |
|
||||
Node::Pat(&hir::Pat {
|
||||
node: hir::PatKind::TupleStruct(ref qpath, ..),
|
||||
kind: hir::PatKind::TupleStruct(ref qpath, ..),
|
||||
..
|
||||
}) |
|
||||
Node::Ty(&hir::Ty {
|
||||
node: hir::TyKind::Path(ref qpath),
|
||||
kind: hir::TyKind::Path(ref qpath),
|
||||
..
|
||||
}) => {
|
||||
self.tables.qpath_res(qpath, hir_id)
|
||||
}
|
||||
|
||||
Node::Binding(&hir::Pat {
|
||||
node: hir::PatKind::Binding(_, canonical_id, ..),
|
||||
kind: hir::PatKind::Binding(_, canonical_id, ..),
|
||||
..
|
||||
}) => Res::Local(canonical_id),
|
||||
|
||||
|
|
@ -965,7 +965,7 @@ impl<'l> PathCollector<'l> {
|
|||
|
||||
impl<'l> Visitor<'l> for PathCollector<'l> {
|
||||
fn visit_pat(&mut self, p: &'l ast::Pat) {
|
||||
match p.node {
|
||||
match p.kind {
|
||||
PatKind::Struct(ref path, ..) => {
|
||||
self.collected_paths.push((p.id, path));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ fn text_sig(text: String) -> Signature {
|
|||
impl Sig for ast::Ty {
|
||||
fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
|
||||
let id = Some(self.id);
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ast::TyKind::Slice(ref ty) => {
|
||||
let nested = ty.make(offset + 1, id, scx)?;
|
||||
let text = format!("[{}]", nested.text);
|
||||
|
|
@ -324,7 +324,7 @@ impl Sig for ast::Item {
|
|||
fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
|
||||
let id = Some(self.id);
|
||||
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ast::ItemKind::Static(ref ty, m, ref expr) => {
|
||||
let mut text = "static ".to_owned();
|
||||
if m == ast::Mutability::Mutable {
|
||||
|
|
@ -765,7 +765,7 @@ impl Sig for ast::Variant {
|
|||
impl Sig for ast::ForeignItem {
|
||||
fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
|
||||
let id = Some(self.id);
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ast::ForeignItemKind::Fn(ref decl, ref generics) => {
|
||||
let mut text = String::new();
|
||||
text.push_str("fn ");
|
||||
|
|
|
|||
|
|
@ -195,24 +195,24 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> {
|
|||
};
|
||||
|
||||
let node_kind = match node {
|
||||
Node::TraitItem(item) => match item.node {
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Method(..) => NodeKind::Fn,
|
||||
_ => NodeKind::Other,
|
||||
}
|
||||
|
||||
Node::ImplItem(item) => match item.node {
|
||||
Node::ImplItem(item) => match item.kind {
|
||||
ImplItemKind::Method(..) => NodeKind::Fn,
|
||||
_ => NodeKind::Other,
|
||||
}
|
||||
|
||||
Node::Item(item) => match item.node {
|
||||
Node::Item(item) => match item.kind {
|
||||
ItemKind::Impl(.., Some(..), _, _) => NodeKind::TraitImpl,
|
||||
ItemKind::Impl(.., None, _, _) => NodeKind::InherentImpl,
|
||||
ItemKind::Fn(..) => NodeKind::Fn,
|
||||
_ => NodeKind::Other,
|
||||
}
|
||||
|
||||
Node::ForeignItem(item) => match item.node {
|
||||
Node::ForeignItem(item) => match item.kind {
|
||||
ForeignItemKind::Fn(..) => NodeKind::Fn,
|
||||
_ => NodeKind::Other,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2075,11 +2075,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
/// internal notion of a type.
|
||||
pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
|
||||
debug!("ast_ty_to_ty(id={:?}, ast_ty={:?} ty_ty={:?})",
|
||||
ast_ty.hir_id, ast_ty, ast_ty.node);
|
||||
ast_ty.hir_id, ast_ty, ast_ty.kind);
|
||||
|
||||
let tcx = self.tcx();
|
||||
|
||||
let result_ty = match ast_ty.node {
|
||||
let result_ty = match ast_ty.kind {
|
||||
hir::TyKind::Slice(ref ty) => {
|
||||
tcx.mk_slice(self.ast_ty_to_ty(&ty))
|
||||
}
|
||||
|
|
@ -2123,7 +2123,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
debug!("ast_ty_to_ty: qself={:?} segment={:?}", qself, segment);
|
||||
let ty = self.ast_ty_to_ty(qself);
|
||||
|
||||
let res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.node {
|
||||
let res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind {
|
||||
path.res
|
||||
} else {
|
||||
Res::Err
|
||||
|
|
@ -2175,13 +2175,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
pub fn const_param_def_id(&self, expr: &hir::Expr) -> Option<DefId> {
|
||||
// Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
|
||||
// currently have to be wrapped in curly brackets, so it's necessary to special-case.
|
||||
let expr = match &expr.node {
|
||||
let expr = match &expr.kind {
|
||||
ExprKind::Block(block, _) if block.stmts.is_empty() && block.expr.is_some() =>
|
||||
block.expr.as_ref().unwrap(),
|
||||
_ => expr,
|
||||
};
|
||||
|
||||
match &expr.node {
|
||||
match &expr.kind {
|
||||
ExprKind::Path(hir::QPath::Resolved(_, path)) => match path.res {
|
||||
Res::Def(DefKind::ConstParam, did) => Some(did),
|
||||
_ => None,
|
||||
|
|
@ -2270,7 +2270,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
expected_ty: Option<Ty<'tcx>>)
|
||||
-> Ty<'tcx>
|
||||
{
|
||||
match ty.node {
|
||||
match ty.kind {
|
||||
hir::TyKind::Infer if expected_ty.is_some() => {
|
||||
self.record_ty(ty.hir_id, expected_ty.unwrap(), ty.span);
|
||||
expected_ty.unwrap()
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
let arm_span = if let hir::ExprKind::Block(blk, _) = &arm.body.node {
|
||||
let arm_span = if let hir::ExprKind::Block(blk, _) = &arm.body.kind {
|
||||
// Point at the block expr instead of the entire block
|
||||
blk.expr.as_ref().map(|e| e.span).unwrap_or(arm.body.span)
|
||||
} else {
|
||||
|
|
@ -219,7 +219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
coercion.coerce_forced_unit(self, &cause, &mut |err| {
|
||||
if let Some((span, msg)) = &ret_reason {
|
||||
err.span_label(*span, msg.as_str());
|
||||
} else if let ExprKind::Block(block, _) = &then_expr.node {
|
||||
} else if let ExprKind::Block(block, _) = &then_expr.kind {
|
||||
if let Some(expr) = &block.expr {
|
||||
err.span_label(expr.span, "found here".to_string());
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
),
|
||||
);
|
||||
if let (Some(expr), Item(hir::Item {
|
||||
node: hir::ItemKind::Fn(..), ..
|
||||
kind: hir::ItemKind::Fn(..), ..
|
||||
})) = (&block.expr, parent) {
|
||||
// check that the `if` expr without `else` is the fn body's expr
|
||||
if expr.span == span {
|
||||
|
|
@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
let mut remove_semicolon = None;
|
||||
let error_sp = if let ExprKind::Block(block, _) = &else_expr.node {
|
||||
let error_sp = if let ExprKind::Block(block, _) = &else_expr.kind {
|
||||
if let Some(expr) = &block.expr {
|
||||
expr.span
|
||||
} else if let Some(stmt) = block.stmts.last() {
|
||||
|
|
@ -345,7 +345,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
// Compute `Span` of `then` part of `if`-expression.
|
||||
let then_sp = if let ExprKind::Block(block, _) = &then_expr.node {
|
||||
let then_sp = if let ExprKind::Block(block, _) = &then_expr.kind {
|
||||
if let Some(expr) = &block.expr {
|
||||
expr.span
|
||||
} else if let Some(stmt) = block.stmts.last() {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue