1- //@ check-pass
1+ //@ revisions: e2015 e2024
2+ //@[e2015] check-pass
3+ //@[e2024] check-fail
4+ //@[e2024] edition:2024
5+ //@[e2024] compile-flags: -Zunstable-options
6+
27use std:: { marker, mem, ptr} ;
38
49fn main ( ) { }
510
611fn _zero ( ) {
712 if false {
813 unsafe { mem:: zeroed ( ) }
9- //~^ warn: never type fallback affects this call to an `unsafe` function
10- //~| warn: this will change its meaning in a future release!
14+ //[e2015]~^ warn: never type fallback affects this call to an `unsafe` function
15+ //[e2015]~| warn: this will change its meaning in a future release!
16+ //[e2024]~^^^ error: never type fallback affects this call to an `unsafe` function
1117 } else {
1218 return ;
1319 } ;
@@ -21,8 +27,9 @@ fn _trans() {
2127 unsafe {
2228 struct Zst ;
2329 core:: mem:: transmute ( Zst )
24- //~^ warn: never type fallback affects this call to an `unsafe` function
25- //~| warn: this will change its meaning in a future release!
30+ //[e2015]~^ warn: never type fallback affects this call to an `unsafe` function
31+ //[e2015]~| warn: this will change its meaning in a future release!
32+ //[e2024]~^^^ error: never type fallback affects this call to an `unsafe` function
2633 }
2734 } else {
2835 return ;
@@ -37,8 +44,9 @@ fn _union() {
3744 }
3845
3946 unsafe { Union { a : ( ) } . b }
40- //~^ warn: never type fallback affects this union access
41- //~| warn: this will change its meaning in a future release!
47+ //[e2015]~^ warn: never type fallback affects this union access
48+ //[e2015]~| warn: this will change its meaning in a future release!
49+ //[e2024]~^^^ error: never type fallback affects this union access
4250 } else {
4351 return ;
4452 } ;
@@ -47,8 +55,9 @@ fn _union() {
4755fn _deref ( ) {
4856 if false {
4957 unsafe { * ptr:: from_ref ( & ( ) ) . cast ( ) }
50- //~^ warn: never type fallback affects this raw pointer dereference
51- //~| warn: this will change its meaning in a future release!
58+ //[e2015]~^ warn: never type fallback affects this raw pointer dereference
59+ //[e2015]~| warn: this will change its meaning in a future release!
60+ //[e2024]~^^^ error: never type fallback affects this raw pointer dereference
5261 } else {
5362 return ;
5463 } ;
@@ -57,16 +66,19 @@ fn _deref() {
5766fn _only_generics ( ) {
5867 if false {
5968 unsafe fn internally_create < T > ( _: Option < T > ) {
60- let _ = mem:: zeroed :: < T > ( ) ;
69+ unsafe {
70+ let _ = mem:: zeroed :: < T > ( ) ;
71+ }
6172 }
6273
6374 // We need the option (and unwrap later) to call a function in a way,
6475 // which makes it affected by the fallback, but without having it return anything
6576 let x = None ;
6677
6778 unsafe { internally_create ( x) }
68- //~^ warn: never type fallback affects this call to an `unsafe` function
69- //~| warn: this will change its meaning in a future release!
79+ //[e2015]~^ warn: never type fallback affects this call to an `unsafe` function
80+ //[e2015]~| warn: this will change its meaning in a future release!
81+ //[e2024]~^^^ error: never type fallback affects this call to an `unsafe` function
7082
7183 x. unwrap ( )
7284 } else {
@@ -77,12 +89,14 @@ fn _only_generics() {
7789fn _stored_function ( ) {
7890 if false {
7991 let zeroed = mem:: zeroed;
80- //~^ warn: never type fallback affects this `unsafe` function
81- //~| warn: this will change its meaning in a future release!
92+ //[e2015]~^ warn: never type fallback affects this `unsafe` function
93+ //[e2015]~| warn: this will change its meaning in a future release!
94+ //[e2024]~^^^ error: never type fallback affects this `unsafe` function
8295
8396 unsafe { zeroed ( ) }
84- //~^ warn: never type fallback affects this call to an `unsafe` function
85- //~| warn: this will change its meaning in a future release!
97+ //[e2015]~^ warn: never type fallback affects this call to an `unsafe` function
98+ //[e2015]~| warn: this will change its meaning in a future release!
99+ //[e2024]~^^^ error: never type fallback affects this call to an `unsafe` function
86100 } else {
87101 return ;
88102 } ;
@@ -91,13 +105,16 @@ fn _stored_function() {
91105fn _only_generics_stored_function ( ) {
92106 if false {
93107 unsafe fn internally_create < T > ( _: Option < T > ) {
94- let _ = mem:: zeroed :: < T > ( ) ;
108+ unsafe {
109+ let _ = mem:: zeroed :: < T > ( ) ;
110+ }
95111 }
96112
97113 let x = None ;
98114 let f = internally_create;
99- //~^ warn: never type fallback affects this `unsafe` function
100- //~| warn: this will change its meaning in a future release!
115+ //[e2015]~^ warn: never type fallback affects this `unsafe` function
116+ //[e2015]~| warn: this will change its meaning in a future release!
117+ //[e2024]~^^^ error: never type fallback affects this `unsafe` function
101118
102119 unsafe { f ( x) }
103120
@@ -120,8 +137,9 @@ fn _method() {
120137 if false {
121138 unsafe {
122139 S ( marker:: PhantomData ) . create_out_of_thin_air ( )
123- //~^ warn: never type fallback affects this call to an `unsafe` method
124- //~| warn: this will change its meaning in a future release!
140+ //[e2015]~^ warn: never type fallback affects this call to an `unsafe` method
141+ //[e2015]~| warn: this will change its meaning in a future release!
142+ //[e2024]~^^^ error: never type fallback affects this call to an `unsafe` method
125143 }
126144 } else {
127145 return ;
@@ -137,8 +155,9 @@ fn _objc() {
137155 macro_rules! msg_send {
138156 ( ) => {
139157 match send_message:: <_ /* ?0 */ >( ) {
140- //~^ warn: never type fallback affects this call to an `unsafe` function
141- //~| warn: this will change its meaning in a future release!
158+ //[e2015]~^ warn: never type fallback affects this call to an `unsafe` function
159+ //[e2015]~| warn: this will change its meaning in a future release!
160+ //[e2024]~^^^ error: never type fallback affects this call to an `unsafe` function
142161 Ok ( x) => x,
143162 Err ( _) => loop { } ,
144163 }
0 commit comments