Skip to content

Commit e04848e

Browse files
committed
Bless a few tests
1 parent 4392c5d commit e04848e

File tree

9 files changed

+102
-71
lines changed

9 files changed

+102
-71
lines changed

library/alloc/src/vec/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -3009,22 +3009,19 @@ impl<T, A: Allocator, const N: usize> TryFrom<Vec<T, A>> for [T; N] {
30093009
/// # Examples
30103010
///
30113011
/// ```
3012-
/// use std::convert::TryInto;
30133012
/// assert_eq!(vec![1, 2, 3].try_into(), Ok([1, 2, 3]));
30143013
/// assert_eq!(<Vec<i32>>::new().try_into(), Ok([]));
30153014
/// ```
30163015
///
30173016
/// If the length doesn't match, the input comes back in `Err`:
30183017
/// ```
3019-
/// use std::convert::TryInto;
30203018
/// let r: Result<[i32; 4], _> = (0..10).collect::<Vec<_>>().try_into();
30213019
/// assert_eq!(r, Err(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]));
30223020
/// ```
30233021
///
30243022
/// If you're fine with just getting a prefix of the `Vec<T>`,
30253023
/// you can call [`.truncate(N)`](Vec::truncate) first.
30263024
/// ```
3027-
/// use std::convert::TryInto;
30283025
/// let mut v = String::from("hello world").into_bytes();
30293026
/// v.sort();
30303027
/// v.truncate(2);

src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff

+64-11
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,33 @@
2222
let mut _20: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
2323
let mut _21: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84
2424
let mut _22: !; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
25-
let mut _23: &[T; 3]; // in scope 0 at $DIR/issue_76432.rs:7:19: 7:29
25+
let mut _23: std::fmt::Arguments; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
26+
let mut _24: &[&str]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
27+
let mut _25: &[&str; 1]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
28+
let _26: &[&str; 1]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
29+
let _27: [&str; 1]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
30+
let mut _28: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
31+
let mut _29: &[std::fmt::ArgumentV1; 0]; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
32+
let _30: &[std::fmt::ArgumentV1; 0]; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
33+
let _31: [std::fmt::ArgumentV1; 0]; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
34+
let mut _32: (); // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
35+
let mut _36: &[T; 3]; // in scope 0 at $DIR/issue_76432.rs:7:19: 7:29
2636
scope 1 {
2737
debug v => _2; // in scope 1 at $DIR/issue_76432.rs:7:9: 7:10
2838
let _13: &T; // in scope 1 at $DIR/issue_76432.rs:9:10: 9:16
2939
let _14: &T; // in scope 1 at $DIR/issue_76432.rs:9:18: 9:24
3040
let _15: &T; // in scope 1 at $DIR/issue_76432.rs:9:26: 9:32
41+
let _33: (); // in scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
42+
let mut _34: &[std::fmt::ArgumentV1; 0]; // in scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
43+
let mut _35: &[&str; 1]; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
3144
scope 2 {
3245
debug v1 => _13; // in scope 2 at $DIR/issue_76432.rs:9:10: 9:16
3346
debug v2 => _14; // in scope 2 at $DIR/issue_76432.rs:9:18: 9:24
3447
debug v3 => _15; // in scope 2 at $DIR/issue_76432.rs:9:26: 9:32
3548
}
49+
scope 3 {
50+
debug _args => _33; // in scope 3 at $SRC_DIR/core/src/panic.rs:LL:COL
51+
}
3652
}
3753

3854
bb0: {
@@ -52,31 +68,59 @@
5268
StorageDead(_6); // scope 0 at $DIR/issue_76432.rs:7:28: 7:29
5369
_4 = &_5; // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
5470
_3 = _4; // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
55-
StorageLive(_23); // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
56-
_23 = _3; // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
71+
StorageLive(_36); // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
72+
_36 = _3; // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
5773
_2 = move _3 as &[T] (Pointer(Unsize)); // scope 0 at $DIR/issue_76432.rs:7:19: 7:29
5874
StorageDead(_3); // scope 0 at $DIR/issue_76432.rs:7:28: 7:29
5975
StorageDead(_4); // scope 0 at $DIR/issue_76432.rs:7:29: 7:30
6076
StorageLive(_9); // scope 1 at $DIR/issue_76432.rs:8:5: 11:6
6177
_10 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
62-
StorageDead(_23); // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
78+
StorageDead(_36); // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
6379
_11 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
6480
_12 = const true; // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
6581
goto -> bb2; // scope 1 at $DIR/issue_76432.rs:9:9: 9:33
6682
}
6783

6884
bb1: {
6985
StorageLive(_22); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
70-
core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
71-
// mir::Constant
72-
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
73-
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
86+
StorageLive(_23); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
87+
StorageLive(_24); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
88+
StorageLive(_25); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
89+
StorageLive(_26); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
90+
_35 = const test::<T>::promoted[1]; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
7491
// ty::Const
75-
// + ty: &str
76-
// + 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 })
92+
// + ty: &[&str; 1]
93+
// + val: Unevaluated(test, [T], Some(promoted[1]))
7794
// mir::Constant
7895
// + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
79-
// + 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 }) }
96+
// + 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]) }) }
97+
_26 = _35; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
98+
_25 = _26; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
99+
_24 = move _25 as &[&str] (Pointer(Unsize)); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
100+
StorageDead(_25); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
101+
StorageLive(_28); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
102+
StorageLive(_29); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
103+
StorageLive(_30); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
104+
StorageLive(_32); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
105+
StorageLive(_33); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
106+
nop; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
107+
StorageDead(_33); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
108+
_34 = const test::<T>::promoted[0]; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
109+
// ty::Const
110+
// + ty: &[std::fmt::ArgumentV1; 0]
111+
// + val: Unevaluated(test, [T], Some(promoted[0]))
112+
// mir::Constant
113+
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
114+
// + 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]) }) }
115+
_30 = _34; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
116+
_29 = _30; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
117+
_28 = move _29 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
118+
StorageDead(_29); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
119+
_23 = Arguments::new_v1(move _24, move _28) -> bb3; // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
120+
// mir::Constant
121+
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
122+
// + user_ty: UserType(5)
123+
// + literal: Const { ty: fn(&[&'static str], &[std::fmt::ArgumentV1]) -> std::fmt::Arguments {std::fmt::Arguments::new_v1}, val: Value(Scalar(<ZST>)) }
80124
}
81125

82126
bb2: {
@@ -114,5 +158,14 @@
114158
StorageDead(_2); // scope 0 at $DIR/issue_76432.rs:12:1: 12:2
115159
return; // scope 0 at $DIR/issue_76432.rs:12:2: 12:2
116160
}
161+
162+
bb3: {
163+
StorageDead(_28); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
164+
StorageDead(_24); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
165+
panic_fmt(move _23); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL
166+
// mir::Constant
167+
// + span: $SRC_DIR/core/src/panic.rs:LL:COL
168+
// + literal: Const { ty: for<'r> fn(std::fmt::Arguments<'r>) -> ! {std::rt::panic_fmt}, val: Value(Scalar(<ZST>)) }
169+
}
117170
}
118171

src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir

+19-44
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn num_to_digit(_1: char) -> u32 {
77
let mut _3: std::option::Option<u32>; // in scope 0 at $DIR/issue-59352.rs:14:26: 14:41
88
let mut _4: char; // in scope 0 at $DIR/issue-59352.rs:14:26: 14:29
99
let mut _5: u32; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23
10-
let mut _11: isize; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23
10+
let mut _10: isize; // in scope 0 at $DIR/issue-59352.rs:14:8: 14:23
1111
scope 1 (inlined char::methods::<impl char>::is_digit) { // at $DIR/issue-59352.rs:14:8: 14:23
1212
debug self => _2; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23
1313
debug radix => _5; // in scope 1 at $DIR/issue-59352.rs:14:8: 14:23
@@ -19,13 +19,6 @@ fn num_to_digit(_1: char) -> u32 {
1919
let mut _9: isize; // in scope 2 at $DIR/issue-59352.rs:14:8: 14:23
2020
}
2121
}
22-
scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { // at $DIR/issue-59352.rs:14:26: 14:50
23-
debug self => _3; // in scope 3 at $DIR/issue-59352.rs:14:26: 14:50
24-
let mut _10: isize; // in scope 3 at $DIR/issue-59352.rs:14:26: 14:50
25-
scope 4 {
26-
debug val => _0; // in scope 4 at $DIR/issue-59352.rs:14:26: 14:50
27-
}
28-
}
2922

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

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

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

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

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

7368
bb5: {
69+
return; // scope 0 at $DIR/issue-59352.rs:15:2: 15:2
70+
}
71+
72+
bb6: {
7473
_6 = &_7; // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
7574
StorageDead(_8); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
7675
StorageLive(_9); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
7776
_9 = discriminant((*_6)); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
78-
StorageLive(_11); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
79-
_11 = move _9; // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
77+
StorageLive(_10); // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
78+
_10 = move _9; // scope 2 at $DIR/issue-59352.rs:14:8: 14:23
8079
StorageDead(_9); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
8180
StorageDead(_6); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
8281
StorageDead(_7); // scope 1 at $DIR/issue-59352.rs:14:8: 14:23
8382
StorageDead(_5); // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
8483
StorageDead(_2); // scope 0 at $DIR/issue-59352.rs:14:22: 14:23
85-
switchInt(move _11) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
86-
}
87-
88-
bb6: {
89-
core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50
90-
// mir::Constant
91-
// + span: $DIR/issue-59352.rs:14:26: 14:50
92-
// + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar(<ZST>)) }
93-
// ty::Const
94-
// + ty: &str
95-
// + 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 })
96-
// mir::Constant
97-
// + span: $DIR/issue-59352.rs:14:26: 14:50
98-
// + 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 }) }
99-
}
100-
101-
bb7: {
102-
unreachable; // scope 3 at $DIR/issue-59352.rs:14:26: 14:50
103-
}
104-
105-
bb8: {
106-
_0 = move ((_3 as Some).0: u32); // scope 3 at $DIR/issue-59352.rs:14:26: 14:50
107-
StorageDead(_10); // scope 0 at $DIR/issue-59352.rs:14:26: 14:50
108-
StorageDead(_3); // scope 0 at $DIR/issue-59352.rs:14:49: 14:50
109-
goto -> bb4; // scope 0 at $DIR/issue-59352.rs:14:5: 14:63
84+
switchInt(move _10) -> [1_isize: bb1, otherwise: bb4]; // scope 0 at $DIR/issue-59352.rs:14:8: 14:23
11085
}
11186
}

0 commit comments

Comments
 (0)