Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2198fae
Make `NonUseContext::AscribeUserTy` carry `ty::Variance`
obeis May 8, 2023
b64e911
Add test.
cjgillot May 10, 2023
d0d4e02
Iteratively replace pointers.
cjgillot May 10, 2023
aeac555
Do not see through copies of mutable pointers.
cjgillot May 10, 2023
9fb1c73
Avoid shadowing.
cjgillot May 10, 2023
a2fe993
Only warn single-use lifetime when the binders match.
cjgillot May 10, 2023
ccd8ad7
Note base types of coercion
compiler-errors May 11, 2023
eadf3bb
Update cargo
heiher May 11, 2023
616fb42
Update browser-ui-test version to 0.16.0
GuillaumeGomez May 10, 2023
0630283
Migrate to 0.16.0 browser-ui-test version
GuillaumeGomez May 10, 2023
8e55400
Convert some GUI tests color checks to use original format
GuillaumeGomez May 11, 2023
cac7e42
Fix backtrace normalization in ice-bug-report-url.rs
uweigand May 10, 2023
7e311dd
Rollup merge of #111366 - obeis:ascribe-user-type-variance, r=lcnr
matthiaskrgr May 11, 2023
62e894f
Rollup merge of #111439 - uweigand:backtrace-normalize, r=compiler-er…
matthiaskrgr May 11, 2023
d0b342c
Rollup merge of #111441 - cjgillot:issue-111422, r=JakobDegen
matthiaskrgr May 11, 2023
7a674e4
Rollup merge of #111444 - cjgillot:issue-111400, r=oli-obk
matthiaskrgr May 11, 2023
beb1ff8
Rollup merge of #111451 - compiler-errors:note-cast-origin, r=b-naber
matthiaskrgr May 11, 2023
fe37a72
Rollup merge of #111456 - loongarch-rs:bump-cargo, r=weihanglo
matthiaskrgr May 11, 2023
8971878
Rollup merge of #111459 - GuillaumeGomez:update-browser-ui-test, r=no…
matthiaskrgr May 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test.
  • Loading branch information
cjgillot committed May 10, 2023
commit b64e9113e257976875e94360462bd2744af78f7b
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
- // MIR for `mut_raw_then_mut_shr` before ReferencePropagation
+ // MIR for `mut_raw_then_mut_shr` after ReferencePropagation

fn mut_raw_then_mut_shr() -> (i32, i32) {
let mut _0: (i32, i32); // return place in scope 0 at $DIR/reference_prop.rs:+0:30: +0:40
let mut _1: i32; // in scope 0 at $DIR/reference_prop.rs:+1:9: +1:14
let mut _4: *mut i32; // in scope 0 at $DIR/reference_prop.rs:+3:16: +3:36
let mut _5: &mut i32; // in scope 0 at $DIR/reference_prop.rs:+3:16: +3:26
let _8: (); // in scope 0 at $DIR/reference_prop.rs:+7:5: +7:26
let mut _9: i32; // in scope 0 at $DIR/reference_prop.rs:+8:6: +8:7
let mut _10: i32; // in scope 0 at $DIR/reference_prop.rs:+8:9: +8:10
scope 1 {
debug x => _1; // in scope 1 at $DIR/reference_prop.rs:+1:9: +1:14
let _2: &mut i32; // in scope 1 at $DIR/reference_prop.rs:+2:9: +2:13
scope 2 {
debug xref => _2; // in scope 2 at $DIR/reference_prop.rs:+2:9: +2:13
let _3: *mut i32; // in scope 2 at $DIR/reference_prop.rs:+3:9: +3:13
scope 3 {
debug xraw => _3; // in scope 3 at $DIR/reference_prop.rs:+3:9: +3:13
let _6: &i32; // in scope 3 at $DIR/reference_prop.rs:+4:9: +4:13
scope 4 {
debug xshr => _6; // in scope 4 at $DIR/reference_prop.rs:+4:9: +4:13
let _7: i32; // in scope 4 at $DIR/reference_prop.rs:+6:9: +6:10
scope 5 {
debug a => _7; // in scope 5 at $DIR/reference_prop.rs:+6:9: +6:10
scope 6 {
}
}
}
}
}
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+1:9: +1:14
_1 = const 2_i32; // scope 0 at $DIR/reference_prop.rs:+1:17: +1:18
- StorageLive(_2); // scope 1 at $DIR/reference_prop.rs:+2:9: +2:13
_2 = &mut _1; // scope 1 at $DIR/reference_prop.rs:+2:16: +2:22
StorageLive(_3); // scope 2 at $DIR/reference_prop.rs:+3:9: +3:13
StorageLive(_4); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:36
- StorageLive(_5); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
- _5 = &mut (*_2); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
- _4 = &raw mut (*_5); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
+ _5 = &mut _1; // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
+ _4 = &raw mut (*_2); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
_3 = _4; // scope 2 at $DIR/reference_prop.rs:+3:16: +3:36
- StorageDead(_5); // scope 2 at $DIR/reference_prop.rs:+3:36: +3:37
StorageDead(_4); // scope 2 at $DIR/reference_prop.rs:+3:36: +3:37
StorageLive(_6); // scope 3 at $DIR/reference_prop.rs:+4:9: +4:13
- _6 = &(*_2); // scope 3 at $DIR/reference_prop.rs:+4:16: +4:22
+ _6 = &_1; // scope 3 at $DIR/reference_prop.rs:+4:16: +4:22
StorageLive(_7); // scope 4 at $DIR/reference_prop.rs:+6:9: +6:10
- _7 = (*_6); // scope 4 at $DIR/reference_prop.rs:+6:13: +6:18
- StorageLive(_8); // scope 5 at $DIR/reference_prop.rs:+7:5: +7:26
- (*_3) = const 4_i32; // scope 6 at $DIR/reference_prop.rs:+7:14: +7:23
- _8 = const (); // scope 6 at $DIR/reference_prop.rs:+7:5: +7:26
- StorageDead(_8); // scope 5 at $DIR/reference_prop.rs:+7:25: +7:26
+ _7 = (*_2); // scope 4 at $DIR/reference_prop.rs:+6:13: +6:18
+ (*_5) = const 4_i32; // scope 6 at $DIR/reference_prop.rs:+7:14: +7:23
StorageLive(_9); // scope 5 at $DIR/reference_prop.rs:+8:6: +8:7
_9 = _7; // scope 5 at $DIR/reference_prop.rs:+8:6: +8:7
StorageLive(_10); // scope 5 at $DIR/reference_prop.rs:+8:9: +8:10
_10 = _1; // scope 5 at $DIR/reference_prop.rs:+8:9: +8:10
_0 = (move _9, move _10); // scope 5 at $DIR/reference_prop.rs:+8:5: +8:11
StorageDead(_10); // scope 5 at $DIR/reference_prop.rs:+8:10: +8:11
StorageDead(_9); // scope 5 at $DIR/reference_prop.rs:+8:10: +8:11
StorageDead(_7); // scope 4 at $DIR/reference_prop.rs:+9:1: +9:2
StorageDead(_6); // scope 3 at $DIR/reference_prop.rs:+9:1: +9:2
StorageDead(_3); // scope 2 at $DIR/reference_prop.rs:+9:1: +9:2
- StorageDead(_2); // scope 1 at $DIR/reference_prop.rs:+9:1: +9:2
StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+9:1: +9:2
return; // scope 0 at $DIR/reference_prop.rs:+9:2: +9:2
}
}

27 changes: 27 additions & 0 deletions tests/mir-opt/reference_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,29 @@ fn maybe_dead(m: bool) {
)
}

fn mut_raw_then_mut_shr() -> (i32, i32) {
let mut x = 2;
let xref = &mut x;
let xraw = &mut *xref as *mut _;
let xshr = &*xref;
// Verify that we completely replace with `x` in both cases.
let a = *xshr;
unsafe { *xraw = 4; }
(a, x)
}

fn unique_with_copies() {
let y = {
let mut a = 0;
let x = &raw mut a;
// `*y` is not replacable below, so we must not replace `*x`.
unsafe { opaque(*x) };
x
};
// But rewriting as `*x` is ok.
unsafe { opaque(*y) };
}

fn main() {
let mut x = 5_usize;
let mut y = 7_usize;
Expand All @@ -444,6 +467,8 @@ fn main() {
multiple_storage();
dominate_storage();
maybe_dead(true);
mut_raw_then_mut_shr();
unique_with_copies();
}

// EMIT_MIR reference_prop.reference_propagation.ReferencePropagation.diff
Expand All @@ -454,3 +479,5 @@ fn main() {
// EMIT_MIR reference_prop.multiple_storage.ReferencePropagation.diff
// EMIT_MIR reference_prop.dominate_storage.ReferencePropagation.diff
// EMIT_MIR reference_prop.maybe_dead.ReferencePropagation.diff
// EMIT_MIR reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff
// EMIT_MIR reference_prop.unique_with_copies.ReferencePropagation.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
- // MIR for `unique_with_copies` before ReferencePropagation
+ // MIR for `unique_with_copies` after ReferencePropagation

fn unique_with_copies() -> () {
let mut _0: (); // return place in scope 0 at $DIR/reference_prop.rs:+0:25: +0:25
let _1: *mut i32; // in scope 0 at $DIR/reference_prop.rs:+1:9: +1:10
let mut _2: i32; // in scope 0 at $DIR/reference_prop.rs:+2:13: +2:18
let _4: (); // in scope 0 at $DIR/reference_prop.rs:+5:18: +5:28
let mut _5: i32; // in scope 0 at $DIR/reference_prop.rs:+5:25: +5:27
let _6: (); // in scope 0 at $DIR/reference_prop.rs:+9:14: +9:24
let mut _7: i32; // in scope 0 at $DIR/reference_prop.rs:+9:21: +9:23
scope 1 {
debug y => _1; // in scope 1 at $DIR/reference_prop.rs:+1:9: +1:10
scope 5 {
}
}
scope 2 {
debug a => _2; // in scope 2 at $DIR/reference_prop.rs:+2:13: +2:18
let _3: *mut i32; // in scope 2 at $DIR/reference_prop.rs:+3:13: +3:14
scope 3 {
debug x => _3; // in scope 3 at $DIR/reference_prop.rs:+3:13: +3:14
scope 4 {
}
}
}

bb0: {
StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+1:9: +1:10
StorageLive(_2); // scope 0 at $DIR/reference_prop.rs:+2:13: +2:18
_2 = const 0_i32; // scope 0 at $DIR/reference_prop.rs:+2:21: +2:22
StorageLive(_3); // scope 2 at $DIR/reference_prop.rs:+3:13: +3:14
_3 = &raw mut _2; // scope 2 at $DIR/reference_prop.rs:+3:17: +3:27
StorageLive(_4); // scope 3 at $DIR/reference_prop.rs:+5:9: +5:30
StorageLive(_5); // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27
- _5 = (*_3); // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27
+ _5 = _2; // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27
_4 = opaque::<i32>(move _5) -> bb1; // scope 4 at $DIR/reference_prop.rs:+5:18: +5:28
// mir::Constant
// + span: $DIR/reference_prop.rs:452:18: 452:24
// + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) }
}

bb1: {
StorageDead(_5); // scope 4 at $DIR/reference_prop.rs:+5:27: +5:28
StorageDead(_4); // scope 3 at $DIR/reference_prop.rs:+5:30: +5:31
_1 = _3; // scope 3 at $DIR/reference_prop.rs:+6:9: +6:10
StorageDead(_3); // scope 2 at $DIR/reference_prop.rs:+7:5: +7:6
StorageDead(_2); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6
StorageLive(_6); // scope 1 at $DIR/reference_prop.rs:+9:5: +9:26
StorageLive(_7); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23
_7 = (*_1); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23
_6 = opaque::<i32>(move _7) -> bb2; // scope 5 at $DIR/reference_prop.rs:+9:14: +9:24
// mir::Constant
// + span: $DIR/reference_prop.rs:456:14: 456:20
// + literal: Const { ty: fn(i32) {opaque::<i32>}, val: Value(<ZST>) }
}

bb2: {
StorageDead(_7); // scope 5 at $DIR/reference_prop.rs:+9:23: +9:24
StorageDead(_6); // scope 1 at $DIR/reference_prop.rs:+9:26: +9:27
_0 = const (); // scope 0 at $DIR/reference_prop.rs:+0:25: +10:2
StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+10:1: +10:2
return; // scope 0 at $DIR/reference_prop.rs:+10:2: +10:2
}
}