about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <github35764891676564198441@oli-obk.de>2018-07-13 16:55:15 +0200
committerOliver Schneider <github35764891676564198441@oli-obk.de>2018-08-07 14:41:33 +0200
commit07e2dd7d96a7fb235ac8a4a56f5c436e381f573d (patch)
tree45623a37a68afc491c09aab95c23c0633c03df78
parentc0aedc0b6a64c919bb618b7c7ffe2622338302dd (diff)
downloadrust-07e2dd7d96a7fb235ac8a4a56f5c436e381f573d.tar.gz
rust-07e2dd7d96a7fb235ac8a4a56f5c436e381f573d.zip
Don't accidentally promote union access in MIR
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs2
-rw-r--r--src/test/ui/const-eval/union_promotion.nll.stderr11
2 files changed, 1 insertions, 12 deletions
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index 89d539f6bca..7a724a2e394 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -515,7 +515,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
                             if let Some(def) = base_ty.ty_adt_def() {
                                 if def.is_union() {
                                     match this.mode {
-                                        Mode::Fn => {},
+                                        Mode::Fn => this.not_const(),
                                         Mode::ConstFn => {
                                             if !this.tcx.sess.features_untracked().const_fn_union {
                                                 emit_feature_err(
diff --git a/src/test/ui/const-eval/union_promotion.nll.stderr b/src/test/ui/const-eval/union_promotion.nll.stderr
deleted file mode 100644
index ea95a8b42a4..00000000000
--- a/src/test/ui/const-eval/union_promotion.nll.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: internal compiler error: unexpected region for local data ReStatic
-  --> $DIR/union_promotion.rs:19:29
-   |
-LL |       let x: &'static bool = &unsafe { //~ borrowed value does not live long enough
-   |  _____________________________^
-LL | |         Foo { a: &1 }.b == Foo { a: &2 }.b
-LL | |     };
-   | |_____^
-
-error: aborting due to previous error
-