about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2020-01-30 20:24:44 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2020-02-02 21:46:29 +0000
commit91cf0e741186a9fa3bf31b07a65dc89324c10296 (patch)
tree3ba9c47408c93cccd614100ad44824b5b9e8f3e0
parentf43c34a134358471726f25fe5973b8c7e177c825 (diff)
downloadrust-91cf0e741186a9fa3bf31b07a65dc89324c10296.tar.gz
rust-91cf0e741186a9fa3bf31b07a65dc89324c10296.zip
Don't requery the param_env of a union
Union fields have the ParamEnv of the union.
-rw-r--r--src/librustc_typeck/check/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 0a917a1853e..8d2cfd9a335 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -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,