Skip to content

Commit

Permalink
Don't report E0740 for type error
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Mar 8, 2023
1 parent 38b9655 commit 08e5a77
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
allowed_union_field(*elem, tcx, param_env)
}
_ => {
// Fallback case: allow `ManuallyDrop` and things that are `Copy`.
// Fallback case: allow `ManuallyDrop` and things that are `Copy`,
// also no need to report an error if the type is unresolved.
ty.ty_adt_def().is_some_and(|adt_def| adt_def.is_manually_drop())
|| ty.is_copy_modulo_regions(tcx, param_env)
|| ty.references_error()
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/union/unresolved-field-isnt-copy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Unresolved fields are not copy, but also shouldn't report an extra E0740.

pub union Foo {
x: *const Missing,
//~^ ERROR cannot find type `Missing` in this scope
}

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/union/unresolved-field-isnt-copy.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0412]: cannot find type `Missing` in this scope
--> $DIR/unresolved-field-isnt-copy.rs:4:15
|
LL | x: *const Missing,
| ^^^^^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0412`.

0 comments on commit 08e5a77

Please sign in to comment.