Skip to content

Commit

Permalink
Report even duplilcate errors in case the feature gat is not active
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Oct 21, 2019
1 parent 0653694 commit 875bdd5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
5 changes: 0 additions & 5 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -1394,11 +1394,6 @@ fn check_union(tcx: TyCtxt<'_>, id: hir::HirId, span: Span) {
/// When the `#![feature(untagged_unions)]` gate is active,
/// check that the fields of the `union` does not contain fields that need dropping.
fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: DefId) -> bool {
// Without the feature we check that all fields are `Copy` in our stability checking
// infrastructure.
if !tcx.features().untagged_unions {
return true;
}
let item_type = tcx.type_of(item_def_id);
if let ty::Adt(def, substs) = item_type.kind {
assert!(def.is_union());
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/feature-gates/feature-gate-untagged_unions.rs
Expand Up @@ -7,11 +7,11 @@ union U2<T: Copy> { // OK
}

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

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

union U5 { //~ ERROR unions with `Drop` implementations are unstable
Expand Down
29 changes: 27 additions & 2 deletions src/test/ui/feature-gates/feature-gate-untagged_unions.stderr
Expand Up @@ -31,6 +31,31 @@ LL | | }
= note: for more information, see https://github.com/rust-lang/rust/issues/32836
= help: add `#![feature(untagged_unions)]` to the crate attributes to enable

error: aborting due to 3 previous errors
error[E0740]: unions may not contain fields that need dropping
--> $DIR/feature-gate-untagged_unions.rs:10:5
|
LL | a: String,
| ^^^^^^^^^
|
note: `std::mem::ManuallyDrop` can be used to wrap the type
--> $DIR/feature-gate-untagged_unions.rs:10:5
|
LL | a: String,
| ^^^^^^^^^

error[E0740]: unions may not contain fields that need dropping
--> $DIR/feature-gate-untagged_unions.rs:14:5
|
LL | a: T,
| ^^^^
|
note: `std::mem::ManuallyDrop` can be used to wrap the type
--> $DIR/feature-gate-untagged_unions.rs:14:5
|
LL | a: T,
| ^^^^

error: aborting due to 5 previous errors

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

0 comments on commit 875bdd5

Please sign in to comment.