Don't report E0740 for type error

This commit is contained in:
Michael Goulet 2023-03-07 22:03:12 +00:00
parent 38b9655311
commit 08e5a77b06
3 changed files with 20 additions and 1 deletions

View File

@ -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()
}
}
}

View File

@ -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() {}

View File

@ -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`.