@@ -30,16 +30,6 @@ mod simplify;
30
30
mod test;
31
31
mod util;
32
32
33
- /// Injects a borrow of `place`. The region is unknown at this point; we rely on NLL
34
- /// inference to find an appropriate one. Therefore you can only call this when NLL
35
- /// is turned on.
36
- fn inject_borrow < ' a , ' gcx , ' tcx > ( tcx : ty:: TyCtxt < ' a , ' gcx , ' tcx > ,
37
- place : Place < ' tcx > )
38
- -> Rvalue < ' tcx > {
39
- assert ! ( tcx. use_mir_borrowck( ) ) ;
40
- Rvalue :: Ref ( tcx. types . re_empty , BorrowKind :: Shared , place)
41
- }
42
-
43
33
/// ArmHasGuard is isomorphic to a boolean flag. It indicates whether
44
34
/// a match arm has a guard expression attached to it.
45
35
#[ derive( Copy , Clone , Debug ) ]
@@ -67,8 +57,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
67
57
// of `discriminant_place`, specifically by applying `Rvalue::Discriminant`
68
58
// (which will work regardless of type) and storing the result in a temp.
69
59
//
70
- // FIXME: would just the borrow into `borrowed_input_temp`
71
- // also achieve the desired effect here? TBD.
60
+ // NOTE: Under NLL, the above issue should no longer occur because it
61
+ // injects a borrow of the matched input, which should have the same effect
62
+ // as eddyb's hack. Once NLL is the default, we can remove the hack.
63
+
72
64
let dummy_source_info = self . source_info ( span) ;
73
65
let dummy_access = Rvalue :: Discriminant ( discriminant_place. clone ( ) ) ;
74
66
let dummy_ty = dummy_access. ty ( & self . local_decls , tcx) ;
@@ -77,7 +69,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
77
69
78
70
let source_info = self . source_info ( span) ;
79
71
let borrowed_input_temp = if tcx. generate_borrow_of_any_match_input ( ) {
80
- let borrowed_input = inject_borrow ( tcx, discriminant_place. clone ( ) ) ;
72
+ // The region is unknown at this point; we rely on NLL
73
+ // inference to find an appropriate one. Therefore you can
74
+ // only use this when NLL is turned on.
75
+ assert ! ( tcx. use_mir_borrowck( ) ) ;
76
+ let borrowed_input =
77
+ Rvalue :: Ref ( tcx. types . re_empty , BorrowKind :: Shared , discriminant_place. clone ( ) ) ;
81
78
let borrowed_input_ty = borrowed_input. ty ( & self . local_decls , tcx) ;
82
79
let borrowed_input_temp = self . temp ( borrowed_input_ty, span) ;
83
80
self . cfg . push_assign ( block, source_info, & borrowed_input_temp, borrowed_input) ;
0 commit comments