File tree 6 files changed +174
-13
lines changed
tests/mir-opt/pre-codegen
6 files changed +174
-13
lines changed Original file line number Diff line number Diff line change @@ -103,10 +103,12 @@ macro_rules! nonzero_integers {
103
103
#[ $stability]
104
104
#[ inline]
105
105
#[ rustc_const_stable( feature = "const_nonzero_get" , since = "1.34.0" ) ]
106
+ #[ rustc_allow_const_fn_unstable( const_assume) ]
106
107
pub const fn get( self ) -> $Int {
108
+ // SAFETY: By definition of this type.
109
+ unsafe { crate :: intrinsics:: assume( self . 0 != 0 ) } ;
107
110
self . 0
108
111
}
109
-
110
112
}
111
113
112
114
#[ stable( feature = "from_nonzero" , since = "1.31.0" ) ]
Original file line number Diff line number Diff line change @@ -341,10 +341,13 @@ impl<T: ?Sized> NonNull<T> {
341
341
/// ```
342
342
#[ stable( feature = "nonnull" , since = "1.25.0" ) ]
343
343
#[ rustc_const_stable( feature = "const_nonnull_as_ptr" , since = "1.32.0" ) ]
344
+ #[ rustc_allow_const_fn_unstable( const_assume, const_ptr_is_null) ]
344
345
#[ rustc_never_returns_null_ptr]
345
346
#[ must_use]
346
347
#[ inline( always) ]
347
348
pub const fn as_ptr ( self ) -> * mut T {
349
+ // SAFETY: By definition of this type.
350
+ unsafe { crate :: intrinsics:: assume ( !self . pointer . is_null ( ) ) } ;
348
351
self . pointer as * mut T
349
352
}
350
353
Original file line number Diff line number Diff line change 38
38
}
39
39
scope 9 (inlined NonNull::<[u8]>::as_ptr) {
40
40
debug self => _5;
41
- let mut _18: *const [u8];
41
+ let mut _18: bool;
42
+ let mut _19: bool;
43
+ let mut _20: *const [u8];
44
+ scope 10 {
45
+ scope 11 (inlined std::ptr::const_ptr::<impl *const [u8]>::is_null) {
46
+ debug self => _20;
47
+ let mut _21: *const u8;
48
+ scope 12 {
49
+ scope 13 (inlined std::ptr::const_ptr::<impl *const T>::is_null::runtime_impl) {
50
+ debug ptr => _21;
51
+ let mut _22: usize;
52
+ scope 14 (inlined std::ptr::const_ptr::<impl *const u8>::addr) {
53
+ debug self => _21;
54
+ let mut _23: *const ();
55
+ scope 15 {
56
+ scope 16 (inlined std::ptr::const_ptr::<impl *const u8>::cast::<()>) {
57
+ debug self => _21;
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
42
65
}
43
66
}
44
67
scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
105
128
StorageDead(_15);
106
129
StorageDead(_12);
107
130
StorageDead(_6);
131
+ StorageLive(_20);
108
132
StorageLive(_18);
109
- _18 = (_5.0: *const [u8]);
110
- _4 = move _18 as *mut [u8] (PtrToPtr);
133
+ StorageLive(_19);
134
+ _20 = (_5.0: *const [u8]);
135
+ StorageLive(_21);
136
+ _21 = _20 as *const u8 (PtrToPtr);
137
+ StorageLive(_22);
138
+ StorageLive(_23);
139
+ _23 = _21 as *const () (PtrToPtr);
140
+ _22 = move _23 as usize (Transmute);
141
+ StorageDead(_23);
142
+ _19 = Eq(move _22, const 0_usize);
143
+ StorageDead(_22);
144
+ StorageDead(_21);
145
+ _18 = Not(move _19);
146
+ StorageDead(_19);
147
+ assume(move _18);
111
148
StorageDead(_18);
149
+ _4 = _20 as *mut [u8] (PtrToPtr);
150
+ StorageDead(_20);
112
151
StorageDead(_5);
113
152
_3 = move _4 as *mut u8 (PtrToPtr);
114
153
StorageDead(_4);
Original file line number Diff line number Diff line change 23
23
}
24
24
scope 6 (inlined NonNull::<[u8]>::as_ptr) {
25
25
debug self => _5;
26
- let mut _12: *const [u8];
26
+ let mut _12: bool;
27
+ let mut _13: bool;
28
+ let mut _14: *const [u8];
29
+ scope 7 {
30
+ scope 8 (inlined std::ptr::const_ptr::<impl *const [u8]>::is_null) {
31
+ debug self => _14;
32
+ let mut _15: *const u8;
33
+ scope 9 {
34
+ scope 10 (inlined std::ptr::const_ptr::<impl *const T>::is_null::runtime_impl) {
35
+ debug ptr => _15;
36
+ let mut _16: usize;
37
+ scope 11 (inlined std::ptr::const_ptr::<impl *const u8>::addr) {
38
+ debug self => _15;
39
+ let mut _17: *const ();
40
+ scope 12 {
41
+ scope 13 (inlined std::ptr::const_ptr::<impl *const u8>::cast::<()>) {
42
+ debug self => _15;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
27
50
}
28
51
}
29
52
scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
48
71
49
72
bb1: {
50
73
StorageDead(_6);
74
+ StorageLive(_14);
51
75
StorageLive(_12);
52
- _12 = (_5.0: *const [u8]);
53
- _4 = move _12 as *mut [u8] (PtrToPtr);
76
+ StorageLive(_13);
77
+ _14 = (_5.0: *const [u8]);
78
+ StorageLive(_15);
79
+ _15 = _14 as *const u8 (PtrToPtr);
80
+ StorageLive(_16);
81
+ StorageLive(_17);
82
+ _17 = _15 as *const () (PtrToPtr);
83
+ _16 = move _17 as usize (Transmute);
84
+ StorageDead(_17);
85
+ _13 = Eq(move _16, const 0_usize);
86
+ StorageDead(_16);
87
+ StorageDead(_15);
88
+ _12 = Not(move _13);
89
+ StorageDead(_13);
90
+ assume(move _12);
54
91
StorageDead(_12);
92
+ _4 = _14 as *mut [u8] (PtrToPtr);
93
+ StorageDead(_14);
55
94
StorageDead(_5);
56
95
_3 = move _4 as *mut u8 (PtrToPtr);
57
96
StorageDead(_4);
Original file line number Diff line number Diff line change 38
38
}
39
39
scope 9 (inlined NonNull::<[u8]>::as_ptr) {
40
40
debug self => _5;
41
- let mut _18: *const [u8];
41
+ let mut _18: bool;
42
+ let mut _19: bool;
43
+ let mut _20: *const [u8];
44
+ scope 10 {
45
+ scope 11 (inlined std::ptr::const_ptr::<impl *const [u8]>::is_null) {
46
+ debug self => _20;
47
+ let mut _21: *const u8;
48
+ scope 12 {
49
+ scope 13 (inlined std::ptr::const_ptr::<impl *const T>::is_null::runtime_impl) {
50
+ debug ptr => _21;
51
+ let mut _22: usize;
52
+ scope 14 (inlined std::ptr::const_ptr::<impl *const u8>::addr) {
53
+ debug self => _21;
54
+ let mut _23: *const ();
55
+ scope 15 {
56
+ scope 16 (inlined std::ptr::const_ptr::<impl *const u8>::cast::<()>) {
57
+ debug self => _21;
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
42
65
}
43
66
}
44
67
scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
105
128
StorageDead(_15);
106
129
StorageDead(_12);
107
130
StorageDead(_6);
131
+ StorageLive(_20);
108
132
StorageLive(_18);
109
- _18 = (_5.0: *const [u8]);
110
- _4 = move _18 as *mut [u8] (PtrToPtr);
133
+ StorageLive(_19);
134
+ _20 = (_5.0: *const [u8]);
135
+ StorageLive(_21);
136
+ _21 = _20 as *const u8 (PtrToPtr);
137
+ StorageLive(_22);
138
+ StorageLive(_23);
139
+ _23 = _21 as *const () (PtrToPtr);
140
+ _22 = move _23 as usize (Transmute);
141
+ StorageDead(_23);
142
+ _19 = Eq(move _22, const 0_usize);
143
+ StorageDead(_22);
144
+ StorageDead(_21);
145
+ _18 = Not(move _19);
146
+ StorageDead(_19);
147
+ assume(move _18);
111
148
StorageDead(_18);
149
+ _4 = _20 as *mut [u8] (PtrToPtr);
150
+ StorageDead(_20);
112
151
StorageDead(_5);
113
152
_3 = move _4 as *mut u8 (PtrToPtr);
114
153
StorageDead(_4);
Original file line number Diff line number Diff line change 23
23
}
24
24
scope 6 (inlined NonNull::<[u8]>::as_ptr) {
25
25
debug self => _5;
26
- let mut _12: *const [u8];
26
+ let mut _12: bool;
27
+ let mut _13: bool;
28
+ let mut _14: *const [u8];
29
+ scope 7 {
30
+ scope 8 (inlined std::ptr::const_ptr::<impl *const [u8]>::is_null) {
31
+ debug self => _14;
32
+ let mut _15: *const u8;
33
+ scope 9 {
34
+ scope 10 (inlined std::ptr::const_ptr::<impl *const T>::is_null::runtime_impl) {
35
+ debug ptr => _15;
36
+ let mut _16: usize;
37
+ scope 11 (inlined std::ptr::const_ptr::<impl *const u8>::addr) {
38
+ debug self => _15;
39
+ let mut _17: *const ();
40
+ scope 12 {
41
+ scope 13 (inlined std::ptr::const_ptr::<impl *const u8>::cast::<()>) {
42
+ debug self => _15;
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
27
50
}
28
51
}
29
52
scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) {
48
71
49
72
bb1: {
50
73
StorageDead(_6);
74
+ StorageLive(_14);
51
75
StorageLive(_12);
52
- _12 = (_5.0: *const [u8]);
53
- _4 = move _12 as *mut [u8] (PtrToPtr);
76
+ StorageLive(_13);
77
+ _14 = (_5.0: *const [u8]);
78
+ StorageLive(_15);
79
+ _15 = _14 as *const u8 (PtrToPtr);
80
+ StorageLive(_16);
81
+ StorageLive(_17);
82
+ _17 = _15 as *const () (PtrToPtr);
83
+ _16 = move _17 as usize (Transmute);
84
+ StorageDead(_17);
85
+ _13 = Eq(move _16, const 0_usize);
86
+ StorageDead(_16);
87
+ StorageDead(_15);
88
+ _12 = Not(move _13);
89
+ StorageDead(_13);
90
+ assume(move _12);
54
91
StorageDead(_12);
92
+ _4 = _14 as *mut [u8] (PtrToPtr);
93
+ StorageDead(_14);
55
94
StorageDead(_5);
56
95
_3 = move _4 as *mut u8 (PtrToPtr);
57
96
StorageDead(_4);
You can’t perform that action at this time.
0 commit comments