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
+
2
7
use std:: { marker, mem, ptr} ;
3
8
4
9
fn main ( ) { }
5
10
6
11
fn _zero ( ) {
7
12
if false {
8
13
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
11
17
} else {
12
18
return ;
13
19
} ;
@@ -21,8 +27,9 @@ fn _trans() {
21
27
unsafe {
22
28
struct Zst ;
23
29
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
26
33
}
27
34
} else {
28
35
return ;
@@ -37,8 +44,9 @@ fn _union() {
37
44
}
38
45
39
46
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
42
50
} else {
43
51
return ;
44
52
} ;
@@ -47,8 +55,9 @@ fn _union() {
47
55
fn _deref ( ) {
48
56
if false {
49
57
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
52
61
} else {
53
62
return ;
54
63
} ;
@@ -57,16 +66,19 @@ fn _deref() {
57
66
fn _only_generics ( ) {
58
67
if false {
59
68
unsafe fn internally_create < T > ( _: Option < T > ) {
60
- let _ = mem:: zeroed :: < T > ( ) ;
69
+ unsafe {
70
+ let _ = mem:: zeroed :: < T > ( ) ;
71
+ }
61
72
}
62
73
63
74
// We need the option (and unwrap later) to call a function in a way,
64
75
// which makes it affected by the fallback, but without having it return anything
65
76
let x = None ;
66
77
67
78
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
70
82
71
83
x. unwrap ( )
72
84
} else {
@@ -77,12 +89,14 @@ fn _only_generics() {
77
89
fn _stored_function ( ) {
78
90
if false {
79
91
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
82
95
83
96
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
86
100
} else {
87
101
return ;
88
102
} ;
@@ -91,13 +105,16 @@ fn _stored_function() {
91
105
fn _only_generics_stored_function ( ) {
92
106
if false {
93
107
unsafe fn internally_create < T > ( _: Option < T > ) {
94
- let _ = mem:: zeroed :: < T > ( ) ;
108
+ unsafe {
109
+ let _ = mem:: zeroed :: < T > ( ) ;
110
+ }
95
111
}
96
112
97
113
let x = None ;
98
114
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
101
118
102
119
unsafe { f ( x) }
103
120
@@ -120,8 +137,9 @@ fn _method() {
120
137
if false {
121
138
unsafe {
122
139
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
125
143
}
126
144
} else {
127
145
return ;
@@ -137,8 +155,9 @@ fn _objc() {
137
155
macro_rules! msg_send {
138
156
( ) => {
139
157
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
142
161
Ok ( x) => x,
143
162
Err ( _) => loop { } ,
144
163
}
0 commit comments