Move optimization to the central processing function
This commit is contained in:
parent
c55db232d8
commit
6195d6dcac
5 changed files with 8 additions and 13 deletions
|
|
@ -335,6 +335,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// Apply rules for safety before inferring closure kind
|
||||
let place = restrict_capture_precision(place);
|
||||
|
||||
let place = truncate_capture_for_optimization(&place);
|
||||
|
||||
let usage_span = if let Some(usage_expr) = capture_info.path_expr_id {
|
||||
self.tcx.hir().span(usage_expr)
|
||||
} else {
|
||||
|
|
@ -1638,11 +1640,6 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
|
|||
place_with_id, diag_expr_id, mode
|
||||
);
|
||||
|
||||
let place_with_id = PlaceWithHirId {
|
||||
place: truncate_capture_for_optimization(&place_with_id.place),
|
||||
..*place_with_id
|
||||
};
|
||||
|
||||
if !self.capture_information.contains_key(&place_with_id.place) {
|
||||
self.init_capture_info_for_place(&place_with_id, diag_expr_id);
|
||||
}
|
||||
|
|
@ -1670,8 +1667,6 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'tcx> {
|
|||
&place_with_id.place,
|
||||
);
|
||||
|
||||
let place = truncate_capture_for_optimization(&place);
|
||||
|
||||
let place_with_id = PlaceWithHirId { place, ..*place_with_id };
|
||||
|
||||
if !self.capture_information.contains_key(&place_with_id.place) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ fn struct_contains_ref_to_another_struct_2() {
|
|||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
let _t = t.0.0;
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref] -> ImmBorrow
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture t[(0, 0),Deref] -> ImmBorrow
|
||||
};
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ fn struct_contains_ref_to_another_struct_3() {
|
|||
//~^ ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
let _t = t.0.0;
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref] -> ByValue
|
||||
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> ByValue
|
||||
//~| NOTE: Min Capture t[(0, 0)] -> ByValue
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ LL | |
|
|||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing t[(0, 0),Deref] -> ImmBorrow
|
||||
note: Capturing t[(0, 0),Deref,(0, 0)] -> ImmBorrow
|
||||
--> $DIR/move_closure.rs:80:18
|
||||
|
|
||||
LL | let _t = t.0.0;
|
||||
|
|
@ -226,7 +226,7 @@ LL | |
|
|||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
note: Capturing t[(0, 0),Deref] -> ByValue
|
||||
note: Capturing t[(0, 0),Deref,(0, 0)] -> ByValue
|
||||
--> $DIR/move_closure.rs:102:18
|
||||
|
|
||||
LL | let _t = t.0.0;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static {
|
|||
//~| NOTE: see issue #15701 <https://github.com/rust-lang/rust/issues/15701>
|
||||
//~| ERROR: First Pass analysis includes:
|
||||
//~| ERROR: Min Capture analysis includes:
|
||||
//~| NOTE: Capturing m[Deref,(0, 0),Deref] -> ImmBorrow
|
||||
//~| NOTE: Capturing m[Deref,(0, 0),Deref,(0, 0)] -> ImmBorrow
|
||||
//~| NOTE: Min Capture m[Deref,(0, 0),Deref] -> ImmBorrow
|
||||
c
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ error: First Pass analysis includes:
|
|||
LL | let c = #[rustc_capture_analysis] || drop(&m.a.0);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: Capturing m[Deref,(0, 0),Deref] -> ImmBorrow
|
||||
note: Capturing m[Deref,(0, 0),Deref,(0, 0)] -> ImmBorrow
|
||||
--> $DIR/edge_case.rs:20:48
|
||||
|
|
||||
LL | let c = #[rustc_capture_analysis] || drop(&m.a.0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue