mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #58079 - ljedrz:HirIdification_phase_1, r=Zoxc
hir: add HirId to main Hir nodes This is the 1st PR in a series dedicated to `HirId`-ification, i.e. deprecating `ast::NodeId`s after the AST > HIR lowering process. The bigger proof of concept can be seen in https://github.com/rust-lang/rust/pull/57578. **Phase 1**: store `HirId` in all remaining (some already have it) main HIR nodes (excluding `*Id` objects). - [x] `Field` - [x] `FieldPat` - [x] `ForeignItem` - [x] `GenericParam` - [x] `Lifetime` - [x] `MacroDef` - [x] `PathSegment` - [x] `PatKind::Binding` - [x] `Stmt` - [x] `StructField` - [x] `TypeBinding` - [x] `VariantData` - [x] `WhereClause` - [x] `WhereEqPredicate` r? @Zoxc Cc @varkor
This commit is contained in:
commit
ec7ecb3076
@ -362,7 +362,7 @@ fn is_c_like_enum(item: &hir::Item) -> bool {
|
||||
if let hir::ItemKind::Enum(ref def, _) = item.node {
|
||||
for variant in &def.variants {
|
||||
match variant.node.data {
|
||||
hir::VariantData::Unit(_) => { /* continue */ }
|
||||
hir::VariantData::Unit(..) => { /* continue */ }
|
||||
_ => { return false; }
|
||||
}
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
|
||||
PatKind::Ref(ref subpattern, _) => {
|
||||
visitor.visit_pat(subpattern)
|
||||
}
|
||||
PatKind::Binding(_, canonical_id, ident, ref optional_subpattern) => {
|
||||
PatKind::Binding(_, canonical_id, _hir_id, ident, ref optional_subpattern) => {
|
||||
visitor.visit_def_mention(Def::Local(canonical_id));
|
||||
visitor.visit_ident(ident);
|
||||
walk_list!(visitor, visit_pat, optional_subpattern);
|
||||
|
@ -741,7 +741,7 @@ impl<'a> LoweringContext<'a> {
|
||||
let params = lifetimes_to_define
|
||||
.into_iter()
|
||||
.map(|(span, hir_name)| {
|
||||
let def_node_id = self.next_id().node_id;
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
|
||||
// Get the name we'll use to make the def-path. Note
|
||||
// that collisions are ok here and this shouldn't
|
||||
@ -764,7 +764,7 @@ impl<'a> LoweringContext<'a> {
|
||||
// Add a definition for the in-band lifetime def.
|
||||
self.resolver.definitions().create_def_with_parent(
|
||||
parent_id.index,
|
||||
def_node_id,
|
||||
node_id,
|
||||
DefPathData::LifetimeParam(str_name),
|
||||
DefIndexAddressSpace::High,
|
||||
Mark::root(),
|
||||
@ -772,7 +772,8 @@ impl<'a> LoweringContext<'a> {
|
||||
);
|
||||
|
||||
hir::GenericParam {
|
||||
id: def_node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
name: hir_name,
|
||||
attrs: hir_vec![],
|
||||
bounds: hir_vec![],
|
||||
@ -1138,8 +1139,11 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
fn lower_ty_binding(&mut self, b: &TypeBinding,
|
||||
itctx: ImplTraitContext<'_>) -> hir::TypeBinding {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(b.id);
|
||||
|
||||
hir::TypeBinding {
|
||||
id: self.lower_node_id(b.id).node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: b.ident,
|
||||
ty: self.lower_ty(&b.ty, itctx),
|
||||
span: b.span,
|
||||
@ -1261,7 +1265,7 @@ impl<'a> LoweringContext<'a> {
|
||||
)
|
||||
}
|
||||
ImplTraitContext::Universal(in_band_ty_params) => {
|
||||
self.lower_node_id(def_node_id);
|
||||
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(def_node_id);
|
||||
// Add a definition for the in-band `Param`.
|
||||
let def_index = self
|
||||
.resolver
|
||||
@ -1277,6 +1281,7 @@ impl<'a> LoweringContext<'a> {
|
||||
let ident = Ident::from_str(&pprust::ty_to_string(t)).with_span_pos(span);
|
||||
in_band_ty_params.push(hir::GenericParam {
|
||||
id: def_node_id,
|
||||
hir_id,
|
||||
name: ParamName::Plain(ident),
|
||||
pure_wrt_drop: false,
|
||||
attrs: hir_vec![],
|
||||
@ -1368,11 +1373,13 @@ impl<'a> LoweringContext<'a> {
|
||||
);
|
||||
|
||||
self.with_hir_id_owner(exist_ty_node_id, |lctx| {
|
||||
let LoweredNodeId { node_id, hir_id } = lctx.next_id();
|
||||
let exist_ty_item_kind = hir::ItemKind::Existential(hir::ExistTy {
|
||||
generics: hir::Generics {
|
||||
params: lifetime_defs,
|
||||
where_clause: hir::WhereClause {
|
||||
id: lctx.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
predicates: Vec::new().into(),
|
||||
},
|
||||
span,
|
||||
@ -1505,8 +1512,10 @@ impl<'a> LoweringContext<'a> {
|
||||
&& !self.already_defined_lifetimes.contains(&name) {
|
||||
self.already_defined_lifetimes.insert(name);
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = self.context.next_id();
|
||||
self.output_lifetimes.push(hir::GenericArg::Lifetime(hir::Lifetime {
|
||||
id: self.context.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span: lifetime.span,
|
||||
name,
|
||||
}));
|
||||
@ -1515,7 +1524,8 @@ impl<'a> LoweringContext<'a> {
|
||||
// definitions will go into the explicit `existential type`
|
||||
// declaration and thus need to have their owner set to that item
|
||||
let def_node_id = self.context.sess.next_node_id();
|
||||
let _ = self.context.lower_node_id_with_owner(def_node_id, self.exist_ty_id);
|
||||
let LoweredNodeId { node_id: _, hir_id } =
|
||||
self.context.lower_node_id_with_owner(def_node_id, self.exist_ty_id);
|
||||
self.context.resolver.definitions().create_def_with_parent(
|
||||
self.parent,
|
||||
def_node_id,
|
||||
@ -1539,6 +1549,7 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
self.output_lifetime_params.push(hir::GenericParam {
|
||||
id: def_node_id,
|
||||
hir_id,
|
||||
name,
|
||||
span: lifetime.span,
|
||||
pure_wrt_drop: false,
|
||||
@ -1904,6 +1915,7 @@ impl<'a> LoweringContext<'a> {
|
||||
hir::PathSegment::new(
|
||||
segment.ident,
|
||||
Some(id.node_id),
|
||||
Some(id.hir_id),
|
||||
Some(def),
|
||||
generic_args,
|
||||
infer_types,
|
||||
@ -1950,13 +1962,15 @@ impl<'a> LoweringContext<'a> {
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
hir::Ty { node: hir::TyKind::Tup(tys), id: node_id, hir_id, span }
|
||||
};
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
|
||||
(
|
||||
hir::GenericArgs {
|
||||
args: hir_vec![GenericArg::Type(mk_tup(this, inputs, span))],
|
||||
bindings: hir_vec![
|
||||
hir::TypeBinding {
|
||||
id: this.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: Ident::from_str(FN_OUTPUT_NAME),
|
||||
ty: output
|
||||
.as_ref()
|
||||
@ -2286,7 +2300,7 @@ impl<'a> LoweringContext<'a> {
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
P(hir::Ty {
|
||||
id: node_id,
|
||||
hir_id: hir_id,
|
||||
hir_id,
|
||||
node: hir::TyKind::Tup(hir_vec![]),
|
||||
span: *span,
|
||||
})
|
||||
@ -2294,12 +2308,14 @@ impl<'a> LoweringContext<'a> {
|
||||
};
|
||||
|
||||
// "<Output = T>"
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
let future_params = P(hir::GenericArgs {
|
||||
args: hir_vec![],
|
||||
bindings: hir_vec![hir::TypeBinding {
|
||||
ident: Ident::from_str(FN_OUTPUT_NAME),
|
||||
ty: output_ty,
|
||||
id: this.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span,
|
||||
}],
|
||||
parenthesized: false,
|
||||
@ -2325,8 +2341,9 @@ impl<'a> LoweringContext<'a> {
|
||||
];
|
||||
|
||||
if let Some((name, span)) = bound_lifetime {
|
||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
||||
bounds.push(hir::GenericBound::Outlives(
|
||||
hir::Lifetime { id: this.next_id().node_id, name, span }));
|
||||
hir::Lifetime { id: node_id, hir_id, name, span }));
|
||||
}
|
||||
|
||||
hir::HirVec::from(bounds)
|
||||
@ -2393,8 +2410,11 @@ impl<'a> LoweringContext<'a> {
|
||||
span: Span,
|
||||
name: hir::LifetimeName,
|
||||
) -> hir::Lifetime {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::Lifetime {
|
||||
id: self.lower_node_id(id).node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span,
|
||||
name: name,
|
||||
}
|
||||
@ -2439,6 +2459,7 @@ impl<'a> LoweringContext<'a> {
|
||||
};
|
||||
let param = hir::GenericParam {
|
||||
id: lt.id,
|
||||
hir_id: lt.hir_id,
|
||||
name: param_name,
|
||||
span: lt.span,
|
||||
pure_wrt_drop: attr::contains_name(¶m.attrs, "may_dangle"),
|
||||
@ -2470,9 +2491,11 @@ impl<'a> LoweringContext<'a> {
|
||||
.chain(params)
|
||||
.collect();
|
||||
}
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(param.id);
|
||||
|
||||
hir::GenericParam {
|
||||
id: self.lower_node_id(param.id).node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
name: hir::ParamName::Plain(ident),
|
||||
pure_wrt_drop: attr::contains_name(¶m.attrs, "may_dangle"),
|
||||
attrs: self.lower_attrs(¶m.attrs),
|
||||
@ -2562,8 +2585,11 @@ impl<'a> LoweringContext<'a> {
|
||||
self.with_anonymous_lifetime_mode(
|
||||
AnonymousLifetimeMode::ReportError,
|
||||
|this| {
|
||||
let LoweredNodeId { node_id, hir_id } = this.lower_node_id(wc.id);
|
||||
|
||||
hir::WhereClause {
|
||||
id: this.lower_node_id(wc.id).node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
predicates: wc.predicates
|
||||
.iter()
|
||||
.map(|predicate| this.lower_where_predicate(predicate))
|
||||
@ -2622,34 +2648,53 @@ impl<'a> LoweringContext<'a> {
|
||||
ref lhs_ty,
|
||||
ref rhs_ty,
|
||||
span,
|
||||
}) => hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
|
||||
id: self.lower_node_id(id).node_id,
|
||||
lhs_ty: self.lower_ty(lhs_ty, ImplTraitContext::disallowed()),
|
||||
rhs_ty: self.lower_ty(rhs_ty, ImplTraitContext::disallowed()),
|
||||
span,
|
||||
}),
|
||||
}) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
lhs_ty: self.lower_ty(lhs_ty, ImplTraitContext::disallowed()),
|
||||
rhs_ty: self.lower_ty(rhs_ty, ImplTraitContext::disallowed()),
|
||||
span,
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_variant_data(&mut self, vdata: &VariantData) -> hir::VariantData {
|
||||
match *vdata {
|
||||
VariantData::Struct(ref fields, id) => hir::VariantData::Struct(
|
||||
fields
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|f| self.lower_struct_field(f))
|
||||
.collect(),
|
||||
self.lower_node_id(id).node_id,
|
||||
),
|
||||
VariantData::Tuple(ref fields, id) => hir::VariantData::Tuple(
|
||||
fields
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|f| self.lower_struct_field(f))
|
||||
.collect(),
|
||||
self.lower_node_id(id).node_id,
|
||||
),
|
||||
VariantData::Unit(id) => hir::VariantData::Unit(self.lower_node_id(id).node_id),
|
||||
VariantData::Struct(ref fields, id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Struct(
|
||||
fields
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|f| self.lower_struct_field(f))
|
||||
.collect(),
|
||||
node_id,
|
||||
hir_id,
|
||||
)
|
||||
},
|
||||
VariantData::Tuple(ref fields, id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Tuple(
|
||||
fields
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|f| self.lower_struct_field(f))
|
||||
.collect(),
|
||||
node_id,
|
||||
hir_id,
|
||||
)
|
||||
},
|
||||
VariantData::Unit(id) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
|
||||
|
||||
hir::VariantData::Unit(node_id, hir_id)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -2689,9 +2734,12 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::StructField {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(f.id);
|
||||
|
||||
hir::StructField {
|
||||
span: f.span,
|
||||
id: self.lower_node_id(f.id).node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: match f.ident {
|
||||
Some(ident) => ident,
|
||||
// FIXME(jseyfried): positional field hygiene
|
||||
@ -2704,8 +2752,11 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn lower_field(&mut self, f: &Field) -> hir::Field {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
|
||||
hir::Field {
|
||||
id: self.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: f.ident,
|
||||
expr: P(self.lower_expr(&f.expr)),
|
||||
span: f.span,
|
||||
@ -3463,11 +3514,13 @@ impl<'a> LoweringContext<'a> {
|
||||
if !def.legacy || attr::contains_name(&i.attrs, "macro_export") ||
|
||||
attr::contains_name(&i.attrs, "rustc_doc_only_macro") {
|
||||
let body = self.lower_token_stream(def.stream());
|
||||
let hir_id = self.lower_node_id(i.id).hir_id;
|
||||
self.exported_macros.push(hir::MacroDef {
|
||||
name: ident.name,
|
||||
vis,
|
||||
attrs,
|
||||
id: i.id,
|
||||
hir_id,
|
||||
span: i.span,
|
||||
body,
|
||||
legacy: def.legacy,
|
||||
@ -3492,10 +3545,11 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem {
|
||||
let node_id = self.lower_node_id(i.id).node_id;
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(i.id);
|
||||
let def_id = self.resolver.definitions().local_def_id(node_id);
|
||||
hir::ForeignItem {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
node: match i.node {
|
||||
@ -3632,9 +3686,11 @@ impl<'a> LoweringContext<'a> {
|
||||
Some(Def::Local(id)) => id,
|
||||
_ => p.id,
|
||||
};
|
||||
let hir_id = self.lower_node_id(canonical_id).hir_id;
|
||||
hir::PatKind::Binding(
|
||||
self.lower_binding_mode(binding_mode),
|
||||
canonical_id,
|
||||
hir_id,
|
||||
ident,
|
||||
sub.as_ref().map(|x| self.lower_pat(x)),
|
||||
)
|
||||
@ -3685,14 +3741,19 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
let fs = fields
|
||||
.iter()
|
||||
.map(|f| Spanned {
|
||||
span: f.span,
|
||||
node: hir::FieldPat {
|
||||
id: self.next_id().node_id,
|
||||
ident: f.node.ident,
|
||||
pat: self.lower_pat(&f.node.pat),
|
||||
is_shorthand: f.node.is_shorthand,
|
||||
},
|
||||
.map(|f| {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
|
||||
Spanned {
|
||||
span: f.span,
|
||||
node: hir::FieldPat {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident: f.node.ident,
|
||||
pat: self.lower_pat(&f.node.pat),
|
||||
is_shorthand: f.node.is_shorthand,
|
||||
},
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
hir::PatKind::Struct(qpath, fs, etc)
|
||||
@ -4347,8 +4408,10 @@ impl<'a> LoweringContext<'a> {
|
||||
ThinVec::new(),
|
||||
))
|
||||
};
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let match_stmt = hir::Stmt {
|
||||
id: self.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Expr(match_expr),
|
||||
span: head_sp,
|
||||
};
|
||||
@ -4374,8 +4437,10 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
|
||||
let body_expr = P(self.expr_block(body_block, ThinVec::new()));
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
let body_stmt = hir::Stmt {
|
||||
id: self.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Expr(body_expr),
|
||||
span: body.span,
|
||||
};
|
||||
@ -4551,16 +4616,26 @@ impl<'a> LoweringContext<'a> {
|
||||
let (l, item_ids) = self.lower_local(l);
|
||||
let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids
|
||||
.into_iter()
|
||||
.map(|item_id| hir::Stmt {
|
||||
id: self.next_id().node_id,
|
||||
node: hir::StmtKind::Item(P(item_id)),
|
||||
span: s.span,
|
||||
.map(|item_id| {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Item(P(item_id)),
|
||||
span: s.span,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
ids.push(hir::Stmt {
|
||||
id: self.lower_node_id(s.id).node_id,
|
||||
node: hir::StmtKind::Local(P(l)),
|
||||
span: s.span,
|
||||
ids.push({
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Local(P(l)),
|
||||
span: s.span,
|
||||
}
|
||||
});
|
||||
return ids;
|
||||
},
|
||||
@ -4569,24 +4644,39 @@ impl<'a> LoweringContext<'a> {
|
||||
let mut id = Some(s.id);
|
||||
return self.lower_item_id(it)
|
||||
.into_iter()
|
||||
.map(|item_id| hir::Stmt {
|
||||
id: id.take()
|
||||
.map(|id| self.lower_node_id(id).node_id)
|
||||
.unwrap_or_else(|| self.next_id().node_id),
|
||||
node: hir::StmtKind::Item(P(item_id)),
|
||||
span: s.span,
|
||||
.map(|item_id| {
|
||||
let LoweredNodeId { node_id, hir_id } = id.take()
|
||||
.map(|id| self.lower_node_id(id))
|
||||
.unwrap_or_else(|| self.next_id());
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Item(P(item_id)),
|
||||
span: s.span,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
StmtKind::Expr(ref e) => hir::Stmt {
|
||||
id: self.lower_node_id(s.id).node_id,
|
||||
node: hir::StmtKind::Expr(P(self.lower_expr(e))),
|
||||
span: s.span,
|
||||
StmtKind::Expr(ref e) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Expr(P(self.lower_expr(e))),
|
||||
span: s.span,
|
||||
}
|
||||
},
|
||||
StmtKind::Semi(ref e) => hir::Stmt {
|
||||
id: self.lower_node_id(s.id).node_id,
|
||||
node: hir::StmtKind::Semi(P(self.lower_expr(e))),
|
||||
span: s.span,
|
||||
StmtKind::Semi(ref e) => {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
|
||||
|
||||
hir::Stmt {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Semi(P(self.lower_expr(e))),
|
||||
span: s.span,
|
||||
}
|
||||
},
|
||||
StmtKind::Mac(..) => panic!("Shouldn't exist here"),
|
||||
}]
|
||||
@ -4697,8 +4787,11 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
|
||||
hir::Field {
|
||||
id: self.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
ident,
|
||||
span,
|
||||
expr,
|
||||
@ -4810,8 +4903,11 @@ impl<'a> LoweringContext<'a> {
|
||||
attrs: ThinVec::new(),
|
||||
source,
|
||||
};
|
||||
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
hir::Stmt {
|
||||
id: self.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::StmtKind::Local(P(local)),
|
||||
span: sp
|
||||
}
|
||||
@ -4906,7 +5002,7 @@ impl<'a> LoweringContext<'a> {
|
||||
P(hir::Pat {
|
||||
id: node_id,
|
||||
hir_id,
|
||||
node: hir::PatKind::Binding(bm, node_id, ident.with_span_pos(span), None),
|
||||
node: hir::PatKind::Binding(bm, node_id, hir_id, ident.with_span_pos(span), None),
|
||||
span,
|
||||
})
|
||||
}
|
||||
@ -4992,8 +5088,10 @@ impl<'a> LoweringContext<'a> {
|
||||
// `'f`.
|
||||
AnonymousLifetimeMode::CreateParameter => {
|
||||
let fresh_name = self.collect_fresh_in_band_lifetime(span);
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
hir::Lifetime {
|
||||
id: self.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span,
|
||||
name: hir::LifetimeName::Param(fresh_name),
|
||||
}
|
||||
@ -5093,8 +5191,11 @@ impl<'a> LoweringContext<'a> {
|
||||
}
|
||||
|
||||
fn new_implicit_lifetime(&mut self, span: Span) -> hir::Lifetime {
|
||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||
|
||||
hir::Lifetime {
|
||||
id: self.next_id().node_id,
|
||||
id: node_id,
|
||||
hir_id,
|
||||
span,
|
||||
name: hir::LifetimeName::Implicit,
|
||||
}
|
||||
|
@ -875,7 +875,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 { node: PatKind::Binding(_, _, _, l, _), .. }) => l.name,
|
||||
Node::StructCtor(_) => self.name(self.get_parent(id)),
|
||||
_ => bug!("no name for {}", self.node_to_string(id))
|
||||
}
|
||||
|
@ -146,6 +146,7 @@ pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId::MAX;
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
|
||||
pub struct Lifetime {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
|
||||
/// Either "'a", referring to a named lifetime definition,
|
||||
@ -321,6 +322,7 @@ pub struct PathSegment {
|
||||
// affected. (In general, we don't bother to get the defs for synthesized
|
||||
// segments, only for segments which have come from the AST).
|
||||
pub id: Option<NodeId>,
|
||||
pub hir_id: Option<HirId>,
|
||||
pub def: Option<Def>,
|
||||
|
||||
/// Type/lifetime parameters attached to this path. They come in
|
||||
@ -343,6 +345,7 @@ impl PathSegment {
|
||||
PathSegment {
|
||||
ident,
|
||||
id: None,
|
||||
hir_id: None,
|
||||
def: None,
|
||||
infer_types: true,
|
||||
args: None,
|
||||
@ -352,6 +355,7 @@ impl PathSegment {
|
||||
pub fn new(
|
||||
ident: Ident,
|
||||
id: Option<NodeId>,
|
||||
hir_id: Option<HirId>,
|
||||
def: Option<Def>,
|
||||
args: GenericArgs,
|
||||
infer_types: bool,
|
||||
@ -359,6 +363,7 @@ impl PathSegment {
|
||||
PathSegment {
|
||||
ident,
|
||||
id,
|
||||
hir_id,
|
||||
def,
|
||||
infer_types,
|
||||
args: if args.is_empty() {
|
||||
@ -528,6 +533,7 @@ pub enum GenericParamKind {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct GenericParam {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub name: ParamName,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub bounds: GenericBounds,
|
||||
@ -558,6 +564,7 @@ impl Generics {
|
||||
params: HirVec::new(),
|
||||
where_clause: WhereClause {
|
||||
id: DUMMY_NODE_ID,
|
||||
hir_id: DUMMY_HIR_ID,
|
||||
predicates: HirVec::new(),
|
||||
},
|
||||
span: DUMMY_SP,
|
||||
@ -601,6 +608,7 @@ pub enum SyntheticTyParamKind {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct WhereClause {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub predicates: HirVec<WherePredicate>,
|
||||
}
|
||||
|
||||
@ -661,6 +669,7 @@ pub struct WhereRegionPredicate {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct WhereEqPredicate {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
pub lhs_ty: P<Ty>,
|
||||
pub rhs_ty: P<Ty>,
|
||||
@ -789,6 +798,7 @@ pub struct MacroDef {
|
||||
pub vis: Visibility,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
pub body: TokenStream,
|
||||
pub legacy: bool,
|
||||
@ -878,6 +888,7 @@ impl Pat {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct FieldPat {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
/// The identifier for the field
|
||||
pub ident: Ident,
|
||||
/// The pattern the field is destructured to
|
||||
@ -924,7 +935,7 @@ pub enum PatKind {
|
||||
/// The `NodeId` is the canonical ID for the variable being bound,
|
||||
/// e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID,
|
||||
/// which is the pattern ID of the first `x`.
|
||||
Binding(BindingAnnotation, NodeId, Ident, Option<P<Pat>>),
|
||||
Binding(BindingAnnotation, NodeId, HirId, Ident, Option<P<Pat>>),
|
||||
|
||||
/// A struct or struct variant pattern, e.g., `Variant {x, y, ..}`.
|
||||
/// The `bool` is `true` in the presence of a `..`.
|
||||
@ -1137,6 +1148,7 @@ impl UnOp {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct Stmt {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub node: StmtKind,
|
||||
pub span: Span,
|
||||
}
|
||||
@ -1204,6 +1216,7 @@ pub enum Guard {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct Field {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub ident: Ident,
|
||||
pub expr: P<Expr>,
|
||||
pub span: Span,
|
||||
@ -1711,6 +1724,7 @@ pub enum ImplItemKind {
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub struct TypeBinding {
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub ident: Ident,
|
||||
pub ty: P<Ty>,
|
||||
pub span: Span,
|
||||
@ -2106,6 +2120,7 @@ pub struct StructField {
|
||||
pub ident: Ident,
|
||||
pub vis: Visibility,
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub ty: P<Ty>,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
}
|
||||
@ -2131,21 +2146,30 @@ impl StructField {
|
||||
/// Id of the whole struct lives in `Item`.
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub enum VariantData {
|
||||
Struct(HirVec<StructField>, NodeId),
|
||||
Tuple(HirVec<StructField>, NodeId),
|
||||
Unit(NodeId),
|
||||
Struct(HirVec<StructField>, NodeId, HirId),
|
||||
Tuple(HirVec<StructField>, NodeId, HirId),
|
||||
Unit(NodeId, HirId),
|
||||
}
|
||||
|
||||
impl VariantData {
|
||||
pub fn fields(&self) -> &[StructField] {
|
||||
match *self {
|
||||
VariantData::Struct(ref fields, _) | VariantData::Tuple(ref fields, _) => fields,
|
||||
VariantData::Struct(ref fields, ..) | VariantData::Tuple(ref fields, ..) => fields,
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
pub fn id(&self) -> NodeId {
|
||||
match *self {
|
||||
VariantData::Struct(_, id) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id,
|
||||
VariantData::Struct(_, id, ..)
|
||||
| VariantData::Tuple(_, id, ..)
|
||||
| VariantData::Unit(id, ..) => id,
|
||||
}
|
||||
}
|
||||
pub fn hir_id(&self) -> HirId {
|
||||
match *self {
|
||||
VariantData::Struct(_, _, hir_id)
|
||||
| VariantData::Tuple(_, _, hir_id)
|
||||
| VariantData::Unit(_, hir_id) => hir_id,
|
||||
}
|
||||
}
|
||||
pub fn is_struct(&self) -> bool {
|
||||
@ -2343,6 +2367,7 @@ pub struct ForeignItem {
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub node: ForeignItemKind,
|
||||
pub id: NodeId,
|
||||
pub hir_id: HirId,
|
||||
pub span: Span,
|
||||
pub vis: Visibility,
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ impl hir::Pat {
|
||||
where F: 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.node {
|
||||
f(binding_mode, p.hir_id, p.span, ident);
|
||||
}
|
||||
true
|
||||
@ -123,8 +123,8 @@ impl hir::Pat {
|
||||
|
||||
pub fn simple_ident(&self) -> Option<ast::Ident> {
|
||||
match self.node {
|
||||
PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) |
|
||||
PatKind::Binding(hir::BindingAnnotation::Mutable, _, ident, None) => Some(ident),
|
||||
PatKind::Binding(hir::BindingAnnotation::Unannotated, _, _, ident, None) |
|
||||
PatKind::Binding(hir::BindingAnnotation::Mutable, _, _, ident, None) => Some(ident),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -1768,7 +1768,7 @@ impl<'a> State<'a> {
|
||||
// is that it doesn't matter
|
||||
match pat.node {
|
||||
PatKind::Wild => self.s.word("_")?,
|
||||
PatKind::Binding(binding_mode, _, ident, ref sub) => {
|
||||
PatKind::Binding(binding_mode, _, _, ident, ref sub) => {
|
||||
match binding_mode {
|
||||
hir::BindingAnnotation::Ref => {
|
||||
self.word_nbsp("ref")?;
|
||||
@ -2246,6 +2246,7 @@ impl<'a> State<'a> {
|
||||
params: hir::HirVec::new(),
|
||||
where_clause: hir::WhereClause {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
hir_id: hir::DUMMY_HIR_ID,
|
||||
predicates: hir::HirVec::new(),
|
||||
},
|
||||
span: syntax_pos::DUMMY_SP,
|
||||
|
@ -159,6 +159,7 @@ impl_stable_hash_for!(struct ast::Label {
|
||||
|
||||
impl_stable_hash_for!(struct hir::Lifetime {
|
||||
id,
|
||||
hir_id,
|
||||
span,
|
||||
name
|
||||
});
|
||||
@ -172,6 +173,7 @@ impl_stable_hash_for!(struct hir::Path {
|
||||
impl_stable_hash_for!(struct hir::PathSegment {
|
||||
ident -> (ident.name),
|
||||
id,
|
||||
hir_id,
|
||||
def,
|
||||
infer_types,
|
||||
args
|
||||
@ -200,6 +202,7 @@ impl_stable_hash_for!(enum hir::TraitBoundModifier {
|
||||
|
||||
impl_stable_hash_for!(struct hir::GenericParam {
|
||||
id,
|
||||
hir_id,
|
||||
name,
|
||||
pure_wrt_drop,
|
||||
attrs,
|
||||
@ -244,6 +247,7 @@ impl_stable_hash_for!(enum hir::SyntheticTyParamKind {
|
||||
|
||||
impl_stable_hash_for!(struct hir::WhereClause {
|
||||
id,
|
||||
hir_id,
|
||||
predicates
|
||||
});
|
||||
|
||||
@ -268,6 +272,7 @@ impl_stable_hash_for!(struct hir::WhereRegionPredicate {
|
||||
|
||||
impl_stable_hash_for!(struct hir::WhereEqPredicate {
|
||||
id,
|
||||
hir_id,
|
||||
span,
|
||||
lhs_ty,
|
||||
rhs_ty
|
||||
@ -285,6 +290,7 @@ impl_stable_hash_for!(struct hir::MethodSig {
|
||||
|
||||
impl_stable_hash_for!(struct hir::TypeBinding {
|
||||
id,
|
||||
hir_id,
|
||||
ident -> (ident.name),
|
||||
ty,
|
||||
span
|
||||
@ -397,6 +403,7 @@ impl_stable_hash_for!(struct hir::MacroDef {
|
||||
vis,
|
||||
attrs,
|
||||
id,
|
||||
hir_id,
|
||||
span,
|
||||
legacy,
|
||||
body
|
||||
@ -423,6 +430,7 @@ impl_stable_hash_for_spanned!(hir::FieldPat);
|
||||
|
||||
impl_stable_hash_for!(struct hir::FieldPat {
|
||||
id -> _,
|
||||
hir_id -> _,
|
||||
ident -> (ident.name),
|
||||
pat,
|
||||
is_shorthand,
|
||||
@ -442,7 +450,7 @@ impl_stable_hash_for!(enum hir::RangeEnd {
|
||||
|
||||
impl_stable_hash_for!(enum hir::PatKind {
|
||||
Wild,
|
||||
Binding(binding_mode, var, name, sub),
|
||||
Binding(binding_mode, var, hir_id, name, sub),
|
||||
Struct(path, field_pats, dotdot),
|
||||
TupleStruct(path, field_pats, dotdot),
|
||||
Path(path),
|
||||
@ -485,6 +493,7 @@ impl_stable_hash_for!(enum hir::UnOp {
|
||||
|
||||
impl_stable_hash_for!(struct hir::Stmt {
|
||||
id,
|
||||
hir_id,
|
||||
node,
|
||||
span,
|
||||
});
|
||||
@ -514,6 +523,7 @@ impl_stable_hash_for!(enum hir::Guard {
|
||||
|
||||
impl_stable_hash_for!(struct hir::Field {
|
||||
id -> _,
|
||||
hir_id -> _,
|
||||
ident,
|
||||
expr,
|
||||
span,
|
||||
@ -836,14 +846,15 @@ impl_stable_hash_for!(struct hir::StructField {
|
||||
ident -> (ident.name),
|
||||
vis,
|
||||
id,
|
||||
hir_id,
|
||||
ty,
|
||||
attrs
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(enum hir::VariantData {
|
||||
Struct(fields, id),
|
||||
Tuple(fields, id),
|
||||
Unit(id)
|
||||
Struct(fields, id, hir_id),
|
||||
Tuple(fields, id, hir_id),
|
||||
Unit(id, hir_id)
|
||||
});
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for hir::Item {
|
||||
@ -929,6 +940,7 @@ impl_stable_hash_for!(struct hir::ForeignItem {
|
||||
attrs,
|
||||
node,
|
||||
id,
|
||||
hir_id,
|
||||
span,
|
||||
vis
|
||||
});
|
||||
|
@ -408,7 +408,7 @@ fn add_from_pat<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, pat: &P<hir::Pat>) {
|
||||
while let Some(pat) = pats.pop_front() {
|
||||
use hir::PatKind::*;
|
||||
match pat.node {
|
||||
Binding(_, _, _, ref inner_pat) => {
|
||||
Binding(_, _, _, _, ref inner_pat) => {
|
||||
pats.extend(inner_pat.iter());
|
||||
}
|
||||
Struct(_, ref fields, _) => {
|
||||
|
@ -1024,7 +1024,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
Node::Variant(&hir::Variant {
|
||||
span,
|
||||
node: hir::VariantKind {
|
||||
data: hir::VariantData::Tuple(ref fields, _),
|
||||
data: hir::VariantData::Tuple(ref fields, ..),
|
||||
..
|
||||
},
|
||||
..
|
||||
|
@ -99,7 +99,7 @@ pub fn gather_move_from_pat<'a, 'c, 'tcx: 'c>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
cmt: &'c mc::cmt_<'tcx>) {
|
||||
let source = get_pattern_source(bccx.tcx,move_pat);
|
||||
let pat_span_path_opt = match move_pat.node {
|
||||
PatKind::Binding(_, _, ident, _) => {
|
||||
PatKind::Binding(_, _, _, ident, _) => {
|
||||
Some(MovePlace {
|
||||
span: move_pat.span,
|
||||
name: ident.name,
|
||||
|
@ -191,7 +191,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
|
||||
// (Issue #49588)
|
||||
continue;
|
||||
}
|
||||
if let PatKind::Binding(_, _, ident, None) = fieldpat.node.pat.node {
|
||||
if let PatKind::Binding(_, _, _, ident, None) = fieldpat.node.pat.node {
|
||||
if cx.tcx.find_field_index(ident, &variant) ==
|
||||
Some(cx.tcx.field_index(fieldpat.node.id, cx.tables)) {
|
||||
let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS,
|
||||
|
@ -340,7 +340,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.node {
|
||||
self.check_snake_case(cx, "variable", &ident);
|
||||
}
|
||||
}
|
||||
|
@ -977,7 +977,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
||||
let body = self.tcx.hir().body(body_id);
|
||||
self.lazy_seq(body.arguments.iter().map(|arg| {
|
||||
match arg.pat.node {
|
||||
PatKind::Binding(_, _, ident, _) => ident.name,
|
||||
PatKind::Binding(_, _, _, ident, _) => ident.name,
|
||||
_ => keywords::Invalid.name(),
|
||||
}
|
||||
}))
|
||||
|
@ -312,6 +312,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
|
||||
if let hir::PatKind::Binding(
|
||||
hir::BindingAnnotation::Unannotated,
|
||||
_,
|
||||
_,
|
||||
upvar_ident,
|
||||
_,
|
||||
) = pat.node
|
||||
|
@ -229,7 +229,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
-> Mir<'tcx>
|
||||
{
|
||||
let span = tcx.hir().span(ctor_id);
|
||||
if let hir::VariantData::Tuple(ref fields, ctor_id) = *v {
|
||||
if let hir::VariantData::Tuple(ref fields, ctor_id, _) = *v {
|
||||
tcx.infer_ctxt().enter(|infcx| {
|
||||
let mut mir = shim::build_adt_ctor(&infcx, ctor_id, fields, span);
|
||||
|
||||
@ -671,7 +671,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
|
||||
mutability: Mutability::Not,
|
||||
};
|
||||
if let Some(Node::Binding(pat)) = tcx_hir.find(var_node_id) {
|
||||
if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
|
||||
if let hir::PatKind::Binding(_, _, _, ident, _) = pat.node {
|
||||
decl.debug_name = ident.name;
|
||||
if let Some(&bm) = hir.tables.pat_binding_modes().get(pat.hir_id) {
|
||||
if bm == ty::BindByValue(hir::MutMutable) {
|
||||
@ -877,8 +877,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
let mut name = None;
|
||||
if let Some(pat) = pattern {
|
||||
match pat.node {
|
||||
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, _)
|
||||
| hir::PatKind::Binding(hir::BindingAnnotation::Mutable, _, ident, _) => {
|
||||
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, _, ident, _)
|
||||
| hir::PatKind::Binding(hir::BindingAnnotation::Mutable, _, _, ident, _) => {
|
||||
name = Some(ident.name);
|
||||
}
|
||||
_ => (),
|
||||
|
@ -285,7 +285,7 @@ impl<'a, 'tcx> MatchVisitor<'a, '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 PatKind::Binding(_, _, _, ident, None) = p.node {
|
||||
if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) {
|
||||
if bm != ty::BindByValue(hir::MutImmutable) {
|
||||
// Nothing to check.
|
||||
@ -503,7 +503,7 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
|
||||
|
||||
for pat in pats {
|
||||
pat.walk(|p| {
|
||||
if let PatKind::Binding(_, _, _, ref sub) = p.node {
|
||||
if let PatKind::Binding(_, _, _, _, ref sub) = p.node {
|
||||
if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) {
|
||||
match bm {
|
||||
ty::BindByValue(..) => {
|
||||
|
@ -513,7 +513,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
PatKind::Binding(_, id, ident, ref sub) => {
|
||||
PatKind::Binding(_, id, _, ident, ref sub) => {
|
||||
let var_ty = self.tables.node_id_to_type(pat.hir_id);
|
||||
if let ty::Error = var_ty.sty {
|
||||
// Avoid ICE
|
||||
|
@ -80,7 +80,7 @@ fn mir_keys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: CrateNum)
|
||||
_: &'tcx hir::Generics,
|
||||
_: ast::NodeId,
|
||||
_: Span) {
|
||||
if let hir::VariantData::Tuple(_, node_id) = *v {
|
||||
if let hir::VariantData::Tuple(_, node_id, _) = *v {
|
||||
self.set.insert(self.tcx.hir().local_def_id(node_id));
|
||||
}
|
||||
intravisit::walk_struct_def(self, v)
|
||||
|
@ -227,7 +227,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
self.demand_eqtype_pat(pat.span, expected, rhs_ty, match_discrim_span);
|
||||
common_type
|
||||
}
|
||||
PatKind::Binding(ba, var_id, _, ref sub) => {
|
||||
PatKind::Binding(ba, var_id, _, _, ref sub) => {
|
||||
let bm = if ba == hir::BindingAnnotation::Unannotated {
|
||||
def_bm
|
||||
} else {
|
||||
|
@ -1005,7 +1005,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||
|
||||
// Add pattern bindings.
|
||||
fn visit_pat(&mut self, p: &'gcx hir::Pat) {
|
||||
if let PatKind::Binding(_, _, ident, _) = p.node {
|
||||
if let PatKind::Binding(_, _, _, ident, _) = p.node {
|
||||
let var_ty = self.assign(p.span, p.id, None);
|
||||
|
||||
if !self.fcx.tcx.features().unsized_locals {
|
||||
|
@ -1455,11 +1455,11 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::PolyFnSig
|
||||
compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi)
|
||||
}
|
||||
|
||||
StructCtor(&VariantData::Tuple(ref fields, _))
|
||||
StructCtor(&VariantData::Tuple(ref fields, ..))
|
||||
| Variant(&Spanned {
|
||||
node:
|
||||
hir::VariantKind {
|
||||
data: VariantData::Tuple(ref fields, _),
|
||||
data: VariantData::Tuple(ref fields, ..),
|
||||
..
|
||||
},
|
||||
..
|
||||
|
@ -3692,7 +3692,7 @@ fn name_from_pat(p: &hir::Pat) -> String {
|
||||
|
||||
match p.node {
|
||||
PatKind::Wild => "_".to_string(),
|
||||
PatKind::Binding(_, _, ident, _) => ident.to_string(),
|
||||
PatKind::Binding(_, _, _, ident, _) => ident.to_string(),
|
||||
PatKind::TupleStruct(ref p, ..) | PatKind::Path(ref p) => qpath_to_string(p),
|
||||
PatKind::Struct(ref name, ref fields, etc) => {
|
||||
format!("{} {{ {}{} }}", qpath_to_string(name),
|
||||
@ -4071,6 +4071,7 @@ where F: Fn(DefId) -> Def {
|
||||
segments: hir::HirVec::from_vec(apb.names.iter().map(|s| hir::PathSegment {
|
||||
ident: ast::Ident::from_str(&s),
|
||||
id: None,
|
||||
hir_id: None,
|
||||
def: None,
|
||||
args: None,
|
||||
infer_types: false,
|
||||
|
@ -174,6 +174,7 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
|
||||
real_name.unwrap_or(last.ident),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
self.generics_to_path_params(generics.clone()),
|
||||
false,
|
||||
));
|
||||
@ -206,6 +207,7 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
|
||||
|
||||
args.push(hir::GenericArg::Lifetime(hir::Lifetime {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
hir_id: hir::DUMMY_HIR_ID,
|
||||
span: DUMMY_SP,
|
||||
name: hir::LifetimeName::Param(name),
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user