mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
Review feedback: Remove a fixme/tbd note and just add a note for the post-NLL future.
Driveby: just inline the two-line `fn inject_borrow` into its one call site and remove its definition.
This commit is contained in:
@@ -30,16 +30,6 @@
|
||||
mod test;
|
||||
mod util;
|
||||
|
||||
/// Injects a borrow of `place`. The region is unknown at this point; we rely on NLL
|
||||
/// inference to find an appropriate one. Therefore you can only call this when NLL
|
||||
/// is turned on.
|
||||
fn inject_borrow<'a, 'gcx, 'tcx>(tcx: ty::TyCtxt<'a, 'gcx, 'tcx>,
|
||||
place: Place<'tcx>)
|
||||
-> Rvalue<'tcx> {
|
||||
assert!(tcx.use_mir_borrowck());
|
||||
Rvalue::Ref(tcx.types.re_empty, BorrowKind::Shared, place)
|
||||
}
|
||||
|
||||
/// ArmHasGuard is isomorphic to a boolean flag. It indicates whether
|
||||
/// a match arm has a guard expression attached to it.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
@@ -67,8 +57,10 @@ pub fn match_expr(&mut self,
|
||||
// of `discriminant_place`, specifically by applying `Rvalue::Discriminant`
|
||||
// (which will work regardless of type) and storing the result in a temp.
|
||||
//
|
||||
// FIXME: would just the borrow into `borrowed_input_temp`
|
||||
// also achieve the desired effect here? TBD.
|
||||
// NOTE: Under NLL, the above issue should no longer occur because it
|
||||
// injects a borrow of the matched input, which should have the same effect
|
||||
// as eddyb's hack. Once NLL is the default, we can remove the hack.
|
||||
|
||||
let dummy_source_info = self.source_info(span);
|
||||
let dummy_access = Rvalue::Discriminant(discriminant_place.clone());
|
||||
let dummy_ty = dummy_access.ty(&self.local_decls, tcx);
|
||||
@@ -77,7 +69,12 @@ pub fn match_expr(&mut self,
|
||||
|
||||
let source_info = self.source_info(span);
|
||||
let borrowed_input_temp = if tcx.generate_borrow_of_any_match_input() {
|
||||
let borrowed_input = inject_borrow(tcx, discriminant_place.clone());
|
||||
// The region is unknown at this point; we rely on NLL
|
||||
// inference to find an appropriate one. Therefore you can
|
||||
// only use this when NLL is turned on.
|
||||
assert!(tcx.use_mir_borrowck());
|
||||
let borrowed_input =
|
||||
Rvalue::Ref(tcx.types.re_empty, BorrowKind::Shared, discriminant_place.clone());
|
||||
let borrowed_input_ty = borrowed_input.ty(&self.local_decls, tcx);
|
||||
let borrowed_input_temp = self.temp(borrowed_input_ty, span);
|
||||
self.cfg.push_assign(block, source_info, &borrowed_input_temp, borrowed_input);
|
||||
|
||||
Reference in New Issue
Block a user