hir: remove NodeId from Expr
This commit is contained in:
parent
021a140dcd
commit
d7ced1dd5a
44 changed files with 307 additions and 305 deletions
|
@ -398,7 +398,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
||||||
args: I) -> CFGIndex {
|
args: I) -> CFGIndex {
|
||||||
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
|
let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
|
||||||
let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
|
let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
|
||||||
let m = self.tcx.hir().get_module_parent(call_expr.id);
|
let m = self.tcx.hir().get_module_parent_by_hir_id(call_expr.hir_id);
|
||||||
if self.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(call_expr)) {
|
if self.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(call_expr)) {
|
||||||
self.add_unreachable_node()
|
self.add_unreachable_node()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -963,7 +963,6 @@ impl<'a> LoweringContext<'a> {
|
||||||
let closure_hir_id = self.lower_node_id(closure_node_id).hir_id;
|
let closure_hir_id = self.lower_node_id(closure_node_id).hir_id;
|
||||||
let decl = self.lower_fn_decl(&decl, None, /* impl trait allowed */ false, None);
|
let decl = self.lower_fn_decl(&decl, None, /* impl trait allowed */ false, None);
|
||||||
let generator = hir::Expr {
|
let generator = hir::Expr {
|
||||||
id: closure_node_id,
|
|
||||||
hir_id: closure_hir_id,
|
hir_id: closure_hir_id,
|
||||||
node: hir::ExprKind::Closure(capture_clause, decl, body_id, span,
|
node: hir::ExprKind::Closure(capture_clause, decl, body_id, span,
|
||||||
Some(hir::GeneratorMovability::Static)),
|
Some(hir::GeneratorMovability::Static)),
|
||||||
|
@ -3932,10 +3931,9 @@ impl<'a> LoweringContext<'a> {
|
||||||
let mut block = this.lower_block(body, true).into_inner();
|
let mut block = this.lower_block(body, true).into_inner();
|
||||||
let tail = block.expr.take().map_or_else(
|
let tail = block.expr.take().map_or_else(
|
||||||
|| {
|
|| {
|
||||||
let LoweredNodeId { node_id, hir_id } = this.next_id();
|
let LoweredNodeId { node_id: _, hir_id } = this.next_id();
|
||||||
let span = this.sess.source_map().end_point(unstable_span);
|
let span = this.sess.source_map().end_point(unstable_span);
|
||||||
hir::Expr {
|
hir::Expr {
|
||||||
id: node_id,
|
|
||||||
span,
|
span,
|
||||||
node: hir::ExprKind::Tup(hir_vec![]),
|
node: hir::ExprKind::Tup(hir_vec![]),
|
||||||
attrs: ThinVec::new(),
|
attrs: ThinVec::new(),
|
||||||
|
@ -4120,10 +4118,9 @@ impl<'a> LoweringContext<'a> {
|
||||||
let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
|
let struct_path = self.std_path(e.span, &struct_path, None, is_unit);
|
||||||
let struct_path = hir::QPath::Resolved(None, P(struct_path));
|
let struct_path = hir::QPath::Resolved(None, P(struct_path));
|
||||||
|
|
||||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
|
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
|
||||||
|
|
||||||
return hir::Expr {
|
return hir::Expr {
|
||||||
id: node_id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
node: if is_unit {
|
node: if is_unit {
|
||||||
hir::ExprKind::Path(struct_path)
|
hir::ExprKind::Path(struct_path)
|
||||||
|
@ -4473,9 +4470,8 @@ impl<'a> LoweringContext<'a> {
|
||||||
self.lower_label(opt_label),
|
self.lower_label(opt_label),
|
||||||
hir::LoopSource::ForLoop,
|
hir::LoopSource::ForLoop,
|
||||||
);
|
);
|
||||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
|
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
|
||||||
let loop_expr = P(hir::Expr {
|
let loop_expr = P(hir::Expr {
|
||||||
id: node_id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
node: loop_expr,
|
node: loop_expr,
|
||||||
span: e.span,
|
span: e.span,
|
||||||
|
@ -4620,10 +4616,9 @@ impl<'a> LoweringContext<'a> {
|
||||||
ExprKind::Mac(_) => panic!("Shouldn't exist here"),
|
ExprKind::Mac(_) => panic!("Shouldn't exist here"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(e.id);
|
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(e.id);
|
||||||
|
|
||||||
hir::Expr {
|
hir::Expr {
|
||||||
id: node_id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
node: kind,
|
node: kind,
|
||||||
span: e.span,
|
span: e.span,
|
||||||
|
@ -4895,9 +4890,8 @@ impl<'a> LoweringContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr(&mut self, span: Span, node: hir::ExprKind, attrs: ThinVec<Attribute>) -> hir::Expr {
|
fn expr(&mut self, span: Span, node: hir::ExprKind, attrs: ThinVec<Attribute>) -> hir::Expr {
|
||||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||||
hir::Expr {
|
hir::Expr {
|
||||||
id: node_id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
node,
|
node,
|
||||||
span,
|
span,
|
||||||
|
|
|
@ -75,10 +75,10 @@ pub enum Code<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Code<'a> {
|
impl<'a> Code<'a> {
|
||||||
pub fn id(&self) -> NodeId {
|
pub fn id(&self) -> ast::HirId {
|
||||||
match *self {
|
match *self {
|
||||||
Code::FnLike(node) => node.id(),
|
Code::FnLike(node) => node.id(),
|
||||||
Code::Expr(block) => block.id,
|
Code::Expr(block) => block.hir_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ struct ItemFnParts<'a> {
|
||||||
vis: &'a ast::Visibility,
|
vis: &'a ast::Visibility,
|
||||||
generics: &'a ast::Generics,
|
generics: &'a ast::Generics,
|
||||||
body: ast::BodyId,
|
body: ast::BodyId,
|
||||||
id: NodeId,
|
id: ast::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
attrs: &'a [Attribute],
|
attrs: &'a [Attribute],
|
||||||
}
|
}
|
||||||
|
@ -114,13 +114,13 @@ struct ItemFnParts<'a> {
|
||||||
struct ClosureParts<'a> {
|
struct ClosureParts<'a> {
|
||||||
decl: &'a FnDecl,
|
decl: &'a FnDecl,
|
||||||
body: ast::BodyId,
|
body: ast::BodyId,
|
||||||
id: NodeId,
|
id: ast::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
attrs: &'a [Attribute],
|
attrs: &'a [Attribute],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ClosureParts<'a> {
|
impl<'a> ClosureParts<'a> {
|
||||||
fn new(d: &'a FnDecl, b: ast::BodyId, id: NodeId, s: Span, attrs: &'a [Attribute]) -> Self {
|
fn new(d: &'a FnDecl, b: ast::BodyId, id: ast::HirId, s: Span, attrs: &'a [Attribute]) -> Self {
|
||||||
ClosureParts {
|
ClosureParts {
|
||||||
decl: d,
|
decl: d,
|
||||||
body: b,
|
body: b,
|
||||||
|
@ -168,7 +168,7 @@ impl<'a> FnLikeNode<'a> {
|
||||||
|c: ClosureParts<'_>| c.span)
|
|c: ClosureParts<'_>| c.span)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id(self) -> NodeId {
|
pub fn id(self) -> ast::HirId {
|
||||||
self.handle(|i: ItemFnParts<'_>| i.id,
|
self.handle(|i: ItemFnParts<'_>| i.id,
|
||||||
|id, _, _: &'a ast::MethodSig, _, _, _, _| id,
|
|id, _, _: &'a ast::MethodSig, _, _, _, _| id,
|
||||||
|c: ClosureParts<'_>| c.id)
|
|c: ClosureParts<'_>| c.id)
|
||||||
|
@ -213,7 +213,7 @@ impl<'a> FnLikeNode<'a> {
|
||||||
|
|
||||||
fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
|
fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
|
||||||
I: FnOnce(ItemFnParts<'a>) -> A,
|
I: FnOnce(ItemFnParts<'a>) -> A,
|
||||||
M: FnOnce(NodeId,
|
M: FnOnce(ast::HirId,
|
||||||
Ident,
|
Ident,
|
||||||
&'a ast::MethodSig,
|
&'a ast::MethodSig,
|
||||||
Option<&'a ast::Visibility>,
|
Option<&'a ast::Visibility>,
|
||||||
|
@ -227,7 +227,7 @@ impl<'a> FnLikeNode<'a> {
|
||||||
map::Node::Item(i) => match i.node {
|
map::Node::Item(i) => match i.node {
|
||||||
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
|
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
|
||||||
item_fn(ItemFnParts {
|
item_fn(ItemFnParts {
|
||||||
id: i.id,
|
id: i.hir_id,
|
||||||
ident: i.ident,
|
ident: i.ident,
|
||||||
decl: &decl,
|
decl: &decl,
|
||||||
body: block,
|
body: block,
|
||||||
|
@ -241,21 +241,21 @@ impl<'a> FnLikeNode<'a> {
|
||||||
},
|
},
|
||||||
map::Node::TraitItem(ti) => match ti.node {
|
map::Node::TraitItem(ti) => match ti.node {
|
||||||
ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => {
|
ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => {
|
||||||
method(ti.id, ti.ident, sig, None, body, ti.span, &ti.attrs)
|
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
|
||||||
}
|
}
|
||||||
_ => bug!("trait method FnLikeNode that is not fn-like"),
|
_ => bug!("trait method FnLikeNode that is not fn-like"),
|
||||||
},
|
},
|
||||||
map::Node::ImplItem(ii) => {
|
map::Node::ImplItem(ii) => {
|
||||||
match ii.node {
|
match ii.node {
|
||||||
ast::ImplItemKind::Method(ref sig, body) => {
|
ast::ImplItemKind::Method(ref sig, body) => {
|
||||||
method(ii.id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
|
method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
|
||||||
}
|
}
|
||||||
_ => bug!("impl method FnLikeNode that is not fn-like")
|
_ => bug!("impl method FnLikeNode that is not fn-like")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
map::Node::Expr(e) => match e.node {
|
map::Node::Expr(e) => match e.node {
|
||||||
ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
|
ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
|
||||||
closure(ClosureParts::new(&decl, block, e.id, e.span, &e.attrs)),
|
closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)),
|
||||||
_ => bug!("expr FnLikeNode that is not fn-like"),
|
_ => bug!("expr FnLikeNode that is not fn-like"),
|
||||||
},
|
},
|
||||||
_ => bug!("other FnLikeNode that is not fn-like"),
|
_ => bug!("other FnLikeNode that is not fn-like"),
|
||||||
|
|
|
@ -799,7 +799,7 @@ impl<'hir> Map<'hir> {
|
||||||
/// false
|
/// false
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get_return_block(&self, id: NodeId) -> Option<NodeId> {
|
pub fn get_return_block(&self, id: HirId) -> Option<HirId> {
|
||||||
let match_fn = |node: &Node<'_>| {
|
let match_fn = |node: &Node<'_>| {
|
||||||
match *node {
|
match *node {
|
||||||
Node::Item(_) |
|
Node::Item(_) |
|
||||||
|
@ -822,7 +822,10 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.walk_parent_nodes(id, match_fn, match_non_returning_block).ok()
|
let node_id = self.hir_to_node_id(id);
|
||||||
|
self.walk_parent_nodes(node_id, match_fn, match_non_returning_block)
|
||||||
|
.ok()
|
||||||
|
.map(|return_node_id| self.node_to_hir_id(return_node_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the `NodeId` for `id`'s parent item, or `id` itself if no
|
/// Retrieves the `NodeId` for `id`'s parent item, or `id` itself if no
|
||||||
|
|
|
@ -1333,7 +1333,6 @@ pub struct AnonConst {
|
||||||
/// An expression
|
/// An expression
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Expr {
|
pub struct Expr {
|
||||||
pub id: NodeId,
|
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub node: ExprKind,
|
pub node: ExprKind,
|
||||||
pub attrs: ThinVec<Attribute>,
|
pub attrs: ThinVec<Attribute>,
|
||||||
|
@ -1436,7 +1435,7 @@ impl Expr {
|
||||||
|
|
||||||
impl fmt::Debug for Expr {
|
impl fmt::Debug for Expr {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "expr({}: {})", self.id,
|
write!(f, "expr({}: {})", self.hir_id,
|
||||||
print::to_string(print::NO_ANN, |s| s.print_expr(self)))
|
print::to_string(print::NO_ANN, |s| s.print_expr(self)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -559,7 +559,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Expr {
|
||||||
hasher: &mut StableHasher<W>) {
|
hasher: &mut StableHasher<W>) {
|
||||||
hcx.while_hashing_hir_bodies(true, |hcx| {
|
hcx.while_hashing_hir_bodies(true, |hcx| {
|
||||||
let hir::Expr {
|
let hir::Expr {
|
||||||
id: _,
|
|
||||||
hir_id: _,
|
hir_id: _,
|
||||||
ref span,
|
ref span,
|
||||||
ref node,
|
ref node,
|
||||||
|
|
|
@ -723,7 +723,7 @@ fn lint_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cnum: CrateNum)
|
||||||
};
|
};
|
||||||
let krate = tcx.hir().krate();
|
let krate = tcx.hir().krate();
|
||||||
|
|
||||||
builder.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |builder| {
|
builder.with_lint_attrs(hir::CRATE_HIR_ID, &krate.attrs, |builder| {
|
||||||
intravisit::walk_crate(builder, krate);
|
intravisit::walk_crate(builder, krate);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -737,13 +737,13 @@ struct LintLevelMapBuilder<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
|
impl<'a, 'tcx> LintLevelMapBuilder<'a, 'tcx> {
|
||||||
fn with_lint_attrs<F>(&mut self,
|
fn with_lint_attrs<F>(&mut self,
|
||||||
id: ast::NodeId,
|
id: hir::HirId,
|
||||||
attrs: &[ast::Attribute],
|
attrs: &[ast::Attribute],
|
||||||
f: F)
|
f: F)
|
||||||
where F: FnOnce(&mut Self)
|
where F: FnOnce(&mut Self)
|
||||||
{
|
{
|
||||||
let push = self.levels.push(attrs);
|
let push = self.levels.push(attrs);
|
||||||
self.levels.register_id(self.tcx.hir().definitions().node_to_hir_id(id));
|
self.levels.register_id(id);
|
||||||
f(self);
|
f(self);
|
||||||
self.levels.pop(push);
|
self.levels.pop(push);
|
||||||
}
|
}
|
||||||
|
@ -755,25 +755,25 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||||
self.with_lint_attrs(it.id, &it.attrs, |builder| {
|
self.with_lint_attrs(it.hir_id, &it.attrs, |builder| {
|
||||||
intravisit::walk_item(builder, it);
|
intravisit::walk_item(builder, it);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
|
fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
|
||||||
self.with_lint_attrs(it.id, &it.attrs, |builder| {
|
self.with_lint_attrs(it.hir_id, &it.attrs, |builder| {
|
||||||
intravisit::walk_foreign_item(builder, it);
|
intravisit::walk_foreign_item(builder, it);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_expr(&mut self, e: &'tcx hir::Expr) {
|
fn visit_expr(&mut self, e: &'tcx hir::Expr) {
|
||||||
self.with_lint_attrs(e.id, &e.attrs, |builder| {
|
self.with_lint_attrs(e.hir_id, &e.attrs, |builder| {
|
||||||
intravisit::walk_expr(builder, e);
|
intravisit::walk_expr(builder, e);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
|
fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
|
||||||
self.with_lint_attrs(s.id, &s.attrs, |builder| {
|
self.with_lint_attrs(s.hir_id, &s.attrs, |builder| {
|
||||||
intravisit::walk_struct_field(builder, s);
|
intravisit::walk_struct_field(builder, s);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -782,25 +782,25 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> {
|
||||||
v: &'tcx hir::Variant,
|
v: &'tcx hir::Variant,
|
||||||
g: &'tcx hir::Generics,
|
g: &'tcx hir::Generics,
|
||||||
item_id: hir::HirId) {
|
item_id: hir::HirId) {
|
||||||
self.with_lint_attrs(v.node.data.id(), &v.node.attrs, |builder| {
|
self.with_lint_attrs(v.node.data.hir_id(), &v.node.attrs, |builder| {
|
||||||
intravisit::walk_variant(builder, v, g, item_id);
|
intravisit::walk_variant(builder, v, g, item_id);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_local(&mut self, l: &'tcx hir::Local) {
|
fn visit_local(&mut self, l: &'tcx hir::Local) {
|
||||||
self.with_lint_attrs(l.id, &l.attrs, |builder| {
|
self.with_lint_attrs(l.hir_id, &l.attrs, |builder| {
|
||||||
intravisit::walk_local(builder, l);
|
intravisit::walk_local(builder, l);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||||
self.with_lint_attrs(trait_item.id, &trait_item.attrs, |builder| {
|
self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |builder| {
|
||||||
intravisit::walk_trait_item(builder, trait_item);
|
intravisit::walk_trait_item(builder, trait_item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||||
self.with_lint_attrs(impl_item.id, &impl_item.attrs, |builder| {
|
self.with_lint_attrs(impl_item.hir_id, &impl_item.attrs, |builder| {
|
||||||
intravisit::walk_impl_item(builder, impl_item);
|
intravisit::walk_impl_item(builder, impl_item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,10 +99,10 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_field_access(&mut self, lhs: &hir::Expr, node_id: ast::NodeId) {
|
fn handle_field_access(&mut self, lhs: &hir::Expr, hir_id: hir::HirId) {
|
||||||
match self.tables.expr_ty_adjusted(lhs).sty {
|
match self.tables.expr_ty_adjusted(lhs).sty {
|
||||||
ty::Adt(def, _) => {
|
ty::Adt(def, _) => {
|
||||||
let index = self.tcx.field_index(node_id, self.tables);
|
let index = self.tcx.field_index(hir_id, self.tables);
|
||||||
self.insert_def_id(def.non_enum_variant().fields[index].did);
|
self.insert_def_id(def.non_enum_variant().fields[index].did);
|
||||||
}
|
}
|
||||||
ty::Tuple(..) => {}
|
ty::Tuple(..) => {}
|
||||||
|
@ -120,7 +120,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||||
if let PatKind::Wild = pat.node.pat.node {
|
if let PatKind::Wild = pat.node.pat.node {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let index = self.tcx.field_index(pat.node.id, self.tables);
|
let index = self.tcx.field_index(pat.node.hir_id, self.tables);
|
||||||
self.insert_def_id(variant.fields[index].did);
|
self.insert_def_id(variant.fields[index].did);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||||
fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &hir::HirVec<hir::Field>) {
|
fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &hir::HirVec<hir::Field>) {
|
||||||
if adt.is_union() && adt.non_enum_variant().fields.len() > 1 && adt.did.is_local() {
|
if adt.is_union() && adt.non_enum_variant().fields.len() > 1 && adt.did.is_local() {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let index = self.tcx.field_index(field.id, self.tables);
|
let index = self.tcx.field_index(field.hir_id, self.tables);
|
||||||
self.insert_def_id(adt.non_enum_variant().fields[index].did);
|
self.insert_def_id(adt.non_enum_variant().fields[index].did);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
||||||
self.lookup_and_handle_method(expr.hir_id);
|
self.lookup_and_handle_method(expr.hir_id);
|
||||||
}
|
}
|
||||||
hir::ExprKind::Field(ref lhs, ..) => {
|
hir::ExprKind::Field(ref lhs, ..) => {
|
||||||
self.handle_field_access(&lhs, expr.id);
|
self.handle_field_access(&lhs, expr.hir_id);
|
||||||
}
|
}
|
||||||
hir::ExprKind::Struct(_, ref fields, _) => {
|
hir::ExprKind::Struct(_, ref fields, _) => {
|
||||||
if let ty::Adt(ref adt, _) = self.tables.expr_ty(expr).sty {
|
if let ty::Adt(ref adt, _) = self.tables.expr_ty(expr).sty {
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub trait Delegate<'tcx> {
|
||||||
// The value found at `cmt` is either copied or moved, depending
|
// The value found at `cmt` is either copied or moved, depending
|
||||||
// on mode.
|
// on mode.
|
||||||
fn consume(&mut self,
|
fn consume(&mut self,
|
||||||
consume_id: ast::NodeId,
|
consume_id: hir::HirId,
|
||||||
consume_span: Span,
|
consume_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
mode: ConsumeMode);
|
mode: ConsumeMode);
|
||||||
|
@ -65,7 +65,7 @@ pub trait Delegate<'tcx> {
|
||||||
// The value found at `borrow` is being borrowed at the point
|
// The value found at `borrow` is being borrowed at the point
|
||||||
// `borrow_id` for the region `loan_region` with kind `bk`.
|
// `borrow_id` for the region `loan_region` with kind `bk`.
|
||||||
fn borrow(&mut self,
|
fn borrow(&mut self,
|
||||||
borrow_id: ast::NodeId,
|
borrow_id: hir::HirId,
|
||||||
borrow_span: Span,
|
borrow_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
loan_region: ty::Region<'tcx>,
|
loan_region: ty::Region<'tcx>,
|
||||||
|
@ -79,7 +79,7 @@ pub trait Delegate<'tcx> {
|
||||||
|
|
||||||
// The path at `cmt` is being assigned to.
|
// The path at `cmt` is being assigned to.
|
||||||
fn mutate(&mut self,
|
fn mutate(&mut self,
|
||||||
assignment_id: ast::NodeId,
|
assignment_id: hir::HirId,
|
||||||
assignment_span: Span,
|
assignment_span: Span,
|
||||||
assignee_cmt: &mc::cmt_<'tcx>,
|
assignee_cmt: &mc::cmt_<'tcx>,
|
||||||
mode: MutateMode);
|
mode: MutateMode);
|
||||||
|
@ -329,7 +329,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delegate_consume(&mut self,
|
fn delegate_consume(&mut self,
|
||||||
consume_id: ast::NodeId,
|
consume_id: hir::HirId,
|
||||||
consume_span: Span,
|
consume_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>) {
|
cmt: &mc::cmt_<'tcx>) {
|
||||||
debug!("delegate_consume(consume_id={}, cmt={:?})",
|
debug!("delegate_consume(consume_id={}, cmt={:?})",
|
||||||
|
@ -349,7 +349,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
debug!("consume_expr(expr={:?})", expr);
|
debug!("consume_expr(expr={:?})", expr);
|
||||||
|
|
||||||
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
||||||
self.delegate_consume(expr.id, expr.span, &cmt);
|
self.delegate_consume(expr.hir_id, expr.span, &cmt);
|
||||||
self.walk_expr(expr);
|
self.walk_expr(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
expr: &hir::Expr,
|
expr: &hir::Expr,
|
||||||
mode: MutateMode) {
|
mode: MutateMode) {
|
||||||
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
||||||
self.delegate.mutate(assignment_expr.id, span, &cmt, mode);
|
self.delegate.mutate(assignment_expr.hir_id, span, &cmt, mode);
|
||||||
self.walk_expr(expr);
|
self.walk_expr(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
expr, r, bk);
|
expr, r, bk);
|
||||||
|
|
||||||
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
||||||
self.delegate.borrow(expr.id, expr.span, &cmt, r, bk, cause);
|
self.delegate.borrow(expr.hir_id, expr.span, &cmt, r, bk, cause);
|
||||||
|
|
||||||
self.walk_expr(expr)
|
self.walk_expr(expr)
|
||||||
}
|
}
|
||||||
|
@ -662,7 +662,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
// Consume those fields of the with expression that are needed.
|
// Consume those fields of the with expression that are needed.
|
||||||
for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() {
|
for (f_index, with_field) in adt.non_enum_variant().fields.iter().enumerate() {
|
||||||
let is_mentioned = fields.iter().any(|f| {
|
let is_mentioned = fields.iter().any(|f| {
|
||||||
self.tcx().field_index(f.id, self.mc.tables) == f_index
|
self.tcx().field_index(f.hir_id, self.mc.tables) == f_index
|
||||||
});
|
});
|
||||||
if !is_mentioned {
|
if !is_mentioned {
|
||||||
let cmt_field = self.mc.cat_field(
|
let cmt_field = self.mc.cat_field(
|
||||||
|
@ -672,7 +672,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
with_field.ident,
|
with_field.ident,
|
||||||
with_field.ty(self.tcx(), substs)
|
with_field.ty(self.tcx(), substs)
|
||||||
);
|
);
|
||||||
self.delegate_consume(with_expr.id, with_expr.span, &cmt_field);
|
self.delegate_consume(with_expr.hir_id, with_expr.span, &cmt_field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
adjustment::Adjust::Unsize => {
|
adjustment::Adjust::Unsize => {
|
||||||
// Creating a closure/fn-pointer or unsizing consumes
|
// Creating a closure/fn-pointer or unsizing consumes
|
||||||
// the input and stores it into the resulting rvalue.
|
// the input and stores it into the resulting rvalue.
|
||||||
self.delegate_consume(expr.id, expr.span, &cmt);
|
self.delegate_consume(expr.hir_id, expr.span, &cmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustment::Adjust::Deref(None) => {}
|
adjustment::Adjust::Deref(None) => {}
|
||||||
|
@ -723,7 +723,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
// this is an autoref of `x`.
|
// this is an autoref of `x`.
|
||||||
adjustment::Adjust::Deref(Some(ref deref)) => {
|
adjustment::Adjust::Deref(Some(ref deref)) => {
|
||||||
let bk = ty::BorrowKind::from_mutbl(deref.mutbl);
|
let bk = ty::BorrowKind::from_mutbl(deref.mutbl);
|
||||||
self.delegate.borrow(expr.id, expr.span, &cmt, deref.region, bk, AutoRef);
|
self.delegate.borrow(expr.hir_id, expr.span, &cmt, deref.region, bk, AutoRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustment::Adjust::Borrow(ref autoref) => {
|
adjustment::Adjust::Borrow(ref autoref) => {
|
||||||
|
@ -741,14 +741,14 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
expr: &hir::Expr,
|
expr: &hir::Expr,
|
||||||
cmt_base: &mc::cmt_<'tcx>,
|
cmt_base: &mc::cmt_<'tcx>,
|
||||||
autoref: &adjustment::AutoBorrow<'tcx>) {
|
autoref: &adjustment::AutoBorrow<'tcx>) {
|
||||||
debug!("walk_autoref(expr.id={} cmt_base={:?} autoref={:?})",
|
debug!("walk_autoref(expr.hir_id={} cmt_base={:?} autoref={:?})",
|
||||||
expr.id,
|
expr.hir_id,
|
||||||
cmt_base,
|
cmt_base,
|
||||||
autoref);
|
autoref);
|
||||||
|
|
||||||
match *autoref {
|
match *autoref {
|
||||||
adjustment::AutoBorrow::Ref(r, m) => {
|
adjustment::AutoBorrow::Ref(r, m) => {
|
||||||
self.delegate.borrow(expr.id,
|
self.delegate.borrow(expr.hir_id,
|
||||||
expr.span,
|
expr.span,
|
||||||
cmt_base,
|
cmt_base,
|
||||||
r,
|
r,
|
||||||
|
@ -757,8 +757,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustment::AutoBorrow::RawPtr(m) => {
|
adjustment::AutoBorrow::RawPtr(m) => {
|
||||||
debug!("walk_autoref: expr.id={} cmt_base={:?}",
|
debug!("walk_autoref: expr.hir_id={} cmt_base={:?}",
|
||||||
expr.id,
|
expr.hir_id,
|
||||||
cmt_base);
|
cmt_base);
|
||||||
|
|
||||||
// Converting from a &T to *T (or &mut T to *mut T) is
|
// Converting from a &T to *T (or &mut T to *mut T) is
|
||||||
|
@ -770,7 +770,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
data: region::ScopeData::Node
|
data: region::ScopeData::Node
|
||||||
}));
|
}));
|
||||||
|
|
||||||
self.delegate.borrow(expr.id,
|
self.delegate.borrow(expr.hir_id,
|
||||||
expr.span,
|
expr.span,
|
||||||
cmt_base,
|
cmt_base,
|
||||||
r,
|
r,
|
||||||
|
@ -864,7 +864,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
// binding being produced.
|
// binding being produced.
|
||||||
let def = Def::Local(canonical_id);
|
let def = Def::Local(canonical_id);
|
||||||
if let Ok(ref binding_cmt) = mc.cat_def(pat.hir_id, pat.span, pat_ty, def) {
|
if let Ok(ref binding_cmt) = mc.cat_def(pat.hir_id, pat.span, pat_ty, def) {
|
||||||
delegate.mutate(pat.id, pat.span, binding_cmt, MutateMode::Init);
|
delegate.mutate(pat.hir_id, pat.span, binding_cmt, MutateMode::Init);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is also a borrow or copy/move of the value being matched.
|
// It is also a borrow or copy/move of the value being matched.
|
||||||
|
@ -872,7 +872,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
ty::BindByReference(m) => {
|
ty::BindByReference(m) => {
|
||||||
if let ty::Ref(r, _, _) = pat_ty.sty {
|
if let ty::Ref(r, _, _) = pat_ty.sty {
|
||||||
let bk = ty::BorrowKind::from_mutbl(m);
|
let bk = ty::BorrowKind::from_mutbl(m);
|
||||||
delegate.borrow(pat.id, pat.span, &cmt_pat, r, bk, RefBinding);
|
delegate.borrow(pat.hir_id, pat.span, &cmt_pat, r, bk, RefBinding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::BindByValue(..) => {
|
ty::BindByValue(..) => {
|
||||||
|
@ -920,10 +920,11 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
|
fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
|
||||||
debug!("walk_captures({:?})", closure_expr);
|
debug!("walk_captures({:?})", closure_expr);
|
||||||
|
|
||||||
self.tcx().with_freevars(closure_expr.id, |freevars| {
|
let closure_node_id = self.tcx().hir().hir_to_node_id(closure_expr.hir_id);
|
||||||
|
let closure_def_id = self.tcx().hir().local_def_id(closure_node_id);
|
||||||
|
self.tcx().with_freevars(closure_node_id, |freevars| {
|
||||||
for freevar in freevars {
|
for freevar in freevars {
|
||||||
let var_hir_id = self.tcx().hir().node_to_hir_id(freevar.var_id());
|
let var_hir_id = self.tcx().hir().node_to_hir_id(freevar.var_id());
|
||||||
let closure_def_id = self.tcx().hir().local_def_id(closure_expr.id);
|
|
||||||
let upvar_id = ty::UpvarId {
|
let upvar_id = ty::UpvarId {
|
||||||
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
||||||
closure_expr_id: closure_def_id.to_local(),
|
closure_expr_id: closure_def_id.to_local(),
|
||||||
|
@ -938,10 +939,10 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
self.param_env,
|
self.param_env,
|
||||||
&cmt_var,
|
&cmt_var,
|
||||||
CaptureMove);
|
CaptureMove);
|
||||||
self.delegate.consume(closure_expr.id, freevar.span, &cmt_var, mode);
|
self.delegate.consume(closure_expr.hir_id, freevar.span, &cmt_var, mode);
|
||||||
}
|
}
|
||||||
ty::UpvarCapture::ByRef(upvar_borrow) => {
|
ty::UpvarCapture::ByRef(upvar_borrow) => {
|
||||||
self.delegate.borrow(closure_expr.id,
|
self.delegate.borrow(closure_expr.hir_id,
|
||||||
fn_decl_span,
|
fn_decl_span,
|
||||||
&cmt_var,
|
&cmt_var,
|
||||||
upvar_borrow.region,
|
upvar_borrow.region,
|
||||||
|
|
|
@ -265,7 +265,7 @@ struct IrMaps<'a, 'tcx: 'a> {
|
||||||
num_vars: usize,
|
num_vars: usize,
|
||||||
live_node_map: HirIdMap<LiveNode>,
|
live_node_map: HirIdMap<LiveNode>,
|
||||||
variable_map: HirIdMap<Variable>,
|
variable_map: HirIdMap<Variable>,
|
||||||
capture_info_map: NodeMap<Rc<Vec<CaptureInfo>>>,
|
capture_info_map: HirIdMap<Rc<Vec<CaptureInfo>>>,
|
||||||
var_kinds: Vec<VarKind>,
|
var_kinds: Vec<VarKind>,
|
||||||
lnks: Vec<LiveNodeKind>,
|
lnks: Vec<LiveNodeKind>,
|
||||||
}
|
}
|
||||||
|
@ -344,8 +344,8 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_captures(&mut self, node_id: NodeId, cs: Vec<CaptureInfo>) {
|
fn set_captures(&mut self, hir_id: HirId, cs: Vec<CaptureInfo>) {
|
||||||
self.capture_info_map.insert(node_id, Rc::new(cs));
|
self.capture_info_map.insert(hir_id, Rc::new(cs));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lnk(&self, ln: LiveNode) -> LiveNodeKind {
|
fn lnk(&self, ln: LiveNode) -> LiveNodeKind {
|
||||||
|
@ -460,7 +460,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
// live nodes required for uses or definitions of variables:
|
// live nodes required for uses or definitions of variables:
|
||||||
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
|
hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => {
|
||||||
debug!("expr {}: path that leads to {:?}", expr.id, path.def);
|
debug!("expr {}: path that leads to {:?}", expr.hir_id, path.def);
|
||||||
if let Def::Local(..) = path.def {
|
if let Def::Local(..) = path.def {
|
||||||
ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span));
|
ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span));
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,8 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
|
||||||
// in better error messages than just pointing at the closure
|
// in better error messages than just pointing at the closure
|
||||||
// construction site.
|
// construction site.
|
||||||
let mut call_caps = Vec::new();
|
let mut call_caps = Vec::new();
|
||||||
ir.tcx.with_freevars(expr.id, |freevars| {
|
let node_id = ir.tcx.hir().hir_to_node_id(expr.hir_id);
|
||||||
|
ir.tcx.with_freevars(node_id, |freevars| {
|
||||||
call_caps.extend(freevars.iter().filter_map(|fv| {
|
call_caps.extend(freevars.iter().filter_map(|fv| {
|
||||||
if let Def::Local(rv) = fv.def {
|
if let Def::Local(rv) = fv.def {
|
||||||
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
|
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
|
||||||
|
@ -487,7 +488,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
ir.set_captures(expr.id, call_caps);
|
ir.set_captures(expr.hir_id, call_caps);
|
||||||
|
|
||||||
intravisit::walk_expr(ir, expr);
|
intravisit::walk_expr(ir, expr);
|
||||||
}
|
}
|
||||||
|
@ -925,7 +926,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute(&mut self, body: &hir::Expr) -> LiveNode {
|
fn compute(&mut self, body: &hir::Expr) -> LiveNode {
|
||||||
debug!("compute: using id for body, {}", self.ir.tcx.hir().node_to_pretty_string(body.id));
|
debug!("compute: using id for body, {}",
|
||||||
|
self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
|
||||||
|
|
||||||
// the fallthrough exit is only for those cases where we do not
|
// the fallthrough exit is only for those cases where we do not
|
||||||
// explicitly return:
|
// explicitly return:
|
||||||
|
@ -940,7 +942,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
for ln_idx in 0..self.ir.num_live_nodes {
|
for ln_idx in 0..self.ir.num_live_nodes {
|
||||||
debug!("{:?}", self.ln_str(LiveNode(ln_idx as u32)));
|
debug!("{:?}", self.ln_str(LiveNode(ln_idx as u32)));
|
||||||
}
|
}
|
||||||
body.id
|
body.hir_id
|
||||||
},
|
},
|
||||||
entry_ln);
|
entry_ln);
|
||||||
|
|
||||||
|
@ -1003,7 +1005,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
|
|
||||||
fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
|
fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
|
||||||
-> LiveNode {
|
-> LiveNode {
|
||||||
debug!("propagate_through_expr: {}", self.ir.tcx.hir().node_to_pretty_string(expr.id));
|
debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id));
|
||||||
|
|
||||||
match expr.node {
|
match expr.node {
|
||||||
// Interesting cases with control flow or which gen/kill
|
// Interesting cases with control flow or which gen/kill
|
||||||
|
@ -1017,11 +1019,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
|
|
||||||
hir::ExprKind::Closure(..) => {
|
hir::ExprKind::Closure(..) => {
|
||||||
debug!("{} is an ExprKind::Closure",
|
debug!("{} is an ExprKind::Closure",
|
||||||
self.ir.tcx.hir().node_to_pretty_string(expr.id));
|
self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id));
|
||||||
|
|
||||||
// the construction of a closure itself is not important,
|
// the construction of a closure itself is not important,
|
||||||
// but we have to consider the closed over variables.
|
// but we have to consider the closed over variables.
|
||||||
let caps = self.ir.capture_info_map.get(&expr.id).cloned().unwrap_or_else(||
|
let caps = self.ir.capture_info_map.get(&expr.hir_id).cloned().unwrap_or_else(||
|
||||||
span_bug!(expr.span, "no registered caps"));
|
span_bug!(expr.span, "no registered caps"));
|
||||||
|
|
||||||
caps.iter().rev().fold(succ, |succ, cap| {
|
caps.iter().rev().fold(succ, |succ, cap| {
|
||||||
|
@ -1170,7 +1172,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprKind::Call(ref f, ref args) => {
|
hir::ExprKind::Call(ref f, ref args) => {
|
||||||
let m = self.ir.tcx.hir().get_module_parent(expr.id);
|
let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
|
||||||
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
|
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
|
||||||
self.s.exit_ln
|
self.s.exit_ln
|
||||||
} else {
|
} else {
|
||||||
|
@ -1181,7 +1183,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprKind::MethodCall(.., ref args) => {
|
hir::ExprKind::MethodCall(.., ref args) => {
|
||||||
let m = self.ir.tcx.hir().get_module_parent(expr.id);
|
let m = self.ir.tcx.hir().get_module_parent_by_hir_id(expr.hir_id);
|
||||||
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
|
let succ = if self.ir.tcx.is_ty_uninhabited_from(m, self.tables.expr_ty(expr)) {
|
||||||
self.s.exit_ln
|
self.s.exit_ln
|
||||||
} else {
|
} else {
|
||||||
|
@ -1387,17 +1389,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!("propagate_through_loop: using id for loop body {} {}",
|
debug!("propagate_through_loop: using id for loop body {} {}",
|
||||||
expr.id, self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
|
expr.hir_id, self.ir.tcx.hir().hir_to_pretty_string(body.hir_id));
|
||||||
|
|
||||||
|
let node_id = self.ir.tcx.hir().hir_to_node_id(expr.hir_id);
|
||||||
self.break_ln.insert(expr.id, succ);
|
self.break_ln.insert(node_id, succ);
|
||||||
|
|
||||||
let cond_ln = match kind {
|
let cond_ln = match kind {
|
||||||
LoopLoop => ln,
|
LoopLoop => ln,
|
||||||
WhileLoop(ref cond) => self.propagate_through_expr(&cond, ln),
|
WhileLoop(ref cond) => self.propagate_through_expr(&cond, ln),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.cont_ln.insert(expr.id, cond_ln);
|
self.cont_ln.insert(node_id, cond_ln);
|
||||||
|
|
||||||
let body_ln = self.propagate_through_block(body, cond_ln);
|
let body_ln = self.propagate_through_block(body, cond_ln);
|
||||||
|
|
||||||
|
|
|
@ -632,7 +632,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
|
pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
|
||||||
debug!("cat_expr: id={} expr={:?}", expr.id, expr);
|
debug!("cat_expr: id={} expr={:?}", expr.hir_id, expr);
|
||||||
|
|
||||||
let expr_ty = self.expr_ty(expr)?;
|
let expr_ty = self.expr_ty(expr)?;
|
||||||
match expr.node {
|
match expr.node {
|
||||||
|
@ -648,10 +648,10 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
hir::ExprKind::Field(ref base, f_ident) => {
|
hir::ExprKind::Field(ref base, f_ident) => {
|
||||||
let base_cmt = Rc::new(self.cat_expr(&base)?);
|
let base_cmt = Rc::new(self.cat_expr(&base)?);
|
||||||
debug!("cat_expr(cat_field): id={} expr={:?} base={:?}",
|
debug!("cat_expr(cat_field): id={} expr={:?} base={:?}",
|
||||||
expr.id,
|
expr.hir_id,
|
||||||
expr,
|
expr,
|
||||||
base_cmt);
|
base_cmt);
|
||||||
let f_index = self.tcx.field_index(expr.id, self.tables);
|
let f_index = self.tcx.field_index(expr.hir_id, self.tables);
|
||||||
Ok(self.cat_field(expr, base_cmt, f_index, f_ident, expr_ty))
|
Ok(self.cat_field(expr, base_cmt, f_index, f_ident, expr_ty))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1321,7 +1321,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
for fp in field_pats {
|
for fp in field_pats {
|
||||||
let field_ty = self.pat_ty_adjusted(&fp.node.pat)?; // see (*2)
|
let field_ty = self.pat_ty_adjusted(&fp.node.pat)?; // see (*2)
|
||||||
let f_index = self.tcx.field_index(fp.node.id, self.tables);
|
let f_index = self.tcx.field_index(fp.node.hir_id, self.tables);
|
||||||
let cmt_field = Rc::new(self.cat_field(pat, cmt.clone(), f_index,
|
let cmt_field = Rc::new(self.cat_field(pat, cmt.clone(), f_index,
|
||||||
fp.node.ident, field_ty));
|
fp.node.ident, field_ty));
|
||||||
self.cat_pattern_(cmt_field, &fp.node.pat, op)?;
|
self.cat_pattern_(cmt_field, &fp.node.pat, op)?;
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::session::{DiagnosticMessageId, Session};
|
||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
use syntax_pos::{Span, MultiSpan};
|
use syntax_pos::{Span, MultiSpan};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast::{NodeId, Attribute};
|
use syntax::ast::Attribute;
|
||||||
use syntax::errors::Applicability;
|
use syntax::errors::Applicability;
|
||||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||||
use syntax::attr::{self, Stability, Deprecation};
|
use syntax::attr::{self, Stability, Deprecation};
|
||||||
|
@ -557,9 +557,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
/// If `id` is `Some(_)`, this function will also check if the item at `def_id` has been
|
/// If `id` is `Some(_)`, this function will also check if the item at `def_id` has been
|
||||||
/// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
|
/// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
|
||||||
/// `id`.
|
/// `id`.
|
||||||
pub fn eval_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) -> EvalResult {
|
pub fn eval_stability(self, def_id: DefId, id: Option<HirId>, span: Span) -> EvalResult {
|
||||||
let lint_deprecated = |def_id: DefId,
|
let lint_deprecated = |def_id: DefId,
|
||||||
id: NodeId,
|
id: HirId,
|
||||||
note: Option<Symbol>,
|
note: Option<Symbol>,
|
||||||
suggestion: Option<Symbol>,
|
suggestion: Option<Symbol>,
|
||||||
message: &str,
|
message: &str,
|
||||||
|
@ -570,9 +570,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
format!("{}", message)
|
format!("{}", message)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut diag = self.struct_span_lint_node(lint, id, span, &msg);
|
let mut diag = self.struct_span_lint_hir(lint, id, span, &msg);
|
||||||
if let Some(suggestion) = suggestion {
|
if let Some(suggestion) = suggestion {
|
||||||
if let hir::Node::Expr(_) = self.hir().get(id) {
|
if let hir::Node::Expr(_) = self.hir().get_by_hir_id(id) {
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
span,
|
span,
|
||||||
&msg,
|
&msg,
|
||||||
|
@ -582,15 +582,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diag.emit();
|
diag.emit();
|
||||||
if id == ast::DUMMY_NODE_ID {
|
if id == hir::DUMMY_HIR_ID {
|
||||||
span_bug!(span, "emitted a {} lint with dummy node id: {:?}", lint.name, def_id);
|
span_bug!(span, "emitted a {} lint with dummy HIR id: {:?}", lint.name, def_id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Deprecated attributes apply in-crate and cross-crate.
|
// Deprecated attributes apply in-crate and cross-crate.
|
||||||
if let Some(id) = id {
|
if let Some(id) = id {
|
||||||
if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
|
if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
|
||||||
let parent_def_id = self.hir().local_def_id(self.hir().get_parent(id));
|
let parent_def_id = self.hir().local_def_id_from_hir_id(
|
||||||
|
self.hir().get_parent_item(id));
|
||||||
let skip = self.lookup_deprecation_entry(parent_def_id)
|
let skip = self.lookup_deprecation_entry(parent_def_id)
|
||||||
.map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));
|
.map_or(false, |parent_depr| parent_depr.same_origin(&depr_entry));
|
||||||
|
|
||||||
|
@ -703,7 +704,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
///
|
///
|
||||||
/// Additionally, this function will also check if the item is deprecated. If so, and `id` is
|
/// Additionally, this function will also check if the item is deprecated. If so, and `id` is
|
||||||
/// not `None`, a deprecated lint attached to `id` will be emitted.
|
/// not `None`, a deprecated lint attached to `id` will be emitted.
|
||||||
pub fn check_stability(self, def_id: DefId, id: Option<NodeId>, span: Span) {
|
pub fn check_stability(self, def_id: DefId, id: Option<HirId>, span: Span) {
|
||||||
match self.eval_stability(def_id, id, span) {
|
match self.eval_stability(def_id, id, span) {
|
||||||
EvalResult::Allow => {}
|
EvalResult::Allow => {}
|
||||||
EvalResult::Deny { feature, reason, issue } => {
|
EvalResult::Deny { feature, reason, issue } => {
|
||||||
|
@ -763,7 +764,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
|
let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
|
||||||
self.tcx.check_stability(def_id, Some(item.id), item.span);
|
self.tcx.check_stability(def_id, Some(item.hir_id), item.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For implementations of traits, check the stability of each item
|
// For implementations of traits, check the stability of each item
|
||||||
|
@ -811,7 +812,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) {
|
fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) {
|
||||||
let id = self.tcx.hir().hir_to_node_id(id);
|
|
||||||
if let Some(def_id) = path.def.opt_def_id() {
|
if let Some(def_id) = path.def.opt_def_id() {
|
||||||
self.tcx.check_stability(def_id, Some(id), path.span)
|
self.tcx.check_stability(def_id, Some(id), path.span)
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,10 +257,10 @@ pub enum ObligationCauseCode<'tcx> {
|
||||||
ReturnNoExpression,
|
ReturnNoExpression,
|
||||||
|
|
||||||
/// `return` with an expression
|
/// `return` with an expression
|
||||||
ReturnType(ast::NodeId),
|
ReturnType(hir::HirId),
|
||||||
|
|
||||||
/// Block implicit return
|
/// Block implicit return
|
||||||
BlockTailExpression(ast::NodeId),
|
BlockTailExpression(hir::HirId),
|
||||||
|
|
||||||
/// #[feature(trivial_bounds)] is not enabled
|
/// #[feature(trivial_bounds)] is not enabled
|
||||||
TrivialBound,
|
TrivialBound,
|
||||||
|
|
|
@ -2775,8 +2775,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn field_index(self, node_id: NodeId, tables: &TypeckTables<'_>) -> usize {
|
pub fn field_index(self, hir_id: hir::HirId, tables: &TypeckTables<'_>) -> usize {
|
||||||
let hir_id = self.hir().node_to_hir_id(node_id);
|
|
||||||
tables.field_indices().get(hir_id).cloned().expect("no index for a field")
|
tables.field_indices().get(hir_id).cloned().expect("no index for a field")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,15 +89,14 @@ struct CheckLoanCtxt<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
|
||||||
fn consume(&mut self,
|
fn consume(&mut self,
|
||||||
consume_id: ast::NodeId,
|
consume_id: hir::HirId,
|
||||||
consume_span: Span,
|
consume_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
mode: euv::ConsumeMode) {
|
mode: euv::ConsumeMode) {
|
||||||
debug!("consume(consume_id={}, cmt={:?}, mode={:?})",
|
debug!("consume(consume_id={}, cmt={:?}, mode={:?})",
|
||||||
consume_id, cmt, mode);
|
consume_id, cmt, mode);
|
||||||
|
|
||||||
let hir_id = self.tcx().hir().node_to_hir_id(consume_id);
|
self.consume_common(consume_id.local_id, consume_span, cmt, mode);
|
||||||
self.consume_common(hir_id.local_id, consume_span, cmt, mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn matched_pat(&mut self,
|
fn matched_pat(&mut self,
|
||||||
|
@ -118,7 +117,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn borrow(&mut self,
|
fn borrow(&mut self,
|
||||||
borrow_id: ast::NodeId,
|
borrow_id: hir::HirId,
|
||||||
borrow_span: Span,
|
borrow_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
loan_region: ty::Region<'tcx>,
|
loan_region: ty::Region<'tcx>,
|
||||||
|
@ -130,22 +129,21 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
|
||||||
borrow_id, cmt, loan_region,
|
borrow_id, cmt, loan_region,
|
||||||
bk, loan_cause);
|
bk, loan_cause);
|
||||||
|
|
||||||
let hir_id = self.tcx().hir().node_to_hir_id(borrow_id);
|
|
||||||
if let Some(lp) = opt_loan_path(cmt) {
|
if let Some(lp) = opt_loan_path(cmt) {
|
||||||
let moved_value_use_kind = match loan_cause {
|
let moved_value_use_kind = match loan_cause {
|
||||||
euv::ClosureCapture(_) => MovedInCapture,
|
euv::ClosureCapture(_) => MovedInCapture,
|
||||||
_ => MovedInUse,
|
_ => MovedInUse,
|
||||||
};
|
};
|
||||||
self.check_if_path_is_moved(hir_id.local_id, borrow_span, moved_value_use_kind, &lp);
|
self.check_if_path_is_moved(borrow_id.local_id, borrow_span, moved_value_use_kind, &lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.check_for_conflicting_loans(hir_id.local_id);
|
self.check_for_conflicting_loans(borrow_id.local_id);
|
||||||
|
|
||||||
self.check_for_loans_across_yields(cmt, loan_region, borrow_span);
|
self.check_for_loans_across_yields(cmt, loan_region, borrow_span);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mutate(&mut self,
|
fn mutate(&mut self,
|
||||||
assignment_id: ast::NodeId,
|
assignment_id: hir::HirId,
|
||||||
assignment_span: Span,
|
assignment_span: Span,
|
||||||
assignee_cmt: &mc::cmt_<'tcx>,
|
assignee_cmt: &mc::cmt_<'tcx>,
|
||||||
mode: euv::MutateMode)
|
mode: euv::MutateMode)
|
||||||
|
@ -176,8 +174,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.check_assignment(self.tcx().hir().node_to_hir_id(assignment_id).local_id,
|
self.check_assignment(assignment_id.local_id, assignment_span, assignee_cmt);
|
||||||
assignment_span, assignee_cmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) { }
|
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) { }
|
||||||
|
@ -188,7 +185,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||||
move_data: &move_data::FlowedMoveData<'c, 'tcx>,
|
move_data: &move_data::FlowedMoveData<'c, 'tcx>,
|
||||||
all_loans: &[Loan<'tcx>],
|
all_loans: &[Loan<'tcx>],
|
||||||
body: &hir::Body) {
|
body: &hir::Body) {
|
||||||
debug!("check_loans(body id={})", body.value.id);
|
debug!("check_loans(body id={})", body.value.hir_id);
|
||||||
|
|
||||||
let def_id = bccx.tcx.hir().body_owner_def_id(body.id());
|
let def_id = bccx.tcx.hir().body_owner_def_id(body.id());
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct GatherLoanCtxt<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||||
fn consume(&mut self,
|
fn consume(&mut self,
|
||||||
consume_id: ast::NodeId,
|
consume_id: hir::HirId,
|
||||||
_consume_span: Span,
|
_consume_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
mode: euv::ConsumeMode) {
|
mode: euv::ConsumeMode) {
|
||||||
|
@ -79,7 +79,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||||
euv::Move(move_reason) => {
|
euv::Move(move_reason) => {
|
||||||
gather_moves::gather_move_from_expr(
|
gather_moves::gather_move_from_expr(
|
||||||
self.bccx, &self.move_data, &mut self.move_error_collector,
|
self.bccx, &self.move_data, &mut self.move_error_collector,
|
||||||
self.bccx.tcx.hir().node_to_hir_id(consume_id).local_id, cmt, move_reason);
|
consume_id.local_id, cmt, move_reason);
|
||||||
}
|
}
|
||||||
euv::Copy => { }
|
euv::Copy => { }
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn borrow(&mut self,
|
fn borrow(&mut self,
|
||||||
borrow_id: ast::NodeId,
|
borrow_id: hir::HirId,
|
||||||
borrow_span: Span,
|
borrow_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
loan_region: ty::Region<'tcx>,
|
loan_region: ty::Region<'tcx>,
|
||||||
|
@ -126,8 +126,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||||
bk={:?}, loan_cause={:?})",
|
bk={:?}, loan_cause={:?})",
|
||||||
borrow_id, cmt, loan_region,
|
borrow_id, cmt, loan_region,
|
||||||
bk, loan_cause);
|
bk, loan_cause);
|
||||||
let hir_id = self.bccx.tcx.hir().node_to_hir_id(borrow_id);
|
|
||||||
self.guarantee_valid(hir_id.local_id,
|
self.guarantee_valid(borrow_id.local_id,
|
||||||
borrow_span,
|
borrow_span,
|
||||||
cmt,
|
cmt,
|
||||||
bk,
|
bk,
|
||||||
|
@ -136,12 +136,13 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mutate(&mut self,
|
fn mutate(&mut self,
|
||||||
assignment_id: ast::NodeId,
|
assignment_id: hir::HirId,
|
||||||
assignment_span: Span,
|
assignment_span: Span,
|
||||||
assignee_cmt: &mc::cmt_<'tcx>,
|
assignee_cmt: &mc::cmt_<'tcx>,
|
||||||
_: euv::MutateMode)
|
_: euv::MutateMode)
|
||||||
{
|
{
|
||||||
self.guarantee_assignment_valid(assignment_id,
|
let node_id = self.bccx.tcx.hir().hir_to_node_id(assignment_id);
|
||||||
|
self.guarantee_assignment_valid(node_id,
|
||||||
assignment_span,
|
assignment_span,
|
||||||
assignee_cmt);
|
assignee_cmt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,8 +425,8 @@ impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
|
||||||
}
|
}
|
||||||
pprust_hir::AnnNode::Expr(expr) => {
|
pprust_hir::AnnNode::Expr(expr) => {
|
||||||
s.s.space()?;
|
s.s.space()?;
|
||||||
s.synth_comment(format!("node_id: {} hir local_id: {}",
|
s.synth_comment(format!("expr hir_id: {} hir local_id: {}",
|
||||||
expr.id, expr.hir_id.local_id.as_u32()))?;
|
expr.hir_id, expr.hir_id.local_id.as_u32()))?;
|
||||||
s.pclose()
|
s.pclose()
|
||||||
}
|
}
|
||||||
pprust_hir::AnnNode::Pat(pat) => {
|
pprust_hir::AnnNode::Pat(pat) => {
|
||||||
|
@ -834,15 +834,15 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
|
||||||
let body_id = match code {
|
let body_id = match code {
|
||||||
blocks::Code::Expr(expr) => {
|
blocks::Code::Expr(expr) => {
|
||||||
// Find the function this expression is from.
|
// Find the function this expression is from.
|
||||||
let mut node_id = expr.id;
|
let mut hir_id = expr.hir_id;
|
||||||
loop {
|
loop {
|
||||||
let node = tcx.hir().get(node_id);
|
let node = tcx.hir().get_by_hir_id(hir_id);
|
||||||
if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
|
if let Some(n) = hir::map::blocks::FnLikeNode::from_node(node) {
|
||||||
break n.body();
|
break n.body();
|
||||||
}
|
}
|
||||||
let parent = tcx.hir().get_parent_node(node_id);
|
let parent = tcx.hir().get_parent_node_by_hir_id(hir_id);
|
||||||
assert_ne!(node_id, parent);
|
assert_ne!(hir_id, parent);
|
||||||
node_id = parent;
|
hir_id = parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blocks::Code::FnLike(fn_like) => fn_like.body(),
|
blocks::Code::FnLike(fn_like) => fn_like.body(),
|
||||||
|
|
|
@ -200,7 +200,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
|
||||||
}
|
}
|
||||||
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.hir_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,
|
||||||
fieldpat.span,
|
fieldpat.span,
|
||||||
&format!("the `{}:` in this pattern is redundant", ident));
|
&format!("the `{}:` in this pattern is redundant", ident));
|
||||||
|
|
|
@ -48,12 +48,12 @@ declare_lint! {
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct TypeLimits {
|
pub struct TypeLimits {
|
||||||
/// Id of the last visited negated expression
|
/// Id of the last visited negated expression
|
||||||
negated_expr_id: ast::NodeId,
|
negated_expr_id: hir::HirId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TypeLimits {
|
impl TypeLimits {
|
||||||
pub fn new() -> TypeLimits {
|
pub fn new() -> TypeLimits {
|
||||||
TypeLimits { negated_expr_id: ast::DUMMY_NODE_ID }
|
TypeLimits { negated_expr_id: hir::DUMMY_HIR_ID }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||||
match e.node {
|
match e.node {
|
||||||
hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
|
hir::ExprKind::Unary(hir::UnNeg, ref expr) => {
|
||||||
// propagate negation, if the negation itself isn't negated
|
// propagate negation, if the negation itself isn't negated
|
||||||
if self.negated_expr_id != e.id {
|
if self.negated_expr_id != e.hir_id {
|
||||||
self.negated_expr_id = expr.id;
|
self.negated_expr_id = expr.hir_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprKind::Binary(binop, ref l, ref r) => {
|
hir::ExprKind::Binary(binop, ref l, ref r) => {
|
||||||
|
@ -97,7 +97,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||||
};
|
};
|
||||||
let (_, max) = int_ty_range(int_type);
|
let (_, max) = int_ty_range(int_type);
|
||||||
let max = max as u128;
|
let max = max as u128;
|
||||||
let negative = self.negated_expr_id == e.id;
|
let negative = self.negated_expr_id == e.hir_id;
|
||||||
|
|
||||||
// Detect literal value out of range [min, max] inclusive
|
// Detect literal value out of range [min, max] inclusive
|
||||||
// avoiding use of -min to prevent overflow/panic
|
// avoiding use of -min to prevent overflow/panic
|
||||||
|
@ -138,8 +138,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
if lit_val < min || lit_val > max {
|
if lit_val < min || lit_val > max {
|
||||||
let parent_id = cx.tcx.hir().get_parent_node(e.id);
|
let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(e.hir_id);
|
||||||
if let Node::Expr(parent_expr) = cx.tcx.hir().get(parent_id) {
|
if let Node::Expr(parent_expr) = cx.tcx.hir().get_by_hir_id(parent_id) {
|
||||||
if let hir::ExprKind::Cast(..) = parent_expr.node {
|
if let hir::ExprKind::Cast(..) = parent_expr.node {
|
||||||
if let ty::Char = cx.tables.expr_ty(parent_expr).sty {
|
if let ty::Char = cx.tables.expr_ty(parent_expr).sty {
|
||||||
let mut err = cx.struct_span_lint(
|
let mut err = cx.struct_span_lint(
|
||||||
|
|
|
@ -58,7 +58,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
||||||
|
|
||||||
let t = cx.tables.expr_ty(&expr);
|
let t = cx.tables.expr_ty(&expr);
|
||||||
let type_permits_lack_of_use = if t.is_unit()
|
let type_permits_lack_of_use = if t.is_unit()
|
||||||
|| cx.tcx.is_ty_uninhabited_from(cx.tcx.hir().get_module_parent(expr.id), t) {
|
|| cx.tcx.is_ty_uninhabited_from(
|
||||||
|
cx.tcx.hir().get_module_parent_by_hir_id(expr.hir_id), t)
|
||||||
|
{
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
match t.sty {
|
match t.sty {
|
||||||
|
|
|
@ -1729,7 +1729,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||||
fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
|
fn encode_info_for_expr(&mut self, expr: &hir::Expr) {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprKind::Closure(..) => {
|
hir::ExprKind::Closure(..) => {
|
||||||
let def_id = self.tcx.hir().local_def_id(expr.id);
|
let def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
|
||||||
self.record(def_id, IsolatedEncoder::encode_info_for_closure, def_id);
|
self.record(def_id, IsolatedEncoder::encode_info_for_closure, def_id);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -103,7 +103,7 @@ fn mirror_stmts<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
},
|
},
|
||||||
pattern,
|
pattern,
|
||||||
initializer: local.init.to_ref(),
|
initializer: local.init.to_ref(),
|
||||||
lint_level: cx.lint_level_of(local.id),
|
lint_level: cx.lint_level_of(local.hir_id),
|
||||||
},
|
},
|
||||||
opt_destruction_scope: opt_dxn_ext,
|
opt_destruction_scope: opt_dxn_ext,
|
||||||
span: stmt_span,
|
span: stmt_span,
|
||||||
|
|
|
@ -24,7 +24,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
||||||
data: region::ScopeData::Node
|
data: region::ScopeData::Node
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("Expr::make_mirror(): id={}, span={:?}", self.id, self.span);
|
debug!("Expr::make_mirror(): id={}, span={:?}", self.hir_id, self.span);
|
||||||
|
|
||||||
let mut expr = make_mirror_unadjusted(cx, self);
|
let mut expr = make_mirror_unadjusted(cx, self);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
|
||||||
kind: ExprKind::Scope {
|
kind: ExprKind::Scope {
|
||||||
region_scope: expr_scope,
|
region_scope: expr_scope,
|
||||||
value: expr.to_ref(),
|
value: expr.to_ref(),
|
||||||
lint_level: cx.lint_level_of(self.id),
|
lint_level: cx.lint_level_of(self.hir_id),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -529,7 +529,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty);
|
span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let upvars = cx.tcx.with_freevars(expr.id, |freevars| {
|
let expr_node_id = cx.tcx.hir().hir_to_node_id(expr.hir_id);
|
||||||
|
let upvars = cx.tcx.with_freevars(expr_node_id, |freevars| {
|
||||||
freevars.iter()
|
freevars.iter()
|
||||||
.zip(substs.upvar_tys(def_id, cx.tcx))
|
.zip(substs.upvar_tys(def_id, cx.tcx))
|
||||||
.map(|(fv, ty)| capture_freevar(cx, expr, fv, ty))
|
.map(|(fv, ty)| capture_freevar(cx, expr, fv, ty))
|
||||||
|
@ -637,7 +638,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
hir::ExprKind::Field(ref source, ..) => {
|
hir::ExprKind::Field(ref source, ..) => {
|
||||||
ExprKind::Field {
|
ExprKind::Field {
|
||||||
lhs: source.to_ref(),
|
lhs: source.to_ref(),
|
||||||
name: Field::new(cx.tcx.field_index(expr.id, cx.tables)),
|
name: Field::new(cx.tcx.field_index(expr.hir_id, cx.tables)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprKind::Cast(ref source, ref cast_ty) => {
|
hir::ExprKind::Cast(ref source, ref cast_ty) => {
|
||||||
|
@ -1184,7 +1185,7 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
let var_hir_id = cx.tcx.hir().node_to_hir_id(freevar.var_id());
|
let var_hir_id = cx.tcx.hir().node_to_hir_id(freevar.var_id());
|
||||||
let upvar_id = ty::UpvarId {
|
let upvar_id = ty::UpvarId {
|
||||||
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
var_path: ty::UpvarPath { hir_id: var_hir_id },
|
||||||
closure_expr_id: cx.tcx.hir().local_def_id(closure_expr.id).to_local(),
|
closure_expr_id: cx.tcx.hir().local_def_id_from_hir_id(closure_expr.hir_id).to_local(),
|
||||||
};
|
};
|
||||||
let upvar_capture = cx.tables().upvar_capture(upvar_id);
|
let upvar_capture = cx.tables().upvar_capture(upvar_id);
|
||||||
let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id);
|
let temp_lifetime = cx.region_scope_tree.temporary_scope(closure_expr.hir_id.local_id);
|
||||||
|
@ -1223,7 +1224,7 @@ fn field_refs<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||||
fields.iter()
|
fields.iter()
|
||||||
.map(|field| {
|
.map(|field| {
|
||||||
FieldExprRef {
|
FieldExprRef {
|
||||||
name: Field::new(cx.tcx.field_index(field.id, cx.tables)),
|
name: Field::new(cx.tcx.field_index(field.hir_id, cx.tables)),
|
||||||
expr: field.expr.to_ref(),
|
expr: field.expr.to_ref(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -197,8 +197,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||||
ty.needs_drop(self.tcx.global_tcx(), param_env)
|
ty.needs_drop(self.tcx.global_tcx(), param_env)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lint_level_of(&self, node_id: ast::NodeId) -> LintLevel {
|
fn lint_level_of(&self, hir_id: hir::HirId) -> LintLevel {
|
||||||
let hir_id = self.tcx.hir().definitions().node_to_hir_id(node_id);
|
|
||||||
let has_lint_level = self.tcx.dep_graph.with_ignore(|| {
|
let has_lint_level = self.tcx.dep_graph.with_ignore(|| {
|
||||||
self.tcx.lint_levels(LOCAL_CRATE).lint_level_set(hir_id).is_some()
|
self.tcx.lint_levels(LOCAL_CRATE).lint_level_set(hir_id).is_some()
|
||||||
});
|
});
|
||||||
|
|
|
@ -171,7 +171,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let module = self.tcx.hir().get_module_parent(scrut.id);
|
let module = self.tcx.hir().get_module_parent_by_hir_id(scrut.hir_id);
|
||||||
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
|
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
|
||||||
let mut have_errors = false;
|
let mut have_errors = false;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
||||||
// Then, if the match has no arms, check whether the scrutinee
|
// Then, if the match has no arms, check whether the scrutinee
|
||||||
// is uninhabited.
|
// is uninhabited.
|
||||||
let pat_ty = self.tables.node_type(scrut.hir_id);
|
let pat_ty = self.tables.node_type(scrut.hir_id);
|
||||||
let module = self.tcx.hir().get_module_parent(scrut.id);
|
let module = self.tcx.hir().get_module_parent_by_hir_id(scrut.hir_id);
|
||||||
if inlined_arms.is_empty() {
|
if inlined_arms.is_empty() {
|
||||||
let scrutinee_is_uninhabited = if self.tcx.features().exhaustive_patterns {
|
let scrutinee_is_uninhabited = if self.tcx.features().exhaustive_patterns {
|
||||||
self.tcx.is_ty_uninhabited_from(module, pat_ty)
|
self.tcx.is_ty_uninhabited_from(module, pat_ty)
|
||||||
|
@ -561,10 +561,10 @@ struct MutationChecker<'a, 'tcx: 'a> {
|
||||||
|
|
||||||
impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
|
impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
|
||||||
fn matched_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: euv::MatchMode) {}
|
fn matched_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: euv::MatchMode) {}
|
||||||
fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {}
|
fn consume(&mut self, _: hir::HirId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {}
|
||||||
fn consume_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: ConsumeMode) {}
|
fn consume_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: ConsumeMode) {}
|
||||||
fn borrow(&mut self,
|
fn borrow(&mut self,
|
||||||
_: ast::NodeId,
|
_: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
_: &cmt_<'_>,
|
_: &cmt_<'_>,
|
||||||
_: ty::Region<'tcx>,
|
_: ty::Region<'tcx>,
|
||||||
|
@ -587,7 +587,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
|
fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
|
||||||
fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_<'_>, mode: MutateMode) {
|
fn mutate(&mut self, _: hir::HirId, span: Span, _: &cmt_<'_>, mode: MutateMode) {
|
||||||
match mode {
|
match mode {
|
||||||
MutateMode::JustWrite | MutateMode::WriteAndRead => {
|
MutateMode::JustWrite | MutateMode::WriteAndRead => {
|
||||||
struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard")
|
struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard")
|
||||||
|
|
|
@ -631,7 +631,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||||
fields.iter()
|
fields.iter()
|
||||||
.map(|field| {
|
.map(|field| {
|
||||||
FieldPattern {
|
FieldPattern {
|
||||||
field: Field::new(self.tcx.field_index(field.node.id,
|
field: Field::new(self.tcx.field_index(field.node.hir_id,
|
||||||
self.tables)),
|
self.tables)),
|
||||||
pattern: self.lower_pattern(&field.node.pat),
|
pattern: self.lower_pattern(&field.node.pat),
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ use rustc::middle::mem_categorization::Categorization;
|
||||||
use rustc::ty::{self, Ty, TyCtxt};
|
use rustc::ty::{self, Ty, TyCtxt};
|
||||||
use rustc::ty::query::Providers;
|
use rustc::ty::query::Providers;
|
||||||
use rustc::ty::subst::Substs;
|
use rustc::ty::subst::Substs;
|
||||||
use rustc::util::nodemap::{ItemLocalSet, NodeSet};
|
use rustc::util::nodemap::{ItemLocalSet, HirIdSet};
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
|
@ -92,7 +92,7 @@ struct CheckCrateVisitor<'a, 'tcx: 'a> {
|
||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
in_fn: bool,
|
in_fn: bool,
|
||||||
in_static: bool,
|
in_static: bool,
|
||||||
mut_rvalue_borrows: NodeSet,
|
mut_rvalue_borrows: HirIdSet,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
identity_substs: &'tcx Substs<'tcx>,
|
identity_substs: &'tcx Substs<'tcx>,
|
||||||
tables: &'a ty::TypeckTables<'tcx>,
|
tables: &'a ty::TypeckTables<'tcx>,
|
||||||
|
@ -169,7 +169,7 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
|
||||||
fn remove_mut_rvalue_borrow(&mut self, pat: &hir::Pat) -> bool {
|
fn remove_mut_rvalue_borrow(&mut self, pat: &hir::Pat) -> bool {
|
||||||
let mut any_removed = false;
|
let mut any_removed = false;
|
||||||
pat.walk(|p| {
|
pat.walk(|p| {
|
||||||
any_removed |= self.mut_rvalue_borrows.remove(&p.id);
|
any_removed |= self.mut_rvalue_borrows.remove(&p.hir_id);
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
any_removed
|
any_removed
|
||||||
|
@ -223,7 +223,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
||||||
hir::StmtKind::Local(ref local) => {
|
hir::StmtKind::Local(ref local) => {
|
||||||
if self.remove_mut_rvalue_borrow(&local.pat) {
|
if self.remove_mut_rvalue_borrow(&local.pat) {
|
||||||
if let Some(init) = &local.init {
|
if let Some(init) = &local.init {
|
||||||
self.mut_rvalue_borrows.insert(init.id);
|
self.mut_rvalue_borrows.insert(init.hir_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
||||||
outer &= check_adjustments(self, ex);
|
outer &= check_adjustments(self, ex);
|
||||||
|
|
||||||
// Handle borrows on (or inside the autorefs of) this expression.
|
// Handle borrows on (or inside the autorefs of) this expression.
|
||||||
if self.mut_rvalue_borrows.remove(&ex.id) {
|
if self.mut_rvalue_borrows.remove(&ex.hir_id) {
|
||||||
outer = NotPromotable
|
outer = NotPromotable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ fn check_expr_kind<'a, 'tcx>(
|
||||||
}
|
}
|
||||||
hir::ExprKind::Cast(ref from, _) => {
|
hir::ExprKind::Cast(ref from, _) => {
|
||||||
let expr_promotability = v.check_expr(from);
|
let expr_promotability = v.check_expr(from);
|
||||||
debug!("Checking const cast(id={})", from.id);
|
debug!("Checking const cast(id={})", from.hir_id);
|
||||||
match v.tables.cast_kinds().get(from.hir_id) {
|
match v.tables.cast_kinds().get(from.hir_id) {
|
||||||
None => {
|
None => {
|
||||||
v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
|
v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
|
||||||
|
@ -456,9 +456,10 @@ fn check_expr_kind<'a, 'tcx>(
|
||||||
hir::ExprKind::Closure(_capture_clause, ref _box_fn_decl,
|
hir::ExprKind::Closure(_capture_clause, ref _box_fn_decl,
|
||||||
body_id, _span, _option_generator_movability) => {
|
body_id, _span, _option_generator_movability) => {
|
||||||
let nested_body_promotable = v.check_nested_body(body_id);
|
let nested_body_promotable = v.check_nested_body(body_id);
|
||||||
|
let node_id = v.tcx.hir().hir_to_node_id(e.hir_id);
|
||||||
// Paths in constant contexts cannot refer to local variables,
|
// Paths in constant contexts cannot refer to local variables,
|
||||||
// as there are none, and thus closures can't have upvars there.
|
// as there are none, and thus closures can't have upvars there.
|
||||||
if v.tcx.with_freevars(e.id, |fv| !fv.is_empty()) {
|
if v.tcx.with_freevars(node_id, |fv| !fv.is_empty()) {
|
||||||
NotPromotable
|
NotPromotable
|
||||||
} else {
|
} else {
|
||||||
nested_body_promotable
|
nested_body_promotable
|
||||||
|
@ -518,7 +519,7 @@ fn check_expr_kind<'a, 'tcx>(
|
||||||
mut_borrow = v.remove_mut_rvalue_borrow(pat);
|
mut_borrow = v.remove_mut_rvalue_borrow(pat);
|
||||||
}
|
}
|
||||||
if mut_borrow {
|
if mut_borrow {
|
||||||
v.mut_rvalue_borrows.insert(expr.id);
|
v.mut_rvalue_borrows.insert(expr.hir_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = v.check_expr(expr);
|
let _ = v.check_expr(expr);
|
||||||
|
@ -619,13 +620,13 @@ fn check_adjustments<'a, 'tcx>(
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
|
impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
|
||||||
fn consume(&mut self,
|
fn consume(&mut self,
|
||||||
_consume_id: ast::NodeId,
|
_consume_id: hir::HirId,
|
||||||
_consume_span: Span,
|
_consume_span: Span,
|
||||||
_cmt: &mc::cmt_<'_>,
|
_cmt: &mc::cmt_<'_>,
|
||||||
_mode: euv::ConsumeMode) {}
|
_mode: euv::ConsumeMode) {}
|
||||||
|
|
||||||
fn borrow(&mut self,
|
fn borrow(&mut self,
|
||||||
borrow_id: ast::NodeId,
|
borrow_id: hir::HirId,
|
||||||
_borrow_span: Span,
|
_borrow_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
_loan_region: ty::Region<'tcx>,
|
_loan_region: ty::Region<'tcx>,
|
||||||
|
@ -678,7 +679,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
|
||||||
|
|
||||||
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
|
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
|
||||||
fn mutate(&mut self,
|
fn mutate(&mut self,
|
||||||
_assignment_id: ast::NodeId,
|
_assignment_id: hir::HirId,
|
||||||
_assignment_span: Span,
|
_assignment_span: Span,
|
||||||
_assignee_cmt: &mc::cmt_<'_>,
|
_assignee_cmt: &mc::cmt_<'_>,
|
||||||
_mode: euv::MutateMode) {
|
_mode: euv::MutateMode) {
|
||||||
|
|
|
@ -271,7 +271,8 @@ fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
|
||||||
return (ctor_vis, span, descr);
|
return (ctor_vis, span, descr);
|
||||||
}
|
}
|
||||||
Node::Expr(expr) => {
|
Node::Expr(expr) => {
|
||||||
return (ty::Visibility::Restricted(tcx.hir().get_module_parent(expr.id)),
|
return (ty::Visibility::Restricted(
|
||||||
|
tcx.hir().get_module_parent_by_hir_id(expr.hir_id)),
|
||||||
expr.span, "private")
|
expr.span, "private")
|
||||||
}
|
}
|
||||||
node => bug!("unexpected node kind: {:?}", node)
|
node => bug!("unexpected node kind: {:?}", node)
|
||||||
|
@ -872,7 +873,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
||||||
// unmentioned fields, just check them all.
|
// unmentioned fields, just check them all.
|
||||||
for (vf_index, variant_field) in variant.fields.iter().enumerate() {
|
for (vf_index, variant_field) in variant.fields.iter().enumerate() {
|
||||||
let field = fields.iter().find(|f| {
|
let field = fields.iter().find(|f| {
|
||||||
self.tcx.field_index(f.id, self.tables) == vf_index
|
self.tcx.field_index(f.hir_id, self.tables) == vf_index
|
||||||
});
|
});
|
||||||
let (use_ctxt, span) = match field {
|
let (use_ctxt, span) = match field {
|
||||||
Some(field) => (field.ident.span, field.span),
|
Some(field) => (field.ident.span, field.span),
|
||||||
|
@ -883,7 +884,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let use_ctxt = field.ident.span;
|
let use_ctxt = field.ident.span;
|
||||||
let index = self.tcx.field_index(field.id, self.tables);
|
let index = self.tcx.field_index(field.hir_id, self.tables);
|
||||||
self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
|
self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -902,7 +903,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
|
||||||
let variant = adt.variant_of_def(def);
|
let variant = adt.variant_of_def(def);
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let use_ctxt = field.node.ident.span;
|
let use_ctxt = field.node.ident.span;
|
||||||
let index = self.tcx.field_index(field.node.id, self.tables);
|
let index = self.tcx.field_index(field.node.hir_id, self.tables);
|
||||||
self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
|
self.check_field(use_ctxt, field.span, adt, &variant.fields[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1517,7 +1517,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let def = self.save_ctxt.get_path_def(hir_expr.id);
|
let node_id = self.save_ctxt.tcx.hir().hir_to_node_id(hir_expr.hir_id);
|
||||||
|
let def = self.save_ctxt.get_path_def(node_id);
|
||||||
self.process_struct_lit(ex, path, fields, adt.variant_of_def(def), base)
|
self.process_struct_lit(ex, path, fields, adt.variant_of_def(def), base)
|
||||||
}
|
}
|
||||||
ast::ExprKind::MethodCall(ref seg, ref args) => self.process_method_call(ex, seg, args),
|
ast::ExprKind::MethodCall(ref seg, ref args) => self.process_method_call(ex, seg, args),
|
||||||
|
|
|
@ -885,7 +885,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||||
let msg = format!("associated type `{}` is private", binding.item_name);
|
let msg = format!("associated type `{}` is private", binding.item_name);
|
||||||
tcx.sess.span_err(binding.span, &msg);
|
tcx.sess.span_err(binding.span, &msg);
|
||||||
}
|
}
|
||||||
tcx.check_stability(assoc_ty.def_id, Some(ref_id), binding.span);
|
tcx.check_stability(assoc_ty.def_id, Some(hir_ref_id), binding.span);
|
||||||
|
|
||||||
if !speculative {
|
if !speculative {
|
||||||
dup_bindings.entry(assoc_ty.def_id)
|
dup_bindings.entry(assoc_ty.def_id)
|
||||||
|
@ -1276,7 +1276,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||||
) -> (Ty<'tcx>, Def) {
|
) -> (Ty<'tcx>, Def) {
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let assoc_ident = assoc_segment.ident;
|
let assoc_ident = assoc_segment.ident;
|
||||||
let ref_id = tcx.hir().hir_to_node_id(hir_ref_id);
|
|
||||||
|
|
||||||
debug!("associated_path_to_ty: {:?}::{}", qself_ty, assoc_ident);
|
debug!("associated_path_to_ty: {:?}::{}", qself_ty, assoc_ident);
|
||||||
|
|
||||||
|
@ -1293,7 +1292,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||||
let def = Def::Variant(variant_def.did);
|
let def = Def::Variant(variant_def.did);
|
||||||
if permit_variants {
|
if permit_variants {
|
||||||
check_type_alias_enum_variants_enabled(tcx, span);
|
check_type_alias_enum_variants_enabled(tcx, span);
|
||||||
tcx.check_stability(variant_def.did, Some(ref_id), span);
|
tcx.check_stability(variant_def.did, Some(hir_ref_id), span);
|
||||||
return (qself_ty, def);
|
return (qself_ty, def);
|
||||||
} else {
|
} else {
|
||||||
variant_resolution = Some(def);
|
variant_resolution = Some(def);
|
||||||
|
@ -1385,7 +1384,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
|
||||||
let msg = format!("{} `{}` is private", def.kind_name(), assoc_ident);
|
let msg = format!("{} `{}` is private", def.kind_name(), assoc_ident);
|
||||||
tcx.sess.span_err(span, &msg);
|
tcx.sess.span_err(span, &msg);
|
||||||
}
|
}
|
||||||
tcx.check_stability(item.def_id, Some(ref_id), span);
|
tcx.check_stability(item.def_id, Some(hir_ref_id), span);
|
||||||
|
|
||||||
if let Some(variant_def) = variant_resolution {
|
if let Some(variant_def) = variant_resolution {
|
||||||
let mut err = tcx.struct_span_lint_hir(
|
let mut err = tcx.struct_span_lint_hir(
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PatKind::Path(ref qpath) => {
|
PatKind::Path(ref qpath) => {
|
||||||
let (def, _, _) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
|
let (def, _, _) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
|
||||||
match def {
|
match def {
|
||||||
Def::Const(..) | Def::AssociatedConst(..) => false,
|
Def::Const(..) | Def::AssociatedConst(..) => false,
|
||||||
_ => true,
|
_ => true,
|
||||||
|
@ -630,7 +630,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
|
|
||||||
if self.diverges.get().always() {
|
if self.diverges.get().always() {
|
||||||
for arm in arms {
|
for arm in arms {
|
||||||
self.warn_if_unreachable(arm.body.id, arm.body.span, "arm");
|
self.warn_if_unreachable(arm.body.hir_id, arm.body.span, "arm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,7 +725,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
let cause = if i == 0 {
|
let cause = if i == 0 {
|
||||||
// The reason for the first arm to fail is not that the match arms diverge,
|
// The reason for the first arm to fail is not that the match arms diverge,
|
||||||
// but rather that there's a prior obligation that doesn't hold.
|
// but rather that there's a prior obligation that doesn't hold.
|
||||||
self.cause(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.id))
|
self.cause(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id))
|
||||||
} else {
|
} else {
|
||||||
self.cause(expr.span, ObligationCauseCode::MatchExpressionArm {
|
self.cause(expr.span, ObligationCauseCode::MatchExpressionArm {
|
||||||
arm_span,
|
arm_span,
|
||||||
|
@ -761,7 +761,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
) -> Ty<'tcx>
|
) -> Ty<'tcx>
|
||||||
{
|
{
|
||||||
// Resolve the path and check the definition for errors.
|
// Resolve the path and check the definition for errors.
|
||||||
let (variant, pat_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, pat.id) {
|
let (variant, pat_ty) = if let Some(variant_ty) = self.check_struct_path(qpath, pat.hir_id)
|
||||||
|
{
|
||||||
variant_ty
|
variant_ty
|
||||||
} else {
|
} else {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
|
@ -779,7 +780,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
self.demand_eqtype_pat(pat.span, expected, pat_ty, match_discrim_span);
|
self.demand_eqtype_pat(pat.span, expected, pat_ty, match_discrim_span);
|
||||||
|
|
||||||
// Type-check subpatterns.
|
// Type-check subpatterns.
|
||||||
if self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc, def_bm) {
|
if self.check_struct_pat_fields(pat_ty, pat.hir_id, pat.span, variant, fields, etc, def_bm)
|
||||||
|
{
|
||||||
pat_ty
|
pat_ty
|
||||||
} else {
|
} else {
|
||||||
self.tcx.types.err
|
self.tcx.types.err
|
||||||
|
@ -795,7 +797,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
// Resolve the path and check the definition for errors.
|
// Resolve the path and check the definition for errors.
|
||||||
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
|
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
|
||||||
match def {
|
match def {
|
||||||
Def::Err => {
|
Def::Err => {
|
||||||
self.set_tainted_by_errors();
|
self.set_tainted_by_errors();
|
||||||
|
@ -818,7 +820,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type-check the path.
|
// Type-check the path.
|
||||||
let pat_ty = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id).0;
|
let pat_ty = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.hir_id).0;
|
||||||
self.demand_suptype(pat.span, expected, pat_ty);
|
self.demand_suptype(pat.span, expected, pat_ty);
|
||||||
pat_ty
|
pat_ty
|
||||||
}
|
}
|
||||||
|
@ -849,7 +851,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Resolve the path and check the definition for errors.
|
// Resolve the path and check the definition for errors.
|
||||||
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.id, pat.span);
|
let (def, opt_ty, segments) = self.resolve_ty_and_def_ufcs(qpath, pat.hir_id, pat.span);
|
||||||
if def == Def::Err {
|
if def == Def::Err {
|
||||||
self.set_tainted_by_errors();
|
self.set_tainted_by_errors();
|
||||||
on_error();
|
on_error();
|
||||||
|
@ -857,7 +859,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type-check the path.
|
// Type-check the path.
|
||||||
let (pat_ty, def) = self.instantiate_value_path(segments, opt_ty, def, pat.span, pat.id);
|
let (pat_ty, def) = self.instantiate_value_path(segments, opt_ty, def, pat.span,
|
||||||
|
pat.hir_id);
|
||||||
if !pat_ty.is_fn() {
|
if !pat_ty.is_fn() {
|
||||||
report_unexpected_def(def);
|
report_unexpected_def(def);
|
||||||
return self.tcx.types.err;
|
return self.tcx.types.err;
|
||||||
|
@ -897,7 +900,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
|
let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
|
||||||
self.check_pat_walk(&subpat, field_ty, def_bm, match_arm_pat_span);
|
self.check_pat_walk(&subpat, field_ty, def_bm, match_arm_pat_span);
|
||||||
|
|
||||||
self.tcx.check_stability(variant.fields[i].did, Some(pat.id), subpat.span);
|
self.tcx.check_stability(variant.fields[i].did, Some(pat.hir_id), subpat.span);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let subpats_ending = if subpats.len() == 1 { "" } else { "s" };
|
let subpats_ending = if subpats.len() == 1 { "" } else { "s" };
|
||||||
|
@ -917,7 +920,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
|
|
||||||
fn check_struct_pat_fields(&self,
|
fn check_struct_pat_fields(&self,
|
||||||
adt_ty: Ty<'tcx>,
|
adt_ty: Ty<'tcx>,
|
||||||
pat_id: ast::NodeId,
|
pat_id: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
variant: &'tcx ty::VariantDef,
|
variant: &'tcx ty::VariantDef,
|
||||||
fields: &'gcx [Spanned<hir::FieldPat>],
|
fields: &'gcx [Spanned<hir::FieldPat>],
|
||||||
|
@ -963,7 +966,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||||
vacant.insert(span);
|
vacant.insert(span);
|
||||||
field_map.get(&ident)
|
field_map.get(&ident)
|
||||||
.map(|(i, f)| {
|
.map(|(i, f)| {
|
||||||
self.write_field_index(field.id, *i);
|
self.write_field_index(field.hir_id, *i);
|
||||||
self.tcx.check_stability(f.did, Some(pat_id), span);
|
self.tcx.check_stability(f.did, Some(pat_id), span);
|
||||||
self.field_ty(span, f, substs)
|
self.field_ty(span, f, substs)
|
||||||
})
|
})
|
||||||
|
|
|
@ -250,7 +250,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
if let &ty::Adt(adt_def, ..) = t {
|
if let &ty::Adt(adt_def, ..) = t {
|
||||||
if adt_def.is_enum() {
|
if adt_def.is_enum() {
|
||||||
if let hir::ExprKind::Call(ref expr, _) = call_expr.node {
|
if let hir::ExprKind::Call(ref expr, _) = call_expr.node {
|
||||||
unit_variant = Some(self.tcx.hir().node_to_pretty_string(expr.id))
|
unit_variant = Some(self.tcx.hir().hir_to_pretty_string(expr.hir_id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,9 +399,9 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
||||||
} else {
|
} else {
|
||||||
("", lint::builtin::TRIVIAL_CASTS)
|
("", lint::builtin::TRIVIAL_CASTS)
|
||||||
};
|
};
|
||||||
let mut err = fcx.tcx.struct_span_lint_node(
|
let mut err = fcx.tcx.struct_span_lint_hir(
|
||||||
lint,
|
lint,
|
||||||
self.expr.id,
|
self.expr.hir_id,
|
||||||
self.span,
|
self.span,
|
||||||
&format!("trivial {}cast: `{}` as `{}`",
|
&format!("trivial {}cast: `{}` as `{}`",
|
||||||
adjective,
|
adjective,
|
||||||
|
@ -417,7 +417,7 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
||||||
self.cast_ty = fcx.structurally_resolved_type(self.span, self.cast_ty);
|
self.cast_ty = fcx.structurally_resolved_type(self.span, self.cast_ty);
|
||||||
|
|
||||||
debug!("check_cast({}, {:?} as {:?})",
|
debug!("check_cast({}, {:?} as {:?})",
|
||||||
self.expr.id,
|
self.expr.hir_id,
|
||||||
self.expr_ty,
|
self.expr_ty,
|
||||||
self.cast_ty);
|
self.cast_ty);
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
opt_kind, expected_sig
|
opt_kind, expected_sig
|
||||||
);
|
);
|
||||||
|
|
||||||
let expr_def_id = self.tcx.hir().local_def_id(expr.id);
|
let expr_def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
|
||||||
|
|
||||||
let ClosureSignatures {
|
let ClosureSignatures {
|
||||||
bound_sig,
|
bound_sig,
|
||||||
|
@ -131,8 +131,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let closure_type = self.tcx.mk_closure(expr_def_id, substs);
|
let closure_type = self.tcx.mk_closure(expr_def_id, substs);
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"check_closure: expr.id={:?} closure_type={:?}",
|
"check_closure: expr.hir_id={:?} closure_type={:?}",
|
||||||
expr.id, closure_type
|
expr.hir_id, closure_type
|
||||||
);
|
);
|
||||||
|
|
||||||
// Tuple up the arguments and insert the resulting function type into
|
// Tuple up the arguments and insert the resulting function type into
|
||||||
|
|
|
@ -1177,7 +1177,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
|
||||||
Expressions::UpFront(coercion_sites) => {
|
Expressions::UpFront(coercion_sites) => {
|
||||||
// if the user gave us an array to validate, check that we got
|
// if the user gave us an array to validate, check that we got
|
||||||
// the next expression in the list, as expected
|
// the next expression in the list, as expected
|
||||||
assert_eq!(coercion_sites[self.pushed].as_coercion_site().id, e.id);
|
assert_eq!(coercion_sites[self.pushed].as_coercion_site().hir_id,
|
||||||
|
e.hir_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.pushed += 1;
|
self.pushed += 1;
|
||||||
|
@ -1208,7 +1209,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
|
||||||
db.span_label(cause.span, "return type is not `()`");
|
db.span_label(cause.span, "return type is not `()`");
|
||||||
}
|
}
|
||||||
ObligationCauseCode::BlockTailExpression(blk_id) => {
|
ObligationCauseCode::BlockTailExpression(blk_id) => {
|
||||||
let parent_id = fcx.tcx.hir().get_parent_node(blk_id);
|
let parent_id = fcx.tcx.hir().get_parent_node_by_hir_id(blk_id);
|
||||||
db = self.report_return_mismatched_types(
|
db = self.report_return_mismatched_types(
|
||||||
cause,
|
cause,
|
||||||
expected,
|
expected,
|
||||||
|
@ -1246,8 +1247,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
|
||||||
found: Ty<'tcx>,
|
found: Ty<'tcx>,
|
||||||
err: TypeError<'tcx>,
|
err: TypeError<'tcx>,
|
||||||
fcx: &FnCtxt<'a, 'gcx, 'tcx>,
|
fcx: &FnCtxt<'a, 'gcx, 'tcx>,
|
||||||
id: syntax::ast::NodeId,
|
id: hir::HirId,
|
||||||
expression: Option<(&'gcx hir::Expr, syntax::ast::NodeId)>,
|
expression: Option<(&'gcx hir::Expr, hir::HirId)>,
|
||||||
) -> DiagnosticBuilder<'a> {
|
) -> DiagnosticBuilder<'a> {
|
||||||
let mut db = fcx.report_mismatched_types(cause, expected, found, err);
|
let mut db = fcx.report_mismatched_types(cause, expected, found, err);
|
||||||
|
|
||||||
|
@ -1257,7 +1258,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
|
||||||
// Verify that this is a tail expression of a function, otherwise the
|
// Verify that this is a tail expression of a function, otherwise the
|
||||||
// label pointing out the cause for the type coercion will be wrong
|
// label pointing out the cause for the type coercion will be wrong
|
||||||
// as prior return coercions would not be relevant (#57664).
|
// as prior return coercions would not be relevant (#57664).
|
||||||
let parent_id = fcx.tcx.hir().get_parent_node(id);
|
let parent_id = fcx.tcx.hir().get_parent_node_by_hir_id(id);
|
||||||
let fn_decl = if let Some((expr, blk_id)) = expression {
|
let fn_decl = if let Some((expr, blk_id)) = expression {
|
||||||
pointing_at_return_type = fcx.suggest_mismatched_types_on_tail(
|
pointing_at_return_type = fcx.suggest_mismatched_types_on_tail(
|
||||||
&mut db,
|
&mut db,
|
||||||
|
@ -1267,7 +1268,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
|
||||||
cause.span,
|
cause.span,
|
||||||
blk_id,
|
blk_id,
|
||||||
);
|
);
|
||||||
let parent = fcx.tcx.hir().get(parent_id);
|
let parent = fcx.tcx.hir().get_by_hir_id(parent_id);
|
||||||
fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
||||||
} else {
|
} else {
|
||||||
fcx.get_fn_decl(parent_id)
|
fcx.get_fn_decl(parent_id)
|
||||||
|
|
|
@ -2,7 +2,6 @@ use crate::check::FnCtxt;
|
||||||
use rustc::infer::InferOk;
|
use rustc::infer::InferOk;
|
||||||
use rustc::traits::{ObligationCause, ObligationCauseCode};
|
use rustc::traits::{ObligationCause, ObligationCauseCode};
|
||||||
|
|
||||||
use syntax::ast;
|
|
||||||
use syntax::util::parser::PREC_POSTFIX;
|
use syntax::util::parser::PREC_POSTFIX;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
|
@ -164,7 +163,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
probe::Mode::MethodCall,
|
probe::Mode::MethodCall,
|
||||||
expected,
|
expected,
|
||||||
checked_ty,
|
checked_ty,
|
||||||
ast::DUMMY_NODE_ID);
|
hir::DUMMY_HIR_ID);
|
||||||
methods.retain(|m| {
|
methods.retain(|m| {
|
||||||
self.has_no_input_arg(m) &&
|
self.has_no_input_arg(m) &&
|
||||||
self.tcx.get_attrs(m.def_id).iter()
|
self.tcx.get_attrs(m.def_id).iter()
|
||||||
|
@ -218,15 +217,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
if let hir::def::Def::Local(id) = path.def {
|
if let hir::def::Def::Local(id) = path.def {
|
||||||
let parent = self.tcx.hir().get_parent_node(id);
|
let parent = self.tcx.hir().get_parent_node(id);
|
||||||
if let Some(Node::Expr(hir::Expr {
|
if let Some(Node::Expr(hir::Expr {
|
||||||
id,
|
hir_id,
|
||||||
node: hir::ExprKind::Closure(_, decl, ..),
|
node: hir::ExprKind::Closure(_, decl, ..),
|
||||||
..
|
..
|
||||||
})) = self.tcx.hir().find(parent) {
|
})) = self.tcx.hir().find(parent) {
|
||||||
let parent = self.tcx.hir().get_parent_node(*id);
|
let parent = self.tcx.hir().get_parent_node_by_hir_id(*hir_id);
|
||||||
if let (Some(Node::Expr(hir::Expr {
|
if let (Some(Node::Expr(hir::Expr {
|
||||||
node: hir::ExprKind::MethodCall(path, span, expr),
|
node: hir::ExprKind::MethodCall(path, span, expr),
|
||||||
..
|
..
|
||||||
})), 1) = (self.tcx.hir().find(parent), decl.inputs.len()) {
|
})), 1) = (self.tcx.hir().find_by_hir_id(parent), decl.inputs.len()) {
|
||||||
let self_ty = self.tables.borrow().node_type(expr[0].hir_id);
|
let self_ty = self.tables.borrow().node_type(expr[0].hir_id);
|
||||||
let self_ty = format!("{:?}", self_ty);
|
let self_ty = format!("{:?}", self_ty);
|
||||||
let name = path.ident.as_str();
|
let name = path.ident.as_str();
|
||||||
|
@ -470,8 +469,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
checked_ty: Ty<'tcx>,
|
checked_ty: Ty<'tcx>,
|
||||||
expected_ty: Ty<'tcx>,
|
expected_ty: Ty<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let parent_id = self.tcx.hir().get_parent_node(expr.id);
|
let parent_id = self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
|
||||||
if let Some(parent) = self.tcx.hir().find(parent_id) {
|
if let Some(parent) = self.tcx.hir().find_by_hir_id(parent_id) {
|
||||||
// Shouldn't suggest `.into()` on `const`s.
|
// Shouldn't suggest `.into()` on `const`s.
|
||||||
if let Node::Item(Item { node: ItemKind::Const(_, _), .. }) = parent {
|
if let Node::Item(Item { node: ItemKind::Const(_, _), .. }) = parent {
|
||||||
// FIXME(estebank): modify once we decide to suggest `as` casts
|
// FIXME(estebank): modify once we decide to suggest `as` casts
|
||||||
|
@ -501,10 +500,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
if let Some(hir::Node::Expr(hir::Expr {
|
if let Some(hir::Node::Expr(hir::Expr {
|
||||||
node: hir::ExprKind::Struct(_, fields, _),
|
node: hir::ExprKind::Struct(_, fields, _),
|
||||||
..
|
..
|
||||||
})) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.id)) {
|
})) = self.tcx.hir().find_by_hir_id(self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id)) {
|
||||||
// `expr` is a literal field for a struct, only suggest if appropriate
|
// `expr` is a literal field for a struct, only suggest if appropriate
|
||||||
for field in fields {
|
for field in fields {
|
||||||
if field.expr.id == expr.id && field.is_shorthand {
|
if field.expr.hir_id == expr.hir_id && field.is_shorthand {
|
||||||
// This is a field literal
|
// This is a field literal
|
||||||
prefix = format!("{}: ", field.ident);
|
prefix = format!("{}: ", field.ident);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
pub fn method_exists(&self,
|
pub fn method_exists(&self,
|
||||||
method_name: ast::Ident,
|
method_name: ast::Ident,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
call_expr_id: ast::NodeId,
|
call_expr_id: hir::HirId,
|
||||||
allow_private: bool)
|
allow_private: bool)
|
||||||
-> bool {
|
-> bool {
|
||||||
let mode = probe::Mode::MethodCall;
|
let mode = probe::Mode::MethodCall;
|
||||||
|
@ -131,7 +131,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
msg: &str,
|
msg: &str,
|
||||||
method_name: ast::Ident,
|
method_name: ast::Ident,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
call_expr_id: ast::NodeId,
|
call_expr_id: hir::HirId,
|
||||||
) {
|
) {
|
||||||
let has_params = self
|
let has_params = self
|
||||||
.probe_for_name(
|
.probe_for_name(
|
||||||
|
@ -202,7 +202,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
.unwrap().insert(import_def_id);
|
.unwrap().insert(import_def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tcx.check_stability(pick.item.def_id, Some(call_expr.id), span);
|
self.tcx.check_stability(pick.item.def_id, Some(call_expr.hir_id), span);
|
||||||
|
|
||||||
let result = self.confirm_method(
|
let result = self.confirm_method(
|
||||||
span,
|
span,
|
||||||
|
@ -255,7 +255,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let mode = probe::Mode::MethodCall;
|
let mode = probe::Mode::MethodCall;
|
||||||
let self_ty = self.resolve_type_vars_if_possible(&self_ty);
|
let self_ty = self.resolve_type_vars_if_possible(&self_ty);
|
||||||
self.probe_for_name(span, mode, method_name, IsSuggestion(false),
|
self.probe_for_name(span, mode, method_name, IsSuggestion(false),
|
||||||
self_ty, call_expr.id, scope)
|
self_ty, call_expr.hir_id, scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `lookup_method_in_trait` is used for overloaded operators.
|
/// `lookup_method_in_trait` is used for overloaded operators.
|
||||||
|
@ -399,7 +399,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
span: Span,
|
span: Span,
|
||||||
method_name: ast::Ident,
|
method_name: ast::Ident,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
expr_id: ast::NodeId
|
expr_id: hir::HirId
|
||||||
) -> Result<Def, MethodError<'tcx>> {
|
) -> Result<Def, MethodError<'tcx>> {
|
||||||
debug!(
|
debug!(
|
||||||
"resolve_ufcs: method_name={:?} self_ty={:?} expr_id={:?}",
|
"resolve_ufcs: method_name={:?} self_ty={:?} expr_id={:?}",
|
||||||
|
|
|
@ -209,7 +209,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
return_type: Ty<'tcx>,
|
return_type: Ty<'tcx>,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
scope_expr_id: ast::NodeId)
|
scope_expr_id: hir::HirId)
|
||||||
-> Vec<ty::AssociatedItem> {
|
-> Vec<ty::AssociatedItem> {
|
||||||
debug!("probe(self_ty={:?}, return_type={}, scope_expr_id={})",
|
debug!("probe(self_ty={:?}, return_type={}, scope_expr_id={})",
|
||||||
self_ty,
|
self_ty,
|
||||||
|
@ -238,7 +238,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
item_name: ast::Ident,
|
item_name: ast::Ident,
|
||||||
is_suggestion: IsSuggestion,
|
is_suggestion: IsSuggestion,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
scope_expr_id: ast::NodeId,
|
scope_expr_id: hir::HirId,
|
||||||
scope: ProbeScope)
|
scope: ProbeScope)
|
||||||
-> PickResult<'tcx> {
|
-> PickResult<'tcx> {
|
||||||
debug!("probe(self_ty={:?}, item_name={}, scope_expr_id={})",
|
debug!("probe(self_ty={:?}, item_name={}, scope_expr_id={})",
|
||||||
|
@ -263,7 +263,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
return_type: Option<Ty<'tcx>>,
|
return_type: Option<Ty<'tcx>>,
|
||||||
is_suggestion: IsSuggestion,
|
is_suggestion: IsSuggestion,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
scope_expr_id: ast::NodeId,
|
scope_expr_id: hir::HirId,
|
||||||
scope: ProbeScope,
|
scope: ProbeScope,
|
||||||
op: OP)
|
op: OP)
|
||||||
-> Result<R, MethodError<'tcx>>
|
-> Result<R, MethodError<'tcx>>
|
||||||
|
@ -340,7 +340,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
"the type of this value must be known \
|
"the type of this value must be known \
|
||||||
to call a method on a raw pointer on it");
|
to call a method on a raw pointer on it");
|
||||||
} else {
|
} else {
|
||||||
self.tcx.lint_node(
|
self.tcx.lint_hir(
|
||||||
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
|
lint::builtin::TYVAR_BEHIND_RAW_POINTER,
|
||||||
scope_expr_id,
|
scope_expr_id,
|
||||||
span,
|
span,
|
||||||
|
@ -825,13 +825,12 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assemble_extension_candidates_for_traits_in_scope(&mut self,
|
fn assemble_extension_candidates_for_traits_in_scope(&mut self,
|
||||||
expr_id: ast::NodeId)
|
expr_hir_id: hir::HirId)
|
||||||
-> Result<(), MethodError<'tcx>> {
|
-> Result<(), MethodError<'tcx>> {
|
||||||
if expr_id == ast::DUMMY_NODE_ID {
|
if expr_hir_id == hir::DUMMY_HIR_ID {
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
let mut duplicates = FxHashSet::default();
|
let mut duplicates = FxHashSet::default();
|
||||||
let expr_hir_id = self.tcx.hir().node_to_hir_id(expr_id);
|
|
||||||
let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
|
let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id);
|
||||||
if let Some(applicable_traits) = opt_applicable_traits {
|
if let Some(applicable_traits) = opt_applicable_traits {
|
||||||
for trait_candidate in applicable_traits.iter() {
|
for trait_candidate in applicable_traits.iter() {
|
||||||
|
@ -1415,7 +1414,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
steps, IsSuggestion(true));
|
steps, IsSuggestion(true));
|
||||||
pcx.allow_similar_names = true;
|
pcx.allow_similar_names = true;
|
||||||
pcx.assemble_inherent_candidates();
|
pcx.assemble_inherent_candidates();
|
||||||
pcx.assemble_extension_candidates_for_traits_in_scope(ast::DUMMY_NODE_ID)?;
|
pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)?;
|
||||||
|
|
||||||
let method_names = pcx.candidate_method_names();
|
let method_names = pcx.candidate_method_names();
|
||||||
pcx.allow_similar_names = false;
|
pcx.allow_similar_names = false;
|
||||||
|
@ -1425,7 +1424,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||||
pcx.reset();
|
pcx.reset();
|
||||||
pcx.method_name = Some(method_name);
|
pcx.method_name = Some(method_name);
|
||||||
pcx.assemble_inherent_candidates();
|
pcx.assemble_inherent_candidates();
|
||||||
pcx.assemble_extension_candidates_for_traits_in_scope(ast::DUMMY_NODE_ID)
|
pcx.assemble_extension_candidates_for_traits_in_scope(hir::DUMMY_HIR_ID)
|
||||||
.ok().map_or(None, |_| {
|
.ok().map_or(None, |_| {
|
||||||
pcx.pick_core()
|
pcx.pick_core()
|
||||||
.and_then(|pick| pick.ok())
|
.and_then(|pick| pick.ok())
|
||||||
|
|
|
@ -137,7 +137,7 @@ use crate::TypeAndSubsts;
|
||||||
use crate::lint;
|
use crate::lint;
|
||||||
use crate::util::captures::Captures;
|
use crate::util::captures::Captures;
|
||||||
use crate::util::common::{ErrorReported, indenter};
|
use crate::util::common::{ErrorReported, indenter};
|
||||||
use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, NodeMap};
|
use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, HirIdMap, NodeMap};
|
||||||
|
|
||||||
pub use self::Expectation::*;
|
pub use self::Expectation::*;
|
||||||
use self::autoderef::Autoderef;
|
use self::autoderef::Autoderef;
|
||||||
|
@ -497,11 +497,11 @@ pub struct BreakableCtxt<'gcx: 'tcx, 'tcx> {
|
||||||
|
|
||||||
pub struct EnclosingBreakables<'gcx: 'tcx, 'tcx> {
|
pub struct EnclosingBreakables<'gcx: 'tcx, 'tcx> {
|
||||||
stack: Vec<BreakableCtxt<'gcx, 'tcx>>,
|
stack: Vec<BreakableCtxt<'gcx, 'tcx>>,
|
||||||
by_id: NodeMap<usize>,
|
by_id: HirIdMap<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gcx, 'tcx> EnclosingBreakables<'gcx, 'tcx> {
|
impl<'gcx, 'tcx> EnclosingBreakables<'gcx, 'tcx> {
|
||||||
fn find_breakable(&mut self, target_id: ast::NodeId) -> &mut BreakableCtxt<'gcx, 'tcx> {
|
fn find_breakable(&mut self, target_id: hir::HirId) -> &mut BreakableCtxt<'gcx, 'tcx> {
|
||||||
let ix = *self.by_id.get(&target_id).unwrap_or_else(|| {
|
let ix = *self.by_id.get(&target_id).unwrap_or_else(|| {
|
||||||
bug!("could not find enclosing breakable with id {}", target_id);
|
bug!("could not find enclosing breakable with id {}", target_id);
|
||||||
});
|
});
|
||||||
|
@ -2049,13 +2049,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
/// Produces warning on the given node, if the current point in the
|
/// Produces warning on the given node, if the current point in the
|
||||||
/// function is unreachable, and there hasn't been another warning.
|
/// function is unreachable, and there hasn't been another warning.
|
||||||
fn warn_if_unreachable(&self, id: ast::NodeId, span: Span, kind: &str) {
|
fn warn_if_unreachable(&self, id: hir::HirId, span: Span, kind: &str) {
|
||||||
if self.diverges.get() == Diverges::Always {
|
if self.diverges.get() == Diverges::Always {
|
||||||
self.diverges.set(Diverges::WarnedAlways);
|
self.diverges.set(Diverges::WarnedAlways);
|
||||||
|
|
||||||
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
|
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
|
||||||
|
|
||||||
self.tcx().lint_node(
|
self.tcx().lint_hir(
|
||||||
lint::builtin::UNREACHABLE_CODE,
|
lint::builtin::UNREACHABLE_CODE,
|
||||||
id, span,
|
id, span,
|
||||||
&format!("unreachable {}", kind));
|
&format!("unreachable {}", kind));
|
||||||
|
@ -2143,8 +2143,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_field_index(&self, node_id: ast::NodeId, index: usize) {
|
pub fn write_field_index(&self, hir_id: hir::HirId, index: usize) {
|
||||||
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
|
|
||||||
self.tables.borrow_mut().field_indices_mut().insert(hir_id, index);
|
self.tables.borrow_mut().field_indices_mut().insert(hir_id, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3007,7 +3006,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// Closure arguments themselves can't be diverging, but
|
// Closure arguments themselves can't be diverging, but
|
||||||
// a previous argument can, e.g., `foo(panic!(), || {})`.
|
// a previous argument can, e.g., `foo(panic!(), || {})`.
|
||||||
if !check_closures {
|
if !check_closures {
|
||||||
self.warn_if_unreachable(arg.id, arg.span, "expression");
|
self.warn_if_unreachable(arg.hir_id, arg.span, "expression");
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_closure = match arg.node {
|
let is_closure = match arg.node {
|
||||||
|
@ -3338,7 +3337,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
ret_coercion.borrow_mut()
|
ret_coercion.borrow_mut()
|
||||||
.coerce(self,
|
.coerce(self,
|
||||||
&self.cause(return_expr.span,
|
&self.cause(return_expr.span,
|
||||||
ObligationCauseCode::ReturnType(return_expr.id)),
|
ObligationCauseCode::ReturnType(return_expr.hir_id)),
|
||||||
return_expr,
|
return_expr,
|
||||||
return_expr_ty);
|
return_expr_ty);
|
||||||
}
|
}
|
||||||
|
@ -3509,13 +3508,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let field_ty = self.field_ty(expr.span, field, substs);
|
let field_ty = self.field_ty(expr.span, field, substs);
|
||||||
// Save the index of all fields regardless of their visibility in case
|
// Save the index of all fields regardless of their visibility in case
|
||||||
// of error recovery.
|
// of error recovery.
|
||||||
self.write_field_index(expr.id, index);
|
self.write_field_index(expr.hir_id, index);
|
||||||
if field.vis.is_accessible_from(def_scope, self.tcx) {
|
if field.vis.is_accessible_from(def_scope, self.tcx) {
|
||||||
let adjustments = autoderef.adjust_steps(self, needs);
|
let adjustments = autoderef.adjust_steps(self, needs);
|
||||||
self.apply_adjustments(base, adjustments);
|
self.apply_adjustments(base, adjustments);
|
||||||
autoderef.finalize(self);
|
autoderef.finalize(self);
|
||||||
|
|
||||||
self.tcx.check_stability(field.did, Some(expr.id), expr.span);
|
self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span);
|
||||||
return field_ty;
|
return field_ty;
|
||||||
}
|
}
|
||||||
private_candidate = Some((base_def.did, field_ty));
|
private_candidate = Some((base_def.did, field_ty));
|
||||||
|
@ -3530,7 +3529,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.apply_adjustments(base, adjustments);
|
self.apply_adjustments(base, adjustments);
|
||||||
autoderef.finalize(self);
|
autoderef.finalize(self);
|
||||||
|
|
||||||
self.write_field_index(expr.id, index);
|
self.write_field_index(expr.hir_id, index);
|
||||||
return field_ty;
|
return field_ty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3547,31 +3546,33 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
"field `{}` of struct `{}` is private",
|
"field `{}` of struct `{}` is private",
|
||||||
field, struct_path);
|
field, struct_path);
|
||||||
// Also check if an accessible method exists, which is often what is meant.
|
// Also check if an accessible method exists, which is often what is meant.
|
||||||
if self.method_exists(field, expr_t, expr.id, false) && !self.expr_in_place(expr.id) {
|
if self.method_exists(field, expr_t, expr.hir_id, false)
|
||||||
|
&& !self.expr_in_place(expr.hir_id)
|
||||||
|
{
|
||||||
self.suggest_method_call(
|
self.suggest_method_call(
|
||||||
&mut err,
|
&mut err,
|
||||||
&format!("a method `{}` also exists, call it with parentheses", field),
|
&format!("a method `{}` also exists, call it with parentheses", field),
|
||||||
field,
|
field,
|
||||||
expr_t,
|
expr_t,
|
||||||
expr.id,
|
expr.hir_id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
field_ty
|
field_ty
|
||||||
} else if field.name == keywords::Invalid.name() {
|
} else if field.name == keywords::Invalid.name() {
|
||||||
self.tcx().types.err
|
self.tcx().types.err
|
||||||
} else if self.method_exists(field, expr_t, expr.id, true) {
|
} else if self.method_exists(field, expr_t, expr.hir_id, true) {
|
||||||
let mut err = type_error_struct!(self.tcx().sess, field.span, expr_t, E0615,
|
let mut err = type_error_struct!(self.tcx().sess, field.span, expr_t, E0615,
|
||||||
"attempted to take value of method `{}` on type `{}`",
|
"attempted to take value of method `{}` on type `{}`",
|
||||||
field, expr_t);
|
field, expr_t);
|
||||||
|
|
||||||
if !self.expr_in_place(expr.id) {
|
if !self.expr_in_place(expr.hir_id) {
|
||||||
self.suggest_method_call(
|
self.suggest_method_call(
|
||||||
&mut err,
|
&mut err,
|
||||||
"use parentheses to call the method",
|
"use parentheses to call the method",
|
||||||
field,
|
field,
|
||||||
expr_t,
|
expr_t,
|
||||||
expr.id
|
expr.hir_id
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.help("methods are immutable and cannot be assigned to");
|
err.help("methods are immutable and cannot be assigned to");
|
||||||
|
@ -3611,7 +3612,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
) {
|
) {
|
||||||
let base = self.tcx.sess.source_map()
|
let base = self.tcx.sess.source_map()
|
||||||
.span_to_snippet(base.span)
|
.span_to_snippet(base.span)
|
||||||
.unwrap_or_else(|_| self.tcx.hir().node_to_pretty_string(base.id));
|
.unwrap_or_else(|_|
|
||||||
|
self.tcx.hir().hir_to_pretty_string(base.hir_id));
|
||||||
let help = "instead of using tuple indexing, use array indexing";
|
let help = "instead of using tuple indexing, use array indexing";
|
||||||
let suggestion = format!("{}[{}]", base, field);
|
let suggestion = format!("{}[{}]", base, field);
|
||||||
let applicability = if len < user_index {
|
let applicability = if len < user_index {
|
||||||
|
@ -3627,7 +3629,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
ty::RawPtr(..) => {
|
ty::RawPtr(..) => {
|
||||||
let base = self.tcx.sess.source_map()
|
let base = self.tcx.sess.source_map()
|
||||||
.span_to_snippet(base.span)
|
.span_to_snippet(base.span)
|
||||||
.unwrap_or_else(|_| self.tcx.hir().node_to_pretty_string(base.id));
|
.unwrap_or_else(|_| self.tcx.hir().hir_to_pretty_string(base.hir_id));
|
||||||
let msg = format!("`{}` is a raw pointer; try dereferencing it", base);
|
let msg = format!("`{}` is a raw pointer; try dereferencing it", base);
|
||||||
let suggestion = format!("(*{}).{}", base, field);
|
let suggestion = format!("(*{}).{}", base, field);
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
|
@ -3752,7 +3754,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
fn check_expr_struct_fields(&self,
|
fn check_expr_struct_fields(&self,
|
||||||
adt_ty: Ty<'tcx>,
|
adt_ty: Ty<'tcx>,
|
||||||
expected: Expectation<'tcx>,
|
expected: Expectation<'tcx>,
|
||||||
expr_id: ast::NodeId,
|
expr_id: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
variant: &'tcx ty::VariantDef,
|
variant: &'tcx ty::VariantDef,
|
||||||
ast_fields: &'gcx [hir::Field],
|
ast_fields: &'gcx [hir::Field],
|
||||||
|
@ -3785,7 +3787,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let ident = tcx.adjust_ident(field.ident, variant.did, self.body_id).0;
|
let ident = tcx.adjust_ident(field.ident, variant.did, self.body_id).0;
|
||||||
let field_type = if let Some((i, v_field)) = remaining_fields.remove(&ident) {
|
let field_type = if let Some((i, v_field)) = remaining_fields.remove(&ident) {
|
||||||
seen_fields.insert(ident, field.span);
|
seen_fields.insert(ident, field.span);
|
||||||
self.write_field_index(field.id, i);
|
self.write_field_index(field.hir_id, i);
|
||||||
|
|
||||||
// We don't look at stability attributes on
|
// We don't look at stability attributes on
|
||||||
// struct-like enums (yet...), but it's definitely not
|
// struct-like enums (yet...), but it's definitely not
|
||||||
|
@ -3873,13 +3875,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
pub fn check_struct_path(&self,
|
pub fn check_struct_path(&self,
|
||||||
qpath: &QPath,
|
qpath: &QPath,
|
||||||
node_id: ast::NodeId)
|
hir_id: hir::HirId)
|
||||||
-> Option<(&'tcx ty::VariantDef, Ty<'tcx>)> {
|
-> Option<(&'tcx ty::VariantDef, Ty<'tcx>)> {
|
||||||
let path_span = match *qpath {
|
let path_span = match *qpath {
|
||||||
QPath::Resolved(_, ref path) => path.span,
|
QPath::Resolved(_, ref path) => path.span,
|
||||||
QPath::TypeRelative(ref qself, _) => qself.span
|
QPath::TypeRelative(ref qself, _) => qself.span
|
||||||
};
|
};
|
||||||
let (def, ty) = self.finish_resolving_struct_path(qpath, path_span, node_id);
|
let (def, ty) = self.finish_resolving_struct_path(qpath, path_span, hir_id);
|
||||||
let variant = match def {
|
let variant = match def {
|
||||||
Def::Err => {
|
Def::Err => {
|
||||||
self.set_tainted_by_errors();
|
self.set_tainted_by_errors();
|
||||||
|
@ -3907,7 +3909,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
if let Some((variant, did, substs)) = variant {
|
if let Some((variant, did, substs)) = variant {
|
||||||
debug!("check_struct_path: did={:?} substs={:?}", did, substs);
|
debug!("check_struct_path: did={:?} substs={:?}", did, substs);
|
||||||
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
|
|
||||||
self.write_user_type_annotation_from_substs(hir_id, did, substs, None);
|
self.write_user_type_annotation_from_substs(hir_id, did, substs, None);
|
||||||
|
|
||||||
// Check bounds on type arguments used in the path.
|
// Check bounds on type arguments used in the path.
|
||||||
|
@ -3936,7 +3937,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
{
|
{
|
||||||
// Find the relevant variant
|
// Find the relevant variant
|
||||||
let (variant, adt_ty) =
|
let (variant, adt_ty) =
|
||||||
if let Some(variant_ty) = self.check_struct_path(qpath, expr.id) {
|
if let Some(variant_ty) = self.check_struct_path(qpath, expr.hir_id) {
|
||||||
variant_ty
|
variant_ty
|
||||||
} else {
|
} else {
|
||||||
self.check_struct_fields_on_error(fields, base_expr);
|
self.check_struct_fields_on_error(fields, base_expr);
|
||||||
|
@ -3956,7 +3957,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
adt.variant_descr());
|
adt.variant_descr());
|
||||||
}
|
}
|
||||||
|
|
||||||
let error_happened = self.check_expr_struct_fields(adt_ty, expected, expr.id, path_span,
|
let error_happened = self.check_expr_struct_fields(adt_ty, expected, expr.hir_id, path_span,
|
||||||
variant, fields, base_expr.is_none());
|
variant, fields, base_expr.is_none());
|
||||||
if let &Some(ref base_expr) = base_expr {
|
if let &Some(ref base_expr) = base_expr {
|
||||||
// If check_expr_struct_fields hit an error, do not attempt to populate
|
// If check_expr_struct_fields hit an error, do not attempt to populate
|
||||||
|
@ -4005,7 +4006,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
expr, expected);
|
expr, expected);
|
||||||
|
|
||||||
// Warn for expressions after diverging siblings.
|
// Warn for expressions after diverging siblings.
|
||||||
self.warn_if_unreachable(expr.id, expr.span, "expression");
|
self.warn_if_unreachable(expr.hir_id, expr.span, "expression");
|
||||||
|
|
||||||
// Hide the outer diverging and has_errors flags.
|
// Hide the outer diverging and has_errors flags.
|
||||||
let old_diverges = self.diverges.get();
|
let old_diverges = self.diverges.get();
|
||||||
|
@ -4021,7 +4022,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
ExprKind::Loop(..) | ExprKind::While(..) |
|
ExprKind::Loop(..) | ExprKind::While(..) |
|
||||||
ExprKind::If(..) | ExprKind::Match(..) => {}
|
ExprKind::If(..) | ExprKind::Match(..) => {}
|
||||||
|
|
||||||
_ => self.warn_if_unreachable(expr.id, expr.span, "expression")
|
_ => self.warn_if_unreachable(expr.hir_id, expr.span, "expression")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any expression that produces a value of type `!` must have diverged
|
// Any expression that produces a value of type `!` must have diverged
|
||||||
|
@ -4038,7 +4039,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
self.diverges.set(self.diverges.get() | old_diverges);
|
self.diverges.set(self.diverges.get() | old_diverges);
|
||||||
self.has_errors.set(self.has_errors.get() | old_has_errors);
|
self.has_errors.set(self.has_errors.get() | old_has_errors);
|
||||||
|
|
||||||
debug!("type of {} is...", self.tcx.hir().node_to_string(expr.id));
|
debug!("type of {} is...", self.tcx.hir().hir_to_string(expr.hir_id));
|
||||||
debug!("... {:?}, expected is {:?}", ty, expected);
|
debug!("... {:?}, expected is {:?}", ty, expected);
|
||||||
|
|
||||||
ty
|
ty
|
||||||
|
@ -4058,7 +4059,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let id = expr.id;
|
let id = expr.hir_id;
|
||||||
match expr.node {
|
match expr.node {
|
||||||
ExprKind::Box(ref subexpr) => {
|
ExprKind::Box(ref subexpr) => {
|
||||||
let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| {
|
let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| {
|
||||||
|
@ -4190,7 +4191,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExprKind::Path(ref qpath) => {
|
ExprKind::Path(ref qpath) => {
|
||||||
let (def, opt_ty, segs) = self.resolve_ty_and_def_ufcs(qpath, expr.id, expr.span);
|
let (def, opt_ty, segs) = self.resolve_ty_and_def_ufcs(qpath, expr.hir_id,
|
||||||
|
expr.span);
|
||||||
let ty = match def {
|
let ty = match def {
|
||||||
Def::Err => {
|
Def::Err => {
|
||||||
self.set_tainted_by_errors();
|
self.set_tainted_by_errors();
|
||||||
|
@ -4255,6 +4257,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
ExprKind::Break(destination, ref expr_opt) => {
|
ExprKind::Break(destination, ref expr_opt) => {
|
||||||
if let Ok(target_id) = destination.target_id {
|
if let Ok(target_id) = destination.target_id {
|
||||||
|
let target_id = tcx.hir().node_to_hir_id(target_id);
|
||||||
let (e_ty, cause);
|
let (e_ty, cause);
|
||||||
if let Some(ref e) = *expr_opt {
|
if let Some(ref e) = *expr_opt {
|
||||||
// If this is a break with a value, we need to type-check
|
// If this is a break with a value, we need to type-check
|
||||||
|
@ -4360,7 +4363,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
*self.ret_coercion_span.borrow_mut() = Some(expr.span);
|
*self.ret_coercion_span.borrow_mut() = Some(expr.span);
|
||||||
}
|
}
|
||||||
let cause = self.cause(expr.span, ObligationCauseCode::ReturnNoExpression);
|
let cause = self.cause(expr.span, ObligationCauseCode::ReturnNoExpression);
|
||||||
if let Some((fn_decl, _)) = self.get_fn_decl(expr.id) {
|
if let Some((fn_decl, _)) = self.get_fn_decl(expr.hir_id) {
|
||||||
coercion.coerce_forced_unit(
|
coercion.coerce_forced_unit(
|
||||||
self,
|
self,
|
||||||
&cause,
|
&cause,
|
||||||
|
@ -4422,7 +4425,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
may_break: false, // Will get updated if/when we find a `break`.
|
may_break: false, // Will get updated if/when we find a `break`.
|
||||||
};
|
};
|
||||||
|
|
||||||
let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || {
|
let (ctxt, ()) = self.with_breakable_ctxt(expr.hir_id, ctxt, || {
|
||||||
self.check_expr_has_type_or_error(&cond, tcx.types.bool);
|
self.check_expr_has_type_or_error(&cond, tcx.types.bool);
|
||||||
let cond_diverging = self.diverges.get();
|
let cond_diverging = self.diverges.get();
|
||||||
self.check_block_no_value(&body);
|
self.check_block_no_value(&body);
|
||||||
|
@ -4458,7 +4461,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
may_break: false, // Will get updated if/when we find a `break`.
|
may_break: false, // Will get updated if/when we find a `break`.
|
||||||
};
|
};
|
||||||
|
|
||||||
let (ctxt, ()) = self.with_breakable_ctxt(expr.id, ctxt, || {
|
let (ctxt, ()) = self.with_breakable_ctxt(expr.hir_id, ctxt, || {
|
||||||
self.check_block_no_value(&body);
|
self.check_block_no_value(&body);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4715,7 +4718,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
fn finish_resolving_struct_path(&self,
|
fn finish_resolving_struct_path(&self,
|
||||||
qpath: &QPath,
|
qpath: &QPath,
|
||||||
path_span: Span,
|
path_span: Span,
|
||||||
node_id: ast::NodeId)
|
hir_id: hir::HirId)
|
||||||
-> (Def, Ty<'tcx>)
|
-> (Def, Ty<'tcx>)
|
||||||
{
|
{
|
||||||
match *qpath {
|
match *qpath {
|
||||||
|
@ -4732,12 +4735,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
Def::Err
|
Def::Err
|
||||||
};
|
};
|
||||||
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
|
|
||||||
let (ty, def) = AstConv::associated_path_to_ty(self, hir_id, path_span,
|
let (ty, def) = AstConv::associated_path_to_ty(self, hir_id, path_span,
|
||||||
ty, def, segment, true);
|
ty, def, segment, true);
|
||||||
|
|
||||||
// Write back the new resolution.
|
// Write back the new resolution.
|
||||||
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
|
|
||||||
self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, def);
|
self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, def);
|
||||||
|
|
||||||
(def, ty)
|
(def, ty)
|
||||||
|
@ -4749,11 +4750,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
/// definition. The newly resolved definition is written into `type_dependent_defs`.
|
/// definition. The newly resolved definition is written into `type_dependent_defs`.
|
||||||
pub fn resolve_ty_and_def_ufcs<'b>(&self,
|
pub fn resolve_ty_and_def_ufcs<'b>(&self,
|
||||||
qpath: &'b QPath,
|
qpath: &'b QPath,
|
||||||
node_id: ast::NodeId,
|
hir_id: hir::HirId,
|
||||||
span: Span)
|
span: Span)
|
||||||
-> (Def, Option<Ty<'tcx>>, &'b [hir::PathSegment])
|
-> (Def, Option<Ty<'tcx>>, &'b [hir::PathSegment])
|
||||||
{
|
{
|
||||||
debug!("resolve_ty_and_def_ufcs: qpath={:?} node_id={:?} span={:?}", qpath, node_id, span);
|
debug!("resolve_ty_and_def_ufcs: qpath={:?} hir_id={:?} span={:?}", qpath, hir_id, span);
|
||||||
let (ty, qself, item_segment) = match *qpath {
|
let (ty, qself, item_segment) = match *qpath {
|
||||||
QPath::Resolved(ref opt_qself, ref path) => {
|
QPath::Resolved(ref opt_qself, ref path) => {
|
||||||
return (path.def,
|
return (path.def,
|
||||||
|
@ -4764,14 +4765,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
(self.to_ty(qself), qself, segment)
|
(self.to_ty(qself), qself, segment)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let hir_id = self.tcx.hir().node_to_hir_id(node_id);
|
|
||||||
if let Some(cached_def) = self.tables.borrow().type_dependent_defs().get(hir_id) {
|
if let Some(cached_def) = self.tables.borrow().type_dependent_defs().get(hir_id) {
|
||||||
// Return directly on cache hit. This is useful to avoid doubly reporting
|
// Return directly on cache hit. This is useful to avoid doubly reporting
|
||||||
// errors with default match binding modes. See #44614.
|
// errors with default match binding modes. See #44614.
|
||||||
return (*cached_def, Some(ty), slice::from_ref(&**item_segment))
|
return (*cached_def, Some(ty), slice::from_ref(&**item_segment))
|
||||||
}
|
}
|
||||||
let item_name = item_segment.ident;
|
let item_name = item_segment.ident;
|
||||||
let def = match self.resolve_ufcs(span, item_name, ty, node_id) {
|
let def = match self.resolve_ufcs(span, item_name, ty, hir_id) {
|
||||||
Ok(def) => def,
|
Ok(def) => def,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
let def = match error {
|
let def = match error {
|
||||||
|
@ -4853,7 +4853,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
hir::StmtKind::Local(..) | hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {}
|
hir::StmtKind::Local(..) | hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.warn_if_unreachable(stmt.id, stmt.span, "statement");
|
self.warn_if_unreachable(stmt.hir_id, stmt.span, "statement");
|
||||||
|
|
||||||
// Hide the outer diverging and `has_errors` flags.
|
// Hide the outer diverging and `has_errors` flags.
|
||||||
let old_diverges = self.diverges.get();
|
let old_diverges = self.diverges.get();
|
||||||
|
@ -4935,8 +4935,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
may_break: false,
|
may_break: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let blk_node_id = self.tcx.hir().hir_to_node_id(blk.hir_id);
|
let (ctxt, ()) = self.with_breakable_ctxt(blk.hir_id, ctxt, || {
|
||||||
let (ctxt, ()) = self.with_breakable_ctxt(blk_node_id, ctxt, || {
|
|
||||||
for s in &blk.stmts {
|
for s in &blk.stmts {
|
||||||
self.check_stmt(s);
|
self.check_stmt(s);
|
||||||
}
|
}
|
||||||
|
@ -4946,12 +4945,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
let tail_expr_ty = tail_expr.map(|t| self.check_expr_with_expectation(t, expected));
|
let tail_expr_ty = tail_expr.map(|t| self.check_expr_with_expectation(t, expected));
|
||||||
|
|
||||||
let mut enclosing_breakables = self.enclosing_breakables.borrow_mut();
|
let mut enclosing_breakables = self.enclosing_breakables.borrow_mut();
|
||||||
let ctxt = enclosing_breakables.find_breakable(blk_node_id);
|
let ctxt = enclosing_breakables.find_breakable(blk.hir_id);
|
||||||
let coerce = ctxt.coerce.as_mut().unwrap();
|
let coerce = ctxt.coerce.as_mut().unwrap();
|
||||||
if let Some(tail_expr_ty) = tail_expr_ty {
|
if let Some(tail_expr_ty) = tail_expr_ty {
|
||||||
let tail_expr = tail_expr.unwrap();
|
let tail_expr = tail_expr.unwrap();
|
||||||
let cause = self.cause(tail_expr.span,
|
let cause = self.cause(tail_expr.span,
|
||||||
ObligationCauseCode::BlockTailExpression(blk_node_id));
|
ObligationCauseCode::BlockTailExpression(blk.hir_id));
|
||||||
coerce.coerce(self,
|
coerce.coerce(self,
|
||||||
&cause,
|
&cause,
|
||||||
tail_expr,
|
tail_expr,
|
||||||
|
@ -4975,6 +4974,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
// that highlight errors inline.
|
// that highlight errors inline.
|
||||||
let mut sp = blk.span;
|
let mut sp = blk.span;
|
||||||
let mut fn_span = None;
|
let mut fn_span = None;
|
||||||
|
let blk_node_id = self.tcx.hir().hir_to_node_id(blk.hir_id);
|
||||||
if let Some((decl, ident)) = self.get_parent_fn_decl(blk_node_id) {
|
if let Some((decl, ident)) = self.get_parent_fn_decl(blk_node_id) {
|
||||||
let ret_sp = decl.output.span();
|
let ret_sp = decl.output.span();
|
||||||
if let Some(block_sp) = self.parent_item_span(blk_node_id) {
|
if let Some(block_sp) = self.parent_item_span(blk_node_id) {
|
||||||
|
@ -5067,13 +5067,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a `NodeId`, return the `FnDecl` of the method it is enclosed by and whether a
|
/// Given a `HirId`, return the `FnDecl` of the method it is enclosed by and whether a
|
||||||
/// suggestion can be made, `None` otherwise.
|
/// suggestion can be made, `None` otherwise.
|
||||||
pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> {
|
pub fn get_fn_decl(&self, blk_id: hir::HirId) -> Option<(hir::FnDecl, bool)> {
|
||||||
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
|
// Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or
|
||||||
// `while` before reaching it, as block tail returns are not available in them.
|
// `while` before reaching it, as block tail returns are not available in them.
|
||||||
self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
|
self.tcx.hir().get_return_block(blk_id).and_then(|blk_id| {
|
||||||
let parent = self.tcx.hir().get(blk_id);
|
let parent = self.tcx.hir().get_by_hir_id(blk_id);
|
||||||
self.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
self.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5090,7 +5090,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
expected: Ty<'tcx>,
|
expected: Ty<'tcx>,
|
||||||
found: Ty<'tcx>,
|
found: Ty<'tcx>,
|
||||||
cause_span: Span,
|
cause_span: Span,
|
||||||
blk_id: ast::NodeId,
|
blk_id: hir::HirId,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
self.suggest_missing_semicolon(err, expression, expected, cause_span);
|
self.suggest_missing_semicolon(err, expression, expected, cause_span);
|
||||||
let mut pointing_at_return_type = false;
|
let mut pointing_at_return_type = false;
|
||||||
|
@ -5303,14 +5303,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
self_ty: Option<Ty<'tcx>>,
|
self_ty: Option<Ty<'tcx>>,
|
||||||
def: Def,
|
def: Def,
|
||||||
span: Span,
|
span: Span,
|
||||||
node_id: ast::NodeId)
|
hir_id: hir::HirId)
|
||||||
-> (Ty<'tcx>, Def) {
|
-> (Ty<'tcx>, Def) {
|
||||||
debug!(
|
debug!(
|
||||||
"instantiate_value_path(segments={:?}, self_ty={:?}, def={:?}, node_id={})",
|
"instantiate_value_path(segments={:?}, self_ty={:?}, def={:?}, hir_id={})",
|
||||||
segments,
|
segments,
|
||||||
self_ty,
|
self_ty,
|
||||||
def,
|
def,
|
||||||
node_id,
|
hir_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
@ -5380,7 +5380,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
Def::Local(nid) | Def::Upvar(nid, ..) => {
|
Def::Local(nid) | Def::Upvar(nid, ..) => {
|
||||||
let ty = self.local_ty(span, nid).decl_ty;
|
let ty = self.local_ty(span, nid).decl_ty;
|
||||||
let ty = self.normalize_associated_types_in(span, &ty);
|
let ty = self.normalize_associated_types_in(span, &ty);
|
||||||
self.write_ty(tcx.hir().node_to_hir_id(node_id), ty);
|
self.write_ty(hir_id, ty);
|
||||||
return (ty, def);
|
return (ty, def);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -5532,7 +5532,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
assert!(!ty.has_escaping_bound_vars());
|
assert!(!ty.has_escaping_bound_vars());
|
||||||
|
|
||||||
// First, store the "user substs" for later.
|
// First, store the "user substs" for later.
|
||||||
let hir_id = tcx.hir().node_to_hir_id(node_id);
|
|
||||||
self.write_user_type_annotation_from_substs(hir_id, def_id, substs, user_self_ty);
|
self.write_user_type_annotation_from_substs(hir_id, def_id, substs, user_self_ty);
|
||||||
|
|
||||||
// Add all the obligations that are required, substituting and
|
// Add all the obligations that are required, substituting and
|
||||||
|
@ -5566,10 +5565,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.check_rustc_args_require_const(def_id, node_id, span);
|
self.check_rustc_args_require_const(def_id, hir_id, span);
|
||||||
|
|
||||||
debug!("instantiate_value_path: type of {:?} is {:?}",
|
debug!("instantiate_value_path: type of {:?} is {:?}",
|
||||||
node_id,
|
hir_id,
|
||||||
ty_substituted);
|
ty_substituted);
|
||||||
self.write_substs(hir_id, substs);
|
self.write_substs(hir_id, substs);
|
||||||
|
|
||||||
|
@ -5578,7 +5577,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
fn check_rustc_args_require_const(&self,
|
fn check_rustc_args_require_const(&self,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
node_id: ast::NodeId,
|
hir_id: hir::HirId,
|
||||||
span: Span) {
|
span: Span) {
|
||||||
// We're only interested in functions tagged with
|
// We're only interested in functions tagged with
|
||||||
// #[rustc_args_required_const], so ignore anything that's not.
|
// #[rustc_args_required_const], so ignore anything that's not.
|
||||||
|
@ -5588,9 +5587,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
// If our calling expression is indeed the function itself, we're good!
|
// If our calling expression is indeed the function itself, we're good!
|
||||||
// If not, generate an error that this can only be called directly.
|
// If not, generate an error that this can only be called directly.
|
||||||
if let Node::Expr(expr) = self.tcx.hir().get(self.tcx.hir().get_parent_node(node_id)) {
|
if let Node::Expr(expr) = self.tcx.hir().get_by_hir_id(
|
||||||
|
self.tcx.hir().get_parent_node_by_hir_id(hir_id))
|
||||||
|
{
|
||||||
if let ExprKind::Call(ref callee, ..) = expr.node {
|
if let ExprKind::Call(ref callee, ..) = expr.node {
|
||||||
if callee.id == node_id {
|
if callee.hir_id == hir_id {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5618,7 +5619,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: ast::NodeId,
|
fn with_breakable_ctxt<F: FnOnce() -> R, R>(&self, id: hir::HirId,
|
||||||
ctxt: BreakableCtxt<'gcx, 'tcx>, f: F)
|
ctxt: BreakableCtxt<'gcx, 'tcx>, f: F)
|
||||||
-> (BreakableCtxt<'gcx, 'tcx>, R) {
|
-> (BreakableCtxt<'gcx, 'tcx>, R) {
|
||||||
let index;
|
let index;
|
||||||
|
@ -5655,22 +5656,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if an expression is contained inside the LHS of an assignment expression.
|
/// Returns `true` if an expression is contained inside the LHS of an assignment expression.
|
||||||
fn expr_in_place(&self, mut expr_id: ast::NodeId) -> bool {
|
fn expr_in_place(&self, mut expr_id: hir::HirId) -> bool {
|
||||||
let mut contained_in_place = false;
|
let mut contained_in_place = false;
|
||||||
|
|
||||||
while let hir::Node::Expr(parent_expr) =
|
while let hir::Node::Expr(parent_expr) =
|
||||||
self.tcx.hir().get(self.tcx.hir().get_parent_node(expr_id))
|
self.tcx.hir().get_by_hir_id(self.tcx.hir().get_parent_node_by_hir_id(expr_id))
|
||||||
{
|
{
|
||||||
match &parent_expr.node {
|
match &parent_expr.node {
|
||||||
hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => {
|
hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => {
|
||||||
if lhs.id == expr_id {
|
if lhs.hir_id == expr_id {
|
||||||
contained_in_place = true;
|
contained_in_place = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
expr_id = parent_expr.id;
|
expr_id = parent_expr.hir_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
contained_in_place
|
contained_in_place
|
||||||
|
|
|
@ -51,8 +51,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
{
|
{
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
debug!("check_binop(expr.id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})",
|
debug!("check_binop(expr.hir_id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})",
|
||||||
expr.id,
|
expr.hir_id,
|
||||||
expr,
|
expr,
|
||||||
op,
|
op,
|
||||||
lhs_expr,
|
lhs_expr,
|
||||||
|
@ -150,8 +150,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
is_assign: IsAssign)
|
is_assign: IsAssign)
|
||||||
-> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>)
|
-> (Ty<'tcx>, Ty<'tcx>, Ty<'tcx>)
|
||||||
{
|
{
|
||||||
debug!("check_overloaded_binop(expr.id={}, op={:?}, is_assign={:?})",
|
debug!("check_overloaded_binop(expr.hir_id={}, op={:?}, is_assign={:?})",
|
||||||
expr.id,
|
expr.hir_id,
|
||||||
op,
|
op,
|
||||||
is_assign);
|
is_assign);
|
||||||
|
|
||||||
|
|
|
@ -694,8 +694,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> {
|
||||||
hir::ExprKind::Ret(Some(ref ret_expr)) => {
|
hir::ExprKind::Ret(Some(ref ret_expr)) => {
|
||||||
let call_site_scope = self.call_site_scope;
|
let call_site_scope = self.call_site_scope;
|
||||||
debug!(
|
debug!(
|
||||||
"visit_expr ExprKind::Ret ret_expr.id {} call_site_scope: {:?}",
|
"visit_expr ExprKind::Ret ret_expr.hir_id {} call_site_scope: {:?}",
|
||||||
ret_expr.id, call_site_scope
|
ret_expr.hir_id, call_site_scope
|
||||||
);
|
);
|
||||||
let call_site_region = self.tcx.mk_region(ty::ReScope(call_site_scope.unwrap()));
|
let call_site_region = self.tcx.mk_region(ty::ReScope(call_site_scope.unwrap()));
|
||||||
self.type_of_node_must_outlive(
|
self.type_of_node_must_outlive(
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for InferBorrowKindVisitor<'a, 'gcx, 'tcx> {
|
||||||
let body = self.fcx.tcx.hir().body(body_id);
|
let body = self.fcx.tcx.hir().body(body_id);
|
||||||
self.visit_body(body);
|
self.visit_body(body);
|
||||||
self.fcx
|
self.fcx
|
||||||
.analyze_closure(expr.id, expr.hir_id, expr.span, body, cc);
|
.analyze_closure(expr.hir_id, expr.span, body, cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
intravisit::walk_expr(self, expr);
|
intravisit::walk_expr(self, expr);
|
||||||
|
@ -77,7 +77,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for InferBorrowKindVisitor<'a, 'gcx, 'tcx> {
|
||||||
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
fn analyze_closure(
|
fn analyze_closure(
|
||||||
&self,
|
&self,
|
||||||
closure_node_id: ast::NodeId,
|
|
||||||
closure_hir_id: hir::HirId,
|
closure_hir_id: hir::HirId,
|
||||||
span: Span,
|
span: Span,
|
||||||
body: &hir::Body,
|
body: &hir::Body,
|
||||||
|
@ -89,7 +88,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"analyze_closure(id={:?}, body.id={:?})",
|
"analyze_closure(id={:?}, body.id={:?})",
|
||||||
closure_node_id,
|
closure_hir_id,
|
||||||
body.id()
|
body.id()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
span_bug!(
|
span_bug!(
|
||||||
span,
|
span,
|
||||||
"type of closure expr {:?} is not a closure {:?}",
|
"type of closure expr {:?} is not a closure {:?}",
|
||||||
closure_node_id,
|
closure_hir_id,
|
||||||
t
|
t
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +120,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let closure_node_id = self.tcx.hir().hir_to_node_id(closure_hir_id);
|
||||||
|
|
||||||
self.tcx.with_freevars(closure_node_id, |freevars| {
|
self.tcx.with_freevars(closure_node_id, |freevars| {
|
||||||
let mut freevar_list: Vec<ty::UpvarId> = Vec::with_capacity(freevars.len());
|
let mut freevar_list: Vec<ty::UpvarId> = Vec::with_capacity(freevars.len());
|
||||||
for freevar in freevars {
|
for freevar in freevars {
|
||||||
|
@ -582,7 +583,7 @@ impl<'a, 'gcx, 'tcx> InferBorrowKind<'a, 'gcx, 'tcx> {
|
||||||
impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
|
||||||
fn consume(
|
fn consume(
|
||||||
&mut self,
|
&mut self,
|
||||||
_consume_id: ast::NodeId,
|
_consume_id: hir::HirId,
|
||||||
_consume_span: Span,
|
_consume_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
mode: euv::ConsumeMode,
|
mode: euv::ConsumeMode,
|
||||||
|
@ -611,7 +612,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
fn borrow(
|
fn borrow(
|
||||||
&mut self,
|
&mut self,
|
||||||
borrow_id: ast::NodeId,
|
borrow_id: hir::HirId,
|
||||||
_borrow_span: Span,
|
_borrow_span: Span,
|
||||||
cmt: &mc::cmt_<'tcx>,
|
cmt: &mc::cmt_<'tcx>,
|
||||||
_loan_region: ty::Region<'tcx>,
|
_loan_region: ty::Region<'tcx>,
|
||||||
|
@ -638,7 +639,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
fn mutate(
|
fn mutate(
|
||||||
&mut self,
|
&mut self,
|
||||||
_assignment_id: ast::NodeId,
|
_assignment_id: hir::HirId,
|
||||||
_assignment_span: Span,
|
_assignment_span: Span,
|
||||||
assignee_cmt: &mc::cmt_<'tcx>,
|
assignee_cmt: &mc::cmt_<'tcx>,
|
||||||
_mode: euv::MutateMode,
|
_mode: euv::MutateMode,
|
||||||
|
|
|
@ -243,11 +243,11 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
hir::ExprKind::Struct(_, ref fields, _) => {
|
hir::ExprKind::Struct(_, ref fields, _) => {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
self.visit_field_id(field.id);
|
self.visit_field_id(field.hir_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprKind::Field(..) => {
|
hir::ExprKind::Field(..) => {
|
||||||
self.visit_field_id(e.id);
|
self.visit_field_id(e.hir_id);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
hir::PatKind::Struct(_, ref fields, _) => {
|
hir::PatKind::Struct(_, ref fields, _) => {
|
||||||
for field in fields {
|
for field in fields {
|
||||||
self.visit_field_id(field.node.id);
|
self.visit_field_id(field.node.hir_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -590,8 +590,7 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_field_id(&mut self, node_id: ast::NodeId) {
|
fn visit_field_id(&mut self, hir_id: hir::HirId) {
|
||||||
let hir_id = self.tcx().hir().node_to_hir_id(node_id);
|
|
||||||
if let Some(index) = self.fcx
|
if let Some(index) = self.fcx
|
||||||
.tables
|
.tables
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||||
|
|
||||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||||
if let hir::ExprKind::Closure(..) = expr.node {
|
if let hir::ExprKind::Closure(..) = expr.node {
|
||||||
let def_id = self.tcx.hir().local_def_id(expr.id);
|
let def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
|
||||||
self.tcx.generics_of(def_id);
|
self.tcx.generics_of(def_id);
|
||||||
self.tcx.type_of(def_id);
|
self.tcx.type_of(def_id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue