This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed
compiler/rustc_middle/src/mir Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ impl UnsafetyViolationDetails {
9595 and cause data races: all of these are undefined behavior",
9696 ) ,
9797 AssignToDroppingUnionField => (
98- "assignment to union field that needs dropping" ,
98+ "assignment to union field that might need dropping" ,
9999 "the previous content of the field will be dropped, which causes undefined \
100100 behavior if the field was not properly initialized",
101101 ) ,
Original file line number Diff line number Diff line change @@ -32,8 +32,8 @@ fn deref_union_field(mut u: URef) {
3232}
3333
3434fn 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
3737 u. a . 1 = 1 ; // OK
3838}
3939
Original file line number Diff line number Diff line change @@ -6,19 +6,19 @@ LL | *(u.p) = 13;
66 |
77 = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
88
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
1010 --> $DIR/union-unsafe.rs:35:5
1111 |
1212LL | u.a = (RefCell::new(0), 1);
13- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that needs dropping
13+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that might need dropping
1414 |
1515 = note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized
1616
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
1818 --> $DIR/union-unsafe.rs:36:5
1919 |
2020LL | u.a.0 = RefCell::new(0);
21- | ^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that needs dropping
21+ | ^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that might need dropping
2222 |
2323 = note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized
2424
You can’t perform that action at this time.
0 commit comments