]> git.lizzy.rs Git - rust.git/commitdiff
Stabilize `let` bindings and destructuring in constants and const fn
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Fri, 28 Dec 2018 19:05:22 +0000 (20:05 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Wed, 9 Jan 2019 09:20:12 +0000 (10:20 +0100)
86 files changed:
src/librustc_mir/transform/qualify_consts.rs
src/librustc_mir/transform/qualify_min_const_fn.rs
src/libsyntax/feature_gate.rs
src/test/compile-fail/const-fn-error.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/issue-37550.rs
src/test/run-pass/ctfe/locals-in-const-fn.rs
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 [deleted file]
src/test/ui/consts/const-block-non-item-statement-2.stderr [deleted file]
src/test/ui/consts/const-block-non-item-statement-3.rs [deleted file]
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/ub-upvars.rs
src/test/ui/consts/const-fn-destructuring-arg.rs
src/test/ui/consts/const-fn-destructuring-arg.stderr [deleted file]
src/test/ui/consts/const-fn-not-safe-for-const.rs
src/test/ui/consts/const-fn-not-safe-for-const.stderr
src/test/ui/consts/const_let_assign.rs
src/test/ui/consts/const_let_assign2.rs
src/test/ui/consts/const_let_assign3.rs
src/test/ui/consts/const_let_assign3.stderr
src/test/ui/consts/const_let_eq.rs
src/test/ui/consts/const_let_eq_float.rs
src/test/ui/consts/const_short_circuit.rs
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/min_const_fn/min_const_fn.rs
src/test/ui/consts/min_const_fn/min_const_fn.stderr
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.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/consts/static_mut_containing_mut_ref2.rs
src/test/ui/consts/static_mut_containing_mut_ref2.stderr
src/test/ui/consts/static_mut_containing_mut_ref3.rs
src/test/ui/consts/static_mut_containing_mut_ref3.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-gates/feature-gate-const_let.rs [deleted file]
src/test/ui/feature-gates/feature-gate-const_let.stderr [deleted file]
src/test/ui/feature-gates/feature-gate-underscore_const_names.rs
src/test/ui/feature-gates/feature-gate-underscore_const_names.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-37550.rs
src/test/ui/issues/issue-37550.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/unsafe/ranged_ints2_const.rs
src/test/ui/unsafe/ranged_ints3_const.rs
src/test/ui/unsafe/ranged_ints4_const.rs
src/test/ui/write-to-static-mut-in-static.rs
src/test/ui/write-to-static-mut-in-static.stderr

index a04dd5bb5970f4045f29bc3ffcd1944778f9f1ba..3d90e55f1e4e257dd73eb6405692a6c3d7e11913 100644 (file)
@@ -21,7 +21,7 @@
 use rustc::middle::lang_items;
 use rustc::session::config::nightly_options;
 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;
@@ -104,7 +104,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>
 }
@@ -139,7 +138,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![]
         }
@@ -168,26 +166,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;
@@ -233,80 +211,46 @@ fn assign(&mut self, dest: &Place<'tcx>, location: Location) {
             return;
         }
 
-        if self.tcx.features().const_let {
-            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 {
+                // We treat all locals equal in constants
+                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),
         }
     }
 
@@ -347,45 +291,6 @@ fn qualify_const(&mut self) -> (Qualif, Lrc<BitSet<Local>>) {
                 TerminatorKind::FalseUnwind { .. } => None,
 
                 TerminatorKind::Return => {
-                    if !self.tcx.features().const_let {
-                        // 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;
                 }
             };
@@ -454,12 +359,8 @@ fn visit_local(&mut self,
             LocalKind::ReturnPointer => {
                 self.not_const();
             }
-            LocalKind::Var if !self.tcx.features().const_let => {
-                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));
-                }
+            LocalKind::Arg |
+            LocalKind::Var if self.mode == Mode::Fn => {
                 self.add(Qualif::NOT_CONST);
             }
             LocalKind::Var |
@@ -1168,46 +1069,6 @@ fn visit_assign(&mut self,
         debug!("visit_assign: dest={:?} rvalue={:?} location={:?}", dest, rvalue, location);
         self.visit_rvalue(rvalue, location);
 
-        // Check the allowed const fn argument forms.
-        if let (Mode::ConstFn, &Place::Local(index)) = (self.mode, dest) {
-            if self.mir.local_kind(index) == LocalKind::Var &&
-               self.const_fn_arg_vars.insert(index) &&
-               !self.tcx.features().const_let {
-                // Direct use of an argument is permitted.
-                match *rvalue {
-                    Rvalue::Use(Operand::Copy(Place::Local(local))) |
-                    Rvalue::Use(Operand::Move(Place::Local(local))) => {
-                        if self.mir.local_kind(local) == LocalKind::Arg {
-                            return;
-                        }
-                    }
-                    _ => {}
-                }
-                // Avoid a generic error for other uses of arguments.
-                if self.qualif.contains(Qualif::FN_ARGUMENT) {
-                    let decl = &self.mir.local_decls[index];
-                    let mut err = feature_err(
-                        &self.tcx.sess.parse_sess,
-                        "const_let",
-                        decl.source_info.span,
-                        GateIssue::Language,
-                        "arguments of constant functions can only be immutable by-value bindings"
-                    );
-                    if self.tcx.sess.teach(&err.get_code().unwrap()) {
-                        err.note("Constant functions are not allowed to mutate anything. Thus, \
-                                  binding to an argument with a mutable pattern is not allowed.");
-                        err.note("Remove any mutable bindings from the argument list to fix this \
-                                  error. In case you need to mutate the argument, try lazily \
-                                  initializing a global variable instead of using a const fn, or \
-                                  refactoring the code to a functional style to avoid mutation if \
-                                  possible.");
-                    }
-                    err.emit();
-                    return;
-                }
-            }
-        }
-
         self.assign(dest, location);
     }
 
index c1c5b18915aede665e4734aef2dd786c436a57f2..6df6841f869f28e97d955ab167a45a3fac2c6d5f 100644 (file)
@@ -65,12 +65,6 @@ pub fn is_min_const_fn(
         }
     }
 
-    for local in mir.vars_iter() {
-        return Err((
-            mir.local_decls[local].source_info.span,
-            "local variables in const fn are unstable".into(),
-        ));
-    }
     for local in &mir.local_decls {
         check_ty(tcx, local.ty, local.source_info.span)?;
     }
@@ -147,7 +141,7 @@ fn check_rvalue(
             check_operand(tcx, mir, operand, span)
         }
         Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) => {
-            check_place(tcx, mir, place, span, PlaceMode::Read)
+            check_place(tcx, mir, place, span)
         }
         Rvalue::Cast(CastKind::Misc, operand, cast_ty) => {
             use rustc::ty::cast::CastTy;
@@ -213,11 +207,6 @@ fn check_rvalue(
     }
 }
 
-enum PlaceMode {
-    Assign,
-    Read,
-}
-
 fn check_statement(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     mir: &'a Mir<'tcx>,
@@ -226,11 +215,11 @@ fn check_statement(
     let span = statement.source_info.span;
     match &statement.kind {
         StatementKind::Assign(place, rval) => {
-            check_place(tcx, mir, place, span, PlaceMode::Assign)?;
+            check_place(tcx, mir, place, span)?;
             check_rvalue(tcx, mir, rval, span)
         }
 
-        StatementKind::FakeRead(_, place) => check_place(tcx, mir, place, span, PlaceMode::Read),
+        StatementKind::FakeRead(_, place) => check_place(tcx, mir, place, span),
 
         // just an assignment
         StatementKind::SetDiscriminant { .. } => Ok(()),
@@ -256,7 +245,7 @@ fn check_operand(
 ) -> McfResult {
     match operand {
         Operand::Move(place) | Operand::Copy(place) => {
-            check_place(tcx, mir, place, span, PlaceMode::Read)
+            check_place(tcx, mir, place, span)
         }
         Operand::Constant(_) => Ok(()),
     }
@@ -267,25 +256,16 @@ fn check_place(
     mir: &'a Mir<'tcx>,
     place: &Place<'tcx>,
     span: Span,
-    mode: PlaceMode,
 ) -> McfResult {
     match place {
-        Place::Local(l) => match mode {
-            PlaceMode::Assign => match mir.local_kind(*l) {
-                LocalKind::Temp | LocalKind::ReturnPointer => Ok(()),
-                LocalKind::Arg | LocalKind::Var => {
-                    Err((span, "assignments in const fn are unstable".into()))
-                }
-            },
-            PlaceMode::Read => Ok(()),
-        },
+        Place::Local(_) => Ok(()),
         // promoteds are always fine, they are essentially constants
         Place::Promoted(_) => Ok(()),
         Place::Static(_) => Err((span, "cannot access `static` items in const fn".into())),
         Place::Projection(proj) => {
             match proj.elem {
                 | ProjectionElem::Deref | ProjectionElem::Field(..) | ProjectionElem::Index(_) => {
-                    check_place(tcx, mir, &proj.base, span, mode)
+                    check_place(tcx, mir, &proj.base, span)
                 }
                 // slice patterns are unstable
                 | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. } => {
@@ -311,10 +291,10 @@ fn check_terminator(
         | TerminatorKind::Resume => Ok(()),
 
         TerminatorKind::Drop { location, .. } => {
-            check_place(tcx, mir, location, span, PlaceMode::Read)
+            check_place(tcx, mir, location, span)
         }
         TerminatorKind::DropAndReplace { location, value, .. } => {
-            check_place(tcx, mir, location, span, PlaceMode::Read)?;
+            check_place(tcx, mir, location, span)?;
             check_operand(tcx, mir, value, span)
         },
 
index cddec3eb23a5a3c53b16cde059f4ded7cb22044f..15cf4334154da408c20317b4e42df9b8c53a5c9b 100644 (file)
@@ -193,9 +193,6 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
     // Allows the definition of `const` functions with some advanced features.
     (active, const_fn, "1.2.0", Some(24111), None),
 
-    // Allows let bindings and destructuring in `const` functions and constants.
-    (active, const_let, "1.22.1", Some(48821), None),
-
     // Allows accessing fields of unions inside `const` functions.
     (active, const_fn_union, "1.27.0", Some(51909), None),
 
@@ -688,6 +685,8 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
     (accepted, min_const_unsafe_fn, "1.33.0", Some(55607), None),
     // `#[cfg_attr(predicate, multiple, attributes, here)]`
     (accepted, cfg_attr_multi, "1.33.0", Some(54881), None),
+    // Allows let bindings and destructuring in `const` functions and constants.
+    (accepted, const_let, "1.33.0", Some(48821), None),
 );
 
 // If you change this, please modify `src/doc/unstable-book` as well. You must
index 9913138693c9490d5cbbadbd020ec61dca454dd7..da6036a04a549e7aa4dbcc1179bd3841a2729283 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(const_fn, const_let)]
+#![feature(const_fn)]
 
 const X : usize = 2;
 
index 90295414d3efc73c1781d00b14eb1b4576e011cf..54ed2efa50bbdeb7dac922030eefa1200cab5340 100644 (file)
@@ -1,8 +1,6 @@
 // run-pass
 #![allow(dead_code)]
 
-#![feature(const_let)]
-
 type Array = [u32; {  let x = 2; 5 }];
 
 pub fn main() {}
index 21ce08ab69c73cb5bf5244bffa361d39ca5e04f2..92bf5ae7b97e734e1f46dcfb2f20099b7e63f3c9 100644 (file)
@@ -1,8 +1,6 @@
 // run-pass
 #![allow(dead_code)]
 
-#![feature(const_let)]
-
 enum Foo {
     Bar = { let x = 1; 3 }
 }
index 732c34dff5a801057f32a8988b4c6e6d7f5bf825..04865830df2ebec06bb9e8550be08dd39c9579e6 100644 (file)
@@ -2,7 +2,7 @@
 #![allow(dead_code)]
 #![allow(unused_variables)]
 
-#![feature(const_fn, const_let)]
+#![feature(const_fn)]
 
 const fn x() {
     let t = true;
index e527e1e88c8da6d8759c6efe7221696a31c78f25..27e93b913f8442bd30816c5a2bd55dc450580517 100644 (file)
@@ -2,7 +2,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 eb0fc39e1bf15f49e2df910b66a78d172272cb1a..acfb3b5e44bab041a8ded3504faab37c026ccb85 100644 (file)
@@ -78,6 +78,7 @@ fn drop(&mut self) {}
 
 static STATIC11: Box<MyOwned> = box MyOwned;
 //~^ ERROR allocations are not allowed in statics
+//~| ERROR static contains unimplemented expression type
 
 static mut STATIC12: UnsafeStruct = UnsafeStruct;
 
@@ -92,12 +93,16 @@ fn drop(&mut self) {}
 
 static STATIC15: &'static [Box<MyOwned>] = &[
     box MyOwned, //~ ERROR allocations are not allowed in statics
+    //~| ERROR contains unimplemented expression
     box MyOwned, //~ ERROR allocations are not allowed in statics
+    //~| ERROR contains unimplemented expression
 ];
 
 static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = (
     &box MyOwned, //~ ERROR allocations are not allowed in statics
+    //~| ERROR contains unimplemented expression
     &box MyOwned, //~ ERROR allocations are not allowed in statics
+    //~| ERROR contains unimplemented expression
 );
 
 static mut STATIC17: SafeEnum = SafeEnum::Variant1;
@@ -105,9 +110,11 @@ fn drop(&mut self) {}
 static STATIC19: Box<isize> =
     box 3;
 //~^ ERROR allocations are not allowed in statics
+    //~| ERROR contains unimplemented expression
 
 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 cannot move out of static item
+    //~| ERROR contains unimplemented expression
 }
index 450a9ba0c0d1135bb13f5053268bff2a05112e86..5b1f265c34aef5c94ff8f1d53394555c4db83e44 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:79: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:89:32
+  --> $DIR/check-static-values-constraints.rs:90:32
    |
 LL |     field2: SafeEnum::Variant4("str".to_string())
    |                                ^^^^^^^^^^^^^^^^^
 
 error[E0010]: allocations are not allowed in statics
-  --> $DIR/check-static-values-constraints.rs:94:5
+  --> $DIR/check-static-values-constraints.rs:95: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:95: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:95:5
+  --> $DIR/check-static-values-constraints.rs:97: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:97: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:99:6
+  --> $DIR/check-static-values-constraints.rs:102: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:102: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:100:6
+  --> $DIR/check-static-values-constraints.rs:104: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:104: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:106:5
+  --> $DIR/check-static-values-constraints.rs:111:5
    |
 LL |     box 3;
    |     ^^^^^ allocation not allowed in statics
 
+error[E0019]: static contains unimplemented expression type
+  --> $DIR/check-static-values-constraints.rs:111:9
+   |
+LL |     box 3;
+   |         ^
+
 error[E0507]: cannot move out of static item
-  --> $DIR/check-static-values-constraints.rs:110:45
+  --> $DIR/check-static-values-constraints.rs:116: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:110:38
+  --> $DIR/check-static-values-constraints.rs:116: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:116: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`.
diff --git a/src/test/ui/consts/const-block-non-item-statement-2.rs b/src/test/ui/consts/const-block-non-item-statement-2.rs
deleted file mode 100644 (file)
index 58a6cf6..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-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 e0c61a9..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:1: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:4: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:8: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:12: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:12: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:12: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:12: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`.
diff --git a/src/test/ui/consts/const-block-non-item-statement-3.rs b/src/test/ui/consts/const-block-non-item-statement-3.rs
deleted file mode 100644 (file)
index 8678409..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-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 0a549bc..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:1: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:1: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:1: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:1: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 2db9e2413e5b5f880d374e6e5748197ff1c4a555..5ecf9a049842d4a1631dff192f522b0b7e60277c 100644 (file)
@@ -1,9 +1,23 @@
+// 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
 }
 
+
+const A: usize = { 1; 2 };
+
+const B: usize = { { } 2 };
+
+macro_rules! foo {
+    () => (())
+}
+
+const C: usize = { foo!(); 2 };
+
+const D: usize = { let x = 4; 2 };
+
+type Array = [u32; {  let x = 2; 5 }];
+type Array2 = [u32; { let mut x = 2; x = 3; x}];
+
 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 f0d751e..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:2: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:2: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:2: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:2: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 ba8d032367ef8841ef8a8fa8320a83506eb52cf2..4d3c714481a290984b67a31d8d688af363c08d07 100644 (file)
@@ -2,7 +2,6 @@
 // The test should never compile successfully
 
 #![feature(const_raw_ptr_deref)]
-#![feature(const_let)]
 
 use std::cell::UnsafeCell;
 
index 6ca9d688bd062e453882f3275925b79cdf4682a0..be1be6c060071cb8b240bbc6ac2fffd3e2a55a37 100644 (file)
@@ -1,5 +1,5 @@
 error[E0019]: static contains unimplemented expression type
-  --> $DIR/assign-to-static-within-other-static-2.rs:17:5
+  --> $DIR/assign-to-static-within-other-static-2.rs:16:5
    |
 LL |     *FOO.0.get() = 5; //~ ERROR contains unimplemented expression type
    |     ^^^^^^^^^^^^^^^^
index 9fe17bfc6a06e207694372f5fec99e45bcefb254..b4c416b1c55f040e3c921e5540e7c6ccf66abd41 100644 (file)
@@ -2,7 +2,6 @@
 // The test should never compile successfully
 
 #![feature(const_raw_ptr_deref)]
-#![feature(const_let)]
 
 use std::cell::UnsafeCell;
 
index 2ab9765305f47e4dff66380c508e55fd77cebbe9..31e49dc10ca60e845264f5dc23eca45bfd2bbbea 100644 (file)
@@ -1,5 +1,5 @@
 error: cannot mutate statics in the initializer of another static
-  --> $DIR/assign-to-static-within-other-static.rs:11:5
+  --> $DIR/assign-to-static-within-other-static.rs:10:5
    |
 LL |     FOO = 5; //~ ERROR cannot mutate statics in the initializer of another static
    |     ^^^^^^^
index 9e6952733bb0b0e624597e9fdd43da80f44f43d6..63321b9120076aedd3ef431a56f31da3135f2027 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 fn main() {}
 
 struct FakeNeedsDrop;
index e128ca07d8659e552aceae29e0f05197a561b167..00de97e6fb3a027a3a119dc0ace1d746171a82d3 100644 (file)
@@ -1,11 +1,11 @@
 error[E0019]: constant contains unimplemented expression type
-  --> $DIR/const_let.rs:15:55
+  --> $DIR/const_let.rs:13:55
    |
 LL | const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x };
    |                                                       ^
 
 error[E0019]: constant contains unimplemented expression type
-  --> $DIR/const_let.rs:19:35
+  --> $DIR/const_let.rs:17:35
    |
 LL | const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); };
    |                                   ^
index 0d5530acc95827ad0bc70291eb4406da202a3dd2..a2a45af7cb086e1361c92fd1687f2835464e205e 100644 (file)
@@ -1,5 +1,3 @@
-#![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 90d2159d7b5512da8b9a638f4f3960923fa61734..422c2bab6ea906567f4f805199568d45ce28ec9a 100644 (file)
@@ -1,5 +1,5 @@
 error[E0019]: constant contains unimplemented expression type
-  --> $DIR/infinite_loop.rs:9:9
+  --> $DIR/infinite_loop.rs:7: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:6:18
+  --> $DIR/infinite_loop.rs:4:18
    |
 LL |       let _ = [(); {
    |  __________________^
@@ -21,7 +21,7 @@ LL | |     }];
    | |_____^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/infinite_loop.rs:10:20
+  --> $DIR/infinite_loop.rs:8:20
    |
 LL |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
    |                    ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
index 2e3d6fb9e84befe4fece3c50e528039ae63d45eb..aafdd5fe61782fe8ed935182d35d72860e222988 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 fn main() {
     let _ = [(); {
         //~^ WARNING Constant evaluating a complex constant, this might take some time
index 329ea8a21f989961593b0cf71552d0c6403bc309..4f1b2ab4c8f4625b3ae3808f2c4d8eec7ed5ba7e 100644 (file)
@@ -1,5 +1,5 @@
 error[E0019]: constant contains unimplemented expression type
-  --> $DIR/issue-52475.rs:8:9
+  --> $DIR/issue-52475.rs:6: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:4:18
+  --> $DIR/issue-52475.rs:2:18
    |
 LL |       let _ = [(); {
    |  __________________^
@@ -21,7 +21,7 @@ LL | |     }];
    | |_____^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/issue-52475.rs:9:17
+  --> $DIR/issue-52475.rs:7:17
    |
 LL |             n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
    |                 ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
index 62090f4180d36a38f7fc776932df0030279b240d..32f0062168b3d6648a5133e25588b5b8639260f1 100644 (file)
@@ -2,7 +2,6 @@
 // The test should never compile successfully
 
 #![feature(const_raw_ptr_deref)]
-#![feature(const_let)]
 
 use std::cell::UnsafeCell;
 
index 12d6e3be40a9945f3c6b3b3e54c2192510f03b74..9fad6868d2038e60cea295c8d52fb5a95df1f0d8 100644 (file)
@@ -1,11 +1,11 @@
 error[E0019]: static contains unimplemented expression type
-  --> $DIR/mod-static-with-const-fn.rs:19:5
+  --> $DIR/mod-static-with-const-fn.rs:18: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:22:5
+  --> $DIR/mod-static-with-const-fn.rs:21:5
    |
 LL |     foo();
    |     ^^^^^
index 16df0c1b0cc0eb26ff0a57371dd0ffed576cbfc3..9b7bca6b72d61eeb6a9273312a649527c0aa3c41 100644 (file)
@@ -1,4 +1,4 @@
-#![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 7f818079a19d11a4f8e42ba5fc68e3f00a5d3565..dcf89f90e31da3e70aa1625c6921cc41424b5256 100644 (file)
@@ -1,17 +1,7 @@
-// test that certain things are disallowed in constant functions
+// compile-pass
 
-#![feature(const_fn)]
-
-// no destructuring
-const fn i((
-            a,
-            //~^ ERROR arguments of constant functions can only be immutable by-value bindings
-            b
-            //~^ ERROR arguments of constant functions can only be immutable by-value bindings
-           ): (u32, u32)) -> u32 {
+const fn i((a, b): (u32, u32)) -> u32 {
     a + b
-    //~^ ERROR let bindings in constant functions are unstable
-    //~| ERROR let bindings in constant functions are unstable
 }
 
 fn main() {}
diff --git a/src/test/ui/consts/const-fn-destructuring-arg.stderr b/src/test/ui/consts/const-fn-destructuring-arg.stderr
deleted file mode 100644 (file)
index db63e83..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-error[E0658]: arguments of constant functions can only be immutable by-value bindings (see issue #48821)
-  --> $DIR/const-fn-destructuring-arg.rs:7:13
-   |
-LL |             a,
-   |             ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: arguments of constant functions can only be immutable by-value bindings (see issue #48821)
-  --> $DIR/const-fn-destructuring-arg.rs:9:13
-   |
-LL |             b
-   |             ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constant functions are unstable (see issue #48821)
-  --> $DIR/const-fn-destructuring-arg.rs:12:5
-   |
-LL |     a + b
-   |     ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constant functions are unstable (see issue #48821)
-  --> $DIR/const-fn-destructuring-arg.rs:12:9
-   |
-LL |     a + b
-   |         ^
-   |
-   = 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 fe672e7b3e6da5691c8556cba51e1d230a336b6a..085ff5c58e60c6c68f693ad5eec77ce2fdd75fae 100644 (file)
@@ -27,13 +27,9 @@ const fn get_Y_addr() -> &'static u32 {
 }
 
 const fn get() -> u32 {
-    let x = 22; //~ ERROR let bindings in constant functions are unstable
-//~^ ERROR statements in constant functions
-    let y = 44; //~ ERROR let bindings in constant functions are unstable
-//~^ ERROR statements in constant functions
+    let x = 22;
+    let y = 44;
     x + y
-//~^ ERROR let bindings in constant functions are unstable
-//~| ERROR let bindings in constant functions are unstable
 }
 
 fn main() {}
index 8cc4c38526238db76ffe555063cb7e17ca4e7989..2003b137c272b8b0ef3b084ccfc32c625235a731 100644 (file)
@@ -16,55 +16,7 @@ error[E0013]: constant functions cannot refer to statics, use a constant instead
 LL |     &Y
    |     ^^
 
-error[E0658]: let bindings in constant functions are unstable (see issue #48821)
-  --> $DIR/const-fn-not-safe-for-const.rs:30:13
-   |
-LL |     let x = 22; //~ ERROR let bindings in constant functions are unstable
-   |             ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constant functions are unstable (see issue #48821)
-  --> $DIR/const-fn-not-safe-for-const.rs:30:13
-   |
-LL |     let x = 22; //~ ERROR let bindings in constant functions are unstable
-   |             ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constant functions are unstable (see issue #48821)
-  --> $DIR/const-fn-not-safe-for-const.rs:32:13
-   |
-LL |     let y = 44; //~ ERROR let bindings in constant functions are unstable
-   |             ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constant functions are unstable (see issue #48821)
-  --> $DIR/const-fn-not-safe-for-const.rs:32:13
-   |
-LL |     let y = 44; //~ ERROR let bindings in constant functions are unstable
-   |             ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constant functions are unstable (see issue #48821)
-  --> $DIR/const-fn-not-safe-for-const.rs:34:5
-   |
-LL |     x + y
-   |     ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constant functions are unstable (see issue #48821)
-  --> $DIR/const-fn-not-safe-for-const.rs:34:9
-   |
-LL |     x + y
-   |         ^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error: aborting due to 9 previous errors
+error: aborting due to 3 previous errors
 
-Some errors occurred: E0013, E0015, E0658.
+Some errors occurred: E0013, E0015.
 For more information about an error, try `rustc --explain E0013`.
index a3c53a451e106732063ff34e2a8f89fc11fba354..0b09b8469fd752f206b6dffa945d78dfffeef1fd 100644 (file)
@@ -1,7 +1,5 @@
 // compile-pass
 
-#![feature(const_let)]
-
 struct S(i32);
 
 const A: () = {
index 0de7396501adc053762a4e2a6b15b06cccd1bdd9..7839aafe5efa620368dc55932c3183a84d1ea834 100644 (file)
@@ -1,6 +1,5 @@
 // compile-pass
 
-#![feature(const_let)]
 #![feature(const_fn)]
 
 pub struct AA {
index c2ed6cd85ab5c176b795a4ad4d8eba8453cbd8da..dd0705edfe78db2bf50e375d4f29997139ca9cf8 100644 (file)
@@ -1,4 +1,3 @@
-#![feature(const_let)]
 #![feature(const_fn)]
 
 struct S {
@@ -18,6 +17,10 @@ const fn foo(&mut self, x: u32) {
     s
 };
 
+type Array = [u32; { let mut x = 2; let y = &mut x; *y = 42; *y}];
+//~^ ERROR references in constants may only refer to immutable values
+//~| ERROR constant contains unimplemented expression type
+
 fn main() {
     assert_eq!(FOO.state, 3);
 }
index 0f294616d255c3f73c7eba1f3b2687a53702427e..ecf6625151dfe673ff0f0935cf68d03670bc4374 100644 (file)
@@ -1,16 +1,28 @@
 error[E0019]: constant function contains unimplemented expression type
-  --> $DIR/const_let_assign3.rs:10:9
+  --> $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:17:5
+  --> $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 2 previous errors
+error[E0017]: references in constants may only refer to immutable values
+  --> $DIR/const_let_assign3.rs:20:45
+   |
+LL | type Array = [u32; { let mut x = 2; let y = &mut x; *y = 42; *y}];
+   |                                             ^^^^^^ constants require immutable values
+
+error[E0019]: constant contains unimplemented expression type
+  --> $DIR/const_let_assign3.rs:20:53
+   |
+LL | type Array = [u32; { let mut x = 2; let y = &mut x; *y = 42; *y}];
+   |                                                     ^^^^^^^
+
+error: aborting due to 4 previous errors
 
 Some errors occurred: E0017, E0019.
 For more information about an error, try `rustc --explain E0017`.
index 8739cb80e9403cf6d780d51f9d01931f8b9ca511..106a45ee1d41fc3c0a6b6e8a24f2cd6c98fc892e 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(const_let, const_fn)]
+#![feature(const_fn)]
 
 // run-pass
 
index 2c7262df367a399d9a10d1ccfc592519c41a7f22..c48f54e567b2cb4f651a601f0badcc7776d291c0 100644 (file)
@@ -1,6 +1,6 @@
 // compile-pass
 
-#![feature(const_let, const_fn)]
+#![feature(const_fn)]
 
 struct Foo<T>(T);
 struct Bar<T> { x: T }
index cc49e4696e58fd9d803cabfede462415844ca35a..1e7b7ed3193557a52dbacef980517bf52c90e839 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(underscore_const_names, const_let)]
+#![feature(underscore_const_names)]
 
 const _: bool = false && false;
 const _: bool = true && false;
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 238b5f7e310036f76cfcc4405bdabbd153336c88..05cf3d5f1f1731aa69eb49a91bc2514d24b9c246 100644 (file)
@@ -96,7 +96,7 @@ const fn foo30_2(x: *mut u32) -> usize { x as usize }
 const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
 //~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
 const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
-const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn
+const fn foo30_6() -> bool { let x = true; x }
 const fn foo36(a: bool, b: bool) -> bool { a && b }
 //~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
 const fn foo37(a: bool, b: bool) -> bool { a || b }
index 1c68df513b69750925746f9d4064fa9f41668ab3..2cae714fbf727cbb25dc889b73bbe208d75a2196 100644 (file)
@@ -112,12 +112,6 @@ error: `if`, `match`, `&&` and `||` are not stable in const fn
 LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
    |                             ^^^^^^^^^^^
 
-error: local variables in const fn are unstable
-  --> $DIR/min_const_fn.rs:99:34
-   |
-LL | const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn
-   |                                  ^
-
 error: `if`, `match`, `&&` and `||` are not stable in const fn
   --> $DIR/min_const_fn.rs:100:44
    |
@@ -208,6 +202,6 @@ error: function pointers in const fn are unstable
 LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
    |                           ^^^^
 
-error: aborting due to 35 previous errors
+error: aborting due to 34 previous errors
 
 For more information about this error, try `rustc --explain E0493`.
index 3dd76b630a883401acf05ed0179268d498c7fb3a..89acfea6ed8ff8d60ae13bdc63c8602ef235fdf3 100644 (file)
@@ -1,6 +1,6 @@
 const fn mutable_ref_in_const() -> u8 {
-    let mut a = 0; //~ ERROR local variables in const fn
-    let b = &mut a;
+    let mut a = 0;
+    let b = &mut a; //~ ERROR mutable references in const fn
     *b
 }
 
@@ -8,8 +8,8 @@ const fn mutable_ref_in_const() -> u8 {
 
 impl X {
     const fn inherent_mutable_ref_in_const() -> u8 {
-        let mut a = 0; //~ ERROR local variables in const fn
-        let b = &mut a;
+        let mut a = 0;
+        let b = &mut a; //~ ERROR mutable references in const fn
         *b
     }
 }
index fa46f5c804fe0eaed14f4360e024bfa122ed4a6a..5ce0f30dc6e1f27bfc7e5578a016a80cc8f26343 100644 (file)
@@ -1,14 +1,14 @@
-error: local variables in const fn are unstable
-  --> $DIR/mutable_borrow.rs:2:9
+error: mutable references in const fn are unstable
+  --> $DIR/mutable_borrow.rs:3:9
    |
-LL |     let mut a = 0; //~ ERROR local variables in const fn
-   |         ^^^^^
+LL |     let b = &mut a; //~ ERROR mutable references in const fn
+   |         ^
 
-error: local variables in const fn are unstable
-  --> $DIR/mutable_borrow.rs:11:13
+error: mutable references in const fn are unstable
+  --> $DIR/mutable_borrow.rs:12:13
    |
-LL |         let mut a = 0; //~ ERROR local variables in const fn
-   |             ^^^^^
+LL |         let b = &mut a; //~ ERROR mutable references in const fn
+   |             ^
 
 error: aborting due to 2 previous errors
 
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 5863429a2f2c5ddd19ad6e7efc57eb130582155f..dedb7db5920891315da02e88b4ef7988207dae46 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 use std::cell::Cell;
 
 const FOO: &u32 = {
index cc3635a979b370f792afd0c1e34da3b5a3141daa..410c51c4b54e1bb666d4bc7a87a760756fa99e16 100644 (file)
@@ -1,17 +1,17 @@
 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:9:18
+  --> $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
    |                  ^^^^^^
index 8de9b00eb111d3bb0baca2e63cd9278d0ba68ced..a8a6d4d99c6ffb959c5156f1cb30c418564415af 100644 (file)
@@ -1,8 +1,10 @@
-#![feature(const_let)]
-
 fn main() {
     let x: &'static u32 = {
         let y = 42;
         &y //~ ERROR does not live long enough
     };
+    let x: &'static u32 = &{ //~ ERROR does not live long enough
+        let y = 42;
+        y
+    };
 }
index 6bbb7495fb0dca1035a811a19ddc173f98730315..d37bd49186032d141e56aee31f8ad56cfa790d91 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
@@ -8,6 +8,20 @@ LL |     };
    |
    = note: borrowed value must be valid for the static lifetime...
 
-error: aborting due to previous error
+error[E0597]: borrowed value does not live long enough
+  --> $DIR/promote_const_let.rs:6:28
+   |
+LL |       let x: &'static u32 = &{ //~ ERROR does not live long enough
+   |  ____________________________^
+LL | |         let y = 42;
+LL | |         y
+LL | |     };
+   | |_____^ 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 2 previous errors
 
 For more information about this error, try `rustc --explain E0597`.
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 4180b1e295ab049d4eaceb20aca335d07d5e479c..ef378fa84518e5cc1e208e87d5e6c192d486042f 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 static mut STDERR_BUFFER_SPACE: u8 = 0;
 
 pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
index f0ae1545056b7ad3ac98d209eb0d3fa7d5e81db5..72186571d697e15f25a57659797eaf712ab7aedf 100644 (file)
@@ -1,11 +1,11 @@
 error[E0017]: references in statics may only refer to immutable values
-  --> $DIR/static_mut_containing_mut_ref2.rs:5:46
+  --> $DIR/static_mut_containing_mut_ref2.rs:3:46
    |
 LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
    |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values
 
 error[E0019]: static contains unimplemented expression type
-  --> $DIR/static_mut_containing_mut_ref2.rs:5:45
+  --> $DIR/static_mut_containing_mut_ref2.rs:3:45
    |
 LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
    |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index 0bc7faa9afdec7b2d170a33883be90041fcfe459..c24c7e27920795a6d8fe14c3f67a5c3a4bd40c90 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 static mut FOO: (u8, u8) = (42, 43);
 
 static mut BAR: () = unsafe { FOO.0 = 99; };
index cae53c6fee9dd9d6297adb4c4a1276e550777a57..e88e49b097af26b7d0cbe13936c58de0a7153b5e 100644 (file)
@@ -1,5 +1,5 @@
 error[E0080]: could not evaluate static initializer
-  --> $DIR/static_mut_containing_mut_ref3.rs:5:31
+  --> $DIR/static_mut_containing_mut_ref3.rs:3:31
    |
 LL | static mut BAR: () = unsafe { FOO.0 = 99; };
    |                               ^^^^^^^^^^ tried to modify a static's initial value from another static's initializer
index fc5dffb37cfe743dac9c2c65c3301dc94f1ae91d..da51035ab555062b2e03c26a658f14690a0d301c 100644 (file)
@@ -4,5 +4,6 @@
 #![allow(warnings)]
 
 const CON : Box<i32> = box 0; //~ ERROR E0010
+//~^ ERROR constant contains unimplemented expression type
 
 fn main() {}
index da0aadfded5f864cd331bf3058035a1e911dda32..77e7b5ec0e860cf50e2102db6e5d0b4a30bfee7c 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:6: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 e62997640f473e1ee2af953cdfc5a3542d7389be..3398e2c28ba6b5cdcf7acb9a81cf5178b78be955 100644 (file)
@@ -2,5 +2,6 @@
 #![allow(warnings)]
 
 const CON : Box<i32> = box 0; //~ ERROR E0010
+//~^ ERROR constant contains unimplemented expression type
 
 fn main() {}
index b4b490922c45f09734b60a8a81b706ad85a90123..1364693109e086bc64d6ccb8510b2e3d28f67ee5 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:4: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`.
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 74cefd7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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() {}
diff --git a/src/test/ui/feature-gates/feature-gate-const_let.stderr b/src/test/ui/feature-gates/feature-gate-const_let.stderr
deleted file mode 100644 (file)
index 5631299..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/feature-gate-const_let.rs:6:13
-   |
-LL |     let x = 42;
-   |             ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/feature-gate-const_let.rs:6:13
-   |
-LL |     let x = 42;
-   |             ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/feature-gate-const_let.rs:3:1
-   |
-LL | / const FOO: usize = {
-LL | |     //~^ ERROR statements in constants are unstable
-LL | |     //~| ERROR: let bindings in constants are unstable
-LL | |     let x = 42;
-...  |
-LL | |     42
-LL | | };
-   | |__^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/feature-gate-const_let.rs:3:1
-   |
-LL | / const FOO: usize = {
-LL | |     //~^ ERROR statements in constants are unstable
-LL | |     //~| ERROR: let bindings in constants are unstable
-LL | |     let x = 42;
-...  |
-LL | |     42
-LL | | };
-   | |__^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in statics are unstable (see issue #48821)
-  --> $DIR/feature-gate-const_let.rs:15:13
-   |
-LL |     let x = 42;
-   |             ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/feature-gate-const_let.rs:15:13
-   |
-LL |     let x = 42;
-   |             ^^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: let bindings in statics are unstable (see issue #48821)
-  --> $DIR/feature-gate-const_let.rs:12:1
-   |
-LL | / static BAR: usize = {
-LL | |     //~^ ERROR statements in statics are unstable
-LL | |     //~| ERROR: let bindings in statics are unstable
-LL | |     let x = 42;
-...  |
-LL | |     42
-LL | | };
-   | |__^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/feature-gate-const_let.rs:12:1
-   |
-LL | / static BAR: usize = {
-LL | |     //~^ ERROR statements in statics are unstable
-LL | |     //~| ERROR: let bindings in statics are unstable
-LL | |     let x = 42;
-...  |
-LL | |     42
-LL | | };
-   | |__^
-   |
-   = help: add #![feature(const_let)] to the crate attributes to enable
-
-error: aborting due to 8 previous errors
-
-For more information about this error, try `rustc --explain E0658`.
index a82b356c75216e7d013e7a04fad57e0055833583..6b97c24a47ed24ce983d85a6b729a6de1cf5f34f 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 trait Trt {}
 struct Str {}
 
index b3658208828e96f237872bc1cbb6805fb2d18c10..d608f3d37cf2ae7000118abe596f611aa49e8f45 100644 (file)
@@ -1,5 +1,5 @@
 error[E0658]: naming constants with `_` is unstable (see issue #54912)
-  --> $DIR/feature-gate-underscore_const_names.rs:8:1
+  --> $DIR/feature-gate-underscore_const_names.rs:6:1
    |
 LL | / const _ : () = {
 LL | | //~^ ERROR is unstable
index 7bbea191cd16723c904b142a6b67baee768a0489..f58a3de281f1ae1123e7ec98c7057e050f72c947 100644 (file)
@@ -1,11 +1,6 @@
 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 1383cdb4438c931755b2acc6489f00da5565989b..9b21ece341a9f2fa87b66cb7b8d39220237591ea 100644 (file)
@@ -1,67 +1,13 @@
-error[E0658]: let bindings in constants are unstable (see issue #48821)
-  --> $DIR/issue-18118.rs:5: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:5: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:8: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:2: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:2: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:8:10
+  --> $DIR/issue-18118.rs:4: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 9db9d30411d6f16cafac1b0689cbffa8f8170d5f..379f1ee0f388dc763c8020c58d5278d2e2afe6d0 100644 (file)
@@ -5,7 +5,6 @@
 const bad : u32 = {
     {
         5;
-        //~^ ERROR statements in constants are unstable
         0
     }
 };
@@ -13,8 +12,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
     }
 };
@@ -22,7 +20,6 @@
 const bad_three : u32 = {
     {
         valid();
-        //~^ ERROR statements in constants are unstable
         0
     }
 };
@@ -30,7 +27,6 @@
 static bad_four : u32 = {
     {
         5;
-        //~^ ERROR statements in statics are unstable
         0
     }
 };
@@ -39,7 +35,6 @@
     {
         invalid();
         //~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
-        //~| ERROR statements in statics are unstable
         0
     }
 };
@@ -47,7 +42,6 @@
 static bad_six : u32 = {
     {
         valid();
-        //~^ ERROR statements in statics are unstable
         0
     }
 };
@@ -55,7 +49,6 @@
 static mut bad_seven : u32 = {
     {
         5;
-        //~^ ERROR statements in statics are unstable
         0
     }
 };
@@ -63,8 +56,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
     }
 };
@@ -72,7 +64,6 @@
 static mut bad_nine : u32 = {
     {
         valid();
-        //~^ ERROR statements in statics are unstable
         0
     }
 };
index 7fe0261281830fe30fe24f1fceabffa3f7be38a6..9b7fe71d9a7d694cd89a2bbe52b53dfb8c766a80 100644 (file)
@@ -1,94 +1,21 @@
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:7: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:15:9
+  --> $DIR/issue-32829-2.rs:14:9
    |
 LL |         invalid();
    |         ^^^^^^^^^
 
-error[E0658]: statements in constants are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:15: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:24: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:32: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:40:9
+  --> $DIR/issue-32829-2.rs:36:9
    |
 LL |         invalid();
    |         ^^^^^^^^^
 
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:40: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:49: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:57: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:65:9
+  --> $DIR/issue-32829-2.rs:58:9
    |
 LL |         invalid();
    |         ^^^^^^^^^
 
-error[E0658]: statements in statics are unstable (see issue #48821)
-  --> $DIR/issue-32829-2.rs:65: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:74: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 12282f3e548870e60e89c1f65283b515329d5874..505c030b967122758a770ba84f1d7081bc9ee04d 100644 (file)
@@ -1,6 +1,6 @@
 const fn x() {
-    let t = true; //~ ERROR local variables in const fn
-    let x = || t;
+    let t = true;
+    let x = || t; //~ ERROR function pointers in const fn are unstable
 }
 
 fn main() {}
index d42f72ad3fac837fb3982fce16a73a2fec17c3e5..d2b03416cb73cb923de830cf930bcd8dfd6a2362 100644 (file)
@@ -1,7 +1,7 @@
-error: local variables in const fn are unstable
-  --> $DIR/issue-37550.rs:2:9
+error: function pointers in const fn are unstable
+  --> $DIR/issue-37550.rs:3:9
    |
-LL |     let t = true; //~ ERROR local variables in const fn
+LL |     let x = || t; //~ ERROR function pointers in const fn are unstable
    |         ^
 
 error: aborting due to previous error
index 3f9c2ef48a7af73baa9f3cadddebe229750b2c68..52ec9e42be78282a46f370d2bc2dca078ab536b0 100644 (file)
@@ -6,5 +6,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 static contains unimplemented expression type
 
 fn main() { }
index 0e4d6ff1d71fa26187ac7bccb027ebc3a9028d36..52a99ce36b8704ced0caa0280cadd1941dafa2df 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:6: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:6: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 2091fffd418ee68c3b315e16f01b5fbb0af6954b..84d401c9fa61df2d7b718119bc3cc11a1af5f2f6 100644 (file)
@@ -2,5 +2,6 @@
 
 static mut a: Box<isize> = box 3;
 //~^ ERROR allocations are not allowed in statics
+//~| ERROR static contains unimplemented expression type
 
 fn main() {}
index a0fa245156f877e369cdaad136af48ff131bda5e..d2c6ba6a2f85a70dc95ecfb4bd66b4c0592327c4 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:3: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 811d166ed65a78c7c486a88b09e58ee103895bb5..1db022e886208f17050815bfd3f2bf65631ad186 100644 (file)
@@ -1,6 +1,5 @@
 // compile-pass
 
-#![feature(const_let)]
 #![feature(underscore_const_names)]
 
 trait Trt {}
index a61e3329bdce8b9dd899aedca44e80e914c63959..c404f259116158b690013c1c6c3354deb3ff1a37 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(rustc_attrs, const_let, const_fn)]
+#![feature(rustc_attrs, const_fn)]
 
 #[rustc_layout_scalar_valid_range_start(1)]
 #[repr(transparent)]
index 6497b611224b6a77b3d17cd7acf41427f68dce90..f8ce81f0d1c37d7e6c86d0f446a38b4bdd6c3b16 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(rustc_attrs, const_let, const_fn)]
+#![feature(rustc_attrs, const_fn)]
 
 use std::cell::Cell;
 
index f589e4739baf17145f7d3e09d0e1e68e086a95fb..9bda1f69652ec82bbcfb73b00677e31843279538 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(rustc_attrs, const_let, const_fn)]
+#![feature(rustc_attrs, const_fn)]
 
 #[rustc_layout_scalar_valid_range_start(1)]
 #[repr(transparent)]
index 3c34a7704e0dfa524d573ca0d64d92bdb2709607..43c63fed8cef19efd88767d2973a012fe0215107 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_let)]
-
 pub static mut A: u32 = 0;
 pub static mut B: () = unsafe { A = 1; };
 //~^ ERROR could not evaluate static initializer
index 7be83b8dafcfdb4a0132861298eab079be712478..eba1c609d2f8355ad3efde3bb3c7f19cf83be76b 100644 (file)
@@ -1,23 +1,23 @@
 error[E0080]: could not evaluate static initializer
-  --> $DIR/write-to-static-mut-in-static.rs:4:33
+  --> $DIR/write-to-static-mut-in-static.rs:2:33
    |
 LL | pub static mut B: () = unsafe { A = 1; };
    |                                 ^^^^^ tried to modify a static's initial value from another static's initializer
 
 error[E0391]: cycle detected when const-evaluating `C`
-  --> $DIR/write-to-static-mut-in-static.rs:7:34
+  --> $DIR/write-to-static-mut-in-static.rs:5:34
    |
 LL | pub static mut C: u32 = unsafe { C = 1; 0 };
    |                                  ^^^^^
    |
 note: ...which requires const-evaluating `C`...
-  --> $DIR/write-to-static-mut-in-static.rs:7:1
+  --> $DIR/write-to-static-mut-in-static.rs:5:1
    |
 LL | pub static mut C: u32 = unsafe { C = 1; 0 };
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: ...which again requires const-evaluating `C`, completing the cycle
 note: cycle used when const-evaluating + checking `C`
-  --> $DIR/write-to-static-mut-in-static.rs:7:1
+  --> $DIR/write-to-static-mut-in-static.rs:5:1
    |
 LL | pub static mut C: u32 = unsafe { C = 1; 0 };
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^