Don't requery the param_env of a union

Union fields have the ParamEnv of the union.
This commit is contained in:
Matthew Jasper 2020-01-30 20:24:44 +00:00
parent f43c34a134
commit 91cf0e7411

View file

@ -1545,11 +1545,11 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: DefId) -> bool {
if let ty::Adt(def, substs) = item_type.kind {
assert!(def.is_union());
let fields = &def.non_enum_variant().fields;
let param_env = tcx.param_env(item_def_id);
for field in fields {
let field_ty = field.ty(tcx, substs);
// We are currently checking the type this field came from, so it must be local.
let field_span = tcx.hir().span_if_local(field.did).unwrap();
let param_env = tcx.param_env(field.did);
if field_ty.needs_drop(tcx, param_env) {
struct_span_err!(
tcx.sess,