]> git.lizzy.rs Git - rust.git/commitdiff
Allow `let` bindings everywhere
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 24 Nov 2018 13:38:31 +0000 (14:38 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Fri, 30 Nov 2018 08:44:06 +0000 (09:44 +0100)
76 files changed:
src/librustc/mir/mod.rs
src/librustc_mir/build/mod.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/mod.rs
src/librustc_mir/shim.rs
src/librustc_mir/transform/promote_consts.rs
src/librustc_mir/transform/qualify_consts.rs
src/libsyntax/feature_gate.rs
src/test/run-pass/ctfe/const-block-non-item-statement-3.rs
src/test/run-pass/ctfe/const-block-non-item-statement.rs
src/test/run-pass/ctfe/locals-in-const-fn.rs
src/test/ui/check-static-values-constraints.nll.stderr
src/test/ui/check-static-values-constraints.rs
src/test/ui/check-static-values-constraints.stderr
src/test/ui/consts/const-block-non-item-statement-2.rs
src/test/ui/consts/const-block-non-item-statement-2.stderr [deleted file]
src/test/ui/consts/const-block-non-item-statement-3.rs
src/test/ui/consts/const-block-non-item-statement-3.stderr [deleted file]
src/test/ui/consts/const-block-non-item-statement.rs
src/test/ui/consts/const-block-non-item-statement.stderr [deleted file]
src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs
src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr
src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs
src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr
src/test/ui/consts/const-eval/const_let.rs
src/test/ui/consts/const-eval/const_let.stderr
src/test/ui/consts/const-eval/infinite_loop.rs
src/test/ui/consts/const-eval/infinite_loop.stderr
src/test/ui/consts/const-eval/issue-52475.rs
src/test/ui/consts/const-eval/issue-52475.stderr
src/test/ui/consts/const-eval/mod-static-with-const-fn.rs
src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr
src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr
src/test/ui/consts/const-eval/ub-upvars.rs
src/test/ui/consts/const_let_assign.rs
src/test/ui/consts/const_let_assign3.rs
src/test/ui/consts/const_let_assign3.stderr
src/test/ui/consts/dangling-alloc-id-ice.rs
src/test/ui/consts/dangling-alloc-id-ice.stderr
src/test/ui/consts/dangling_raw_ptr.rs
src/test/ui/consts/dangling_raw_ptr.stderr
src/test/ui/consts/issue-54224.rs
src/test/ui/consts/issue-54224.stderr [deleted file]
src/test/ui/consts/min_const_fn/mutable_borrow.nll.stderr [new file with mode: 0644]
src/test/ui/consts/min_const_fn/mutable_borrow.rs
src/test/ui/consts/min_const_fn/mutable_borrow.stderr
src/test/ui/consts/partial_qualif.rs
src/test/ui/consts/partial_qualif.stderr
src/test/ui/consts/projection_qualif.rs
src/test/ui/consts/projection_qualif.stderr
src/test/ui/consts/promote_const_let.nll.stderr
src/test/ui/consts/promote_const_let.rs
src/test/ui/consts/promote_const_let.stderr
src/test/ui/consts/qualif_overwrite.rs
src/test/ui/consts/qualif_overwrite.stderr
src/test/ui/consts/qualif_overwrite_2.rs
src/test/ui/consts/qualif_overwrite_2.stderr
src/test/ui/error-codes/E0010-teach.rs
src/test/ui/error-codes/E0010-teach.stderr
src/test/ui/error-codes/E0010.rs
src/test/ui/error-codes/E0010.stderr
src/test/ui/feature-gate-underscore_const_names.rs
src/test/ui/feature-gate-underscore_const_names.stderr
src/test/ui/feature-gates/feature-gate-const_let.rs [deleted file]
src/test/ui/issues/issue-18118.nll.stderr
src/test/ui/issues/issue-18118.rs
src/test/ui/issues/issue-18118.stderr
src/test/ui/issues/issue-32829-2.rs
src/test/ui/issues/issue-32829-2.stderr
src/test/ui/issues/issue-7364.rs
src/test/ui/issues/issue-7364.stderr
src/test/ui/static/static-mut-not-constant.rs
src/test/ui/static/static-mut-not-constant.stderr
src/test/ui/underscore_const_names.rs
src/test/ui/write-to-static-mut-in-static.rs
src/test/ui/write-to-static-mut-in-static.stderr

index 2607f5fd08b4217d9d93f6ee07f20b8aee401613..a82a7b555a05e869b970f2e5f124af5bca8f8810 100644 (file)
@@ -149,6 +149,12 @@ pub struct Mir<'tcx> {
     /// This is used for the "rust-call" ABI.
     pub spread_arg: Option<Local>,
 
+    /// Mark this MIR of a const context other than const functions as having converted a `&&` or
+    /// `||` expression into `&` or `|` respectively. This is problematic because if we ever stop
+    /// this conversion from happening and use short circuiting, we will cause the following code
+    /// to change the value of `x`: `let mut x = 42; false && { x = 55; true };`
+    pub const_can_have_let_mut_bindings: bool,
+
     /// A span representing this MIR, for error reporting
     pub span: Span,
 
@@ -167,6 +173,7 @@ pub fn new(
         arg_count: usize,
         upvar_decls: Vec<UpvarDecl>,
         span: Span,
+        const_can_have_let_mut_bindings: bool,
     ) -> Self {
         // We need `arg_count` locals, and one for the return place
         assert!(
@@ -191,6 +198,7 @@ pub fn new(
             spread_arg: None,
             span,
             cache: cache::Cache::new(),
+            const_can_have_let_mut_bindings,
         }
     }
 
@@ -421,6 +429,7 @@ pub enum Safety {
     arg_count,
     upvar_decls,
     spread_arg,
+    const_can_have_let_mut_bindings,
     span,
     cache
 });
@@ -2974,6 +2983,7 @@ impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
         arg_count,
         upvar_decls,
         spread_arg,
+        const_can_have_let_mut_bindings,
         span,
         cache,
     }
index d95a74be77696018fffe42c381b30c9885af4e69..ab19cd9dd5bedf5cbddc6ac2c19dbe35f607e5a7 100644 (file)
@@ -854,15 +854,17 @@ fn finish(self,
             }
         }
 
-        Mir::new(self.cfg.basic_blocks,
-                 self.source_scopes,
-                 ClearCrossCrate::Set(self.source_scope_local_data),
-                 IndexVec::new(),
-                 yield_ty,
-                 self.local_decls,
-                 self.arg_count,
-                 self.upvar_decls,
-                 self.fn_span
+        Mir::new(
+            self.cfg.basic_blocks,
+            self.source_scopes,
+            ClearCrossCrate::Set(self.source_scope_local_data),
+            IndexVec::new(),
+            yield_ty,
+            self.local_decls,
+            self.arg_count,
+            self.upvar_decls,
+            self.fn_span,
+            self.hir.const_can_have_let_mut_bindings(),
         )
     }
 
index 2e9edf20c5708f3e2dc966fd2d04a10f9d1fa44d..951651aa1ce1c6b0d44a8b57dcaab0e5aadf74fa 100644 (file)
@@ -372,6 +372,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                     // FIXME(eddyb) use logical ops in constants when
                     // they can handle that kind of control-flow.
                     (hir::BinOpKind::And, hir::Constness::Const) => {
+                        cx.const_can_have_let_mut_bindings = false;
                         ExprKind::Binary {
                             op: BinOp::BitAnd,
                             lhs: lhs.to_ref(),
@@ -379,6 +380,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                         }
                     }
                     (hir::BinOpKind::Or, hir::Constness::Const) => {
+                        cx.const_can_have_let_mut_bindings = false;
                         ExprKind::Binary {
                             op: BinOp::BitOr,
                             lhs: lhs.to_ref(),
index c414088b653221c099ffb5f80ec38c4882fa9035..8ee1eac0e331a5afe32bdf47281d1d6bf52e8459 100644 (file)
@@ -56,6 +56,9 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
 
     /// True if this constant/function needs overflow checks.
     check_overflow: bool,
+
+    /// See field with the same name on `Mir`
+    const_can_have_let_mut_bindings: bool,
 }
 
 impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
@@ -96,9 +99,13 @@ pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
             constness,
             body_owner_kind,
             check_overflow,
+            const_can_have_let_mut_bindings: true,
         }
     }
 
+    pub fn const_can_have_let_mut_bindings(&self) -> bool {
+        self.const_can_have_let_mut_bindings
+    }
 }
 
 impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
index 93bf1b3e36e38a8c7ce5f48b69b244062e663ffa..5a08165608d53d3fd209e3befe465eeb4726bda8 100644 (file)
@@ -219,7 +219,8 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         local_decls_for_sig(&sig, span),
         sig.inputs().len(),
         vec![],
-        span
+        span,
+        true,
     );
 
     if let Some(..) = ty {
@@ -387,7 +388,8 @@ fn into_mir(self) -> Mir<'tcx> {
             self.local_decls,
             self.sig.inputs().len(),
             vec![],
-            self.span
+            self.span,
+            true,
         )
     }
 
@@ -835,7 +837,8 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         local_decls,
         sig.inputs().len(),
         vec![],
-        span
+        span,
+        true,
     );
     if let Abi::RustCall = sig.abi {
         mir.spread_arg = Some(Local::new(sig.inputs().len()));
@@ -912,6 +915,7 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
         local_decls,
         sig.inputs().len(),
         vec![],
-        span
+        span,
+        true,
     )
 }
index c5add6260789a34e485f5852b45695cc3d093374..3a0094bcd625af6ffde470600a96300845b7f848 100644 (file)
@@ -412,7 +412,8 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
                 initial_locals,
                 0,
                 vec![],
-                mir.span
+                mir.span,
+                false,
             ),
             tcx,
             source: mir,
index 61e79990f92258375fe44d50edf5f9b07fcf0f9a..8eae45376642bd19b82fce368b93b2c05482ac8c 100644 (file)
@@ -30,7 +30,7 @@
 use rustc::middle::lang_items;
 use rustc_target::spec::abi::Abi;
 use syntax::ast::LitKind;
-use syntax::feature_gate::{UnstableFeatures, feature_err, emit_feature_err, GateIssue};
+use syntax::feature_gate::{UnstableFeatures, emit_feature_err, GateIssue};
 use syntax_pos::{Span, DUMMY_SP};
 
 use std::fmt;
@@ -114,7 +114,6 @@ struct Qualifier<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
     param_env: ty::ParamEnv<'tcx>,
     local_qualif: IndexVec<Local, Option<Qualif>>,
     qualif: Qualif,
-    const_fn_arg_vars: BitSet<Local>,
     temp_promotion_state: IndexVec<Local, TempState>,
     promotion_candidates: Vec<Candidate>
 }
@@ -149,7 +148,6 @@ fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             param_env,
             local_qualif,
             qualif: Qualif::empty(),
-            const_fn_arg_vars: BitSet::new_empty(mir.local_decls.len()),
             temp_promotion_state: temps,
             promotion_candidates: vec![]
         }
@@ -178,26 +176,6 @@ fn not_const(&mut self) {
         }
     }
 
-    /// Error about extra statements in a constant.
-    fn statement_like(&mut self) {
-        self.add(Qualif::NOT_CONST);
-        if self.mode != Mode::Fn {
-            let mut err = feature_err(
-                &self.tcx.sess.parse_sess,
-                "const_let",
-                self.span,
-                GateIssue::Language,
-                &format!("statements in {}s are unstable", self.mode),
-            );
-            if self.tcx.sess.teach(&err.get_code().unwrap()) {
-                err.note("Blocks in constants may only contain items (such as constant, function \
-                          definition, etc...) and a tail expression.");
-                err.help("To avoid it, you have to replace the non-item object.");
-            }
-            err.emit();
-        }
-    }
-
     /// Add the given qualification to self.qualif.
     fn add(&mut self, qualif: Qualif) {
         self.qualif = self.qualif | qualif;
@@ -243,87 +221,48 @@ fn assign(&mut self, dest: &Place<'tcx>, location: Location) {
             return;
         }
 
-        if self.const_let_allowed() {
-            let mut dest = dest;
-            let index = loop {
-                match dest {
-                    // with `const_let` active, we treat all locals equal
-                    Place::Local(index) => break *index,
-                    // projections are transparent for assignments
-                    // we qualify the entire destination at once, even if just a field would have
-                    // stricter qualification
-                    Place::Projection(proj) => {
-                        // Catch more errors in the destination. `visit_place` also checks various
-                        // projection rules like union field access and raw pointer deref
-                        self.visit_place(
-                            dest,
-                            PlaceContext::MutatingUse(MutatingUseContext::Store),
-                            location
-                        );
-                        dest = &proj.base;
-                    },
-                    Place::Promoted(..) => bug!("promoteds don't exist yet during promotion"),
-                    Place::Static(..) => {
-                        // Catch more errors in the destination. `visit_place` also checks that we
-                        // do not try to access statics from constants or try to mutate statics
-                        self.visit_place(
-                            dest,
-                            PlaceContext::MutatingUse(MutatingUseContext::Store),
-                            location
-                        );
-                        return;
-                    }
+        let mut dest = dest;
+        let index = loop {
+            match dest {
+                Place::Local(index) => break *index,
+                // projections are transparent for assignments
+                // we qualify the entire destination at once, even if just a field would have
+                // stricter qualification
+                Place::Projection(proj) => {
+                    // Catch more errors in the destination. `visit_place` also checks various
+                    // projection rules like union field access and raw pointer deref
+                    self.visit_place(
+                        dest,
+                        PlaceContext::MutatingUse(MutatingUseContext::Store),
+                        location
+                    );
+                    dest = &proj.base;
+                },
+                Place::Promoted(..) => bug!("promoteds don't exist yet during promotion"),
+                Place::Static(..) => {
+                    // Catch more errors in the destination. `visit_place` also checks that we
+                    // do not try to access statics from constants or try to mutate statics
+                    self.visit_place(
+                        dest,
+                        PlaceContext::MutatingUse(MutatingUseContext::Store),
+                        location
+                    );
+                    return;
                 }
-            };
-            debug!("store to var {:?}", index);
-            match &mut self.local_qualif[index] {
-                // this is overly restrictive, because even full assignments do not clear the qualif
-                // While we could special case full assignments, this would be inconsistent with
-                // aggregates where we overwrite all fields via assignments, which would not get
-                // that feature.
-                Some(ref mut qualif) => *qualif = *qualif | self.qualif,
-                // insert new qualification
-                qualif @ None => *qualif = Some(self.qualif),
-            }
-            return;
-        }
-
-        match *dest {
-            Place::Local(index) if self.mir.local_kind(index) == LocalKind::Temp ||
-                                   self.mir.local_kind(index) == LocalKind::ReturnPointer => {
-                debug!("store to {:?} (temp or return pointer)", index);
-                store(&mut self.local_qualif[index])
-            }
-
-            Place::Projection(box Projection {
-                base: Place::Local(index),
-                elem: ProjectionElem::Deref
-            }) if self.mir.local_kind(index) == LocalKind::Temp
-               && self.mir.local_decls[index].ty.is_box()
-               && self.local_qualif[index].map_or(false, |qualif| {
-                    qualif.contains(Qualif::NOT_CONST)
-               }) => {
-                // Part of `box expr`, we should've errored
-                // already for the Box allocation Rvalue.
-            }
-
-            // This must be an explicit assignment.
-            _ => {
-                // Catch more errors in the destination.
-                self.visit_place(
-                    dest,
-                    PlaceContext::MutatingUse(MutatingUseContext::Store),
-                    location
-                );
-                self.statement_like();
             }
+        };
+        debug!("store to var {:?}", index);
+        match &mut self.local_qualif[index] {
+            // this is overly restrictive, because even full assignments do not clear the qualif
+            // While we could special case full assignments, this would be inconsistent with
+            // aggregates where we overwrite all fields via assignments, which would not get
+            // that feature.
+            Some(ref mut qualif) => *qualif = *qualif | self.qualif,
+            // insert new qualification
+            qualif @ None => *qualif = Some(self.qualif),
         }
     }
 
-    fn const_let_allowed(&self) -> bool {
-        self.tcx.features().const_let || self.mode == Mode::ConstFn
-    }
-
     /// Qualify a whole const, static initializer or const fn.
     fn qualify_const(&mut self) -> (Qualif, Lrc<BitSet<Local>>) {
         debug!("qualifying {} {:?}", self.mode, self.def_id);
@@ -360,48 +299,7 @@ fn qualify_const(&mut self) -> (Qualif, Lrc<BitSet<Local>>) {
                 TerminatorKind::FalseEdges { .. } |
                 TerminatorKind::FalseUnwind { .. } => None,
 
-                TerminatorKind::Return => {
-                    if !self.const_let_allowed() {
-                        // Check for unused values. This usually means
-                        // there are extra statements in the AST.
-                        for temp in mir.temps_iter() {
-                            if self.local_qualif[temp].is_none() {
-                                continue;
-                            }
-
-                            let state = self.temp_promotion_state[temp];
-                            if let TempState::Defined { location, uses: 0 } = state {
-                                let data = &mir[location.block];
-                                let stmt_idx = location.statement_index;
-
-                                // Get the span for the initialization.
-                                let source_info = if stmt_idx < data.statements.len() {
-                                    data.statements[stmt_idx].source_info
-                                } else {
-                                    data.terminator().source_info
-                                };
-                                self.span = source_info.span;
-
-                                // Treat this as a statement in the AST.
-                                self.statement_like();
-                            }
-                        }
-
-                        // Make sure there are no extra unassigned variables.
-                        self.qualif = Qualif::NOT_CONST;
-                        for index in mir.vars_iter() {
-                            if !self.const_fn_arg_vars.contains(index) {
-                                debug!("unassigned variable {:?}", index);
-                                self.assign(&Place::Local(index), Location {
-                                    block: bb,
-                                    statement_index: usize::MAX,
-                                });
-                            }
-                        }
-                    }
-
-                    break;
-                }
+                TerminatorKind::Return => break,
             };
 
             match target {
@@ -468,14 +366,6 @@ fn visit_local(&mut self,
             LocalKind::ReturnPointer => {
                 self.not_const();
             }
-            LocalKind::Var if !self.const_let_allowed() => {
-                if self.mode != Mode::Fn {
-                    emit_feature_err(&self.tcx.sess.parse_sess, "const_let",
-                                    self.span, GateIssue::Language,
-                                    &format!("let bindings in {}s are unstable",self.mode));
-                }
-                self.add(Qualif::NOT_CONST);
-            }
             LocalKind::Var |
             LocalKind::Arg |
             LocalKind::Temp => {
@@ -556,7 +446,9 @@ fn visit_place(&mut self,
                     this.super_place(place, context, location);
                     match proj.elem {
                         ProjectionElem::Deref => {
-                            this.add(Qualif::NOT_CONST);
+                            if context.is_mutating_use() {
+                                this.not_const()
+                            }
                             let base_ty = proj.base.ty(this.mir, this.tcx).to_ty(this.tcx);
                             match this.mode {
                                 Mode::Fn => {},
@@ -1291,6 +1183,19 @@ fn run_pass<'a, 'tcx>(&self,
             // Do the actual promotion, now that we know what's viable.
             promote_consts::promote_candidates(mir, tcx, temps, candidates);
         } else {
+            if !mir.const_can_have_let_mut_bindings {
+                for local in mir.mut_vars_iter() {
+                    let span = mir.local_decls[local].source_info.span;
+                    tcx.sess.span_err(
+                        span,
+                        &format!(
+                            "Cannot have both mutable bindings and \
+                            short circuiting operators in {}",
+                            mode,
+                        ),
+                    );
+                }
+            }
             let promoted_temps = if mode == Mode::Const {
                 // Already computed by `mir_const_qualif`.
                 const_promoted_temps.unwrap()
index 3bc349170514cbc8f2146695b1d74a8fc0a180a8..586659ecd9ca27451c7782023b22483c8f46872d 100644 (file)
@@ -209,9 +209,6 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
     // Allows the definition of `const fn` functions with some advanced features.
     (active, const_fn, "1.2.0", Some(24111), None),
 
-    // Allows let bindings and destructuring in `const fn` functions and constants.
-    (active, const_let, "1.22.1", Some(48821), None),
-
     // Allows accessing fields of unions inside const fn.
     (active, const_fn_union, "1.27.0", Some(51909), None),
 
index 0fcf9a5acbdb192b07427da49ab0218b93babedf..997476853ec4e3a6aaa5591c14adc7422efcf241 100644 (file)
@@ -11,8 +11,6 @@
 // run-pass
 #![allow(dead_code)]
 
-#![feature(const_let)]
-
 type Array = [u32; {  let x = 2; 5 }];
 
 pub fn main() {}
index b7ed8af35d4c1de056bdba84d0a6e7f0255ae570..0943818e2b7dc4708f8e8507864010614d8b0425 100644 (file)
@@ -11,8 +11,6 @@
 // run-pass
 #![allow(dead_code)]
 
-#![feature(const_let)]
-
 enum Foo {
     Bar = { let x = 1; 3 }
 }
index d10465b9dcd266e39c3a43d3edc35ba52b6ca939..c4413dba69fb27f983ab870db0f74f77d2c31404 100644 (file)
@@ -12,7 +12,7 @@
 
 // https://github.com/rust-lang/rust/issues/48821
 
-#![feature(const_fn, const_let)]
+#![feature(const_fn)]
 
 const fn foo(i: usize) -> usize {
     let x = i;
index 5522e22fb1fa28089a33a6c8851a39b7b52cf70a..ac549cd8d1a485af11f611ee800991634784bd24 100644 (file)
@@ -13,44 +13,80 @@ error[E0010]: allocations are not allowed in statics
 LL | static STATIC11: Box<MyOwned> = box MyOwned;
    |                                 ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:89:37
+   |
+LL | static STATIC11: Box<MyOwned> = box MyOwned;
+   |                                     ^^^^^^^
+
 error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
-  --> $DIR/check-static-values-constraints.rs:99:32
+  --> $DIR/check-static-values-constraints.rs:100:32
    |
 LL |     field2: SafeEnum::Variant4("str".to_string())
    |                                ^^^^^^^^^^^^^^^^^
 
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:104:5
+  --> $DIR/check-static-values-constraints.rs:105:5
    |
 LL |     box MyOwned, //~ ERROR allocations are not allowed in statics
    |     ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:105:9
+   |
+LL |     box MyOwned, //~ ERROR allocations are not allowed in statics
+   |         ^^^^^^^
+
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:105:5
+  --> $DIR/check-static-values-constraints.rs:107:5
    |
 LL |     box MyOwned, //~ ERROR allocations are not allowed in statics
    |     ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:107:9
+   |
+LL |     box MyOwned, //~ ERROR allocations are not allowed in statics
+   |         ^^^^^^^
+
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:109:6
+  --> $DIR/check-static-values-constraints.rs:112:6
    |
 LL |     &box MyOwned, //~ ERROR allocations are not allowed in statics
    |      ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:112:10
+   |
+LL |     &box MyOwned, //~ ERROR allocations are not allowed in statics
+   |          ^^^^^^^
+
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:110:6
+  --> $DIR/check-static-values-constraints.rs:114:6
    |
 LL |     &box MyOwned, //~ ERROR allocations are not allowed in statics
    |      ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:114:10
+   |
+LL |     &box MyOwned, //~ ERROR allocations are not allowed in statics
+   |          ^^^^^^^
+
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:116:5
+  --> $DIR/check-static-values-constraints.rs:121:5
    |
 LL |     box 3;
    |     ^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:121:9
+   |
+LL |     box 3;
+   |         ^
+
 error[E0507]: cannot move out of static item
-  --> $DIR/check-static-values-constraints.rs:120:45
+  --> $DIR/check-static-values-constraints.rs:126:45
    |
 LL |     let y = { static x: Box<isize> = box 3; x };
    |                                             ^
@@ -59,12 +95,18 @@ LL |     let y = { static x: Box<isize> = box 3; x };
    |                                             help: consider borrowing here: `&x`
 
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:120:38
+  --> $DIR/check-static-values-constraints.rs:126:38
    |
 LL |     let y = { static x: Box<isize> = box 3; x };
    |                                      ^^^^^ allocation not allowed in statics
 
-error: aborting due to 10 previous errors
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:126:42
+   |
+LL |     let y = { static x: Box<isize> = box 3; x };
+   |                                          ^
+
+error: aborting due to 17 previous errors
 
-Some errors occurred: E0010, E0015, E0493, E0507.
+Some errors occurred: E0010, E0015, E0019, E0493, E0507.
 For more information about an error, try `rustc --explain E0010`.
index 37f665960c8c821aada4c30e4382363ca050b46d..1822af333231ea6237922717c9e02b8aff961649 100644 (file)
@@ -88,6 +88,7 @@ fn drop(&mut self) {}
 
 static STATIC11: Box<MyOwned> = box MyOwned;
 //~^ ERROR allocations are not allowed in statics
+//~| ERROR contains unimplemented expression type
 
 static mut STATIC12: UnsafeStruct = UnsafeStruct;
 
@@ -102,12 +103,16 @@ fn drop(&mut self) {}
 
 static STATIC15: &'static [Box<MyOwned>] = &[
     box MyOwned, //~ ERROR allocations are not allowed in statics
+    //~^ ERROR contains unimplemented expression type
     box MyOwned, //~ ERROR allocations are not allowed in statics
+    //~^ ERROR contains unimplemented expression type
 ];
 
 static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = (
     &box MyOwned, //~ ERROR allocations are not allowed in statics
+    //~^ ERROR contains unimplemented expression type
     &box MyOwned, //~ ERROR allocations are not allowed in statics
+    //~^ ERROR contains unimplemented expression type
 );
 
 static mut STATIC17: SafeEnum = SafeEnum::Variant1;
@@ -115,9 +120,11 @@ fn drop(&mut self) {}
 static STATIC19: Box<isize> =
     box 3;
 //~^ ERROR allocations are not allowed in statics
+//~| ERROR contains unimplemented expression type
 
 pub fn main() {
     let y = { static x: Box<isize> = box 3; x };
     //~^ ERROR allocations are not allowed in statics
     //~^^ ERROR cannot move out of static item
+    //~| ERROR contains unimplemented expression type
 }
index ac979a3fa7cfcebf711441bee02b65bf6ab6e0e6..40f8555f6afa7c7a82cfa9d8e7fc31a84a4177ae 100644 (file)
@@ -13,55 +13,97 @@ error[E0010]: allocations are not allowed in statics
 LL | static STATIC11: Box<MyOwned> = box MyOwned;
    |                                 ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:89:37
+   |
+LL | static STATIC11: Box<MyOwned> = box MyOwned;
+   |                                     ^^^^^^^
+
 error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
-  --> $DIR/check-static-values-constraints.rs:99:32
+  --> $DIR/check-static-values-constraints.rs:100:32
    |
 LL |     field2: SafeEnum::Variant4("str".to_string())
    |                                ^^^^^^^^^^^^^^^^^
 
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:104:5
+  --> $DIR/check-static-values-constraints.rs:105:5
    |
 LL |     box MyOwned, //~ ERROR allocations are not allowed in statics
    |     ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:105:9
+   |
+LL |     box MyOwned, //~ ERROR allocations are not allowed in statics
+   |         ^^^^^^^
+
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:105:5
+  --> $DIR/check-static-values-constraints.rs:107:5
    |
 LL |     box MyOwned, //~ ERROR allocations are not allowed in statics
    |     ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:107:9
+   |
+LL |     box MyOwned, //~ ERROR allocations are not allowed in statics
+   |         ^^^^^^^
+
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:109:6
+  --> $DIR/check-static-values-constraints.rs:112:6
    |
 LL |     &box MyOwned, //~ ERROR allocations are not allowed in statics
    |      ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:112:10
+   |
+LL |     &box MyOwned, //~ ERROR allocations are not allowed in statics
+   |          ^^^^^^^
+
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:110:6
+  --> $DIR/check-static-values-constraints.rs:114:6
    |
 LL |     &box MyOwned, //~ ERROR allocations are not allowed in statics
    |      ^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:114:10
+   |
+LL |     &box MyOwned, //~ ERROR allocations are not allowed in statics
+   |          ^^^^^^^
+
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:116:5
+  --> $DIR/check-static-values-constraints.rs:121:5
    |
 LL |     box 3;
    |     ^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:121:9
+   |
+LL |     box 3;
+   |         ^
+
 error[E0507]: cannot move out of static item
-  --> $DIR/check-static-values-constraints.rs:120:45
+  --> $DIR/check-static-values-constraints.rs:126:45
    |
 LL |     let y = { static x: Box<isize> = box 3; x };
    |                                             ^ cannot move out of static item
 
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:120:38
+  --> $DIR/check-static-values-constraints.rs:126:38
    |
 LL |     let y = { static x: Box<isize> = box 3; x };
    |                                      ^^^^^ allocation not allowed in statics
 
-error: aborting due to 10 previous errors
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:126:42
+   |
+LL |     let y = { static x: Box<isize> = box 3; x };
+   |                                          ^
+
+error: aborting due to 17 previous errors
 
-Some errors occurred: E0010, E0015, E0493, E0507.
+Some errors occurred: E0010, E0015, E0019, E0493, E0507.
 For more information about an error, try `rustc --explain E0010`.
index f80d55cb342676dd96ec04aef47d924f65a0300f..0e96f96e3d14e92f378fdbc9640a87a6d9a38a7c 100644 (file)
@@ -8,21 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-pass
+
 const A: usize = { 1; 2 };
-//~^ ERROR statements in constants are unstable
 
 const B: usize = { { } 2 };
-//~^ ERROR statements in constants are unstable
 
 macro_rules! foo {
-    () => (()) //~ ERROR statements in constants are unstable
+    () => (())
 }
 const C: usize = { foo!(); 2 };
 
 const D: usize = { let x = 4; 2 };
-//~^ ERROR let bindings in constants are unstable
-//~| ERROR statements in constants are unstable
-//~| ERROR let bindings in constants are unstable
-//~| ERROR statements in constants are unstable
 
 pub fn main() {}
diff --git a/src/test/ui/consts/const-block-non-item-statement-2.stderr b/src/test/ui/consts/const-block-non-item-statement-2.stderr
deleted file mode 100644 (file)
index 580f7e0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-2.rs:11:20
-   |
-LL | const A: usize = { 1; 2 };
-   |                    ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-2.rs:14:20
-   |
-LL | const B: usize = { { } 2 };
-   |                    ^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-2.rs:18:12
-   |
-LL |     () => (()) //~ ERROR statements in constants are unstable
-   |            ^^
-LL | }
-LL | const C: usize = { foo!(); 2 };
-   |                    ------- in this macro invocation
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-2.rs:22:28
-   |
-LL | const D: usize = { let x = 4; 2 };
-   |                            ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-2.rs:22:28
-   |
-LL | const D: usize = { let x = 4; 2 };
-   |                            ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-2.rs:22:1
-   |
-LL | const D: usize = { let x = 4; 2 };
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-2.rs:22:1
-   |
-LL | const D: usize = { let x = 4; 2 };
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error: aborting due to 7 previous errors
-
-For more information about this error, try `rustc --explain E0658`.
index cfa4b778dde80b48324cb17de35c5eebdaa18610..496e5486e9b99234a19a8a122e3f099ce0498bdb 100644 (file)
@@ -8,10 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-pass
+
 type Array = [u32; {  let x = 2; 5 }];
-//~^ ERROR let bindings in constants are unstable
-//~| ERROR statements in constants are unstable
-//~| ERROR let bindings in constants are unstable
-//~| ERROR statements in constants are unstable
 
 pub fn main() {}
diff --git a/src/test/ui/consts/const-block-non-item-statement-3.stderr b/src/test/ui/consts/const-block-non-item-statement-3.stderr
deleted file mode 100644 (file)
index 0124288..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-3.rs:11:31
-   |
-LL | type Array = [u32; {  let x = 2; 5 }];
-   |                               ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-3.rs:11:31
-   |
-LL | type Array = [u32; {  let x = 2; 5 }];
-   |                               ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-3.rs:11:20
-   |
-LL | type Array = [u32; {  let x = 2; 5 }];
-   |                    ^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement-3.rs:11:20
-   |
-LL | type Array = [u32; {  let x = 2; 5 }];
-   |                    ^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0658`.
index f974a24c26f72f40511317056bc0c089e6a5c8f3..281a07808e9272beb1bf58ccf76b8cf190a1e057 100644 (file)
@@ -8,12 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// compile-pass
+
 enum Foo {
     Bar = { let x = 1; 3 }
-    //~^ ERROR let bindings in constants are unstable
-    //~| ERROR statements in constants are unstable
-    //~| ERROR let bindings in constants are unstable
-    //~| ERROR statements in constants are unstable
 }
 
 pub fn main() {}
diff --git a/src/test/ui/consts/const-block-non-item-statement.stderr b/src/test/ui/consts/const-block-non-item-statement.stderr
deleted file mode 100644 (file)
index b367a9d..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement.rs:12:21
-   |
-LL |     Bar = { let x = 1; 3 }
-   |                     ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement.rs:12:21
-   |
-LL |     Bar = { let x = 1; 3 }
-   |                     ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement.rs:12:11
-   |
-LL |     Bar = { let x = 1; 3 }
-   |           ^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/const-block-non-item-statement.rs:12:11
-   |
-LL |     Bar = { let x = 1; 3 }
-   |           ^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0658`.
index ef0de61d219adbbb91b553b34b405b54b315271f..ad0dfabebedea7e53342b4dfe36497063a234ba4 100644 (file)
@@ -12,7 +12,6 @@
 // The test should never compile successfully
 
 #![feature(const_raw_ptr_deref)]
-#![feature(const_let)]
 
 use std::cell::UnsafeCell;
 
@@ -24,7 +23,7 @@ unsafe impl Sync for Foo {}
 static FOO: Foo = Foo(UnsafeCell::new(42));
 
 static BAR: () = unsafe {
-    *FOO.0.get() = 5; //~ ERROR could not evaluate static initializer
+    *FOO.0.get() = 5; //~ ERROR static contains unimplemented expression type
 };
 
 fn main() {}
index 0892b05a69df273ea05da0cba2433462b118c3e9..740c1ab0b2d69fcd82d1ff6e6d21e6fc9ec628a3 100644 (file)
@@ -1,9 +1,9 @@
-error[E0080]: could not evaluate static initializer
-  --> $DIR/assign-to-static-within-other-static-2.rs:27:5
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/assign-to-static-within-other-static-2.rs:26:5
    |
-LL |     *FOO.0.get() = 5; //~ ERROR could not evaluate static initializer
-   |     ^^^^^^^^^^^^^^^^ tried to modify a static's initial value from another static's initializer
+LL |     *FOO.0.get() = 5; //~ ERROR static contains unimplemented expression type
+   |     ^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0080`.
+For more information about this error, try `rustc --explain E0019`.
index 6f16f644eec68177c7d9161f7c29d7b0c6589cb3..2f786fb16cc80111d5defb93aa9c6b4f93df2278 100644 (file)
@@ -12,7 +12,6 @@
 // The test should never compile successfully
 
 #![feature(const_raw_ptr_deref)]
-#![feature(const_let)]
 
 use std::cell::UnsafeCell;
 
index ca652c9df32adb2c1f6869e2fcfc35d5118dbdca..031a87701266f36704fb2a3a5cd186fd660882df 100644 (file)
@@ -1,5 +1,5 @@
 error: cannot mutate statics in the initializer of another static
-  --> $DIR/assign-to-static-within-other-static.rs:21:5
+  --> $DIR/assign-to-static-within-other-static.rs:20:5
    |
 LL |     FOO = 5; //~ ERROR cannot mutate statics in the initializer of another static
    |     ^^^^^^^
index 602d4da24f3836c6760463224762b24e0ccaa6b8..3b5014a57b590c71ab32f8b772af91986251f697 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(const_let)]
-
 fn main() {}
 
 struct FakeNeedsDrop;
index 86e3482fda6b949b6c270ad4f48c4c005851e581..f0c17bca36a7cc84a636a1c896fc023370ca39c2 100644 (file)
@@ -1,11 +1,11 @@
 error[E0019]: constant contains unimplemented expression type
-  --> $DIR/const_let.rs:25:55
+  --> $DIR/const_let.rs:23:55
    |
 LL | const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x };
    |                                                       ^
 
 error[E0019]: constant contains unimplemented expression type
-  --> $DIR/const_let.rs:29:35
+  --> $DIR/const_let.rs:27:35
    |
 LL | const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); };
    |                                   ^
index d23b6250b4df2e8830042120b1498c8f4c29f2e7..4aad5216442ce5cd1446d485f4721a337b5a1648 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(const_let)]
-
 fn main() {
     // Tests the Collatz conjecture with an incorrect base case (0 instead of 1).
     // The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
index 2ff80e5efb57d49852b91cf4d0e71e924dc1f6b3..04a3362d95e7802d50a671958e9189b4a1f4667f 100644 (file)
@@ -1,5 +1,5 @@
 error[E0019]: constant contains unimplemented expression type
-  --> $DIR/infinite_loop.rs:19:9
+  --> $DIR/infinite_loop.rs:17:9
    |
 LL | /         while n != 0 { //~ ERROR constant contains unimplemented expression type
 LL | |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
@@ -8,7 +8,7 @@ LL | |         }
    | |_________^
 
 warning: Constant evaluating a complex constant, this might take some time
-  --> $DIR/infinite_loop.rs:16:18
+  --> $DIR/infinite_loop.rs:14:18
    |
 LL |       let _ = [(); {
    |  __________________^
@@ -21,7 +21,7 @@ LL | |     }];
    | |_____^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/infinite_loop.rs:20:20
+  --> $DIR/infinite_loop.rs:18:20
    |
 LL |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
    |                    ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
index b21c1827e2ba2ef4b40ebbf9fd41e3a0e4925d03..970d1a056f330e02332d9a8d70e4f2539355de89 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(const_let)]
-
 fn main() {
     let _ = [(); {
         //~^ WARNING Constant evaluating a complex constant, this might take some time
index c0cd98b2fca1e1f5dc58c84bbceef2affa5b64fd..128979a67a91257993779039f650b7448cb0beb0 100644 (file)
@@ -1,5 +1,5 @@
 error[E0019]: constant contains unimplemented expression type
-  --> $DIR/issue-52475.rs:18:9
+  --> $DIR/issue-52475.rs:16:9
    |
 LL | /         while n < 5 { //~ ERROR constant contains unimplemented expression type
 LL | |             n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
@@ -8,7 +8,7 @@ LL | |         }
    | |_________^
 
 warning: Constant evaluating a complex constant, this might take some time
-  --> $DIR/issue-52475.rs:14:18
+  --> $DIR/issue-52475.rs:12:18
    |
 LL |       let _ = [(); {
    |  __________________^
@@ -21,7 +21,7 @@ LL | |     }];
    | |_____^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/issue-52475.rs:19:17
+  --> $DIR/issue-52475.rs:17:17
    |
 LL |             n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
    |                 ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
index 01fcc8307c0c11b55ad8b2bda635a018297cf729..8132d26d63b148838af28d53961b9dd82be7a75d 100644 (file)
@@ -12,7 +12,6 @@
 // The test should never compile successfully
 
 #![feature(const_raw_ptr_deref)]
-#![feature(const_let)]
 
 use std::cell::UnsafeCell;
 
@@ -27,9 +26,7 @@ fn foo() {}
 
 static BAR: () = unsafe {
     *FOO.0.get() = 5;
-    // we do not error on the above access, because that is not detectable statically. Instead,
-    // const evaluation will error when trying to evaluate it. Due to the error below, we never even
-    // attempt to const evaluate `BAR`, so we don't see the error
+    //~^ ERROR static contains unimplemented expression
 
     foo();
     //~^ ERROR calls in statics are limited to constant functions, tuple structs and tuple variants
index 01ad1fc9a21b9fac6164b2a5bf06b57e81ddbbae..eb5e88ad6931df523036b6838d692999493ab379 100644 (file)
@@ -1,9 +1,16 @@
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/mod-static-with-const-fn.rs:28:5
+   |
+LL |     *FOO.0.get() = 5;
+   |     ^^^^^^^^^^^^^^^^
+
 error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
-  --> $DIR/mod-static-with-const-fn.rs:34:5
+  --> $DIR/mod-static-with-const-fn.rs:31:5
    |
 LL |     foo();
    |     ^^^^^
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0015`.
+Some errors occurred: E0015, E0019.
+For more information about an error, try `rustc --explain E0015`.
index 7141d7ac8b8625396852c91bb6cee85fc7598781..20e6593f88ae8219db7cefd9715914480b242074 100644 (file)
@@ -20,17 +20,6 @@ LL |     let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR doe
 LL | }
    | - temporary value is freed at the end of this statement
 
-error[E0716]: temporary value dropped while borrowed
-  --> $DIR/promoted_raw_ptr_ops.rs:17:28
-   |
-LL |     let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
-   |            ------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
-   |            |
-   |            type annotation requires that borrow lasts for `'static`
-LL |     let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
-LL | }
-   | - temporary value is freed at the end of this statement
-
 error[E0716]: temporary value dropped while borrowed
   --> $DIR/promoted_raw_ptr_ops.rs:18:29
    |
@@ -41,6 +30,6 @@ LL |     let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does
 LL | }
    | - temporary value is freed at the end of this statement
 
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0716`.
index 6661de4ab2cb586bcaa737211848c2a56d51ca7b..a9d5d6901522ab9ab5082276ff02e97692e30d34 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(const_transmute,const_let)]
+#![feature(const_transmute)]
 #![allow(const_err)] // make sure we cannot allow away the errors tested here
 
 use std::mem;
index a3c53a451e106732063ff34e2a8f89fc11fba354..0b09b8469fd752f206b6dffa945d78dfffeef1fd 100644 (file)
@@ -1,7 +1,5 @@
 // compile-pass
 
-#![feature(const_let)]
-
 struct S(i32);
 
 const A: () = {
index 83825456b5c61d9f732303cd858e69afdd6da34f..dd9690ef858b9405a5f66c891892220f54123f95 100644 (file)
@@ -1,4 +1,3 @@
-#![feature(const_let)]
 #![feature(const_fn)]
 
 struct S {
@@ -8,6 +7,7 @@ struct S {
 impl S {
     const fn foo(&mut self, x: u32) {
         self.state = x;
+        //~^ ERROR constant function contains unimplemented expression
     }
 }
 
index 7f9a953c10fe8ae8b9fe0190b3e5097751aa86a9..7380906bec7b3b47b84b5223c7a72de38e9526f6 100644 (file)
@@ -1,9 +1,16 @@
+error[E0019]: constant function contains unimplemented expression type
+  --> $DIR/const_let_assign3.rs:9:9
+   |
+LL |         self.state = x;
+   |         ^^^^^^^^^^^^^^
+
 error[E0017]: references in constants may only refer to immutable values
   --> $DIR/const_let_assign3.rs:16:5
    |
 LL |     s.foo(3); //~ ERROR references in constants may only refer to immutable values
    |     ^ constants require immutable values
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0017`.
+Some errors occurred: E0017, E0019.
+For more information about an error, try `rustc --explain E0017`.
index 695d33b6908984b4c7e6874c1b1965c51aaa2447..dbc50f1fbd4b4c75efcaf784d0b1165685e9662a 100644 (file)
@@ -1,7 +1,5 @@
 // https://github.com/rust-lang/rust/issues/55223
 
-#![feature(const_let)]
-
 union Foo<'a> {
     y: &'a (),
     long_live_the_unit: &'static (),
index a5fa88e5e683242f6089a4f91fc7eddc6c924e31..2cd8711f03d3168ed8e696c4c8b40b6a49a1f3d8 100644 (file)
@@ -1,5 +1,5 @@
 error: any use of this value will cause an error
-  --> $DIR/dangling-alloc-id-ice.rs:10:1
+  --> $DIR/dangling-alloc-id-ice.rs:8:1
    |
 LL | / const FOO: &() = { //~ ERROR any use of this value will cause an error
 LL | |     let y = ();
index 7fc773412f2f8e55f87de5331c9090c3cc852514..c2d8e6d421a2876346286962f7b620bc946114ed 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 const FOO: *const u32 = { //~ ERROR any use of this value will cause an error
     let x = 42;
     &x
index 3b20936f8ae971a293050214cbd1141e0b660696..091f1f785cb02a2824d36e8917f4267d000bf360 100644 (file)
@@ -1,5 +1,5 @@
 error: any use of this value will cause an error
-  --> $DIR/dangling_raw_ptr.rs:3:1
+  --> $DIR/dangling_raw_ptr.rs:1:1
    |
 LL | / const FOO: *const u32 = { //~ ERROR any use of this value will cause an error
 LL | |     let x = 42;
index b5a8fe8819cdd6091b2be1b41244549cd6aad7e2..bb6be37340cf9ffb6a5af5fa14ac9ca3d10628b0 100644 (file)
@@ -1,6 +1,8 @@
+// compile-pass
+
 #![feature(nll)]
 
-const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]); //~ ERROR temporary value dropped while borrowed
+const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]);
 
 use std::borrow::Cow;
 
@@ -9,6 +11,5 @@
 
 
 pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]);
-//~^ ERROR temporary value dropped while borrowed
 
 fn main() {}
diff --git a/src/test/ui/consts/issue-54224.stderr b/src/test/ui/consts/issue-54224.stderr
deleted file mode 100644 (file)
index 451f49c..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0716]: temporary value dropped while borrowed
-  --> $DIR/issue-54224.rs:3:39
-   |
-LL | const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]); //~ ERROR temporary value dropped while borrowed
-   |                                 ------^^^^^^^^^-
-   |                                 |     |        |
-   |                                 |     |        temporary value is freed at the end of this statement
-   |                                 |     creates a temporary which is freed while still in use
-   |                                 using this value as a constant requires that borrow lasts for `'static`
-
-error[E0716]: temporary value dropped while borrowed
-  --> $DIR/issue-54224.rs:11:57
-   |
-LL | pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]);
-   |                                          ---------------^^^^^^^^^-
-   |                                          |              |        |
-   |                                          |              |        temporary value is freed at the end of this statement
-   |                                          |              creates a temporary which is freed while still in use
-   |                                          using this value as a constant requires that borrow lasts for `'static`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0716`.
diff --git a/src/test/ui/consts/min_const_fn/mutable_borrow.nll.stderr b/src/test/ui/consts/min_const_fn/mutable_borrow.nll.stderr
new file mode 100644 (file)
index 0000000..7a0cd93
--- /dev/null
@@ -0,0 +1,51 @@
+error: mutable references in const fn are unstable
+  --> $DIR/mutable_borrow.rs:3:9
+   |
+LL |     let b = &mut a; //~ ERROR mutable references in const fn are unstable
+   |         ^
+
+error: mutable references in const fn are unstable
+  --> $DIR/mutable_borrow.rs:12:13
+   |
+LL |         let b = &mut a; //~ ERROR mutable references in const fn are unstable
+   |             ^
+
+error[E0017]: references in statics may only refer to immutable values
+  --> $DIR/mutable_borrow.rs:19:13
+   |
+LL |     let b = &mut a; //~ references in statics may only refer to immutable
+   |             ^^^^^^ statics require immutable values
+
+error[E0017]: references in statics may only refer to immutable values
+  --> $DIR/mutable_borrow.rs:26:15
+   |
+LL |     { let b = &mut a; }  //~ references in statics may only refer to immutable
+   |               ^^^^^^ statics require immutable values
+
+error[E0017]: references in statics may only refer to immutable values
+  --> $DIR/mutable_borrow.rs:37:17
+   |
+LL |     let mut a = &mut None; //~ references in statics may only refer to immutable values
+   |                 ^^^^^^^^^ statics require immutable values
+
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/mutable_borrow.rs:39:5
+   |
+LL |     *a = Some(Foo); //~ unimplemented expression type
+   |     ^^
+
+error[E0716]: temporary value dropped while borrowed
+  --> $DIR/mutable_borrow.rs:37:22
+   |
+LL |     let mut a = &mut None; //~ references in statics may only refer to immutable values
+   |                      ^^^^ creates a temporary which is freed while still in use
+...
+LL |     a
+   |     - using this value as a static requires that borrow lasts for `'static`
+LL | };
+   | - temporary value is freed at the end of this statement
+
+error: aborting due to 7 previous errors
+
+Some errors occurred: E0017, E0019, E0716.
+For more information about an error, try `rustc --explain E0017`.
index 85f9a154c84911fd824d80bc9b4a11d380674e2e..d9a4164aa13eb2f5ca53dfa78b142fc22c1c828d 100644 (file)
@@ -14,4 +14,30 @@ const fn inherent_mutable_ref_in_const() -> u8 {
     }
 }
 
+static mut FOO: u32 = {
+    let mut a = 0;
+    let b = &mut a; //~ references in statics may only refer to immutable
+    *b
+};
+
+static mut BAR: Option<String> = {
+    let mut a = None;
+    // taking a mutable reference erases everything we know about `a`
+    { let b = &mut a; }  //~ references in statics may only refer to immutable
+    a
+};
+
+struct Foo;
+
+impl Drop for Foo {
+    fn drop(&mut self) {}
+}
+
+static mut BAR2: &mut Option<Foo> = {
+    let mut a = &mut None; //~ references in statics may only refer to immutable values
+    //~^ does not live long enough
+    *a = Some(Foo); //~ unimplemented expression type
+    a
+};
+
 fn main() {}
index 7414fa94bfbcab320554d56783f1425819c55a25..ac619490197449cde6f05e4ccb2ae3535a3838d8 100644 (file)
@@ -10,5 +10,42 @@ error: mutable references in const fn are unstable
 LL |         let b = &mut a; //~ ERROR mutable references in const fn are unstable
    |             ^
 
-error: aborting due to 2 previous errors
+error[E0017]: references in statics may only refer to immutable values
+  --> $DIR/mutable_borrow.rs:19:13
+   |
+LL |     let b = &mut a; //~ references in statics may only refer to immutable
+   |             ^^^^^^ statics require immutable values
+
+error[E0017]: references in statics may only refer to immutable values
+  --> $DIR/mutable_borrow.rs:26:15
+   |
+LL |     { let b = &mut a; }  //~ references in statics may only refer to immutable
+   |               ^^^^^^ statics require immutable values
+
+error[E0017]: references in statics may only refer to immutable values
+  --> $DIR/mutable_borrow.rs:37:17
+   |
+LL |     let mut a = &mut None; //~ references in statics may only refer to immutable values
+   |                 ^^^^^^^^^ statics require immutable values
+
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/mutable_borrow.rs:39:5
+   |
+LL |     *a = Some(Foo); //~ unimplemented expression type
+   |     ^^
+
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/mutable_borrow.rs:37:22
+   |
+LL |     let mut a = &mut None; //~ references in statics may only refer to immutable values
+   |                      ^^^^ temporary value does not live long enough
+...
+LL | };
+   | - temporary value only lives until here
+   |
+   = note: borrowed value must be valid for the static lifetime...
+
+error: aborting due to 7 previous errors
 
+Some errors occurred: E0017, E0019, E0597.
+For more information about an error, try `rustc --explain E0017`.
index 4ce41f80f82c8dff332491835619331abdf21e40..32c68e69f4beda7d4d4ba48908ce00ae90aaf899 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 use std::cell::Cell;
 
 const FOO: &(Cell<usize>, bool) = {
index d695f64e2c3b55a6a1d9fddf1372cfc6f9ba6856..967fb83b78b087d64d18cc5770af96a3c0f04de5 100644 (file)
@@ -1,5 +1,5 @@
 error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
-  --> $DIR/partial_qualif.rs:8:5
+  --> $DIR/partial_qualif.rs:6:5
    |
 LL |     &{a} //~ ERROR cannot borrow a constant which may contain interior mutability
    |     ^^^^
index 34e8eaba9f28f6ba91d96425eb73470958218e9b..411cdff3d24d48577603badb95e298434c2b8d95 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 use std::cell::Cell;
 
 const FOO: &u32 = {
@@ -7,6 +5,7 @@
     {
         let b: *mut u32 = &mut a; //~ ERROR may only refer to immutable values
         unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
+        //~^ ERROR constant contains unimplemented expression
     }
     &{a}
 };
index d5252f199beac10bf42384c0e212c2b948574d7f..410c51c4b54e1bb666d4bc7a87a760756fa99e16 100644 (file)
@@ -1,18 +1,24 @@
 error[E0017]: references in constants may only refer to immutable values
-  --> $DIR/projection_qualif.rs:8:27
+  --> $DIR/projection_qualif.rs:6:27
    |
 LL |         let b: *mut u32 = &mut a; //~ ERROR may only refer to immutable values
    |                           ^^^^^^ constants require immutable values
 
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/projection_qualif.rs:7:18
+   |
+LL |         unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
+   |                  ^^^^^^
+
 error[E0658]: dereferencing raw pointers in constants is unstable (see issue #51911)
-  --> $DIR/projection_qualif.rs:9:18
+  --> $DIR/projection_qualif.rs:7:18
    |
 LL |         unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
    |                  ^^^^^^
    |
    = help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
-Some errors occurred: E0017, E0658.
+Some errors occurred: E0017, E0019, E0658.
 For more information about an error, try `rustc --explain E0017`.
index d8749bb5fd90bff0251e2c94a71fe0ffd246fa9d..1fc345d5a12feb2a808a5432cb6ef06c588fe077 100644 (file)
@@ -1,5 +1,5 @@
 error[E0597]: `y` does not live long enough
-  --> $DIR/promote_const_let.rs:6:9
+  --> $DIR/promote_const_let.rs:4:9
    |
 LL |     let x: &'static u32 = {
    |            ------------ type annotation requires that `y` is borrowed for `'static`
index 8de9b00eb111d3bb0baca2e63cd9278d0ba68ced..cbebe84d9058c267bc133a8046386a0d49c00ade 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 fn main() {
     let x: &'static u32 = {
         let y = 42;
index 6bbb7495fb0dca1035a811a19ddc173f98730315..2ec4ad90855a2bb99dd5b1e47294cf62420063a7 100644 (file)
@@ -1,5 +1,5 @@
 error[E0597]: `y` does not live long enough
-  --> $DIR/promote_const_let.rs:6:10
+  --> $DIR/promote_const_let.rs:4:10
    |
 LL |         &y //~ ERROR does not live long enough
    |          ^ borrowed value does not live long enough
index 806a74ee4530b0f798783a60930668b78d6c0ccc..430eea37de73c60cb76e51b054d1e346e136393a 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 use std::cell::Cell;
 
 // this is overly conservative. The reset to `None` should clear `a` of all qualifications
index 4fac64bf8063f19dbec23b44a35eb5278989fee8..30479139e314c82c0d51341b79b678dafd8d9960 100644 (file)
@@ -1,5 +1,5 @@
 error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
-  --> $DIR/qualif_overwrite.rs:12:5
+  --> $DIR/qualif_overwrite.rs:10:5
    |
 LL |     &{a} //~ ERROR cannot borrow a constant which may contain interior mutability
    |     ^^^^
index 29557a3da47811d491291021e7fc49bc339d5872..fa79b5c14a73629e80853143aaff2217c7f83d2f 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 use std::cell::Cell;
 
 // const qualification is not smart enough to know about fields and always assumes that there might
index 181b728c7b76f2746f63f1e59a150238eccc4359..8276db99a12c0b264b227387cbb90b70b1a3e03a 100644 (file)
@@ -1,5 +1,5 @@
 error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
-  --> $DIR/qualif_overwrite_2.rs:10:5
+  --> $DIR/qualif_overwrite_2.rs:8:5
    |
 LL |     &{a.0} //~ ERROR cannot borrow a constant which may contain interior mutability
    |     ^^^^^^
index e5ccf32af1473e44693414e08e0220636fbccfd5..13371175f9caac456a4d4ca83af31af450b276c8 100644 (file)
@@ -14,5 +14,6 @@
 #![allow(warnings)]
 
 const CON : Box<i32> = box 0; //~ ERROR E0010
+//~^ ERROR contains unimplemented expression type
 
 fn main() {}
index fa5c767caf24d6d3eb41de0e767be7fb2ac960c4..670698891d42882fcfae2e313f75411b0d791d6f 100644 (file)
@@ -6,6 +6,16 @@ LL | const CON : Box<i32> = box 0; //~ ERROR E0010
    |
    = note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time.
 
-error: aborting due to previous error
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/E0010-teach.rs:16:28
+   |
+LL | const CON : Box<i32> = box 0; //~ ERROR E0010
+   |                            ^
+   |
+   = note: A function call isn't allowed in the const's initialization expression because the expression's value must be known at compile-time.
+   = note: Remember: you can't use a function call inside a const's initialization expression! However, you can use it anywhere else.
+
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0010`.
+Some errors occurred: E0010, E0019.
+For more information about an error, try `rustc --explain E0010`.
index 66a9319a7df4345c03a622818760910fb8adc696..7a80b335c5619a14aaf85c2d090e3956a5a6e6da 100644 (file)
@@ -12,5 +12,6 @@
 #![allow(warnings)]
 
 const CON : Box<i32> = box 0; //~ ERROR E0010
+//~^ ERROR contains unimplemented expression type
 
 fn main() {}
index 83c1b409a5174aba042fd73b872726425b2d641b..01295469b2bb240dbcf1f22d0aeff90ebe341a96 100644 (file)
@@ -4,6 +4,13 @@ error[E0010]: allocations are not allowed in constants
 LL | const CON : Box<i32> = box 0; //~ ERROR E0010
    |                        ^^^^^ allocation not allowed in constants
 
-error: aborting due to previous error
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/E0010.rs:14:28
+   |
+LL | const CON : Box<i32> = box 0; //~ ERROR E0010
+   |                            ^
+
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0010`.
+Some errors occurred: E0010, E0019.
+For more information about an error, try `rustc --explain E0010`.
index b283e28651487c427bec09e160c8ab4806bcbd94..3724eaf61ca0a2e80476047039319ba040c65982 100644 (file)
@@ -7,7 +7,6 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
-#![feature(const_let)]
 
 trait Trt {}
 struct Str {}
index ab90ef8f11f7cf22bcc5ef847013210b9ff5bb59..050ad8710309e4a0d82818f3a12474be88220a1d 100644 (file)
@@ -1,5 +1,5 @@
 error[E0658]: naming constants with `_` is unstable (see issue #54912)
-  --> $DIR/feature-gate-underscore_const_names.rs:17:1
+  --> $DIR/feature-gate-underscore_const_names.rs:16:1
    |
 LL | / const _ : () = {
 LL | |     use std::marker::PhantomData;
diff --git a/src/test/ui/feature-gates/feature-gate-const_let.rs b/src/test/ui/feature-gates/feature-gate-const_let.rs
deleted file mode 100644 (file)
index 9bf957a..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test use of const let without feature gate.
-
-const FOO: usize = {
-    //~^ ERROR statements in constants are unstable
-    //~| ERROR: let bindings in constants are unstable
-    let x = 42;
-    //~^ ERROR statements in constants are unstable
-    //~| ERROR: let bindings in constants are unstable
-    42
-};
-
-static BAR: usize = {
-    //~^ ERROR statements in statics are unstable
-    //~| ERROR: let bindings in statics are unstable
-    let x = 42;
-    //~^ ERROR statements in statics are unstable
-    //~| ERROR: let bindings in statics are unstable
-    42
-};
-
-fn main() {}
index 9e680e87f79a89aa81b69556dcd94fb5610b67b0..9529b60c1b6ade4256ad95f2435ad71a271fbd5f 100644 (file)
@@ -1,68 +1,14 @@
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:15:17
-   |
-LL |         let p = 3;
-   |                 ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:15:17
-   |
-LL |         let p = 3;
-   |                 ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:18:9
-   |
-LL |         &p //~ ERROR `p` does not live long enough
-   |         ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:12:5
-   |
-LL | /     const z: &'static isize = {
-LL | |         //~^ ERROR let bindings in constants are unstable
-LL | |         //~| ERROR statements in constants are unstable
-LL | |         let p = 3;
-...  |
-LL | |         //~^ ERROR let bindings in constants are unstable
-LL | |     };
-   | |______^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:12:5
-   |
-LL | /     const z: &'static isize = {
-LL | |         //~^ ERROR let bindings in constants are unstable
-LL | |         //~| ERROR statements in constants are unstable
-LL | |         let p = 3;
-...  |
-LL | |         //~^ ERROR let bindings in constants are unstable
-LL | |     };
-   | |______^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
 error[E0597]: `p` does not live long enough
-  --> $DIR/issue-18118.rs:18:9
+  --> $DIR/issue-18118.rs:14:9
    |
 LL |         &p //~ ERROR `p` does not live long enough
    |         ^^
    |         |
    |         borrowed value does not live long enough
    |         using this value as a constant requires that `p` is borrowed for `'static`
-LL |         //~^ ERROR let bindings in constants are unstable
 LL |     };
    |     - `p` dropped here while still borrowed
 
-error: aborting due to 6 previous errors
+error: aborting due to previous error
 
-Some errors occurred: E0597, E0658.
-For more information about an error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0597`.
index 7194c159c1e98a79409b7c11ff291cc36f66c68d..05e46230db29aa1c64d92df052792a1bb50f7f25 100644 (file)
 
 pub fn main() {
     const z: &'static isize = {
-        //~^ ERROR let bindings in constants are unstable
-        //~| ERROR statements in constants are unstable
         let p = 3;
-        //~^ ERROR let bindings in constants are unstable
-        //~| ERROR statements in constants are unstable
         &p //~ ERROR `p` does not live long enough
-        //~^ ERROR let bindings in constants are unstable
     };
 }
index 2d83b86e5f40bf9c608638bee12c80e02c75a203..4f755745b2857316d6b5c8b41b92b89f1b3d004b 100644 (file)
@@ -1,67 +1,13 @@
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:15:17
-   |
-LL |         let p = 3;
-   |                 ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:15:17
-   |
-LL |         let p = 3;
-   |                 ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:18:9
-   |
-LL |         &p //~ ERROR `p` does not live long enough
-   |         ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:12:5
-   |
-LL | /     const z: &'static isize = {
-LL | |         //~^ ERROR let bindings in constants are unstable
-LL | |         //~| ERROR statements in constants are unstable
-LL | |         let p = 3;
-...  |
-LL | |         //~^ ERROR let bindings in constants are unstable
-LL | |     };
-   | |______^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:12:5
-   |
-LL | /     const z: &'static isize = {
-LL | |         //~^ ERROR let bindings in constants are unstable
-LL | |         //~| ERROR statements in constants are unstable
-LL | |         let p = 3;
-...  |
-LL | |         //~^ ERROR let bindings in constants are unstable
-LL | |     };
-   | |______^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
 error[E0597]: `p` does not live long enough
-  --> $DIR/issue-18118.rs:18:10
+  --> $DIR/issue-18118.rs:14:10
    |
 LL |         &p //~ ERROR `p` does not live long enough
    |          ^ borrowed value does not live long enough
-LL |         //~^ ERROR let bindings in constants are unstable
 LL |     };
    |     - borrowed value only lives until here
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error: aborting due to 6 previous errors
+error: aborting due to previous error
 
-Some errors occurred: E0597, E0658.
-For more information about an error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0597`.
index 2b223bac8e67b7d849f19e6387a916c404878107..b5026d8c5e1e5d57b6b910dfe94139019975af1f 100644 (file)
@@ -15,7 +15,6 @@
 const bad : u32 = {
     {
         5;
-        //~^ ERROR statements in constants are unstable
         0
     }
 };
@@ -23,8 +22,7 @@
 const bad_two : u32 = {
     {
         invalid();
-        //~^ ERROR statements in constants are unstable
-        //~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
+        //~^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
         0
     }
 };
@@ -32,7 +30,6 @@
 const bad_three : u32 = {
     {
         valid();
-        //~^ ERROR statements in constants are unstable
         0
     }
 };
@@ -40,7 +37,6 @@
 static bad_four : u32 = {
     {
         5;
-        //~^ ERROR statements in statics are unstable
         0
     }
 };
@@ -49,7 +45,6 @@
     {
         invalid();
         //~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
-        //~| ERROR statements in statics are unstable
         0
     }
 };
@@ -57,7 +52,6 @@
 static bad_six : u32 = {
     {
         valid();
-        //~^ ERROR statements in statics are unstable
         0
     }
 };
@@ -65,7 +59,6 @@
 static mut bad_seven : u32 = {
     {
         5;
-        //~^ ERROR statements in statics are unstable
         0
     }
 };
@@ -73,8 +66,7 @@
 static mut bad_eight : u32 = {
     {
         invalid();
-        //~^ ERROR statements in statics are unstable
-        //~| ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
+        //~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
         0
     }
 };
@@ -82,7 +74,6 @@
 static mut bad_nine : u32 = {
     {
         valid();
-        //~^ ERROR statements in statics are unstable
         0
     }
 };
index 6d6b94ca4bc6d2c36db553142a8b13e176ca42c2..5e5cdf8adda2ce071087e9766bfe33eeb4f23e82 100644 (file)
@@ -1,94 +1,21 @@
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:17:9
-   |
-LL |         5;
-   |         ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
 error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
-  --> $DIR/issue-32829-2.rs:25:9
+  --> $DIR/issue-32829-2.rs:24:9
    |
 LL |         invalid();
    |         ^^^^^^^^^
 
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:25:9
-   |
-LL |         invalid();
-   |         ^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:34:9
-   |
-LL |         valid();
-   |         ^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:42:9
-   |
-LL |         5;
-   |         ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
 error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
-  --> $DIR/issue-32829-2.rs:50:9
+  --> $DIR/issue-32829-2.rs:46:9
    |
 LL |         invalid();
    |         ^^^^^^^^^
 
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:50:9
-   |
-LL |         invalid();
-   |         ^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:59:9
-   |
-LL |         valid();
-   |         ^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:67:9
-   |
-LL |         5;
-   |         ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
 error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
-  --> $DIR/issue-32829-2.rs:75:9
+  --> $DIR/issue-32829-2.rs:68:9
    |
 LL |         invalid();
    |         ^^^^^^^^^
 
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:75:9
-   |
-LL |         invalid();
-   |         ^^^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:84:9
-   |
-LL |         valid();
-   |         ^^^^^^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error: aborting due to 12 previous errors
+error: aborting due to 3 previous errors
 
-Some errors occurred: E0015, E0658.
-For more information about an error, try `rustc --explain E0015`.
+For more information about this error, try `rustc --explain E0015`.
index 801a1301ad77496fcdcf6fa9991ec4a95bf5e29f..fca4fb62fad22f92dfb5b32e6eb9dadf30a4a828 100644 (file)
@@ -16,5 +16,6 @@
 static boxed: Box<RefCell<isize>> = box RefCell::new(0);
 //~^ ERROR allocations are not allowed in statics
 //~| ERROR `std::cell::RefCell<isize>` cannot be shared between threads safely [E0277]
+//~| ERROR contains unimplemented expression type
 
 fn main() { }
index b0d732bdb6fa6eb5a73dc011b12dc9544e2ed383..b6594b1caca2cfcad6cf7839c119821760d70698 100644 (file)
@@ -4,6 +4,12 @@ error[E0010]: allocations are not allowed in statics
 LL | static boxed: Box<RefCell<isize>> = box RefCell::new(0);
    |                                     ^^^^^^^^^^^^^^^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/issue-7364.rs:16:41
+   |
+LL | static boxed: Box<RefCell<isize>> = box RefCell::new(0);
+   |                                         ^^^^^^^^^^^^^^^
+
 error[E0277]: `std::cell::RefCell<isize>` cannot be shared between threads safely
   --> $DIR/issue-7364.rs:16:1
    |
@@ -15,7 +21,7 @@ LL | static boxed: Box<RefCell<isize>> = box RefCell::new(0);
    = note: required because it appears within the type `std::boxed::Box<std::cell::RefCell<isize>>`
    = note: shared static variables must have a type that implements `Sync`
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
-Some errors occurred: E0010, E0277.
+Some errors occurred: E0010, E0019, E0277.
 For more information about an error, try `rustc --explain E0010`.
index 7e6ced12fe69aad1a6e08b03243e72a0d44c53ad..a25236b53b51ffe67f6440858d677f0cf7bb478a 100644 (file)
@@ -12,5 +12,6 @@
 
 static mut a: Box<isize> = box 3;
 //~^ ERROR allocations are not allowed in statics
+//~| ERROR static contains unimplemented expression
 
 fn main() {}
index ad44121e76316d5ac37a480ce465f525dc6ee79c..d9250e85d3e3f0d975b32f86eddedf807277ec3e 100644 (file)
@@ -4,6 +4,13 @@ error[E0010]: allocations are not allowed in statics
 LL | static mut a: Box<isize> = box 3;
    |                            ^^^^^ allocation not allowed in statics
 
-error: aborting due to previous error
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/static-mut-not-constant.rs:13:32
+   |
+LL | static mut a: Box<isize> = box 3;
+   |                                ^
+
+error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0010`.
+Some errors occurred: E0010, E0019.
+For more information about an error, try `rustc --explain E0010`.
index 8d31fd0b1e93d6dd415804ba2dfa4309e99bef8d..bb123f46a577217b2e7f7b21c2c8900e56619bda 100644 (file)
@@ -10,7 +10,6 @@
 
 // compile-pass
 
-#![feature(const_let)]
 #![feature(underscore_const_names)]
 
 trait Trt {}
index 191f09b54ee7324a334877e8dc4405af6586dd81..9a570a4381b32deb1626a4868204fb1644b77053 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(const_let)]
-
 pub static mut A: u32 = 0;
 pub static mut B: () = unsafe { A = 1; };
 //~^ ERROR cannot mutate statics in the initializer of another static
index 673a71b4642f39028ae47e1a13b093819a9fc8ef..e7233c5b8a5e003f568077c366ed990d59a9adee 100644 (file)
@@ -1,11 +1,11 @@
 error: cannot mutate statics in the initializer of another static
-  --> $DIR/write-to-static-mut-in-static.rs:14:33
+  --> $DIR/write-to-static-mut-in-static.rs:12:33
    |
 LL | pub static mut B: () = unsafe { A = 1; };
    |                                 ^^^^^
 
 error: cannot mutate statics in the initializer of another static
-  --> $DIR/write-to-static-mut-in-static.rs:17:34
+  --> $DIR/write-to-static-mut-in-static.rs:15:34
    |
 LL | pub static mut C: u32 = unsafe { C = 1; 0 };
    |                                  ^^^^^