hir: remove NodeId from Pat and FieldPat
This commit is contained in:
parent
77fa041fc1
commit
50b8bc8c8c
17 changed files with 87 additions and 102 deletions
|
@ -3740,12 +3740,11 @@ impl<'a> LoweringContext<'a> {
|
||||||
let fs = fields
|
let fs = fields
|
||||||
.iter()
|
.iter()
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||||
|
|
||||||
Spanned {
|
Spanned {
|
||||||
span: f.span,
|
span: f.span,
|
||||||
node: hir::FieldPat {
|
node: hir::FieldPat {
|
||||||
id: node_id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
ident: f.node.ident,
|
ident: f.node.ident,
|
||||||
pat: self.lower_pat(&f.node.pat),
|
pat: self.lower_pat(&f.node.pat),
|
||||||
|
@ -3777,9 +3776,8 @@ impl<'a> LoweringContext<'a> {
|
||||||
PatKind::Mac(_) => panic!("Shouldn't exist here"),
|
PatKind::Mac(_) => panic!("Shouldn't exist here"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(p.id);
|
let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(p.id);
|
||||||
P(hir::Pat {
|
P(hir::Pat {
|
||||||
id: node_id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
node,
|
node,
|
||||||
span: p.span,
|
span: p.span,
|
||||||
|
@ -4353,7 +4351,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
let iter = self.str_to_ident("iter");
|
let iter = self.str_to_ident("iter");
|
||||||
|
|
||||||
let next_ident = self.str_to_ident("__next");
|
let next_ident = self.str_to_ident("__next");
|
||||||
let next_pat = self.pat_ident_binding_mode(
|
let (next_pat, next_pat_nid) = self.pat_ident_binding_mode(
|
||||||
desugared_span,
|
desugared_span,
|
||||||
next_ident,
|
next_ident,
|
||||||
hir::BindingAnnotation::Mutable,
|
hir::BindingAnnotation::Mutable,
|
||||||
|
@ -4362,9 +4360,9 @@ impl<'a> LoweringContext<'a> {
|
||||||
// `::std::option::Option::Some(val) => next = val`
|
// `::std::option::Option::Some(val) => next = val`
|
||||||
let pat_arm = {
|
let pat_arm = {
|
||||||
let val_ident = self.str_to_ident("val");
|
let val_ident = self.str_to_ident("val");
|
||||||
let val_pat = self.pat_ident(pat.span, val_ident);
|
let (val_pat, val_pat_nid) = self.pat_ident(pat.span, val_ident);
|
||||||
let val_expr = P(self.expr_ident(pat.span, val_ident, val_pat.id));
|
let val_expr = P(self.expr_ident(pat.span, val_ident, val_pat_nid));
|
||||||
let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat.id));
|
let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat_nid));
|
||||||
let assign = P(self.expr(
|
let assign = P(self.expr(
|
||||||
pat.span,
|
pat.span,
|
||||||
hir::ExprKind::Assign(next_expr, val_expr),
|
hir::ExprKind::Assign(next_expr, val_expr),
|
||||||
|
@ -4383,7 +4381,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// `mut iter`
|
// `mut iter`
|
||||||
let iter_pat = self.pat_ident_binding_mode(
|
let (iter_pat, iter_pat_nid) = self.pat_ident_binding_mode(
|
||||||
desugared_span,
|
desugared_span,
|
||||||
iter,
|
iter,
|
||||||
hir::BindingAnnotation::Mutable
|
hir::BindingAnnotation::Mutable
|
||||||
|
@ -4391,7 +4389,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
|
|
||||||
// `match ::std::iter::Iterator::next(&mut iter) { ... }`
|
// `match ::std::iter::Iterator::next(&mut iter) { ... }`
|
||||||
let match_expr = {
|
let match_expr = {
|
||||||
let iter = P(self.expr_ident(head_sp, iter, iter_pat.id));
|
let iter = P(self.expr_ident(head_sp, iter, iter_pat_nid));
|
||||||
let ref_mut_iter = self.expr_mut_addr_of(head_sp, iter);
|
let ref_mut_iter = self.expr_mut_addr_of(head_sp, iter);
|
||||||
let next_path = &["iter", "Iterator", "next"];
|
let next_path = &["iter", "Iterator", "next"];
|
||||||
let next_path = P(self.expr_std_path(head_sp, next_path, None, ThinVec::new()));
|
let next_path = P(self.expr_std_path(head_sp, next_path, None, ThinVec::new()));
|
||||||
|
@ -4415,7 +4413,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
span: head_sp,
|
span: head_sp,
|
||||||
};
|
};
|
||||||
|
|
||||||
let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat.id));
|
let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat_nid));
|
||||||
|
|
||||||
// `let mut __next`
|
// `let mut __next`
|
||||||
let next_let = self.stmt_let_pat(
|
let next_let = self.stmt_let_pat(
|
||||||
|
@ -4542,11 +4540,11 @@ impl<'a> LoweringContext<'a> {
|
||||||
// `Ok(val) => #[allow(unreachable_code)] val,`
|
// `Ok(val) => #[allow(unreachable_code)] val,`
|
||||||
let ok_arm = {
|
let ok_arm = {
|
||||||
let val_ident = self.str_to_ident("val");
|
let val_ident = self.str_to_ident("val");
|
||||||
let val_pat = self.pat_ident(e.span, val_ident);
|
let (val_pat, val_pat_nid) = self.pat_ident(e.span, val_ident);
|
||||||
let val_expr = P(self.expr_ident_with_attrs(
|
let val_expr = P(self.expr_ident_with_attrs(
|
||||||
e.span,
|
e.span,
|
||||||
val_ident,
|
val_ident,
|
||||||
val_pat.id,
|
val_pat_nid,
|
||||||
ThinVec::from(attrs.clone()),
|
ThinVec::from(attrs.clone()),
|
||||||
));
|
));
|
||||||
let ok_pat = self.pat_ok(e.span, val_pat);
|
let ok_pat = self.pat_ok(e.span, val_pat);
|
||||||
|
@ -4558,12 +4556,12 @@ impl<'a> LoweringContext<'a> {
|
||||||
// return Try::from_error(From::from(err)),`
|
// return Try::from_error(From::from(err)),`
|
||||||
let err_arm = {
|
let err_arm = {
|
||||||
let err_ident = self.str_to_ident("err");
|
let err_ident = self.str_to_ident("err");
|
||||||
let err_local = self.pat_ident(e.span, err_ident);
|
let (err_local, err_local_nid) = self.pat_ident(e.span, err_ident);
|
||||||
let from_expr = {
|
let from_expr = {
|
||||||
let path = &["convert", "From", "from"];
|
let path = &["convert", "From", "from"];
|
||||||
let from = P(self.expr_std_path(
|
let from = P(self.expr_std_path(
|
||||||
e.span, path, None, ThinVec::new()));
|
e.span, path, None, ThinVec::new()));
|
||||||
let err_expr = self.expr_ident(e.span, err_ident, err_local.id);
|
let err_expr = self.expr_ident(e.span, err_ident, err_local_nid);
|
||||||
|
|
||||||
self.expr_call(e.span, from, hir_vec![err_expr])
|
self.expr_call(e.span, from, hir_vec![err_expr])
|
||||||
};
|
};
|
||||||
|
@ -4911,15 +4909,15 @@ impl<'a> LoweringContext<'a> {
|
||||||
ident: Ident,
|
ident: Ident,
|
||||||
ex: P<hir::Expr>,
|
ex: P<hir::Expr>,
|
||||||
) -> (hir::Stmt, NodeId) {
|
) -> (hir::Stmt, NodeId) {
|
||||||
let pat = if mutbl {
|
let (pat, pat_nid) = if mutbl {
|
||||||
self.pat_ident_binding_mode(sp, ident, hir::BindingAnnotation::Mutable)
|
self.pat_ident_binding_mode(sp, ident, hir::BindingAnnotation::Mutable)
|
||||||
} else {
|
} else {
|
||||||
self.pat_ident(sp, ident)
|
self.pat_ident(sp, ident)
|
||||||
};
|
};
|
||||||
let pat_id = pat.id;
|
|
||||||
(
|
(
|
||||||
self.stmt_let_pat(sp, Some(ex), pat, hir::LocalSource::Normal),
|
self.stmt_let_pat(sp, Some(ex), pat, hir::LocalSource::Normal),
|
||||||
pat_id,
|
pat_nid,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4977,7 +4975,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
self.pat(span, pt)
|
self.pat(span, pt)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_ident(&mut self, span: Span, ident: Ident) -> P<hir::Pat> {
|
fn pat_ident(&mut self, span: Span, ident: Ident) -> (P<hir::Pat>, NodeId) {
|
||||||
self.pat_ident_binding_mode(span, ident, hir::BindingAnnotation::Unannotated)
|
self.pat_ident_binding_mode(span, ident, hir::BindingAnnotation::Unannotated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4986,15 +4984,17 @@ impl<'a> LoweringContext<'a> {
|
||||||
span: Span,
|
span: Span,
|
||||||
ident: Ident,
|
ident: Ident,
|
||||||
bm: hir::BindingAnnotation,
|
bm: hir::BindingAnnotation,
|
||||||
) -> P<hir::Pat> {
|
) -> (P<hir::Pat>, NodeId) {
|
||||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
||||||
|
|
||||||
P(hir::Pat {
|
(
|
||||||
id: node_id,
|
P(hir::Pat {
|
||||||
hir_id,
|
hir_id,
|
||||||
node: hir::PatKind::Binding(bm, node_id, hir_id, ident.with_span_pos(span), None),
|
node: hir::PatKind::Binding(bm, node_id, hir_id, ident.with_span_pos(span), None),
|
||||||
span,
|
span,
|
||||||
})
|
}),
|
||||||
|
node_id
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_wild(&mut self, span: Span) -> P<hir::Pat> {
|
fn pat_wild(&mut self, span: Span) -> P<hir::Pat> {
|
||||||
|
@ -5002,9 +5002,8 @@ impl<'a> LoweringContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat(&mut self, span: Span, pat: hir::PatKind) -> P<hir::Pat> {
|
fn pat(&mut self, span: Span, pat: hir::PatKind) -> P<hir::Pat> {
|
||||||
let LoweredNodeId { node_id, hir_id } = self.next_id();
|
let LoweredNodeId { node_id: _, hir_id } = self.next_id();
|
||||||
P(hir::Pat {
|
P(hir::Pat {
|
||||||
id: node_id,
|
|
||||||
hir_id,
|
hir_id,
|
||||||
node: pat,
|
node: pat,
|
||||||
span,
|
span,
|
||||||
|
|
|
@ -834,7 +834,6 @@ pub struct Block {
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
#[derive(Clone, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Pat {
|
pub struct Pat {
|
||||||
pub id: NodeId,
|
|
||||||
pub hir_id: HirId,
|
pub hir_id: HirId,
|
||||||
pub node: PatKind,
|
pub node: PatKind,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
@ -842,7 +841,7 @@ pub struct Pat {
|
||||||
|
|
||||||
impl fmt::Debug for Pat {
|
impl fmt::Debug for Pat {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "pat({}: {})", self.id,
|
write!(f, "pat({}: {})", self.hir_id,
|
||||||
print::to_string(print::NO_ANN, |s| s.print_pat(self)))
|
print::to_string(print::NO_ANN, |s| s.print_pat(self)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,7 +896,6 @@ impl Pat {
|
||||||
/// except `is_shorthand` is true.
|
/// except `is_shorthand` is true.
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub struct FieldPat {
|
pub struct FieldPat {
|
||||||
pub id: NodeId,
|
|
||||||
pub hir_id: HirId,
|
pub hir_id: HirId,
|
||||||
/// The identifier for the field.
|
/// The identifier for the field.
|
||||||
pub ident: Ident,
|
pub ident: Ident,
|
||||||
|
|
|
@ -421,7 +421,6 @@ impl_stable_hash_for!(struct hir::Block {
|
||||||
});
|
});
|
||||||
|
|
||||||
impl_stable_hash_for!(struct hir::Pat {
|
impl_stable_hash_for!(struct hir::Pat {
|
||||||
id -> _,
|
|
||||||
hir_id -> _,
|
hir_id -> _,
|
||||||
node,
|
node,
|
||||||
span,
|
span,
|
||||||
|
@ -430,7 +429,6 @@ impl_stable_hash_for!(struct hir::Pat {
|
||||||
impl_stable_hash_for_spanned!(hir::FieldPat);
|
impl_stable_hash_for_spanned!(hir::FieldPat);
|
||||||
|
|
||||||
impl_stable_hash_for!(struct hir::FieldPat {
|
impl_stable_hash_for!(struct hir::FieldPat {
|
||||||
id -> _,
|
|
||||||
hir_id -> _,
|
hir_id -> _,
|
||||||
ident -> (ident.name),
|
ident -> (ident.name),
|
||||||
pat,
|
pat,
|
||||||
|
|
|
@ -19,7 +19,6 @@ use crate::ty::{self, TyCtxt, adjustment};
|
||||||
use crate::hir::{self, PatKind};
|
use crate::hir::{self, PatKind};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax::ast;
|
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use crate::util::nodemap::ItemLocalSet;
|
use crate::util::nodemap::ItemLocalSet;
|
||||||
|
@ -74,7 +73,7 @@ pub trait Delegate<'tcx> {
|
||||||
|
|
||||||
// The local variable `id` is declared but not initialized.
|
// The local variable `id` is declared but not initialized.
|
||||||
fn decl_without_init(&mut self,
|
fn decl_without_init(&mut self,
|
||||||
id: ast::NodeId,
|
id: hir::HirId,
|
||||||
span: Span);
|
span: Span);
|
||||||
|
|
||||||
// The path at `cmt` is being assigned to.
|
// The path at `cmt` is being assigned to.
|
||||||
|
@ -609,8 +608,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
|
||||||
match local.init {
|
match local.init {
|
||||||
None => {
|
None => {
|
||||||
local.pat.each_binding(|_, hir_id, span, _| {
|
local.pat.each_binding(|_, hir_id, span, _| {
|
||||||
let node_id = self.mc.tcx.hir().hir_to_node_id(hir_id);
|
self.delegate.decl_without_init(hir_id, span);
|
||||||
self.delegate.decl_without_init(node_id, span);
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ pub enum Categorization<'tcx> {
|
||||||
ThreadLocal(ty::Region<'tcx>), // value that cannot move, but still restricted in scope
|
ThreadLocal(ty::Region<'tcx>), // value that cannot move, but still restricted in scope
|
||||||
StaticItem,
|
StaticItem,
|
||||||
Upvar(Upvar), // upvar referenced by closure env
|
Upvar(Upvar), // upvar referenced by closure env
|
||||||
Local(ast::NodeId), // local variable
|
Local(hir::HirId), // local variable
|
||||||
Deref(cmt<'tcx>, PointerKind<'tcx>), // deref of a ptr
|
Deref(cmt<'tcx>, PointerKind<'tcx>), // deref of a ptr
|
||||||
Interior(cmt<'tcx>, InteriorKind), // something interior: field, tuple, etc
|
Interior(cmt<'tcx>, InteriorKind), // something interior: field, tuple, etc
|
||||||
Downcast(cmt<'tcx>, DefId), // selects a particular enum variant (*1)
|
Downcast(cmt<'tcx>, DefId), // selects a particular enum variant (*1)
|
||||||
|
@ -198,9 +198,9 @@ pub struct cmt_<'tcx> {
|
||||||
pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
|
pub type cmt<'tcx> = Rc<cmt_<'tcx>>;
|
||||||
|
|
||||||
pub enum ImmutabilityBlame<'tcx> {
|
pub enum ImmutabilityBlame<'tcx> {
|
||||||
ImmLocal(ast::NodeId),
|
ImmLocal(hir::HirId),
|
||||||
ClosureEnv(LocalDefId),
|
ClosureEnv(LocalDefId),
|
||||||
LocalDeref(ast::NodeId),
|
LocalDeref(hir::HirId),
|
||||||
AdtFieldDeref(&'tcx ty::AdtDef, &'tcx ty::FieldDef)
|
AdtFieldDeref(&'tcx ty::AdtDef, &'tcx ty::FieldDef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,8 +230,8 @@ impl<'tcx> cmt_<'tcx> {
|
||||||
Categorization::Deref(ref base_cmt, BorrowedPtr(ty::ImmBorrow, _)) => {
|
Categorization::Deref(ref base_cmt, BorrowedPtr(ty::ImmBorrow, _)) => {
|
||||||
// try to figure out where the immutable reference came from
|
// try to figure out where the immutable reference came from
|
||||||
match base_cmt.cat {
|
match base_cmt.cat {
|
||||||
Categorization::Local(node_id) =>
|
Categorization::Local(hir_id) =>
|
||||||
Some(ImmutabilityBlame::LocalDeref(node_id)),
|
Some(ImmutabilityBlame::LocalDeref(hir_id)),
|
||||||
Categorization::Interior(ref base_cmt, InteriorField(field_index)) => {
|
Categorization::Interior(ref base_cmt, InteriorField(field_index)) => {
|
||||||
base_cmt.resolve_field(field_index.0).map(|(adt_def, field_def)| {
|
base_cmt.resolve_field(field_index.0).map(|(adt_def, field_def)| {
|
||||||
ImmutabilityBlame::AdtFieldDeref(adt_def, field_def)
|
ImmutabilityBlame::AdtFieldDeref(adt_def, field_def)
|
||||||
|
@ -247,8 +247,8 @@ impl<'tcx> cmt_<'tcx> {
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Categorization::Local(node_id) => {
|
Categorization::Local(hir_id) => {
|
||||||
Some(ImmutabilityBlame::ImmLocal(node_id))
|
Some(ImmutabilityBlame::ImmLocal(hir_id))
|
||||||
}
|
}
|
||||||
Categorization::Rvalue(..) |
|
Categorization::Rvalue(..) |
|
||||||
Categorization::Upvar(..) |
|
Categorization::Upvar(..) |
|
||||||
|
@ -741,7 +741,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
|
||||||
Ok(cmt_ {
|
Ok(cmt_ {
|
||||||
hir_id,
|
hir_id,
|
||||||
span,
|
span,
|
||||||
cat: Categorization::Local(vid),
|
cat: Categorization::Local(self.tcx.hir().node_to_hir_id(vid)),
|
||||||
mutbl: MutabilityCategory::from_local(self.tcx, self.tables, vid),
|
mutbl: MutabilityCategory::from_local(self.tcx, self.tables, vid),
|
||||||
ty: expr_ty,
|
ty: expr_ty,
|
||||||
note: NoteNone
|
note: NoteNone
|
||||||
|
@ -1495,7 +1495,7 @@ impl<'tcx> cmt_<'tcx> {
|
||||||
"non-place".into()
|
"non-place".into()
|
||||||
}
|
}
|
||||||
Categorization::Local(vid) => {
|
Categorization::Local(vid) => {
|
||||||
if tcx.hir().is_argument(vid) {
|
if tcx.hir().is_argument(tcx.hir().hir_to_node_id(vid)) {
|
||||||
"argument"
|
"argument"
|
||||||
} else {
|
} else {
|
||||||
"local variable"
|
"local variable"
|
||||||
|
|
|
@ -2397,7 +2397,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
|
|
||||||
let help_name = if let Some(body) = parent {
|
let help_name = if let Some(body) = parent {
|
||||||
let arg = &self.tcx.hir().body(body).arguments[index];
|
let arg = &self.tcx.hir().body(body).arguments[index];
|
||||||
format!("`{}`", self.tcx.hir().node_to_pretty_string(arg.pat.id))
|
format!("`{}`", self.tcx.hir().hir_to_pretty_string(arg.pat.hir_id))
|
||||||
} else {
|
} else {
|
||||||
format!("argument {}", index + 1)
|
format!("argument {}", index + 1)
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,6 @@ use rustc::middle::mem_categorization as mc;
|
||||||
use rustc::middle::mem_categorization::Categorization;
|
use rustc::middle::mem_categorization::Categorization;
|
||||||
use rustc::middle::region;
|
use rustc::middle::region;
|
||||||
use rustc::ty::{self, TyCtxt, RegionKind};
|
use rustc::ty::{self, TyCtxt, RegionKind};
|
||||||
use syntax::ast;
|
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::hir::Node;
|
use rustc::hir::Node;
|
||||||
|
@ -177,7 +176,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
|
||||||
self.check_assignment(assignment_id.local_id, assignment_span, assignee_cmt);
|
self.check_assignment(assignment_id.local_id, assignment_span, assignee_cmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) { }
|
fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||||
|
@ -887,11 +886,10 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
||||||
// Check for reassignments to (immutable) local variables. This
|
// Check for reassignments to (immutable) local variables. This
|
||||||
// needs to be done here instead of in check_loans because we
|
// needs to be done here instead of in check_loans because we
|
||||||
// depend on move data.
|
// depend on move data.
|
||||||
if let Categorization::Local(local_id) = assignee_cmt.cat {
|
if let Categorization::Local(hir_id) = assignee_cmt.cat {
|
||||||
let lp = opt_loan_path(assignee_cmt).unwrap();
|
let lp = opt_loan_path(assignee_cmt).unwrap();
|
||||||
self.move_data.each_assignment_of(assignment_id, &lp, |assign| {
|
self.move_data.each_assignment_of(assignment_id, &lp, |assign| {
|
||||||
if assignee_cmt.mutbl.is_mutable() {
|
if assignee_cmt.mutbl.is_mutable() {
|
||||||
let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
|
|
||||||
self.bccx.used_mut_nodes.borrow_mut().insert(hir_id);
|
self.bccx.used_mut_nodes.borrow_mut().insert(hir_id);
|
||||||
} else {
|
} else {
|
||||||
self.bccx.report_reassigned_immutable_variable(
|
self.bccx.report_reassigned_immutable_variable(
|
||||||
|
|
|
@ -11,7 +11,6 @@ use rustc::middle::mem_categorization::InteriorOffsetKind as Kind;
|
||||||
use rustc::ty::{self, Ty};
|
use rustc::ty::{self, Ty};
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax::ast;
|
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
use rustc::hir::Node;
|
use rustc::hir::Node;
|
||||||
|
@ -48,9 +47,9 @@ pub enum PatternSource<'tcx> {
|
||||||
/// with a reference to the let
|
/// with a reference to the let
|
||||||
fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> PatternSource<'tcx> {
|
fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> PatternSource<'tcx> {
|
||||||
|
|
||||||
let parent = tcx.hir().get_parent_node(pat.id);
|
let parent = tcx.hir().get_parent_node_by_hir_id(pat.hir_id);
|
||||||
|
|
||||||
match tcx.hir().get(parent) {
|
match tcx.hir().get_by_hir_id(parent) {
|
||||||
Node::Expr(ref e) => {
|
Node::Expr(ref e) => {
|
||||||
// the enclosing expression must be a `match` or something else
|
// the enclosing expression must be a `match` or something else
|
||||||
assert!(match e.node {
|
assert!(match e.node {
|
||||||
|
@ -67,11 +66,10 @@ fn get_pattern_source<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, pat: &Pat) -> Patte
|
||||||
|
|
||||||
pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
pub fn gather_decl<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||||
move_data: &MoveData<'tcx>,
|
move_data: &MoveData<'tcx>,
|
||||||
var_id: ast::NodeId,
|
var_id: hir::HirId,
|
||||||
var_ty: Ty<'tcx>) {
|
var_ty: Ty<'tcx>) {
|
||||||
let loan_path = Rc::new(LoanPath::new(LpVar(var_id), var_ty));
|
let loan_path = Rc::new(LoanPath::new(LpVar(var_id), var_ty));
|
||||||
let hir_id = bccx.tcx.hir().node_to_hir_id(var_id);
|
move_data.add_move(bccx.tcx, loan_path, var_id.local_id, Declared);
|
||||||
move_data.add_move(bccx.tcx, loan_path, hir_id.local_id, Declared);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||||
|
|
|
@ -104,8 +104,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
|
||||||
Categorization::Upvar(..) => {
|
Categorization::Upvar(..) => {
|
||||||
self.bccx.tcx.mk_region(ty::ReScope(self.item_scope))
|
self.bccx.tcx.mk_region(ty::ReScope(self.item_scope))
|
||||||
}
|
}
|
||||||
Categorization::Local(local_id) => {
|
Categorization::Local(hir_id) => {
|
||||||
let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
|
|
||||||
self.bccx.tcx.mk_region(ty::ReScope(
|
self.bccx.tcx.mk_region(ty::ReScope(
|
||||||
self.bccx.region_scope_tree.var_scope(hir_id.local_id)))
|
self.bccx.region_scope_tree.var_scope(hir_id.local_id)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,10 +147,10 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
|
||||||
assignee_cmt);
|
assignee_cmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decl_without_init(&mut self, id: ast::NodeId, _span: Span) {
|
fn decl_without_init(&mut self, id: hir::HirId, _span: Span) {
|
||||||
let ty = self.bccx
|
let ty = self.bccx
|
||||||
.tables
|
.tables
|
||||||
.node_type(self.bccx.tcx.hir().node_to_hir_id(id));
|
.node_type(id);
|
||||||
gather_moves::gather_decl(self.bccx, &self.move_data, id, ty);
|
gather_moves::gather_decl(self.bccx, &self.move_data, id, ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,9 +438,8 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
while let Some(current_path) = wrapped_path {
|
while let Some(current_path) = wrapped_path {
|
||||||
wrapped_path = match current_path.kind {
|
wrapped_path = match current_path.kind {
|
||||||
LpVar(local_id) => {
|
LpVar(hir_id) => {
|
||||||
if !through_borrow {
|
if !through_borrow {
|
||||||
let hir_id = self.bccx.tcx.hir().node_to_hir_id(local_id);
|
|
||||||
self.bccx.used_mut_nodes.borrow_mut().insert(hir_id);
|
self.bccx.used_mut_nodes.borrow_mut().insert(hir_id);
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|
|
@ -335,7 +335,7 @@ impl<'tcx> Hash for LoanPath<'tcx> {
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub enum LoanPathKind<'tcx> {
|
pub enum LoanPathKind<'tcx> {
|
||||||
LpVar(ast::NodeId), // `x` in README.md
|
LpVar(hir::HirId), // `x` in README.md
|
||||||
LpUpvar(ty::UpvarId), // `x` captured by-value into closure
|
LpUpvar(ty::UpvarId), // `x` captured by-value into closure
|
||||||
LpDowncast(Rc<LoanPath<'tcx>>, DefId), // `x` downcast to particular enum variant
|
LpDowncast(Rc<LoanPath<'tcx>>, DefId), // `x` downcast to particular enum variant
|
||||||
LpExtend(Rc<LoanPath<'tcx>>, mc::MutabilityCategory, LoanPathElem<'tcx>)
|
LpExtend(Rc<LoanPath<'tcx>>, mc::MutabilityCategory, LoanPathElem<'tcx>)
|
||||||
|
@ -417,8 +417,7 @@ fn closure_to_block(closure_id: LocalDefId,
|
||||||
impl<'a, 'tcx> LoanPath<'tcx> {
|
impl<'a, 'tcx> LoanPath<'tcx> {
|
||||||
pub fn kill_scope(&self, bccx: &BorrowckCtxt<'a, 'tcx>) -> region::Scope {
|
pub fn kill_scope(&self, bccx: &BorrowckCtxt<'a, 'tcx>) -> region::Scope {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
LpVar(local_id) => {
|
LpVar(hir_id) => {
|
||||||
let hir_id = bccx.tcx.hir().node_to_hir_id(local_id);
|
|
||||||
bccx.region_scope_tree.var_scope(hir_id.local_id)
|
bccx.region_scope_tree.var_scope(hir_id.local_id)
|
||||||
}
|
}
|
||||||
LpUpvar(upvar_id) => {
|
LpUpvar(upvar_id) => {
|
||||||
|
@ -919,7 +918,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
self.note_immutability_blame(
|
self.note_immutability_blame(
|
||||||
&mut db,
|
&mut db,
|
||||||
err.cmt.immutability_blame(),
|
err.cmt.immutability_blame(),
|
||||||
self.tcx.hir().hir_to_node_id(err.cmt.hir_id)
|
err.cmt.hir_id
|
||||||
);
|
);
|
||||||
db.emit();
|
db.emit();
|
||||||
self.signal_error();
|
self.signal_error();
|
||||||
|
@ -1135,7 +1134,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
self.note_immutability_blame(
|
self.note_immutability_blame(
|
||||||
&mut err,
|
&mut err,
|
||||||
blame,
|
blame,
|
||||||
self.tcx.hir().hir_to_node_id(cmt.hir_id)
|
cmt.hir_id
|
||||||
);
|
);
|
||||||
|
|
||||||
if is_closure {
|
if is_closure {
|
||||||
|
@ -1175,8 +1174,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_binding_mode(&self, node_id: ast::NodeId) -> ty::BindingMode {
|
fn local_binding_mode(&self, hir_id: hir::HirId) -> ty::BindingMode {
|
||||||
let pat = match self.tcx.hir().get(node_id) {
|
let pat = match self.tcx.hir().get_by_hir_id(hir_id) {
|
||||||
Node::Binding(pat) => pat,
|
Node::Binding(pat) => pat,
|
||||||
node => bug!("bad node for local: {:?}", node)
|
node => bug!("bad node for local: {:?}", node)
|
||||||
};
|
};
|
||||||
|
@ -1192,16 +1191,16 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_ty(&self, node_id: ast::NodeId) -> (Option<&hir::Ty>, bool) {
|
fn local_ty(&self, hir_id: hir::HirId) -> (Option<&hir::Ty>, bool) {
|
||||||
let parent = self.tcx.hir().get_parent_node(node_id);
|
let parent = self.tcx.hir().get_parent_node_by_hir_id(hir_id);
|
||||||
let parent_node = self.tcx.hir().get(parent);
|
let parent_node = self.tcx.hir().get_by_hir_id(parent);
|
||||||
|
|
||||||
// The parent node is like a fn
|
// The parent node is like a fn
|
||||||
if let Some(fn_like) = FnLikeNode::from_node(parent_node) {
|
if let Some(fn_like) = FnLikeNode::from_node(parent_node) {
|
||||||
// `nid`'s parent's `Body`
|
// `nid`'s parent's `Body`
|
||||||
let fn_body = self.tcx.hir().body(fn_like.body());
|
let fn_body = self.tcx.hir().body(fn_like.body());
|
||||||
// Get the position of `node_id` in the arguments list
|
// Get the position of `node_id` in the arguments list
|
||||||
let arg_pos = fn_body.arguments.iter().position(|arg| arg.pat.id == node_id);
|
let arg_pos = fn_body.arguments.iter().position(|arg| arg.pat.hir_id == hir_id);
|
||||||
if let Some(i) = arg_pos {
|
if let Some(i) = arg_pos {
|
||||||
// The argument's `Ty`
|
// The argument's `Ty`
|
||||||
(Some(&fn_like.decl().inputs[i]),
|
(Some(&fn_like.decl().inputs[i]),
|
||||||
|
@ -1217,17 +1216,17 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
fn note_immutability_blame(&self,
|
fn note_immutability_blame(&self,
|
||||||
db: &mut DiagnosticBuilder<'_>,
|
db: &mut DiagnosticBuilder<'_>,
|
||||||
blame: Option<ImmutabilityBlame<'_>>,
|
blame: Option<ImmutabilityBlame<'_>>,
|
||||||
error_node_id: ast::NodeId) {
|
error_hir_id: hir::HirId) {
|
||||||
match blame {
|
match blame {
|
||||||
None => {}
|
None => {}
|
||||||
Some(ImmutabilityBlame::ClosureEnv(_)) => {}
|
Some(ImmutabilityBlame::ClosureEnv(_)) => {}
|
||||||
Some(ImmutabilityBlame::ImmLocal(node_id)) => {
|
Some(ImmutabilityBlame::ImmLocal(hir_id)) => {
|
||||||
self.note_immutable_local(db, error_node_id, node_id)
|
self.note_immutable_local(db, error_hir_id, hir_id)
|
||||||
}
|
}
|
||||||
Some(ImmutabilityBlame::LocalDeref(node_id)) => {
|
Some(ImmutabilityBlame::LocalDeref(hir_id)) => {
|
||||||
match self.local_binding_mode(node_id) {
|
match self.local_binding_mode(hir_id) {
|
||||||
ty::BindByReference(..) => {
|
ty::BindByReference(..) => {
|
||||||
let let_span = self.tcx.hir().span(node_id);
|
let let_span = self.tcx.hir().span_by_hir_id(hir_id);
|
||||||
let suggestion = suggest_ref_mut(self.tcx, let_span);
|
let suggestion = suggest_ref_mut(self.tcx, let_span);
|
||||||
if let Some(replace_str) = suggestion {
|
if let Some(replace_str) = suggestion {
|
||||||
db.span_suggestion(
|
db.span_suggestion(
|
||||||
|
@ -1244,7 +1243,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::BindByValue(..) => {
|
ty::BindByValue(..) => {
|
||||||
if let (Some(local_ty), is_implicit_self) = self.local_ty(node_id) {
|
if let (Some(local_ty), is_implicit_self) = self.local_ty(hir_id) {
|
||||||
if let Some(msg) =
|
if let Some(msg) =
|
||||||
self.suggest_mut_for_immutable(local_ty, is_implicit_self) {
|
self.suggest_mut_for_immutable(local_ty, is_implicit_self) {
|
||||||
db.span_label(local_ty.span, msg);
|
db.span_label(local_ty.span, msg);
|
||||||
|
@ -1273,12 +1272,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
// not a mutable reference) or to avoid borrowing altogether
|
// not a mutable reference) or to avoid borrowing altogether
|
||||||
fn note_immutable_local(&self,
|
fn note_immutable_local(&self,
|
||||||
db: &mut DiagnosticBuilder<'_>,
|
db: &mut DiagnosticBuilder<'_>,
|
||||||
borrowed_node_id: ast::NodeId,
|
borrowed_hir_id: hir::HirId,
|
||||||
binding_node_id: ast::NodeId) {
|
binding_hir_id: hir::HirId) {
|
||||||
let let_span = self.tcx.hir().span(binding_node_id);
|
let let_span = self.tcx.hir().span_by_hir_id(binding_hir_id);
|
||||||
if let ty::BindByValue(..) = self.local_binding_mode(binding_node_id) {
|
if let ty::BindByValue(..) = self.local_binding_mode(binding_hir_id) {
|
||||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) {
|
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(let_span) {
|
||||||
let (ty, is_implicit_self) = self.local_ty(binding_node_id);
|
let (ty, is_implicit_self) = self.local_ty(binding_hir_id);
|
||||||
if is_implicit_self && snippet != "self" {
|
if is_implicit_self && snippet != "self" {
|
||||||
// avoid suggesting `mut &self`.
|
// avoid suggesting `mut &self`.
|
||||||
return
|
return
|
||||||
|
@ -1291,9 +1290,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
},
|
},
|
||||||
)) = ty.map(|t| &t.node)
|
)) = ty.map(|t| &t.node)
|
||||||
{
|
{
|
||||||
let borrow_expr_id = self.tcx.hir().get_parent_node(borrowed_node_id);
|
let borrow_expr_id = self.tcx.hir().get_parent_node_by_hir_id(borrowed_hir_id);
|
||||||
db.span_suggestion(
|
db.span_suggestion(
|
||||||
self.tcx.hir().span(borrow_expr_id),
|
self.tcx.hir().span_by_hir_id(borrow_expr_id),
|
||||||
"consider removing the `&mut`, as it is an \
|
"consider removing the `&mut`, as it is an \
|
||||||
immutable binding to a mutable reference",
|
immutable binding to a mutable reference",
|
||||||
snippet,
|
snippet,
|
||||||
|
@ -1373,7 +1372,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
if let Categorization::Deref(..) = err.cmt.cat {
|
if let Categorization::Deref(..) = err.cmt.cat {
|
||||||
db.span_label(*error_span, "cannot borrow as mutable");
|
db.span_label(*error_span, "cannot borrow as mutable");
|
||||||
} else if let Categorization::Local(local_id) = err.cmt.cat {
|
} else if let Categorization::Local(local_id) = err.cmt.cat {
|
||||||
let span = self.tcx.hir().span(local_id);
|
let span = self.tcx.hir().span_by_hir_id(local_id);
|
||||||
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||||
if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
|
if snippet.starts_with("ref mut ") || snippet.starts_with("&mut ") {
|
||||||
db.span_label(*error_span, "cannot reborrow mutably");
|
db.span_label(*error_span, "cannot reborrow mutably");
|
||||||
|
@ -1401,7 +1400,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||||
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
|
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
|
||||||
}
|
}
|
||||||
LpVar(id) => {
|
LpVar(id) => {
|
||||||
out.push_str(&self.tcx.hir().name(id).as_str());
|
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
LpDowncast(ref lp_base, variant_def_id) => {
|
LpDowncast(ref lp_base, variant_def_id) => {
|
||||||
|
@ -1512,7 +1511,7 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
LpVar(id) => {
|
LpVar(id) => {
|
||||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id)))
|
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().hir_to_string(id)))
|
||||||
}
|
}
|
||||||
|
|
||||||
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => {
|
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath {hir_id: var_id}, closure_expr_id }) => {
|
||||||
|
@ -1547,7 +1546,7 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
LpVar(id) => {
|
LpVar(id) => {
|
||||||
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_user_string(id)))
|
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().hir_to_user_string(id)))
|
||||||
}
|
}
|
||||||
|
|
||||||
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => {
|
LpUpvar(ty::UpvarId{ var_path: ty::UpvarPath { hir_id }, closure_expr_id: _ }) => {
|
||||||
|
|
|
@ -428,8 +428,8 @@ impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
|
||||||
}
|
}
|
||||||
pprust_hir::AnnNode::Pat(pat) => {
|
pprust_hir::AnnNode::Pat(pat) => {
|
||||||
s.s.space()?;
|
s.s.space()?;
|
||||||
s.synth_comment(format!("pat node_id: {} hir local_id: {}",
|
s.synth_comment(format!("pat hir_id: {} hir local_id: {}",
|
||||||
pat.id, pat.hir_id.local_id.as_u32()))
|
pat.hir_id, pat.hir_id.local_id.as_u32()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||||
|
|
||||||
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
|
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
|
||||||
let tcx = self.tcx.global_tcx();
|
let tcx = self.tcx.global_tcx();
|
||||||
let p = match tcx.hir().get(p.id) {
|
let p = match tcx.hir().get_by_hir_id(p.hir_id) {
|
||||||
Node::Pat(p) | Node::Binding(p) => p,
|
Node::Pat(p) | Node::Binding(p) => p,
|
||||||
node => bug!("pattern became {:?}", node)
|
node => bug!("pattern became {:?}", node)
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,6 @@ use rustc::hir::{self, Pat, PatKind};
|
||||||
use smallvec::smallvec;
|
use smallvec::smallvec;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
use syntax::ast;
|
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
||||||
|
|
||||||
|
@ -241,7 +240,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
|
fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
|
||||||
let module = self.tcx.hir().get_module_parent(pat.id);
|
let module = self.tcx.hir().get_module_parent_by_hir_id(pat.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 patcx = PatternContext::new(self.tcx,
|
let mut patcx = PatternContext::new(self.tcx,
|
||||||
self.param_env.and(self.identity_substs),
|
self.param_env.and(self.identity_substs),
|
||||||
|
@ -586,7 +585,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
|
||||||
ty::ImmBorrow | ty::UniqueImmBorrow => {}
|
ty::ImmBorrow | ty::UniqueImmBorrow => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
|
fn decl_without_init(&mut self, _: hir::HirId, _: Span) {}
|
||||||
fn mutate(&mut self, _: hir::HirId, 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 => {
|
||||||
|
|
|
@ -26,7 +26,6 @@ use rustc::ty::subst::{InternalSubsts, SubstsRef};
|
||||||
use rustc::util::nodemap::{ItemLocalSet, HirIdSet};
|
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_pos::{Span, DUMMY_SP};
|
use syntax_pos::{Span, DUMMY_SP};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use Promotability::*;
|
use Promotability::*;
|
||||||
|
@ -677,7 +676,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: hir::HirId, _span: Span) {}
|
||||||
fn mutate(&mut self,
|
fn mutate(&mut self,
|
||||||
_assignment_id: hir::HirId,
|
_assignment_id: hir::HirId,
|
||||||
_assignment_span: Span,
|
_assignment_span: Span,
|
||||||
|
|
|
@ -1008,9 +1008,10 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||||
if let PatKind::Binding(_, _, _, ident, _) = p.node {
|
if let PatKind::Binding(_, _, _, ident, _) = p.node {
|
||||||
let var_ty = self.assign(p.span, p.hir_id, None);
|
let var_ty = self.assign(p.span, p.hir_id, None);
|
||||||
|
|
||||||
|
let node_id = self.fcx.tcx.hir().hir_to_node_id(p.hir_id);
|
||||||
if !self.fcx.tcx.features().unsized_locals {
|
if !self.fcx.tcx.features().unsized_locals {
|
||||||
self.fcx.require_type_is_sized(var_ty, p.span,
|
self.fcx.require_type_is_sized(var_ty, p.span,
|
||||||
traits::VariableType(p.id));
|
traits::VariableType(node_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Pattern binding {} is assigned to {} with type {:?}",
|
debug!("Pattern binding {} is assigned to {} with type {:?}",
|
||||||
|
|
|
@ -635,7 +635,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
|
fn decl_without_init(&mut self, _id: hir::HirId, _span: Span) {}
|
||||||
|
|
||||||
fn mutate(
|
fn mutate(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue