Skip to content

Commit 08e5a77

Browse files
Don't report E0740 for type error
1 parent 38b9655 commit 08e5a77

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
114114
allowed_union_field(*elem, tcx, param_env)
115115
}
116116
_ => {
117-
// Fallback case: allow `ManuallyDrop` and things that are `Copy`.
117+
// Fallback case: allow `ManuallyDrop` and things that are `Copy`,
118+
// also no need to report an error if the type is unresolved.
118119
ty.ty_adt_def().is_some_and(|adt_def| adt_def.is_manually_drop())
119120
|| ty.is_copy_modulo_regions(tcx, param_env)
121+
|| ty.references_error()
120122
}
121123
}
122124
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Unresolved fields are not copy, but also shouldn't report an extra E0740.
2+
3+
pub union Foo {
4+
x: *const Missing,
5+
//~^ ERROR cannot find type `Missing` in this scope
6+
}
7+
8+
fn main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `Missing` in this scope
2+
--> $DIR/unresolved-field-isnt-copy.rs:4:15
3+
|
4+
LL | x: *const Missing,
5+
| ^^^^^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)