Skip to content

Commit 875bdd5

Browse files
committed
Report even duplilcate errors in case the feature gat is not active
1 parent 0653694 commit 875bdd5

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

src/librustc_typeck/check/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1394,11 +1394,6 @@ fn check_union(tcx: TyCtxt<'_>, id: hir::HirId, span: Span) {
13941394
/// When the `#![feature(untagged_unions)]` gate is active,
13951395
/// check that the fields of the `union` does not contain fields that need dropping.
13961396
fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: DefId) -> bool {
1397-
// Without the feature we check that all fields are `Copy` in our stability checking
1398-
// infrastructure.
1399-
if !tcx.features().untagged_unions {
1400-
return true;
1401-
}
14021397
let item_type = tcx.type_of(item_def_id);
14031398
if let ty::Adt(def, substs) = item_type.kind {
14041399
assert!(def.is_union());

src/test/ui/feature-gates/feature-gate-untagged_unions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ union U2<T: Copy> { // OK
77
}
88

99
union U3 { //~ ERROR unions with non-`Copy` fields are unstable
10-
a: String,
10+
a: String, //~ ERROR unions may not contain fields that need dropping
1111
}
1212

1313
union U4<T> { //~ ERROR unions with non-`Copy` fields are unstable
14-
a: T,
14+
a: T, //~ ERROR unions may not contain fields that need dropping
1515
}
1616

1717
union U5 { //~ ERROR unions with `Drop` implementations are unstable

src/test/ui/feature-gates/feature-gate-untagged_unions.stderr

+27-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,31 @@ LL | | }
3131
= note: for more information, see https://github.com/rust-lang/rust/issues/32836
3232
= help: add `#![feature(untagged_unions)]` to the crate attributes to enable
3333

34-
error: aborting due to 3 previous errors
34+
error[E0740]: unions may not contain fields that need dropping
35+
--> $DIR/feature-gate-untagged_unions.rs:10:5
36+
|
37+
LL | a: String,
38+
| ^^^^^^^^^
39+
|
40+
note: `std::mem::ManuallyDrop` can be used to wrap the type
41+
--> $DIR/feature-gate-untagged_unions.rs:10:5
42+
|
43+
LL | a: String,
44+
| ^^^^^^^^^
45+
46+
error[E0740]: unions may not contain fields that need dropping
47+
--> $DIR/feature-gate-untagged_unions.rs:14:5
48+
|
49+
LL | a: T,
50+
| ^^^^
51+
|
52+
note: `std::mem::ManuallyDrop` can be used to wrap the type
53+
--> $DIR/feature-gate-untagged_unions.rs:14:5
54+
|
55+
LL | a: T,
56+
| ^^^^
57+
58+
error: aborting due to 5 previous errors
3559

36-
For more information about this error, try `rustc --explain E0658`.
60+
Some errors have detailed explanations: E0658, E0740.
61+
For more information about an error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)