Skip to content

Commit

Permalink
Bless a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Dec 18, 2021
1 parent 4392c5d commit e04848e
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 71 deletions.
3 changes: 0 additions & 3 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3009,22 +3009,19 @@ impl<T, A: Allocator, const N: usize> TryFrom<Vec<T, A>> for [T; N] {
/// # Examples
///
/// ```
/// use std::convert::TryInto;
/// assert_eq!(vec![1, 2, 3].try_into(), Ok([1, 2, 3]));
/// assert_eq!(<Vec<i32>>::new().try_into(), Ok([]));
/// ```
///
/// If the length doesn't match, the input comes back in `Err`:
/// ```
/// use std::convert::TryInto;
/// let r: Result<[i32; 4], _> = (0..10).collect::<Vec<_>>().try_into();
/// assert_eq!(r, Err(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
/// ```
///
/// If you're fine with just getting a prefix of the `Vec<T>`,
/// you can call [`.truncate(N)`](Vec::truncate) first.
/// ```
/// use std::convert::TryInto;
/// let mut v = String::from("hello world").into_bytes();
/// v.sort();
/// v.truncate(2);
Expand Down
75 changes: 64 additions & 11 deletions src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,33 @@
let mut _20: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
let mut _21: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
let mut _22: !; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
let mut _23: &[T; 3]; // in scope 0 at $DIR/issue_76432.rs:7:19: 7:29
let mut _23: std::fmt::Arguments; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
let mut _24: &[&str]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
let mut _25: &[&str; 1]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
let _26: &[&str; 1]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
let _27: [&str; 1]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
let mut _28: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
let mut _29: &[std::fmt::ArgumentV1; 0]; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
let _30: &[std::fmt::ArgumentV1; 0]; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
let _31: [std::fmt::ArgumentV1; 0]; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
let mut _32: (); // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
let mut _36: &[T; 3]; // in scope 0 at $DIR/issue_76432.rs:7:19: 7:29
scope 1 {
debug v => _2; // in scope 1 at $DIR/issue_76432.rs:7:9: 7:10
let _13: &T; // in scope 1 at $DIR/issue_76432.rs:9:10: 9:16
let _14: &T; // in scope 1 at $DIR/issue_76432.rs:9:18: 9:24
let _15: &T; // in scope 1 at $DIR/issue_76432.rs:9:26: 9:32
let _33: (); // in scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
let mut _34: &[std::fmt::ArgumentV1; 0]; // in scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
let mut _35: &[&str; 1]; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
scope 2 {
debug v1 => _13; // in scope 2 at $DIR/issue_76432.rs:9:10: 9:16
debug v2 => _14; // in scope 2 at $DIR/issue_76432.rs:9:18: 9:24
debug v3 => _15; // in scope 2 at $DIR/issue_76432.rs:9:26: 9:32
}
scope 3 {
debug _args => _33; // in scope 3 at $SRC_DIR/core/src/panic.rs:LL:COL
}
}

bb0: {
Expand All @@ -52,31 +68,59 @@
StorageDead(_6); // scope 0 at $DIR/issue_76432.rs:7:28: 7:29
_4 = &_5; // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
_3 = _4; // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
StorageLive(_23); // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
_23 = _3; // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
StorageLive(_36); // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
_36 = _3; // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
_2 = move _3 as &[T] (Pointer(Unsize)); // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
StorageDead(_3); // scope 0 at $DIR/issue_76432.rs:7:28: 7:29
StorageDead(_4); // scope 0 at $DIR/issue_76432.rs:7:29: 7:30
StorageLive(_9); // scope 1 at $DIR/issue_76432.rs:8:5: 11:6
_10 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
StorageDead(_23); // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
StorageDead(_36); // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
_11 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
_12 = const true; // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
goto -> bb2; // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
}

bb1: {
StorageLive(_22); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
// mir::Constant
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
StorageLive(_23); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
StorageLive(_24); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageLive(_25); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageLive(_26); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_35 = const test::<T>::promoted[1]; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
// ty::Const
// + ty: &str
// + val: Value(Slice { data: Allocation { bytes: [105, 110, 116, 101, 114, 110, 97, 108, 32, 101, 114, 114, 111, 114, 58, 32, 101, 110, 116, 101, 114, 101, 100, 32, 117, 110, 114, 101, 97, 99, 104, 97, 98, 108, 101, 32, 99, 111, 100, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [1099511627775], len: Size { raw: 40 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 40 })
// + ty: &[&str; 1]
// + val: Unevaluated(test, [T], Some(promoted[1]))
// mir::Constant
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [105, 110, 116, 101, 114, 110, 97, 108, 32, 101, 114, 114, 111, 114, 58, 32, 101, 110, 116, 101, 114, 101, 100, 32, 117, 110, 114, 101, 97, 99, 104, 97, 98, 108, 101, 32, 99, 111, 100, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [1099511627775], len: Size { raw: 40 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 40 }) }
// + literal: Const { ty: &[&str; 1], val: Unevaluated(Unevaluated { def: WithOptConstParam { did: DefId(0:6 ~ issue_76432[HASH]::test), const_param_did: None }, substs_: Some([T]), promoted: Some(promoted[1]) }) }
_26 = _35; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_25 = _26; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
_24 = move _25 as &[&str] (Pointer(Unsize)); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageDead(_25); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
StorageLive(_28); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
StorageLive(_29); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
StorageLive(_30); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
StorageLive(_32); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
StorageLive(_33); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
nop; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
StorageDead(_33); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
_34 = const test::<T>::promoted[0]; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
// ty::Const
// + ty: &[std::fmt::ArgumentV1; 0]
// + val: Unevaluated(test, [T], Some(promoted[0]))
// mir::Constant
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
// + literal: Const { ty: &[std::fmt::ArgumentV1; 0], val: Unevaluated(Unevaluated { def: WithOptConstParam { did: DefId(0:6 ~ issue_76432[HASH]::test), const_param_did: None }, substs_: Some([T]), promoted: Some(promoted[0]) }) }
_30 = _34; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
_29 = _30; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
_28 = move _29 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
StorageDead(_29); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
_23 = Arguments::new_v1(move _24, move _28) -> bb3; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
// mir::Constant
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
// + user_ty: UserType(5)
// + literal: Const { ty: fn(&[&'static str], &[std::fmt::ArgumentV1]) -> std::fmt::Arguments {std::fmt::Arguments::new_v1}, val: Value(Scalar(<ZST>)) }
}

bb2: {
Expand Down Expand Up @@ -114,5 +158,14 @@
StorageDead(_2); // scope 0 at $DIR/issue_76432.rs:12:1: 12:2
return; // scope 0 at $DIR/issue_76432.rs:12:2: 12:2
}

bb3: {
StorageDead(_28); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
StorageDead(_24); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
panic_fmt(move _23); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
// mir::Constant
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
// + literal: Const { ty: for<'r> fn(std::fmt::Arguments<'r>) -> ! {std::rt::panic_fmt}, val: Value(Scalar(<ZST>)) }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn num_to_digit(_1: char) -> u32 {
let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/issue-59352.rs:14:26: 14:41
let mut _4: char; // in scope 0 at $DIR/issue-59352.rs:14:26: 14:29
let mut _5: u32; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23
let mut _11: isize; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23
let mut _10: isize; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23
scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue-59352.rs:14:8: 14:23
debug self => _2; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23
debug radix => _5; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23
Expand All @@ -19,13 +19,6 @@ fn num_to_digit(_1: char) -> u32 {
let mut _9: isize; // in scope 2 at $DIR/issue-59352.rs:14:8: 14:23
}
}
scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { // at $DIR/issue-59352.rs:14:26: 14:50
debug self => _3; // in scope 3 at $DIR/issue-59352.rs:14:26: 14:50
let mut _10: isize; // in scope 3 at $DIR/issue-59352.rs:14:26: 14:50
scope 4 {
debug val => _0; // in scope 4 at $DIR/issue-59352.rs:14:26: 14:50
}
}

bb0: {
StorageLive(_2); // scope 0 at $DIR/issue-59352.rs:14:8: 14:11
Expand All @@ -36,14 +29,14 @@ fn num_to_digit(_1: char) -> u32 {
StorageLive(_7); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
StorageLive(_8); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
_8 = _2; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
_7 = char::methods::<impl char>::to_digit(move _8, const 8_u32) -> bb5; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
_7 = char::methods::<impl char>::to_digit(move _8, const 8_u32) -> bb6; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
// mir::Constant
// + span: $DIR/issue-59352.rs:14:8: 14:23
// + literal: Const { ty: fn(char, u32) -> std::option::Option<u32> {std::char::methods::<impl char>::to_digit}, val: Value(Scalar(<ZST>)) }
}

bb1: {
StorageDead(_11); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
StorageDead(_10); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
StorageLive(_3); // scope 0 at $DIR/issue-59352.rs:14:26: 14:41
StorageLive(_4); // scope 0 at $DIR/issue-59352.rs:14:26: 14:29
_4 = _1; // scope 0 at $DIR/issue-59352.rs:14:26: 14:29
Expand All @@ -55,57 +48,39 @@ fn num_to_digit(_1: char) -> u32 {

bb2: {
StorageDead(_4); // scope 0 at $DIR/issue-59352.rs:14:40: 14:41
StorageLive(_10); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50
_10 = discriminant(_3); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50
switchInt(move _10) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $DIR/issue-59352.rs:14:26: 14:50
_0 = Option::<u32>::unwrap(move _3) -> bb3; // scope 0 at $DIR/issue-59352.rs:14:26: 14:50
// mir::Constant
// + span: $DIR/issue-59352.rs:14:42: 14:48
// + literal: Const { ty: fn(std::option::Option<u32>) -> u32 {std::option::Option::<u32>::unwrap}, val: Value(Scalar(<ZST>)) }
}

bb3: {
StorageDead(_11); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
_0 = const 0_u32; // scope 0 at $DIR/issue-59352.rs:14:60: 14:61
goto -> bb4; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63
StorageDead(_3); // scope 0 at $DIR/issue-59352.rs:14:49: 14:50
goto -> bb5; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63
}

bb4: {
return; // scope 0 at $DIR/issue-59352.rs:15:2: 15:2
StorageDead(_10); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
_0 = const 0_u32; // scope 0 at $DIR/issue-59352.rs:14:60: 14:61
goto -> bb5; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63
}

bb5: {
return; // scope 0 at $DIR/issue-59352.rs:15:2: 15:2
}

bb6: {
_6 = &_7; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
StorageDead(_8); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
StorageLive(_9); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
_9 = discriminant((*_6)); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
StorageLive(_11); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
_11 = move _9; // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
StorageLive(_10); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
_10 = move _9; // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
StorageDead(_9); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
StorageDead(_6); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
StorageDead(_7); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
StorageDead(_5); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
StorageDead(_2); // scope 0 at $DIR/issue-59352.rs:14:22: 14:23
switchInt(move _11) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
}

bb6: {
core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50
// mir::Constant
// + span: $DIR/issue-59352.rs:14:26: 14:50
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
// ty::Const
// + ty: &str
// + val: Value(Slice { data: Allocation { bytes: [99, 97, 108, 108, 101, 100, 32, 96, 79, 112, 116, 105, 111, 110, 58, 58, 117, 110, 119, 114, 97, 112, 40, 41, 96, 32, 111, 110, 32, 97, 32, 96, 78, 111, 110, 101, 96, 32, 118, 97, 108, 117, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [8796093022207], len: Size { raw: 43 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 43 })
// mir::Constant
// + span: $DIR/issue-59352.rs:14:26: 14:50
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [99, 97, 108, 108, 101, 100, 32, 96, 79, 112, 116, 105, 111, 110, 58, 58, 117, 110, 119, 114, 97, 112, 40, 41, 96, 32, 111, 110, 32, 97, 32, 96, 78, 111, 110, 101, 96, 32, 118, 97, 108, 117, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [8796093022207], len: Size { raw: 43 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 43 }) }
}

bb7: {
unreachable; // scope 3 at $DIR/issue-59352.rs:14:26: 14:50
}

bb8: {
_0 = move ((_3 as Some).0: u32); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50
StorageDead(_10); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50
StorageDead(_3); // scope 0 at $DIR/issue-59352.rs:14:49: 14:50
goto -> bb4; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63
switchInt(move _10) -> [1_isize: bb1, otherwise: bb4]; // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
}
}
Loading

0 comments on commit e04848e

Please sign in to comment.