Skip to content

Commit

Permalink
Update MIR opt and incremental tests for THIR unsafeck
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Nov 7, 2023
1 parent 77b19d9 commit e33cb9f
Show file tree
Hide file tree
Showing 133 changed files with 329 additions and 666 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_mir_build/src/check_unsafety.rs
Expand Up @@ -11,7 +11,7 @@ use rustc_session::lint::builtin::{UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
use rustc_session::lint::Level;
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use rustc_span::{sym, Span};

use std::mem;
use std::ops::Bound;
Expand Down Expand Up @@ -841,7 +841,8 @@ impl UnsafeOpKind {

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

Expand Down
2 changes: 1 addition & 1 deletion tests/incremental/hashes/function_interfaces.rs
Expand Up @@ -109,7 +109,7 @@ pub fn make_unsafe() {}
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(
cfg = "cfail2",
except = "hir_owner, hir_owner_nodes, optimized_mir, typeck, fn_sig"
except = "hir_owner, hir_owner_nodes, typeck, fn_sig"
)]
#[rustc_clean(cfg = "cfail3")]
#[rustc_clean(
Expand Down
8 changes: 4 additions & 4 deletions tests/incremental/hashes/inherent_impls.rs
Expand Up @@ -348,9 +348,9 @@ impl Foo {
// Make method unsafe ----------------------------------------------------------
#[cfg(any(cfail1,cfail4))]
impl Foo {
//------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------
//--------------------------
//------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------
//--------------------------
pub fn make_method_unsafe(&self) { }
}
Expand All @@ -361,9 +361,9 @@ impl Foo {
#[rustc_clean(cfg="cfail5")]
#[rustc_clean(cfg="cfail6")]
impl Foo {
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir")]
#[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
#[rustc_clean(cfg="cfail6")]
pub unsafe fn make_method_unsafe(&self) { }
}
Expand Down
Expand Up @@ -17,8 +17,6 @@ fn main() -> () {
let _3: *mut usize;
scope 3 {
debug z => _3;
scope 4 {
}
}
}
}
Expand Down
Expand Up @@ -17,8 +17,6 @@ fn main() -> () {
let _3: *mut usize;
scope 3 {
debug z => _3;
scope 4 {
}
}
}
}
Expand Down
Expand Up @@ -3,8 +3,6 @@
fn main() -> () {
let mut _0: ();
let _1: ();
scope 1 {
}

bb0: {
StorageLive(_1);
Expand Down
2 changes: 0 additions & 2 deletions tests/mir-opt/box_expr.main.ElaborateDrops.diff
Expand Up @@ -15,8 +15,6 @@
scope 1 {
debug x => _1;
}
scope 2 {
}

bb0: {
StorageLive(_1);
Expand Down
Expand Up @@ -93,17 +93,13 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>,
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});
let _17: ();
scope 2 {
}
scope 3 {
debug result => _17;
}
}
scope 4 {
scope 3 {
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});
let _33: ();
scope 5 {
}
scope 6 {
scope 4 {
debug result => _33;
}
}
Expand Down
Expand Up @@ -16,14 +16,10 @@ fn move_out_by_subslice() -> () {
scope 1 {
debug a => _1;
let _12: [std::boxed::Box<i32>; 2];
scope 4 {
scope 2 {
debug _y => _12;
}
}
scope 2 {
}
scope 3 {
}

bb0: {
StorageLive(_1);
Expand Down
Expand Up @@ -16,14 +16,10 @@ fn move_out_from_end() -> () {
scope 1 {
debug a => _1;
let _12: std::boxed::Box<i32>;
scope 4 {
scope 2 {
debug _y => _12;
}
}
scope 2 {
}
scope 3 {
}

bb0: {
StorageLive(_1);
Expand Down
Expand Up @@ -9,8 +9,6 @@
let mut _4: &i32;
let _5: *const i32;
+ let mut _6: &[&i32; 1];
scope 1 {
}

bb0: {
StorageLive(_1);
Expand Down
2 changes: 0 additions & 2 deletions tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff
Expand Up @@ -14,8 +14,6 @@
debug ptr => _3;
let _5: bool;
scope 3 {
}
scope 4 {
debug ret => _5;
}
}
Expand Down
Expand Up @@ -13,11 +13,9 @@
let mut _9: &[i32; 3];
scope 1 {
debug a => _1;
let _5: i32;
scope 2 {
let _5: i32;
scope 3 {
debug _b => _5;
}
debug _b => _5;
}
}

Expand Down
Expand Up @@ -13,11 +13,9 @@
let mut _9: &[i32; 3];
scope 1 {
debug a => _1;
let _5: i32;
scope 2 {
let _5: i32;
scope 3 {
debug _b => _5;
}
debug _b => _5;
}
}

Expand Down
Expand Up @@ -13,11 +13,9 @@
let mut _9: &[i32; 3];
scope 1 {
debug a => _1;
let _5: i32;
scope 2 {
let _5: i32;
scope 3 {
debug _b => _5;
}
debug _b => _5;
}
}

Expand Down
Expand Up @@ -13,11 +13,9 @@
let mut _9: &[i32; 3];
scope 1 {
debug a => _1;
let _5: i32;
scope 2 {
let _5: i32;
scope 3 {
debug _b => _5;
}
debug _b => _5;
}
}

Expand Down
Expand Up @@ -15,8 +15,6 @@
scope 1 {
debug x => _1;
}
scope 2 {
}

bb0: {
StorageLive(_1);
Expand Down
Expand Up @@ -15,8 +15,6 @@
scope 1 {
debug x => _1;
}
scope 2 {
}

bb0: {
StorageLive(_1);
Expand Down
2 changes: 0 additions & 2 deletions tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff
Expand Up @@ -11,8 +11,6 @@
debug v => _1;
let _4: bool;
scope 2 {
}
scope 3 {
debug y => _4;
}
}
Expand Down
12 changes: 3 additions & 9 deletions tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff
Expand Up @@ -12,24 +12,18 @@
scope 1 {
debug _invalid_char => _1;
let _3: [E; 1];
scope 3 {
scope 2 {
debug _invalid_tag => _3;
let _6: [Empty; 1];
scope 5 {
scope 3 {
debug _enum_without_variants => const [ZeroSized: Empty];
let _9: main::Str<"���">;
scope 7 {
scope 4 {
debug _non_utf8_str => const Str::<"���">;
}
}
scope 6 {
}
}
scope 4 {
}
}
scope 2 {
}

bb0: {
StorageLive(_1);
Expand Down
12 changes: 3 additions & 9 deletions tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff
Expand Up @@ -12,26 +12,20 @@
scope 1 {
debug _invalid_char => _1;
let _3: [E; 1];
scope 3 {
scope 2 {
debug _invalid_tag => _3;
let _6: [Empty; 1];
scope 5 {
scope 3 {
- debug _enum_without_variants => _6;
+ debug _enum_without_variants => const [ZeroSized: Empty];
let _9: main::Str<"���">;
scope 7 {
scope 4 {
- debug _non_utf8_str => _9;
+ debug _non_utf8_str => const Str::<"���">;
}
}
scope 6 {
}
}
scope 4 {
}
}
scope 2 {
}

bb0: {
StorageLive(_1);
Expand Down
Expand Up @@ -11,8 +11,6 @@
debug x => _1;
let _5: u32;
scope 2 {
}
scope 3 {
debug y => _5;
}
}
Expand Down
Expand Up @@ -3,8 +3,6 @@

fn from_char() -> i32 {
let mut _0: i32;
scope 1 {
}

bb0: {
- _0 = const 'R' as i32 (Transmute);
Expand Down
Expand Up @@ -3,8 +3,6 @@

fn from_char() -> i32 {
let mut _0: i32;
scope 1 {
}

bb0: {
- _0 = const 'R' as i32 (Transmute);
Expand Down
Expand Up @@ -3,8 +3,6 @@

fn invalid_bool() -> bool {
let mut _0: bool;
scope 1 {
}

bb0: {
- _0 = const -1_i8 as bool (Transmute);
Expand Down
Expand Up @@ -3,8 +3,6 @@

fn invalid_bool() -> bool {
let mut _0: bool;
scope 1 {
}

bb0: {
- _0 = const -1_i8 as bool (Transmute);
Expand Down
Expand Up @@ -3,8 +3,6 @@

fn invalid_char() -> char {
let mut _0: char;
scope 1 {
}

bb0: {
- _0 = const _ as char (Transmute);
Expand Down
Expand Up @@ -3,8 +3,6 @@

fn invalid_char() -> char {
let mut _0: char;
scope 1 {
}

bb0: {
- _0 = const _ as char (Transmute);
Expand Down
Expand Up @@ -4,8 +4,6 @@
fn less_as_i8() -> i8 {
let mut _0: i8;
let mut _1: std::cmp::Ordering;
scope 1 {
}

bb0: {
StorageLive(_1);
Expand Down
Expand Up @@ -4,8 +4,6 @@
fn less_as_i8() -> i8 {
let mut _0: i8;
let mut _1: std::cmp::Ordering;
scope 1 {
}

bb0: {
StorageLive(_1);
Expand Down
Expand Up @@ -5,8 +5,6 @@
let mut _0: u32;
let mut _1: undef_union_as_integer::Union32;
let mut _2: ();
scope 1 {
}

bb0: {
StorageLive(_1);
Expand Down
Expand Up @@ -5,8 +5,6 @@
let mut _0: u32;
let mut _1: undef_union_as_integer::Union32;
let mut _2: ();
scope 1 {
}

bb0: {
StorageLive(_1);
Expand Down

0 comments on commit e33cb9f

Please sign in to comment.