mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 17:48:10 +00:00
Auto merge of #56638 - matthewjasper:remove-ref-region, r=nikomatsakis
Remove some `Region`s from HAIR Use `ReErased` for any regions that need to be created in RValue::Ref in MIR generation. We will change them to all to `ReVar` before borrow checking anyway. r? @nikomatsakis
This commit is contained in:
commit
d22fa2d87d
@ -67,7 +67,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
block.and(Rvalue::Repeat(value_operand, count))
|
block.and(Rvalue::Repeat(value_operand, count))
|
||||||
}
|
}
|
||||||
ExprKind::Borrow {
|
ExprKind::Borrow {
|
||||||
region,
|
|
||||||
borrow_kind,
|
borrow_kind,
|
||||||
arg,
|
arg,
|
||||||
} => {
|
} => {
|
||||||
@ -75,7 +74,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
BorrowKind::Shared => unpack!(block = this.as_read_only_place(block, arg)),
|
BorrowKind::Shared => unpack!(block = this.as_read_only_place(block, arg)),
|
||||||
_ => unpack!(block = this.as_place(block, arg)),
|
_ => unpack!(block = this.as_place(block, arg)),
|
||||||
};
|
};
|
||||||
block.and(Rvalue::Ref(region, borrow_kind, arg_place))
|
block.and(Rvalue::Ref(this.hir.tcx().types.re_erased, borrow_kind, arg_place))
|
||||||
}
|
}
|
||||||
ExprKind::Binary { op, lhs, rhs } => {
|
ExprKind::Binary { op, lhs, rhs } => {
|
||||||
let lhs = unpack!(block = this.as_operand(block, scope, lhs));
|
let lhs = unpack!(block = this.as_operand(block, scope, lhs));
|
||||||
@ -249,11 +248,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
BorrowKind::Mut {
|
BorrowKind::Mut {
|
||||||
allow_two_phase_borrow: false,
|
allow_two_phase_borrow: false,
|
||||||
},
|
},
|
||||||
region,
|
|
||||||
arg,
|
arg,
|
||||||
} => unpack!(
|
} => unpack!(
|
||||||
block = this.limit_capture_mutability(
|
block = this.limit_capture_mutability(
|
||||||
upvar.span, upvar.ty, scope, block, arg, region,
|
upvar.span, upvar.ty, scope, block, arg,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
_ => unpack!(block = this.as_operand(block, scope, upvar)),
|
_ => unpack!(block = this.as_operand(block, scope, upvar)),
|
||||||
@ -500,7 +498,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
temp_lifetime: Option<region::Scope>,
|
temp_lifetime: Option<region::Scope>,
|
||||||
mut block: BasicBlock,
|
mut block: BasicBlock,
|
||||||
arg: ExprRef<'tcx>,
|
arg: ExprRef<'tcx>,
|
||||||
region: &'tcx ty::RegionKind,
|
|
||||||
) -> BlockAnd<Operand<'tcx>> {
|
) -> BlockAnd<Operand<'tcx>> {
|
||||||
let this = self;
|
let this = self;
|
||||||
|
|
||||||
@ -582,7 +579,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
block,
|
block,
|
||||||
source_info,
|
source_info,
|
||||||
&Place::Local(temp),
|
&Place::Local(temp),
|
||||||
Rvalue::Ref(region, borrow_kind, arg_place),
|
Rvalue::Ref(this.hir.tcx().types.re_erased, borrow_kind, arg_place),
|
||||||
);
|
);
|
||||||
|
|
||||||
// In constants, temp_lifetime is None. We should not need to drop
|
// In constants, temp_lifetime is None. We should not need to drop
|
||||||
|
@ -640,7 +640,7 @@ struct Binding<'tcx> {
|
|||||||
var_id: NodeId,
|
var_id: NodeId,
|
||||||
var_ty: Ty<'tcx>,
|
var_ty: Ty<'tcx>,
|
||||||
mutability: Mutability,
|
mutability: Mutability,
|
||||||
binding_mode: BindingMode<'tcx>,
|
binding_mode: BindingMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Indicates that the type of `source` must be a subtype of the
|
/// Indicates that the type of `source` must be a subtype of the
|
||||||
@ -1369,7 +1369,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
// Assign each of the bindings. Since we are binding for a
|
// Assign each of the bindings. Since we are binding for a
|
||||||
// guard expression, this will never trigger moves out of the
|
// guard expression, this will never trigger moves out of the
|
||||||
// candidate.
|
// candidate.
|
||||||
let re_empty = self.hir.tcx().types.re_empty;
|
let re_erased = self.hir.tcx().types.re_erased;
|
||||||
for binding in bindings {
|
for binding in bindings {
|
||||||
let source_info = self.source_info(binding.span);
|
let source_info = self.source_info(binding.span);
|
||||||
|
|
||||||
@ -1385,11 +1385,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
self.schedule_drop_for_binding(binding.var_id, binding.span, RefWithinGuard);
|
self.schedule_drop_for_binding(binding.var_id, binding.span, RefWithinGuard);
|
||||||
match binding.binding_mode {
|
match binding.binding_mode {
|
||||||
BindingMode::ByValue => {
|
BindingMode::ByValue => {
|
||||||
let rvalue = Rvalue::Ref(re_empty, BorrowKind::Shared, binding.source.clone());
|
let rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, binding.source.clone());
|
||||||
self.cfg
|
self.cfg
|
||||||
.push_assign(block, source_info, &ref_for_guard, rvalue);
|
.push_assign(block, source_info, &ref_for_guard, rvalue);
|
||||||
}
|
}
|
||||||
BindingMode::ByRef(region, borrow_kind) => {
|
BindingMode::ByRef(borrow_kind) => {
|
||||||
// Tricky business: For `ref id` and `ref mut id`
|
// Tricky business: For `ref id` and `ref mut id`
|
||||||
// patterns, we want `id` within the guard to
|
// patterns, we want `id` within the guard to
|
||||||
// correspond to a temp of type `& &T` or `& &mut
|
// correspond to a temp of type `& &T` or `& &mut
|
||||||
@ -1429,10 +1429,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
allow_two_phase_borrow: true,
|
allow_two_phase_borrow: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let rvalue = Rvalue::Ref(region, borrow_kind, binding.source.clone());
|
let rvalue = Rvalue::Ref(re_erased, borrow_kind, binding.source.clone());
|
||||||
self.cfg
|
self.cfg
|
||||||
.push_assign(block, source_info, &val_for_guard, rvalue);
|
.push_assign(block, source_info, &val_for_guard, rvalue);
|
||||||
let rvalue = Rvalue::Ref(region, BorrowKind::Shared, val_for_guard);
|
let rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, val_for_guard);
|
||||||
self.cfg
|
self.cfg
|
||||||
.push_assign(block, source_info, &ref_for_guard, rvalue);
|
.push_assign(block, source_info, &ref_for_guard, rvalue);
|
||||||
}
|
}
|
||||||
@ -1450,6 +1450,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
block, bindings
|
block, bindings
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
let re_erased = self.hir.tcx().types.re_erased;
|
||||||
// Assign each of the bindings. This may trigger moves out of the candidate.
|
// Assign each of the bindings. This may trigger moves out of the candidate.
|
||||||
for binding in bindings {
|
for binding in bindings {
|
||||||
let source_info = self.source_info(binding.span);
|
let source_info = self.source_info(binding.span);
|
||||||
@ -1460,8 +1462,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
BindingMode::ByValue => {
|
BindingMode::ByValue => {
|
||||||
Rvalue::Use(self.consume_by_copy_or_move(binding.source.clone()))
|
Rvalue::Use(self.consume_by_copy_or_move(binding.source.clone()))
|
||||||
}
|
}
|
||||||
BindingMode::ByRef(region, borrow_kind) => {
|
BindingMode::ByRef(borrow_kind) => {
|
||||||
Rvalue::Ref(region, borrow_kind, binding.source.clone())
|
Rvalue::Ref(re_erased, borrow_kind, binding.source.clone())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.cfg.push_assign(block, source_info, &local, rvalue);
|
self.cfg.push_assign(block, source_info, &local, rvalue);
|
||||||
@ -1507,7 +1509,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
let tcx = self.hir.tcx();
|
let tcx = self.hir.tcx();
|
||||||
let binding_mode = match mode {
|
let binding_mode = match mode {
|
||||||
BindingMode::ByValue => ty::BindingMode::BindByValue(mutability.into()),
|
BindingMode::ByValue => ty::BindingMode::BindByValue(mutability.into()),
|
||||||
BindingMode::ByRef { .. } => ty::BindingMode::BindByReference(mutability.into()),
|
BindingMode::ByRef(_) => ty::BindingMode::BindByReference(mutability.into()),
|
||||||
};
|
};
|
||||||
debug!("declare_binding: user_ty={:?}", user_ty);
|
debug!("declare_binding: user_ty={:?}", user_ty);
|
||||||
let local = LocalDecl::<'tcx> {
|
let local = LocalDecl::<'tcx> {
|
||||||
@ -1545,7 +1547,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> {
|
let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> {
|
||||||
// See previous comment.
|
// See previous comment.
|
||||||
mutability: Mutability::Not,
|
mutability: Mutability::Not,
|
||||||
ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty),
|
ty: tcx.mk_imm_ref(tcx.types.re_erased, var_ty),
|
||||||
user_ty: UserTypeProjections::none(),
|
user_ty: UserTypeProjections::none(),
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
source_info,
|
source_info,
|
||||||
@ -1614,7 +1616,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
|
|
||||||
for (matched_place, borrow_kind) in all_fake_borrows {
|
for (matched_place, borrow_kind) in all_fake_borrows {
|
||||||
let borrowed_input =
|
let borrowed_input =
|
||||||
Rvalue::Ref(tcx.types.re_empty, borrow_kind, matched_place.clone());
|
Rvalue::Ref(tcx.types.re_erased, borrow_kind, matched_place.clone());
|
||||||
let borrowed_input_ty = borrowed_input.ty(&self.local_decls, tcx);
|
let borrowed_input_ty = borrowed_input.ty(&self.local_decls, tcx);
|
||||||
let borrowed_input_temp = self.temp(borrowed_input_ty, source_info.span);
|
let borrowed_input_temp = self.temp(borrowed_input_ty, source_info.span);
|
||||||
self.cfg.push_assign(
|
self.cfg.push_assign(
|
||||||
|
@ -304,17 +304,16 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
let (mty, method) = self.hir.trait_method(eq_def_id, "eq", ty, &[ty.into()]);
|
let (mty, method) = self.hir.trait_method(eq_def_id, "eq", ty, &[ty.into()]);
|
||||||
let method = self.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(method));
|
let method = self.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(method));
|
||||||
|
|
||||||
|
let re_erased = self.hir.tcx().types.re_erased;
|
||||||
// take the argument by reference
|
// take the argument by reference
|
||||||
let region_scope = self.topmost_scope();
|
|
||||||
let region = self.hir.tcx().mk_region(ty::ReScope(region_scope));
|
|
||||||
let tam = ty::TypeAndMut {
|
let tam = ty::TypeAndMut {
|
||||||
ty,
|
ty,
|
||||||
mutbl: Mutability::MutImmutable,
|
mutbl: Mutability::MutImmutable,
|
||||||
};
|
};
|
||||||
let ref_ty = self.hir.tcx().mk_ref(region, tam);
|
let ref_ty = self.hir.tcx().mk_ref(re_erased, tam);
|
||||||
|
|
||||||
// let lhs_ref_place = &lhs;
|
// let lhs_ref_place = &lhs;
|
||||||
let ref_rvalue = Rvalue::Ref(region, BorrowKind::Shared, place);
|
let ref_rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, place);
|
||||||
let lhs_ref_place = self.temp(ref_ty, test.span);
|
let lhs_ref_place = self.temp(ref_ty, test.span);
|
||||||
self.cfg.push_assign(block, source_info, &lhs_ref_place, ref_rvalue);
|
self.cfg.push_assign(block, source_info, &lhs_ref_place, ref_rvalue);
|
||||||
let val = Operand::Move(lhs_ref_place);
|
let val = Operand::Move(lhs_ref_place);
|
||||||
@ -324,7 +323,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
self.cfg.push_assign(block, source_info, &rhs_place, Rvalue::Use(expect));
|
self.cfg.push_assign(block, source_info, &rhs_place, Rvalue::Use(expect));
|
||||||
|
|
||||||
// let rhs_ref_place = &rhs_place;
|
// let rhs_ref_place = &rhs_place;
|
||||||
let ref_rvalue = Rvalue::Ref(region, BorrowKind::Shared, rhs_place);
|
let ref_rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, rhs_place);
|
||||||
let rhs_ref_place = self.temp(ref_ty, test.span);
|
let rhs_ref_place = self.temp(ref_ty, test.span);
|
||||||
self.cfg.push_assign(block, source_info, &rhs_ref_place, ref_rvalue);
|
self.cfg.push_assign(block, source_info, &rhs_ref_place, ref_rvalue);
|
||||||
let expect = Operand::Move(rhs_ref_place);
|
let expect = Operand::Move(rhs_ref_place);
|
||||||
|
@ -124,7 +124,6 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||||||
}),
|
}),
|
||||||
span,
|
span,
|
||||||
kind: ExprKind::Borrow {
|
kind: ExprKind::Borrow {
|
||||||
region: deref.region,
|
|
||||||
borrow_kind: deref.mutbl.to_borrow_kind(),
|
borrow_kind: deref.mutbl.to_borrow_kind(),
|
||||||
arg: expr.to_ref(),
|
arg: expr.to_ref(),
|
||||||
},
|
},
|
||||||
@ -132,32 +131,24 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||||||
|
|
||||||
overloaded_place(cx, hir_expr, adjustment.target, Some(call), vec![expr.to_ref()])
|
overloaded_place(cx, hir_expr, adjustment.target, Some(call), vec![expr.to_ref()])
|
||||||
}
|
}
|
||||||
Adjust::Borrow(AutoBorrow::Ref(r, m)) => {
|
Adjust::Borrow(AutoBorrow::Ref(_, m)) => {
|
||||||
ExprKind::Borrow {
|
ExprKind::Borrow {
|
||||||
region: r,
|
|
||||||
borrow_kind: m.to_borrow_kind(),
|
borrow_kind: m.to_borrow_kind(),
|
||||||
arg: expr.to_ref(),
|
arg: expr.to_ref(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Adjust::Borrow(AutoBorrow::RawPtr(m)) => {
|
Adjust::Borrow(AutoBorrow::RawPtr(m)) => {
|
||||||
// Convert this to a suitable `&foo` and
|
// Convert this to a suitable `&foo` and
|
||||||
// then an unsafe coercion. Limit the region to be just this
|
// then an unsafe coercion.
|
||||||
// expression.
|
|
||||||
let region = ty::ReScope(region::Scope {
|
|
||||||
id: hir_expr.hir_id.local_id,
|
|
||||||
data: region::ScopeData::Node
|
|
||||||
});
|
|
||||||
let region = cx.tcx.mk_region(region);
|
|
||||||
expr = Expr {
|
expr = Expr {
|
||||||
temp_lifetime,
|
temp_lifetime,
|
||||||
ty: cx.tcx.mk_ref(region,
|
ty: cx.tcx.mk_ref(cx.tcx.types.re_erased,
|
||||||
ty::TypeAndMut {
|
ty::TypeAndMut {
|
||||||
ty: expr.ty,
|
ty: expr.ty,
|
||||||
mutbl: m,
|
mutbl: m,
|
||||||
}),
|
}),
|
||||||
span,
|
span,
|
||||||
kind: ExprKind::Borrow {
|
kind: ExprKind::Borrow {
|
||||||
region,
|
|
||||||
borrow_kind: m.to_borrow_kind(),
|
borrow_kind: m.to_borrow_kind(),
|
||||||
arg: expr.to_ref(),
|
arg: expr.to_ref(),
|
||||||
},
|
},
|
||||||
@ -323,12 +314,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprKind::AddrOf(mutbl, ref expr) => {
|
hir::ExprKind::AddrOf(mutbl, ref expr) => {
|
||||||
let region = match expr_ty.sty {
|
|
||||||
ty::Ref(r, _, _) => r,
|
|
||||||
_ => span_bug!(expr.span, "type of & not region"),
|
|
||||||
};
|
|
||||||
ExprKind::Borrow {
|
ExprKind::Borrow {
|
||||||
region,
|
|
||||||
borrow_kind: mutbl.to_borrow_kind(),
|
borrow_kind: mutbl.to_borrow_kind(),
|
||||||
arg: expr.to_ref(),
|
arg: expr.to_ref(),
|
||||||
}
|
}
|
||||||
@ -1222,7 +1208,6 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||||||
ty: freevar_ty,
|
ty: freevar_ty,
|
||||||
span: closure_expr.span,
|
span: closure_expr.span,
|
||||||
kind: ExprKind::Borrow {
|
kind: ExprKind::Borrow {
|
||||||
region: upvar_borrow.region,
|
|
||||||
borrow_kind,
|
borrow_kind,
|
||||||
arg: captured_var.to_ref(),
|
arg: captured_var.to_ref(),
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,7 @@ use rustc::hir::def_id::DefId;
|
|||||||
use rustc::infer::canonical::Canonical;
|
use rustc::infer::canonical::Canonical;
|
||||||
use rustc::middle::region;
|
use rustc::middle::region;
|
||||||
use rustc::ty::subst::Substs;
|
use rustc::ty::subst::Substs;
|
||||||
use rustc::ty::{AdtDef, UpvarSubsts, Region, Ty, Const, LazyConst, UserTypeAnnotation};
|
use rustc::ty::{AdtDef, UpvarSubsts, Ty, Const, LazyConst, UserTypeAnnotation};
|
||||||
use rustc::ty::layout::VariantIdx;
|
use rustc::ty::layout::VariantIdx;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
@ -235,7 +235,6 @@ pub enum ExprKind<'tcx> {
|
|||||||
id: DefId,
|
id: DefId,
|
||||||
},
|
},
|
||||||
Borrow {
|
Borrow {
|
||||||
region: Region<'tcx>,
|
|
||||||
borrow_kind: BorrowKind,
|
borrow_kind: BorrowKind,
|
||||||
arg: ExprRef<'tcx>,
|
arg: ExprRef<'tcx>,
|
||||||
},
|
},
|
||||||
|
@ -39,9 +39,9 @@ pub enum PatternError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum BindingMode<'tcx> {
|
pub enum BindingMode {
|
||||||
ByValue,
|
ByValue,
|
||||||
ByRef(Region<'tcx>, BorrowKind),
|
ByRef(BorrowKind),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -117,7 +117,7 @@ pub enum PatternKind<'tcx> {
|
|||||||
Binding {
|
Binding {
|
||||||
mutability: Mutability,
|
mutability: Mutability,
|
||||||
name: ast::Name,
|
name: ast::Name,
|
||||||
mode: BindingMode<'tcx>,
|
mode: BindingMode,
|
||||||
var: ast::NodeId,
|
var: ast::NodeId,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
subpattern: Option<Pattern<'tcx>>,
|
subpattern: Option<Pattern<'tcx>>,
|
||||||
@ -181,7 +181,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
|
|||||||
PatternKind::Binding { mutability, name, mode, ref subpattern, .. } => {
|
PatternKind::Binding { mutability, name, mode, ref subpattern, .. } => {
|
||||||
let is_mut = match mode {
|
let is_mut = match mode {
|
||||||
BindingMode::ByValue => mutability == Mutability::Mut,
|
BindingMode::ByValue => mutability == Mutability::Mut,
|
||||||
BindingMode::ByRef(_, bk) => {
|
BindingMode::ByRef(bk) => {
|
||||||
write!(f, "ref ")?;
|
write!(f, "ref ")?;
|
||||||
match bk { BorrowKind::Mut { .. } => true, _ => false }
|
match bk { BorrowKind::Mut { .. } => true, _ => false }
|
||||||
}
|
}
|
||||||
@ -512,12 +512,9 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||||||
|
|
||||||
PatKind::Binding(_, id, ident, ref sub) => {
|
PatKind::Binding(_, id, ident, ref sub) => {
|
||||||
let var_ty = self.tables.node_id_to_type(pat.hir_id);
|
let var_ty = self.tables.node_id_to_type(pat.hir_id);
|
||||||
let region = match var_ty.sty {
|
if let ty::Error = var_ty.sty {
|
||||||
ty::Ref(r, _, _) => Some(r),
|
// Avoid ICE
|
||||||
ty::Error => { // Avoid ICE
|
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
||||||
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
};
|
};
|
||||||
let bm = *self.tables.pat_binding_modes().get(pat.hir_id)
|
let bm = *self.tables.pat_binding_modes().get(pat.hir_id)
|
||||||
.expect("missing binding mode");
|
.expect("missing binding mode");
|
||||||
@ -528,10 +525,10 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
|||||||
(Mutability::Not, BindingMode::ByValue),
|
(Mutability::Not, BindingMode::ByValue),
|
||||||
ty::BindByReference(hir::MutMutable) =>
|
ty::BindByReference(hir::MutMutable) =>
|
||||||
(Mutability::Not, BindingMode::ByRef(
|
(Mutability::Not, BindingMode::ByRef(
|
||||||
region.unwrap(), BorrowKind::Mut { allow_two_phase_borrow: false })),
|
BorrowKind::Mut { allow_two_phase_borrow: false })),
|
||||||
ty::BindByReference(hir::MutImmutable) =>
|
ty::BindByReference(hir::MutImmutable) =>
|
||||||
(Mutability::Not, BindingMode::ByRef(
|
(Mutability::Not, BindingMode::ByRef(
|
||||||
region.unwrap(), BorrowKind::Shared)),
|
BorrowKind::Shared)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// A ref x pattern is the same node used for x, and as such it has
|
// A ref x pattern is the same node used for x, and as such it has
|
||||||
@ -1042,7 +1039,7 @@ macro_rules! CloneImpls {
|
|||||||
|
|
||||||
CloneImpls!{ <'tcx>
|
CloneImpls!{ <'tcx>
|
||||||
Span, Field, Mutability, ast::Name, ast::NodeId, usize, ty::Const<'tcx>,
|
Span, Field, Mutability, ast::Name, ast::NodeId, usize, ty::Const<'tcx>,
|
||||||
Region<'tcx>, Ty<'tcx>, BindingMode<'tcx>, &'tcx AdtDef,
|
Region<'tcx>, Ty<'tcx>, BindingMode, &'tcx AdtDef,
|
||||||
&'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserTypeAnnotation<'tcx>,
|
&'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserTypeAnnotation<'tcx>,
|
||||||
UserTypeProjection<'tcx>, PatternTypeProjection<'tcx>
|
UserTypeProjection<'tcx>, PatternTypeProjection<'tcx>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user