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