Skip to content

Commit e33cb9f

Browse files
committed
Update MIR opt and incremental tests for THIR unsafeck
1 parent 77b19d9 commit e33cb9f

File tree

133 files changed

+329
-666
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+329
-666
lines changed

compiler/rustc_mir_build/src/check_unsafety.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_session::lint::builtin::{UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
1111
use rustc_session::lint::Level;
1212
use rustc_span::def_id::{DefId, LocalDefId};
1313
use rustc_span::symbol::Symbol;
14-
use rustc_span::Span;
14+
use rustc_span::{sym, Span};
1515

1616
use std::mem;
1717
use std::ops::Bound;
@@ -841,7 +841,8 @@ impl UnsafeOpKind {
841841

842842
pub fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
843843
// Closures and inline consts are handled by their owner, if it has a body
844-
if tcx.is_typeck_child(def.to_def_id()) {
844+
// Don't safety check custom MIR
845+
if tcx.is_typeck_child(def.to_def_id()) || tcx.has_attr(def, sym::custom_mir) {
845846
return;
846847
}
847848

tests/incremental/hashes/function_interfaces.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn make_unsafe() {}
109109
#[cfg(not(any(cfail1,cfail4)))]
110110
#[rustc_clean(
111111
cfg = "cfail2",
112-
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
112+
except = "hir_owner, hir_owner_nodes, typeck, fn_sig"
113113
)]
114114
#[rustc_clean(cfg = "cfail3")]
115115
#[rustc_clean(

tests/incremental/hashes/inherent_impls.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ impl Foo {
348348
// Make method unsafe ----------------------------------------------------------
349349
#[cfg(any(cfail1,cfail4))]
350350
impl Foo {
351-
//------------------------------------------------------------------------------------------
351+
//----------------------------------------------------------------------------
352352
//--------------------------
353-
//------------------------------------------------------------------------------------------
353+
//----------------------------------------------------------------------------
354354
//--------------------------
355355
pub fn make_method_unsafe(&self) { }
356356
}
@@ -361,9 +361,9 @@ impl Foo {
361361
#[rustc_clean(cfg="cfail5")]
362362
#[rustc_clean(cfg="cfail6")]
363363
impl Foo {
364-
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
364+
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
365365
#[rustc_clean(cfg="cfail3")]
366-
#[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
366+
#[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
367367
#[rustc_clean(cfg="cfail6")]
368368
pub unsafe fn make_method_unsafe(&self) { }
369369
}

tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.panic-abort.mir

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ fn main() -> () {
1717
let _3: *mut usize;
1818
scope 3 {
1919
debug z => _3;
20-
scope 4 {
21-
}
2220
}
2321
}
2422
}

tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ fn main() -> () {
1717
let _3: *mut usize;
1818
scope 3 {
1919
debug z => _3;
20-
scope 4 {
21-
}
2220
}
2321
}
2422
}

tests/mir-opt/asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
fn main() -> () {
44
let mut _0: ();
55
let _1: ();
6-
scope 1 {
7-
}
86

97
bb0: {
108
StorageLive(_1);

tests/mir-opt/box_expr.main.ElaborateDrops.diff

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
scope 1 {
1616
debug x => _1;
1717
}
18-
scope 2 {
19-
}
2018

2119
bb0: {
2220
StorageLive(_1);

tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir

+2-6
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,13 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>,
9393
debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:12:14: 12:16});
9494
let _17: ();
9595
scope 2 {
96-
}
97-
scope 3 {
9896
debug result => _17;
9997
}
10098
}
101-
scope 4 {
99+
scope 3 {
102100
debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:12:14: 12:16});
103101
let _33: ();
104-
scope 5 {
105-
}
106-
scope 6 {
102+
scope 4 {
107103
debug result => _33;
108104
}
109105
}

tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir

+1-5
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@ fn move_out_by_subslice() -> () {
1616
scope 1 {
1717
debug a => _1;
1818
let _12: [std::boxed::Box<i32>; 2];
19-
scope 4 {
19+
scope 2 {
2020
debug _y => _12;
2121
}
2222
}
23-
scope 2 {
24-
}
25-
scope 3 {
26-
}
2723

2824
bb0: {
2925
StorageLive(_1);

tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir

+1-5
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@ fn move_out_from_end() -> () {
1616
scope 1 {
1717
debug a => _1;
1818
let _12: std::boxed::Box<i32>;
19-
scope 4 {
19+
scope 2 {
2020
debug _y => _12;
2121
}
2222
}
23-
scope 2 {
24-
}
25-
scope 3 {
26-
}
2723

2824
bb0: {
2925
StorageLive(_1);

tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
let mut _4: &i32;
1010
let _5: *const i32;
1111
+ let mut _6: &[&i32; 1];
12-
scope 1 {
13-
}
1412

1513
bb0: {
1614
StorageLive(_1);

tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
debug ptr => _3;
1515
let _5: bool;
1616
scope 3 {
17-
}
18-
scope 4 {
1917
debug ret => _5;
2018
}
2119
}

tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
let mut _9: &[i32; 3];
1414
scope 1 {
1515
debug a => _1;
16+
let _5: i32;
1617
scope 2 {
17-
let _5: i32;
18-
scope 3 {
19-
debug _b => _5;
20-
}
18+
debug _b => _5;
2119
}
2220
}
2321

tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
let mut _9: &[i32; 3];
1414
scope 1 {
1515
debug a => _1;
16+
let _5: i32;
1617
scope 2 {
17-
let _5: i32;
18-
scope 3 {
19-
debug _b => _5;
20-
}
18+
debug _b => _5;
2119
}
2220
}
2321

tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
let mut _9: &[i32; 3];
1414
scope 1 {
1515
debug a => _1;
16+
let _5: i32;
1617
scope 2 {
17-
let _5: i32;
18-
scope 3 {
19-
debug _b => _5;
20-
}
18+
debug _b => _5;
2119
}
2220
}
2321

tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
let mut _9: &[i32; 3];
1414
scope 1 {
1515
debug a => _1;
16+
let _5: i32;
1617
scope 2 {
17-
let _5: i32;
18-
scope 3 {
19-
debug _b => _5;
20-
}
18+
debug _b => _5;
2119
}
2220
}
2321

tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
scope 1 {
1616
debug x => _1;
1717
}
18-
scope 2 {
19-
}
2018

2119
bb0: {
2220
StorageLive(_1);

tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
scope 1 {
1616
debug x => _1;
1717
}
18-
scope 2 {
19-
}
2018

2119
bb0: {
2220
StorageLive(_1);

tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
debug v => _1;
1212
let _4: bool;
1313
scope 2 {
14-
}
15-
scope 3 {
1614
debug y => _4;
1715
}
1816
}

tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff

+3-9
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,18 @@
1212
scope 1 {
1313
debug _invalid_char => _1;
1414
let _3: [E; 1];
15-
scope 3 {
15+
scope 2 {
1616
debug _invalid_tag => _3;
1717
let _6: [Empty; 1];
18-
scope 5 {
18+
scope 3 {
1919
debug _enum_without_variants => const [ZeroSized: Empty];
2020
let _9: main::Str<"���">;
21-
scope 7 {
21+
scope 4 {
2222
debug _non_utf8_str => const Str::<"���">;
2323
}
2424
}
25-
scope 6 {
26-
}
27-
}
28-
scope 4 {
2925
}
3026
}
31-
scope 2 {
32-
}
3327

3428
bb0: {
3529
StorageLive(_1);

tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff

+3-9
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,20 @@
1212
scope 1 {
1313
debug _invalid_char => _1;
1414
let _3: [E; 1];
15-
scope 3 {
15+
scope 2 {
1616
debug _invalid_tag => _3;
1717
let _6: [Empty; 1];
18-
scope 5 {
18+
scope 3 {
1919
- debug _enum_without_variants => _6;
2020
+ debug _enum_without_variants => const [ZeroSized: Empty];
2121
let _9: main::Str<"���">;
22-
scope 7 {
22+
scope 4 {
2323
- debug _non_utf8_str => _9;
2424
+ debug _non_utf8_str => const Str::<"���">;
2525
}
2626
}
27-
scope 6 {
28-
}
29-
}
30-
scope 4 {
3127
}
3228
}
33-
scope 2 {
34-
}
3529

3630
bb0: {
3731
StorageLive(_1);

tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
debug x => _1;
1212
let _5: u32;
1313
scope 2 {
14-
}
15-
scope 3 {
1614
debug y => _5;
1715
}
1816
}

tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
fn from_char() -> i32 {
55
let mut _0: i32;
6-
scope 1 {
7-
}
86

97
bb0: {
108
- _0 = const 'R' as i32 (Transmute);

tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
fn from_char() -> i32 {
55
let mut _0: i32;
6-
scope 1 {
7-
}
86

97
bb0: {
108
- _0 = const 'R' as i32 (Transmute);

tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
fn invalid_bool() -> bool {
55
let mut _0: bool;
6-
scope 1 {
7-
}
86

97
bb0: {
108
- _0 = const -1_i8 as bool (Transmute);

tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
fn invalid_bool() -> bool {
55
let mut _0: bool;
6-
scope 1 {
7-
}
86

97
bb0: {
108
- _0 = const -1_i8 as bool (Transmute);

tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
fn invalid_char() -> char {
55
let mut _0: char;
6-
scope 1 {
7-
}
86

97
bb0: {
108
- _0 = const _ as char (Transmute);

tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
fn invalid_char() -> char {
55
let mut _0: char;
6-
scope 1 {
7-
}
86

97
bb0: {
108
- _0 = const _ as char (Transmute);

tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
fn less_as_i8() -> i8 {
55
let mut _0: i8;
66
let mut _1: std::cmp::Ordering;
7-
scope 1 {
8-
}
97

108
bb0: {
119
StorageLive(_1);

tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
fn less_as_i8() -> i8 {
55
let mut _0: i8;
66
let mut _1: std::cmp::Ordering;
7-
scope 1 {
8-
}
97

108
bb0: {
119
StorageLive(_1);

tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
let mut _0: u32;
66
let mut _1: undef_union_as_integer::Union32;
77
let mut _2: ();
8-
scope 1 {
9-
}
108

119
bb0: {
1210
StorageLive(_1);

tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
let mut _0: u32;
66
let mut _1: undef_union_as_integer::Union32;
77
let mut _2: ();
8-
scope 1 {
9-
}
108

119
bb0: {
1210
StorageLive(_1);

0 commit comments

Comments
 (0)