File tree 3 files changed +7
-7
lines changed
compiler/rustc_middle/src/mir
3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ impl UnsafetyViolationDetails {
95
95
and cause data races: all of these are undefined behavior",
96
96
) ,
97
97
AssignToDroppingUnionField => (
98
- "assignment to union field that needs dropping" ,
98
+ "assignment to union field that might need dropping" ,
99
99
"the previous content of the field will be dropped, which causes undefined \
100
100
behavior if the field was not properly initialized",
101
101
) ,
Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ fn deref_union_field(mut u: URef) {
32
32
}
33
33
34
34
fn assign_noncopy_union_field ( mut u : URefCell ) {
35
- u. a = ( RefCell :: new ( 0 ) , 1 ) ; //~ ERROR assignment to union field that needs dropping
36
- u. a . 0 = RefCell :: new ( 0 ) ; //~ ERROR assignment to union field that needs dropping
35
+ u. a = ( RefCell :: new ( 0 ) , 1 ) ; //~ ERROR assignment to union field that might need dropping
36
+ u. a . 0 = RefCell :: new ( 0 ) ; //~ ERROR assignment to union field that might need dropping
37
37
u. a . 1 = 1 ; // OK
38
38
}
39
39
Original file line number Diff line number Diff line change @@ -6,19 +6,19 @@ LL | *(u.p) = 13;
6
6
|
7
7
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
8
8
9
- error[E0133]: assignment to union field that needs dropping is unsafe and requires unsafe function or block
9
+ error[E0133]: assignment to union field that might need dropping is unsafe and requires unsafe function or block
10
10
--> $DIR/union-unsafe.rs:35:5
11
11
|
12
12
LL | u.a = (RefCell::new(0), 1);
13
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that needs dropping
13
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that might need dropping
14
14
|
15
15
= note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized
16
16
17
- error[E0133]: assignment to union field that needs dropping is unsafe and requires unsafe function or block
17
+ error[E0133]: assignment to union field that might need dropping is unsafe and requires unsafe function or block
18
18
--> $DIR/union-unsafe.rs:36:5
19
19
|
20
20
LL | u.a.0 = RefCell::new(0);
21
- | ^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that needs dropping
21
+ | ^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that might need dropping
22
22
|
23
23
= note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized
24
24
You can’t perform that action at this time.
0 commit comments