]> git.lizzy.rs Git - rust.git/commitdiff
Remove const_in_array_rep_expr
authorkadmin <julianknodt@gmail.com>
Tue, 26 Jan 2021 22:49:30 +0000 (22:49 +0000)
committerkadmin <julianknodt@gmail.com>
Sat, 30 Jan 2021 23:20:24 +0000 (23:20 +0000)
43 files changed:
compiler/rustc_feature/src/active.rs
compiler/rustc_feature/src/removed.rs
compiler/rustc_middle/src/traits/mod.rs
compiler/rustc_mir/src/borrow_check/type_check/mod.rs
compiler/rustc_mir/src/transform/check_consts/qualifs.rs
compiler/rustc_mir/src/transform/promote_consts.rs
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
library/alloc/src/lib.rs
src/doc/unstable-book/src/language-features/const-in-array-repeat-expressions.md [deleted file]
src/test/ui/array-slice-vec/repeat_empty_ok.rs [new file with mode: 0644]
src/test/ui/array-slice-vec/repeat_empty_ok.stderr [new file with mode: 0644]
src/test/ui/consts/const-blocks/const-repeat.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/fn-call-in-const.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/fn-call-in-non-const.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr [new file with mode: 0644]
src/test/ui/consts/const-blocks/migrate-fail.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/migrate-fail.stderr [new file with mode: 0644]
src/test/ui/consts/const-blocks/migrate-pass.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/nll-fail.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/nll-fail.stderr [new file with mode: 0644]
src/test/ui/consts/const-blocks/nll-pass.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/run-pass.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/trait-error.rs [new file with mode: 0644]
src/test/ui/consts/const-blocks/trait-error.stderr [new file with mode: 0644]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-repeat.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.stderr [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs [deleted file]
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr [deleted file]
src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.rs [deleted file]
src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.stderr [deleted file]
src/test/ui/issues/issue-80371.rs [deleted file]
src/test/ui/issues/issue-80371.stderr [deleted file]
src/test/ui/unused/unused-closure.rs
src/test/ui/unused/unused-closure.stderr

index cd3c8fded633f05e4074076e13fe08756a6c8541..e12b533b110d22fc4124852c52fd2d5848f49e27 100644 (file)
@@ -485,9 +485,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
     /// Allows `async || body` closures.
     (active, async_closure, "1.37.0", Some(62290), None),
 
-    /// Allows `[x; N]` where `x` is a constant (RFC 2203).
-    (active, const_in_array_repeat_expressions, "1.37.0", Some(49147), None),
-
     /// Allows `impl Trait` to be used inside type aliases (RFC 2515).
     (active, type_alias_impl_trait, "1.38.0", Some(63063), None),
 
index 07bd1602cda325af18b5c5266af147d85befc9e1..38a3a4e3d4411275fe060e681570ba34d184047c 100644 (file)
@@ -97,6 +97,9 @@ macro_rules! declare_features {
     (removed, extern_in_paths, "1.33.0", Some(55600), None,
      Some("subsumed by `::foo::bar` paths")),
     (removed, quote, "1.33.0", Some(29601), None, None),
+    /// Allows `[x; N]` where `x` is a constant (RFC 2203).
+    (removed, const_in_array_repeat_expressions,  "1.37.0", Some(49147), None,
+     Some("removed due to causing promotable bugs")),
     /// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
     (removed, dropck_parametricity, "1.38.0", Some(28498), None, None),
     (removed, await_macro, "1.38.0", Some(50547), None,
index 0a663f793aa753cc8cf84404e2d20f97d12e0708..163b400973b7cd2a0feb05f38c383223a0a02f95 100644 (file)
@@ -228,8 +228,7 @@ pub enum ObligationCauseCode<'tcx> {
     /// Inline asm operand type must be `Sized`.
     InlineAsmSized,
     /// `[T, ..n]` implies that `T` must be `Copy`.
-    /// If `true`, suggest `const_in_array_repeat_expressions` feature flag.
-    RepeatVec(bool),
+    RepeatVec,
 
     /// Types of fields (other than the last, except for packed structs) in a struct must be sized.
     FieldSized {
index fb9820e853f8f38b463e28df6b2ba1d6cd2c18e2..8de8b32bd64af249df5dcbc1568d9f8b145e19ab 100644 (file)
 use crate::dataflow::impls::MaybeInitializedPlaces;
 use crate::dataflow::move_paths::MoveData;
 use crate::dataflow::ResultsCursor;
-use crate::transform::{
-    check_consts::ConstCx,
-    promote_consts::should_suggest_const_in_array_repeat_expressions_attribute,
-};
 
 use crate::borrow_check::{
     borrow_set::BorrowSet,
@@ -1997,22 +1993,13 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
                             let span = body.source_info(location).span;
                             let ty = operand.ty(body, tcx);
                             if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty, span) {
-                                let ccx = ConstCx::new_with_param_env(tcx, body, self.param_env);
-                                // To determine if `const_in_array_repeat_expressions` feature gate should
-                                // be mentioned, need to check if the rvalue is promotable.
-                                let should_suggest =
-                                    should_suggest_const_in_array_repeat_expressions_attribute(
-                                        &ccx, operand,
-                                    );
-                                debug!("check_rvalue: should_suggest={:?}", should_suggest);
-
                                 let def_id = body.source.def_id().expect_local();
                                 self.infcx.report_selection_error(
                                     &traits::Obligation::new(
                                         ObligationCause::new(
                                             span,
                                             self.tcx().hir().local_def_id_to_hir_id(def_id),
-                                            traits::ObligationCauseCode::RepeatVec(should_suggest),
+                                            traits::ObligationCauseCode::RepeatVec,
                                         ),
                                         self.param_env,
                                         ty::Binder::bind(ty::TraitRef::new(
index 4d159ed34038038bb2b529c17707e738a67e82bf..0ce1980f10a1186645e16747b7c6891a410ad7ce 100644 (file)
@@ -246,7 +246,8 @@ pub fn in_operand<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, operand: &Oper
     };
 
     // Check the qualifs of the value of `const` items.
-    if let ty::ConstKind::Unevaluated(def, _, None) = constant.literal.val {
+    if let ty::ConstKind::Unevaluated(def, _, promoted) = constant.literal.val {
+        assert!(promoted.is_none());
         // Don't peek inside trait associated constants.
         if cx.tcx.trait_of_item(def.did).is_none() {
             let qualifs = if let Some((did, param_did)) = def.as_const_arg() {
index d8758e045443c6ac3110200c5122bc1f37386ced..b4504a0e223f6899d36d7126b40567ff7a81ab19 100644 (file)
@@ -102,9 +102,6 @@ pub enum Candidate {
     /// Borrow of a constant temporary, candidate for lifetime extension.
     Ref(Location),
 
-    /// Promotion of the `x` in `[x; 32]`.
-    Repeat(Location),
-
     /// Currently applied to function calls where the callee has the unstable
     /// `#[rustc_args_required_const]` attribute as well as the SIMD shuffle
     /// intrinsic. The intrinsic requires the arguments are indeed constant and
@@ -120,14 +117,14 @@ impl Candidate {
     /// Returns `true` if we should use the "explicit" rules for promotability for this `Candidate`.
     fn forces_explicit_promotion(&self) -> bool {
         match self {
-            Candidate::Ref(_) | Candidate::Repeat(_) => false,
+            Candidate::Ref(_) => false,
             Candidate::Argument { .. } | Candidate::InlineAsm { .. } => true,
         }
     }
 
     fn source_info(&self, body: &Body<'_>) -> SourceInfo {
         match self {
-            Candidate::Ref(location) | Candidate::Repeat(location) => *body.source_info(*location),
+            Candidate::Ref(location) => *body.source_info(*location),
             Candidate::Argument { bb, .. } | Candidate::InlineAsm { bb, .. } => {
                 *body.source_info(body.terminator_loc(*bb))
             }
@@ -213,11 +210,6 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
             Rvalue::Ref(..) => {
                 self.candidates.push(Candidate::Ref(location));
             }
-            Rvalue::Repeat(..) if self.ccx.tcx.features().const_in_array_repeat_expressions => {
-                // FIXME(#49147) only promote the element when it isn't `Copy`
-                // (so that code that can copy it at runtime is unaffected).
-                self.candidates.push(Candidate::Repeat(location));
-            }
             _ => {}
         }
     }
@@ -334,21 +326,6 @@ fn validate_candidate(&self, candidate: Candidate) -> Result<(), Unpromotable> {
                     _ => bug!(),
                 }
             }
-            Candidate::Repeat(loc) => {
-                assert!(!self.explicit);
-
-                let statement = &self.body[loc.block].statements[loc.statement_index];
-                match &statement.kind {
-                    StatementKind::Assign(box (_, Rvalue::Repeat(ref operand, _))) => {
-                        if !self.tcx.features().const_in_array_repeat_expressions {
-                            return Err(Unpromotable);
-                        }
-
-                        self.validate_operand(operand)
-                    }
-                    _ => bug!(),
-                }
-            }
             Candidate::Argument { bb, index } => {
                 assert!(self.explicit);
 
@@ -1090,18 +1067,6 @@ fn promote_candidate(
                         _ => bug!(),
                     }
                 }
-                Candidate::Repeat(loc) => {
-                    let statement = &mut blocks[loc.block].statements[loc.statement_index];
-                    match statement.kind {
-                        StatementKind::Assign(box (_, Rvalue::Repeat(ref mut operand, _))) => {
-                            let ty = operand.ty(local_decls, self.tcx);
-                            let span = statement.source_info.span;
-
-                            Rvalue::Use(mem::replace(operand, promoted_operand(ty, span)))
-                        }
-                        _ => bug!(),
-                    }
-                }
                 Candidate::Argument { bb, index } => {
                     let terminator = blocks[bb].terminator_mut();
                     match terminator.kind {
@@ -1182,8 +1147,7 @@ pub fn promote_candidates<'tcx>(
     let mut extra_statements = vec![];
     for candidate in candidates.into_iter().rev() {
         match candidate {
-            Candidate::Repeat(Location { block, statement_index })
-            | Candidate::Ref(Location { block, statement_index }) => {
+            Candidate::Ref(Location { block, statement_index }) => {
                 if let StatementKind::Assign(box (place, _)) =
                     &body[block].statements[statement_index].kind
                 {
@@ -1267,27 +1231,3 @@ pub fn promote_candidates<'tcx>(
 
     promotions
 }
-
-/// This function returns `true` if the `const_in_array_repeat_expressions` feature attribute should
-/// be suggested. This function is probably quite expensive, it shouldn't be run in the happy path.
-/// Feature attribute should be suggested if `operand` can be promoted and the feature is not
-/// enabled.
-crate fn should_suggest_const_in_array_repeat_expressions_attribute<'tcx>(
-    ccx: &ConstCx<'_, 'tcx>,
-    operand: &Operand<'tcx>,
-) -> bool {
-    let mut rpo = traversal::reverse_postorder(&ccx.body);
-    let (temps, _) = collect_temps_and_candidates(&ccx, &mut rpo);
-    let validator = Validator { ccx, temps: &temps, explicit: false };
-
-    let should_promote = validator.validate_operand(operand).is_ok();
-    let feature_flag = validator.ccx.tcx.features().const_in_array_repeat_expressions;
-    debug!(
-        "should_suggest_const_in_array_repeat_expressions_flag: def_id={:?} \
-            should_promote={:?} feature_flag={:?}",
-        validator.ccx.def_id(),
-        should_promote,
-        feature_flag
-    );
-    should_promote && !feature_flag
-}
index 0724a9290e91c64a4db86c501480ec111544a0d4..690591930deb9d9af28f2de778898460d20a71a1 100644 (file)
@@ -1881,23 +1881,10 @@ fn note_obligation_cause_code<T>(
             ObligationCauseCode::Coercion { source: _, target } => {
                 err.note(&format!("required by cast to type `{}`", self.ty_to_string(target)));
             }
-            ObligationCauseCode::RepeatVec(suggest_const_in_array_repeat_expressions) => {
+            ObligationCauseCode::RepeatVec => {
                 err.note(
                     "the `Copy` trait is required because the repeated element will be copied",
                 );
-                if suggest_const_in_array_repeat_expressions {
-                    err.note(
-                        "this array initializer can be evaluated at compile-time, see issue \
-                         #49147 <https://github.com/rust-lang/rust/issues/49147> \
-                         for more information",
-                    );
-                    if tcx.sess.opts.unstable_features.is_nightly_build() {
-                        err.help(
-                            "add `#![feature(const_in_array_repeat_expressions)]` to the \
-                             crate attributes to enable",
-                        );
-                    }
-                }
             }
             ObligationCauseCode::VariableType(hir_id) => {
                 let parent_node = self.tcx.hir().get_parent_node(hir_id);
index d7ae353282e799decf035238000f86db0420b5cd..d8f774f723c85c8bc8f437ac78c47c095d98c686 100644 (file)
@@ -89,7 +89,6 @@
 #![feature(coerce_unsized)]
 #![feature(const_btree_new)]
 #![feature(const_fn)]
-#![feature(const_in_array_repeat_expressions)]
 #![feature(cow_is_borrowed)]
 #![feature(const_cow_is_borrowed)]
 #![feature(dispatch_from_dyn)]
diff --git a/src/doc/unstable-book/src/language-features/const-in-array-repeat-expressions.md b/src/doc/unstable-book/src/language-features/const-in-array-repeat-expressions.md
deleted file mode 100644 (file)
index 9409169..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# `const_in_array_repeat_expressions`
-
-The tracking issue for this feature is: [#49147]
-
-[#49147]: https://github.com/rust-lang/rust/issues/49147
-
-------------------------
-
-Relaxes the rules for repeat expressions, `[x; N]` such that `x` may also be `const` (strictly
-speaking rvalue promotable), in addition to `typeof(x): Copy`. The result of `[x; N]` where `x` is
-`const` is itself also `const`.
diff --git a/src/test/ui/array-slice-vec/repeat_empty_ok.rs b/src/test/ui/array-slice-vec/repeat_empty_ok.rs
new file mode 100644 (file)
index 0000000..25463ea
--- /dev/null
@@ -0,0 +1,15 @@
+#![crate_type = "lib"]
+
+pub struct Header<'a> {
+    pub value: &'a [u8],
+}
+
+pub fn test() {
+    let headers = [Header{value: &[]}; 128];
+    //~^ ERROR the trait bound
+}
+
+pub fn test2() {
+    let headers = [Header{value: &[0]}; 128];
+    //~^ ERROR the trait bound
+}
diff --git a/src/test/ui/array-slice-vec/repeat_empty_ok.stderr b/src/test/ui/array-slice-vec/repeat_empty_ok.stderr
new file mode 100644 (file)
index 0000000..85baa12
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied
+  --> $DIR/repeat_empty_ok.rs:8:19
+   |
+LL |     let headers = [Header{value: &[]}; 128];
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>`
+   |
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied
+  --> $DIR/repeat_empty_ok.rs:13:19
+   |
+LL |     let headers = [Header{value: &[0]}; 128];
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>`
+   |
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/const-blocks/const-repeat.rs b/src/test/ui/consts/const-blocks/const-repeat.rs
new file mode 100644 (file)
index 0000000..65d0231
--- /dev/null
@@ -0,0 +1,27 @@
+// run-pass
+
+// Repeating a *constant* of non-Copy type (not just a constant expression) is already stable.
+
+const EMPTY: Vec<i32> = Vec::new();
+
+pub fn bar() -> [Vec<i32>; 2] {
+    [EMPTY; 2]
+}
+
+struct Bomb;
+
+impl Drop for Bomb {
+    fn drop(&mut self) {
+        panic!("BOOM!");
+    }
+}
+
+const BOOM: Bomb = Bomb;
+
+fn main() {
+    let _x = bar();
+
+    // Make sure the destructor does not get called for empty arrays. `[CONST; N]` should
+    // instantiate (and then later drop) the const exactly `N` times.
+    let _x = [BOOM; 0];
+}
diff --git a/src/test/ui/consts/const-blocks/fn-call-in-const.rs b/src/test/ui/consts/const-blocks/fn-call-in-const.rs
new file mode 100644 (file)
index 0000000..7936af7
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+
+#![feature(inline_const)]
+#![allow(unused, incomplete_features)]
+
+// Some type that is not copyable.
+struct Bar;
+
+const fn type_no_copy() -> Option<Bar> {
+    None
+}
+
+const fn type_copy() -> u32 {
+    3
+}
+
+const _: [u32; 2] = [type_copy(); 2];
+
+// This is allowed because all promotion contexts use the explicit rules for promotability when
+// inside an explicit const context.
+const _: [Option<Bar>; 2] = [const { type_no_copy() }; 2];
+
+fn main() {}
diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs b/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs
new file mode 100644 (file)
index 0000000..1921784
--- /dev/null
@@ -0,0 +1,16 @@
+// Some type that is not copyable.
+struct Bar;
+
+const fn no_copy() -> Option<Bar> {
+    None
+}
+
+const fn copy() -> u32 {
+    3
+}
+
+fn main() {
+    let _: [u32; 2] = [copy(); 2];
+    let _: [Option<Bar>; 2] = [no_copy(); 2];
+    //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied
+}
diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr
new file mode 100644 (file)
index 0000000..b75452c
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
+  --> $DIR/fn-call-in-non-const.rs:14:31
+   |
+LL |     let _: [Option<Bar>; 2] = [no_copy(); 2];
+   |                               ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
+   |
+   = help: the following implementations were found:
+             <Option<T> as Copy>
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/const-blocks/migrate-fail.rs b/src/test/ui/consts/const-blocks/migrate-fail.rs
new file mode 100644 (file)
index 0000000..bb12139
--- /dev/null
@@ -0,0 +1,24 @@
+// ignore-compare-mode-nll
+// compile-flags: -Z borrowck=migrate
+#![allow(warnings)]
+
+// Some type that is not copyable.
+struct Bar;
+
+mod non_constants {
+    use Bar;
+
+    fn no_impl_copy_empty_value_multiple_elements() {
+        let x = None;
+        let arr: [Option<Bar>; 2] = [x; 2];
+        //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277]
+    }
+
+    fn no_impl_copy_value_multiple_elements() {
+        let x = Some(Bar);
+        let arr: [Option<Bar>; 2] = [x; 2];
+        //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277]
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/const-blocks/migrate-fail.stderr b/src/test/ui/consts/const-blocks/migrate-fail.stderr
new file mode 100644 (file)
index 0000000..0fdbbc3
--- /dev/null
@@ -0,0 +1,23 @@
+error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
+  --> $DIR/migrate-fail.rs:13:37
+   |
+LL |         let arr: [Option<Bar>; 2] = [x; 2];
+   |                                     ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
+   |
+   = help: the following implementations were found:
+             <Option<T> as Copy>
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
+  --> $DIR/migrate-fail.rs:19:37
+   |
+LL |         let arr: [Option<Bar>; 2] = [x; 2];
+   |                                     ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
+   |
+   = help: the following implementations were found:
+             <Option<T> as Copy>
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/const-blocks/migrate-pass.rs b/src/test/ui/consts/const-blocks/migrate-pass.rs
new file mode 100644 (file)
index 0000000..3195717
--- /dev/null
@@ -0,0 +1,127 @@
+// check-pass
+// compile-flags: -Z borrowck=migrate
+// ignore-compare-mode-nll
+#![allow(warnings)]
+
+// Some type that is not copyable.
+struct Bar;
+
+mod constants {
+    use Bar;
+
+    fn no_impl_copy_empty_value_no_elements() {
+        const FOO: Option<Bar> = None;
+        const ARR: [Option<Bar>; 0] = [FOO; 0];
+    }
+
+    fn no_impl_copy_empty_value_single_element() {
+        const FOO: Option<Bar> = None;
+        const ARR: [Option<Bar>; 1] = [FOO; 1];
+    }
+
+    fn no_impl_copy_empty_value_multiple_elements() {
+        const FOO: Option<Bar> = None;
+        const ARR: [Option<Bar>; 2] = [FOO; 2];
+    }
+
+    fn no_impl_copy_value_no_elements() {
+        const FOO: Option<Bar> = Some(Bar);
+        const ARR: [Option<Bar>; 0] = [FOO; 0];
+    }
+
+    fn no_impl_copy_value_single_element() {
+        const FOO: Option<Bar> = Some(Bar);
+        const ARR: [Option<Bar>; 1] = [FOO; 1];
+    }
+
+    fn no_impl_copy_value_multiple_elements() {
+        const FOO: Option<Bar> = Some(Bar);
+        const ARR: [Option<Bar>; 2] = [FOO; 2];
+    }
+
+    fn impl_copy_empty_value_no_elements() {
+        const FOO: Option<u32> = None;
+        const ARR: [Option<u32>; 0] = [FOO; 0];
+    }
+
+    fn impl_copy_empty_value_one_element() {
+        const FOO: Option<u32> = None;
+        const ARR: [Option<u32>; 1] = [FOO; 1];
+    }
+
+    fn impl_copy_empty_value_multiple_elements() {
+        const FOO: Option<u32> = None;
+        const ARR: [Option<u32>; 2] = [FOO; 2];
+    }
+
+    fn impl_copy_value_no_elements() {
+        const FOO: Option<u32> = Some(4);
+        const ARR: [Option<u32>; 0] = [FOO; 0];
+    }
+
+    fn impl_copy_value_one_element() {
+        const FOO: Option<u32> = Some(4);
+        const ARR: [Option<u32>; 1] = [FOO; 1];
+    }
+
+    fn impl_copy_value_multiple_elements() {
+        const FOO: Option<u32> = Some(4);
+        const ARR: [Option<u32>; 2] = [FOO; 2];
+    }
+}
+
+mod non_constants {
+    use Bar;
+
+    fn no_impl_copy_empty_value_no_elements() {
+        let x = None;
+        let arr: [Option<Bar>; 0] = [x; 0];
+    }
+
+    fn no_impl_copy_empty_value_single_element() {
+        let x = None;
+        let arr: [Option<Bar>; 1] = [x; 1];
+    }
+
+    fn no_impl_copy_value_no_elements() {
+        let x = Some(Bar);
+        let arr: [Option<Bar>; 0] = [x; 0];
+    }
+
+    fn no_impl_copy_value_single_element() {
+        let x = Some(Bar);
+        let arr: [Option<Bar>; 1] = [x; 1];
+    }
+
+    fn impl_copy_empty_value_no_elements() {
+        let x: Option<u32> = None;
+        let arr: [Option<u32>; 0] = [x; 0];
+    }
+
+    fn impl_copy_empty_value_one_element() {
+        let x: Option<u32> = None;
+        let arr: [Option<u32>; 1] = [x; 1];
+    }
+
+    fn impl_copy_empty_value_multiple_elements() {
+        let x: Option<u32> = None;
+        let arr: [Option<u32>; 2] = [x; 2];
+    }
+
+    fn impl_copy_value_no_elements() {
+        let x: Option<u32> = Some(4);
+        let arr: [Option<u32>; 0] = [x; 0];
+    }
+
+    fn impl_copy_value_one_element() {
+        let x: Option<u32> = Some(4);
+        let arr: [Option<u32>; 1] = [x; 1];
+    }
+
+    fn impl_copy_value_multiple_elements() {
+        let x: Option<u32> = Some(4);
+        let arr: [Option<u32>; 2] = [x; 2];
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/const-blocks/nll-fail.rs b/src/test/ui/consts/const-blocks/nll-fail.rs
new file mode 100644 (file)
index 0000000..871387c
--- /dev/null
@@ -0,0 +1,23 @@
+// ignore-compare-mode-nll
+#![allow(warnings)]
+
+// Some type that is not copyable.
+struct Bar;
+
+mod non_constants {
+    use Bar;
+
+    fn no_impl_copy_empty_value_multiple_elements() {
+        let x = None;
+        let arr: [Option<Bar>; 2] = [x; 2];
+        //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277]
+    }
+
+    fn no_impl_copy_value_multiple_elements() {
+        let x = Some(Bar);
+        let arr: [Option<Bar>; 2] = [x; 2];
+        //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277]
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/const-blocks/nll-fail.stderr b/src/test/ui/consts/const-blocks/nll-fail.stderr
new file mode 100644 (file)
index 0000000..8122085
--- /dev/null
@@ -0,0 +1,23 @@
+error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
+  --> $DIR/nll-fail.rs:12:37
+   |
+LL |         let arr: [Option<Bar>; 2] = [x; 2];
+   |                                     ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
+   |
+   = help: the following implementations were found:
+             <Option<T> as Copy>
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
+  --> $DIR/nll-fail.rs:18:37
+   |
+LL |         let arr: [Option<Bar>; 2] = [x; 2];
+   |                                     ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
+   |
+   = help: the following implementations were found:
+             <Option<T> as Copy>
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/const-blocks/nll-pass.rs b/src/test/ui/consts/const-blocks/nll-pass.rs
new file mode 100644 (file)
index 0000000..d8defa1
--- /dev/null
@@ -0,0 +1,126 @@
+// check-pass
+// ignore-compare-mode-nll
+#![allow(warnings)]
+
+// Some type that is not copyable.
+struct Bar;
+
+mod constants {
+    use Bar;
+
+    fn no_impl_copy_empty_value_no_elements() {
+        const FOO: Option<Bar> = None;
+        const ARR: [Option<Bar>; 0] = [FOO; 0];
+    }
+
+    fn no_impl_copy_empty_value_single_element() {
+        const FOO: Option<Bar> = None;
+        const ARR: [Option<Bar>; 1] = [FOO; 1];
+    }
+
+    fn no_impl_copy_empty_value_multiple_elements() {
+        const FOO: Option<Bar> = None;
+        const ARR: [Option<Bar>; 2] = [FOO; 2];
+    }
+
+    fn no_impl_copy_value_no_elements() {
+        const FOO: Option<Bar> = Some(Bar);
+        const ARR: [Option<Bar>; 0] = [FOO; 0];
+    }
+
+    fn no_impl_copy_value_single_element() {
+        const FOO: Option<Bar> = Some(Bar);
+        const ARR: [Option<Bar>; 1] = [FOO; 1];
+    }
+
+    fn no_impl_copy_value_multiple_elements() {
+        const FOO: Option<Bar> = Some(Bar);
+        const ARR: [Option<Bar>; 2] = [FOO; 2];
+    }
+
+    fn impl_copy_empty_value_no_elements() {
+        const FOO: Option<u32> = None;
+        const ARR: [Option<u32>; 0] = [FOO; 0];
+    }
+
+    fn impl_copy_empty_value_one_element() {
+        const FOO: Option<u32> = None;
+        const ARR: [Option<u32>; 1] = [FOO; 1];
+    }
+
+    fn impl_copy_empty_value_multiple_elements() {
+        const FOO: Option<u32> = None;
+        const ARR: [Option<u32>; 2] = [FOO; 2];
+    }
+
+    fn impl_copy_value_no_elements() {
+        const FOO: Option<u32> = Some(4);
+        const ARR: [Option<u32>; 0] = [FOO; 0];
+    }
+
+    fn impl_copy_value_one_element() {
+        const FOO: Option<u32> = Some(4);
+        const ARR: [Option<u32>; 1] = [FOO; 1];
+    }
+
+    fn impl_copy_value_multiple_elements() {
+        const FOO: Option<u32> = Some(4);
+        const ARR: [Option<u32>; 2] = [FOO; 2];
+    }
+}
+
+mod non_constants {
+    use Bar;
+
+    fn no_impl_copy_empty_value_no_elements() {
+        let x = None;
+        let arr: [Option<Bar>; 0] = [x; 0];
+    }
+
+    fn no_impl_copy_empty_value_single_element() {
+        let x = None;
+        let arr: [Option<Bar>; 1] = [x; 1];
+    }
+
+    fn no_impl_copy_value_no_elements() {
+        let x = Some(Bar);
+        let arr: [Option<Bar>; 0] = [x; 0];
+    }
+
+    fn no_impl_copy_value_single_element() {
+        let x = Some(Bar);
+        let arr: [Option<Bar>; 1] = [x; 1];
+    }
+
+    fn impl_copy_empty_value_no_elements() {
+        let x: Option<u32> = None;
+        let arr: [Option<u32>; 0] = [x; 0];
+    }
+
+    fn impl_copy_empty_value_one_element() {
+        let x: Option<u32> = None;
+        let arr: [Option<u32>; 1] = [x; 1];
+    }
+
+    fn impl_copy_empty_value_multiple_elements() {
+        let x: Option<u32> = None;
+        let arr: [Option<u32>; 2] = [x; 2];
+    }
+
+    fn impl_copy_value_no_elements() {
+        let x: Option<u32> = Some(4);
+        let arr: [Option<u32>; 0] = [x; 0];
+    }
+
+    fn impl_copy_value_one_element() {
+        let x: Option<u32> = Some(4);
+        let arr: [Option<u32>; 1] = [x; 1];
+    }
+
+    fn impl_copy_value_multiple_elements() {
+        let x: Option<u32> = Some(4);
+        let arr: [Option<u32>; 2] = [x; 2];
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/consts/const-blocks/run-pass.rs b/src/test/ui/consts/const-blocks/run-pass.rs
new file mode 100644 (file)
index 0000000..e11f69b
--- /dev/null
@@ -0,0 +1,11 @@
+// run-pass
+
+#[derive(Debug, Eq, PartialEq)]
+struct Bar;
+
+fn main() {
+    const FOO: Option<Bar> = None;
+    const ARR: [Option<Bar>; 2] = [FOO; 2];
+
+    assert_eq!(ARR, [None::<Bar>, None::<Bar>]);
+}
diff --git a/src/test/ui/consts/const-blocks/trait-error.rs b/src/test/ui/consts/const-blocks/trait-error.rs
new file mode 100644 (file)
index 0000000..5a614cb
--- /dev/null
@@ -0,0 +1,7 @@
+#[derive(Copy, Clone)]
+struct Foo<T>(T);
+
+fn main() {
+    [Foo(String::new()); 4];
+    //~^ ERROR the trait bound `Foo<String>: Copy` is not satisfied [E0277]
+}
diff --git a/src/test/ui/consts/const-blocks/trait-error.stderr b/src/test/ui/consts/const-blocks/trait-error.stderr
new file mode 100644 (file)
index 0000000..26e2848
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0277]: the trait bound `Foo<String>: Copy` is not satisfied
+  --> $DIR/trait-error.rs:5:5
+   |
+LL |     [Foo(String::new()); 4];
+   |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Foo<String>`
+   |
+   = help: the following implementations were found:
+             <Foo<T> as Copy>
+   = note: the `Copy` trait is required because the repeated element will be copied
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-repeat.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-repeat.rs
deleted file mode 100644 (file)
index 65d0231..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// run-pass
-
-// Repeating a *constant* of non-Copy type (not just a constant expression) is already stable.
-
-const EMPTY: Vec<i32> = Vec::new();
-
-pub fn bar() -> [Vec<i32>; 2] {
-    [EMPTY; 2]
-}
-
-struct Bomb;
-
-impl Drop for Bomb {
-    fn drop(&mut self) {
-        panic!("BOOM!");
-    }
-}
-
-const BOOM: Bomb = Bomb;
-
-fn main() {
-    let _x = bar();
-
-    // Make sure the destructor does not get called for empty arrays. `[CONST; N]` should
-    // instantiate (and then later drop) the const exactly `N` times.
-    let _x = [BOOM; 0];
-}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs
deleted file mode 100644 (file)
index da1bae1..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-
-#![allow(unused)]
-#![feature(const_in_array_repeat_expressions)]
-
-// Some type that is not copyable.
-struct Bar;
-
-const fn type_no_copy() -> Option<Bar> {
-    None
-}
-
-const fn type_copy() -> u32 {
-    3
-}
-
-const _: [u32; 2] = [type_copy(); 2];
-
-// This is allowed because all promotion contexts use the explicit rules for promotability when
-// inside an explicit const context.
-const _: [Option<Bar>; 2] = [type_no_copy(); 2];
-
-fn main() {}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.rs
deleted file mode 100644 (file)
index d40facf..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#![feature(const_in_array_repeat_expressions)]
-
-// Some type that is not copyable.
-struct Bar;
-
-const fn no_copy() -> Option<Bar> {
-    None
-}
-
-const fn copy() -> u32 {
-    3
-}
-
-fn main() {
-    let _: [u32; 2] = [copy(); 2];
-    let _: [Option<Bar>; 2] = [no_copy(); 2];
-    //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied
-}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.stderr b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.stderr
deleted file mode 100644 (file)
index 4809243..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
-  --> $DIR/fn-call-in-non-const.rs:16:31
-   |
-LL |     let _: [Option<Bar>; 2] = [no_copy(); 2];
-   |                               ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
-   |
-   = help: the following implementations were found:
-             <Option<T> as Copy>
-   = note: the `Copy` trait is required because the repeated element will be copied
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs
deleted file mode 100644 (file)
index d04b0b7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// ignore-compare-mode-nll
-// compile-flags: -Z borrowck=migrate
-#![feature(const_in_array_repeat_expressions)]
-#![allow(warnings)]
-
-// Some type that is not copyable.
-struct Bar;
-
-mod non_constants {
-    use Bar;
-
-    fn no_impl_copy_empty_value_multiple_elements() {
-        let x = None;
-        let arr: [Option<Bar>; 2] = [x; 2];
-        //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277]
-    }
-
-    fn no_impl_copy_value_multiple_elements() {
-        let x = Some(Bar);
-        let arr: [Option<Bar>; 2] = [x; 2];
-        //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277]
-    }
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr
deleted file mode 100644 (file)
index 476d48f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
-  --> $DIR/migrate-fail.rs:14:37
-   |
-LL |         let arr: [Option<Bar>; 2] = [x; 2];
-   |                                     ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
-   |
-   = help: the following implementations were found:
-             <Option<T> as Copy>
-   = note: the `Copy` trait is required because the repeated element will be copied
-
-error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
-  --> $DIR/migrate-fail.rs:20:37
-   |
-LL |         let arr: [Option<Bar>; 2] = [x; 2];
-   |                                     ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
-   |
-   = help: the following implementations were found:
-             <Option<T> as Copy>
-   = note: the `Copy` trait is required because the repeated element will be copied
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs
deleted file mode 100644 (file)
index bfa8ebc..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-// check-pass
-// compile-flags: -Z borrowck=migrate
-// ignore-compare-mode-nll
-#![feature(const_in_array_repeat_expressions)]
-#![allow(warnings)]
-
-// Some type that is not copyable.
-struct Bar;
-
-mod constants {
-    use Bar;
-
-    fn no_impl_copy_empty_value_no_elements() {
-        const FOO: Option<Bar> = None;
-        const ARR: [Option<Bar>; 0] = [FOO; 0];
-    }
-
-    fn no_impl_copy_empty_value_single_element() {
-        const FOO: Option<Bar> = None;
-        const ARR: [Option<Bar>; 1] = [FOO; 1];
-    }
-
-    fn no_impl_copy_empty_value_multiple_elements() {
-        const FOO: Option<Bar> = None;
-        const ARR: [Option<Bar>; 2] = [FOO; 2];
-    }
-
-    fn no_impl_copy_value_no_elements() {
-        const FOO: Option<Bar> = Some(Bar);
-        const ARR: [Option<Bar>; 0] = [FOO; 0];
-    }
-
-    fn no_impl_copy_value_single_element() {
-        const FOO: Option<Bar> = Some(Bar);
-        const ARR: [Option<Bar>; 1] = [FOO; 1];
-    }
-
-    fn no_impl_copy_value_multiple_elements() {
-        const FOO: Option<Bar> = Some(Bar);
-        const ARR: [Option<Bar>; 2] = [FOO; 2];
-    }
-
-    fn impl_copy_empty_value_no_elements() {
-        const FOO: Option<u32> = None;
-        const ARR: [Option<u32>; 0] = [FOO; 0];
-    }
-
-    fn impl_copy_empty_value_one_element() {
-        const FOO: Option<u32> = None;
-        const ARR: [Option<u32>; 1] = [FOO; 1];
-    }
-
-    fn impl_copy_empty_value_multiple_elements() {
-        const FOO: Option<u32> = None;
-        const ARR: [Option<u32>; 2] = [FOO; 2];
-    }
-
-    fn impl_copy_value_no_elements() {
-        const FOO: Option<u32> = Some(4);
-        const ARR: [Option<u32>; 0] = [FOO; 0];
-    }
-
-    fn impl_copy_value_one_element() {
-        const FOO: Option<u32> = Some(4);
-        const ARR: [Option<u32>; 1] = [FOO; 1];
-    }
-
-    fn impl_copy_value_multiple_elements() {
-        const FOO: Option<u32> = Some(4);
-        const ARR: [Option<u32>; 2] = [FOO; 2];
-    }
-}
-
-mod non_constants {
-    use Bar;
-
-    fn no_impl_copy_empty_value_no_elements() {
-        let x = None;
-        let arr: [Option<Bar>; 0] = [x; 0];
-    }
-
-    fn no_impl_copy_empty_value_single_element() {
-        let x = None;
-        let arr: [Option<Bar>; 1] = [x; 1];
-    }
-
-    fn no_impl_copy_value_no_elements() {
-        let x = Some(Bar);
-        let arr: [Option<Bar>; 0] = [x; 0];
-    }
-
-    fn no_impl_copy_value_single_element() {
-        let x = Some(Bar);
-        let arr: [Option<Bar>; 1] = [x; 1];
-    }
-
-    fn impl_copy_empty_value_no_elements() {
-        let x: Option<u32> = None;
-        let arr: [Option<u32>; 0] = [x; 0];
-    }
-
-    fn impl_copy_empty_value_one_element() {
-        let x: Option<u32> = None;
-        let arr: [Option<u32>; 1] = [x; 1];
-    }
-
-    fn impl_copy_empty_value_multiple_elements() {
-        let x: Option<u32> = None;
-        let arr: [Option<u32>; 2] = [x; 2];
-    }
-
-    fn impl_copy_value_no_elements() {
-        let x: Option<u32> = Some(4);
-        let arr: [Option<u32>; 0] = [x; 0];
-    }
-
-    fn impl_copy_value_one_element() {
-        let x: Option<u32> = Some(4);
-        let arr: [Option<u32>; 1] = [x; 1];
-    }
-
-    fn impl_copy_value_multiple_elements() {
-        let x: Option<u32> = Some(4);
-        let arr: [Option<u32>; 2] = [x; 2];
-    }
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs
deleted file mode 100644 (file)
index 2d5c59d..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// ignore-compare-mode-nll
-#![feature(const_in_array_repeat_expressions, nll)]
-#![allow(warnings)]
-
-// Some type that is not copyable.
-struct Bar;
-
-mod non_constants {
-    use Bar;
-
-    fn no_impl_copy_empty_value_multiple_elements() {
-        let x = None;
-        let arr: [Option<Bar>; 2] = [x; 2];
-        //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277]
-    }
-
-    fn no_impl_copy_value_multiple_elements() {
-        let x = Some(Bar);
-        let arr: [Option<Bar>; 2] = [x; 2];
-        //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277]
-    }
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr
deleted file mode 100644 (file)
index 3aa6999..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
-  --> $DIR/nll-fail.rs:13:37
-   |
-LL |         let arr: [Option<Bar>; 2] = [x; 2];
-   |                                     ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
-   |
-   = help: the following implementations were found:
-             <Option<T> as Copy>
-   = note: the `Copy` trait is required because the repeated element will be copied
-
-error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied
-  --> $DIR/nll-fail.rs:19:37
-   |
-LL |         let arr: [Option<Bar>; 2] = [x; 2];
-   |                                     ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>`
-   |
-   = help: the following implementations were found:
-             <Option<T> as Copy>
-   = note: the `Copy` trait is required because the repeated element will be copied
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs
deleted file mode 100644 (file)
index a304f87..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-// check-pass
-// ignore-compare-mode-nll
-#![allow(warnings)]
-#![feature(const_in_array_repeat_expressions, nll)]
-
-// Some type that is not copyable.
-struct Bar;
-
-mod constants {
-    use Bar;
-
-    fn no_impl_copy_empty_value_no_elements() {
-        const FOO: Option<Bar> = None;
-        const ARR: [Option<Bar>; 0] = [FOO; 0];
-    }
-
-    fn no_impl_copy_empty_value_single_element() {
-        const FOO: Option<Bar> = None;
-        const ARR: [Option<Bar>; 1] = [FOO; 1];
-    }
-
-    fn no_impl_copy_empty_value_multiple_elements() {
-        const FOO: Option<Bar> = None;
-        const ARR: [Option<Bar>; 2] = [FOO; 2];
-    }
-
-    fn no_impl_copy_value_no_elements() {
-        const FOO: Option<Bar> = Some(Bar);
-        const ARR: [Option<Bar>; 0] = [FOO; 0];
-    }
-
-    fn no_impl_copy_value_single_element() {
-        const FOO: Option<Bar> = Some(Bar);
-        const ARR: [Option<Bar>; 1] = [FOO; 1];
-    }
-
-    fn no_impl_copy_value_multiple_elements() {
-        const FOO: Option<Bar> = Some(Bar);
-        const ARR: [Option<Bar>; 2] = [FOO; 2];
-    }
-
-    fn impl_copy_empty_value_no_elements() {
-        const FOO: Option<u32> = None;
-        const ARR: [Option<u32>; 0] = [FOO; 0];
-    }
-
-    fn impl_copy_empty_value_one_element() {
-        const FOO: Option<u32> = None;
-        const ARR: [Option<u32>; 1] = [FOO; 1];
-    }
-
-    fn impl_copy_empty_value_multiple_elements() {
-        const FOO: Option<u32> = None;
-        const ARR: [Option<u32>; 2] = [FOO; 2];
-    }
-
-    fn impl_copy_value_no_elements() {
-        const FOO: Option<u32> = Some(4);
-        const ARR: [Option<u32>; 0] = [FOO; 0];
-    }
-
-    fn impl_copy_value_one_element() {
-        const FOO: Option<u32> = Some(4);
-        const ARR: [Option<u32>; 1] = [FOO; 1];
-    }
-
-    fn impl_copy_value_multiple_elements() {
-        const FOO: Option<u32> = Some(4);
-        const ARR: [Option<u32>; 2] = [FOO; 2];
-    }
-}
-
-mod non_constants {
-    use Bar;
-
-    fn no_impl_copy_empty_value_no_elements() {
-        let x = None;
-        let arr: [Option<Bar>; 0] = [x; 0];
-    }
-
-    fn no_impl_copy_empty_value_single_element() {
-        let x = None;
-        let arr: [Option<Bar>; 1] = [x; 1];
-    }
-
-    fn no_impl_copy_value_no_elements() {
-        let x = Some(Bar);
-        let arr: [Option<Bar>; 0] = [x; 0];
-    }
-
-    fn no_impl_copy_value_single_element() {
-        let x = Some(Bar);
-        let arr: [Option<Bar>; 1] = [x; 1];
-    }
-
-    fn impl_copy_empty_value_no_elements() {
-        let x: Option<u32> = None;
-        let arr: [Option<u32>; 0] = [x; 0];
-    }
-
-    fn impl_copy_empty_value_one_element() {
-        let x: Option<u32> = None;
-        let arr: [Option<u32>; 1] = [x; 1];
-    }
-
-    fn impl_copy_empty_value_multiple_elements() {
-        let x: Option<u32> = None;
-        let arr: [Option<u32>; 2] = [x; 2];
-    }
-
-    fn impl_copy_value_no_elements() {
-        let x: Option<u32> = Some(4);
-        let arr: [Option<u32>; 0] = [x; 0];
-    }
-
-    fn impl_copy_value_one_element() {
-        let x: Option<u32> = Some(4);
-        let arr: [Option<u32>; 1] = [x; 1];
-    }
-
-    fn impl_copy_value_multiple_elements() {
-        let x: Option<u32> = Some(4);
-        let arr: [Option<u32>; 2] = [x; 2];
-    }
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs
deleted file mode 100644 (file)
index 27bf5da..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// run-pass
-#![feature(const_in_array_repeat_expressions)]
-
-#[derive(Debug, Eq, PartialEq)]
-struct Bar;
-
-fn main() {
-    const FOO: Option<Bar> = None;
-    const ARR: [Option<Bar>; 2] = [FOO; 2];
-
-    assert_eq!(ARR, [None::<Bar>, None::<Bar>]);
-}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs
deleted file mode 100644 (file)
index f8df7aa..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#![feature(const_in_array_repeat_expressions)]
-
-#[derive(Copy, Clone)]
-struct Foo<T>(T);
-
-fn main() {
-    [Foo(String::new()); 4];
-    //~^ ERROR the trait bound `Foo<String>: Copy` is not satisfied [E0277]
-}
diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr
deleted file mode 100644 (file)
index 26de67e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0277]: the trait bound `Foo<String>: Copy` is not satisfied
-  --> $DIR/trait-error.rs:7:5
-   |
-LL |     [Foo(String::new()); 4];
-   |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Foo<String>`
-   |
-   = help: the following implementations were found:
-             <Foo<T> as Copy>
-   = note: the `Copy` trait is required because the repeated element will be copied
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.rs b/src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.rs
deleted file mode 100644 (file)
index 5ed302b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#![allow(warnings)]
-
-struct Bar;
-
-// This function would compile with the feature gate, and tests that it is suggested.
-fn foo() {
-    let arr: [Option<String>; 2] = [None::<String>; 2];
-    //~^ ERROR the trait bound `Option<String>: Copy` is not satisfied [E0277]
-}
-
-// This function would not compile with the feature gate, and tests that it is not suggested.
-fn bar() {
-    let arr: [Option<String>; 2] = [Some("foo".to_string()); 2];
-    //~^ ERROR the trait bound `Option<String>: Copy` is not satisfied [E0277]
-}
-
-fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.stderr b/src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.stderr
deleted file mode 100644 (file)
index ca17061..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-error[E0277]: the trait bound `Option<String>: Copy` is not satisfied
-  --> $DIR/feature-gate-const_in_array_repeat_expressions.rs:7:36
-   |
-LL |     let arr: [Option<String>; 2] = [None::<String>; 2];
-   |                                    ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option<String>`
-   |
-   = help: the following implementations were found:
-             <Option<T> as Copy>
-   = note: the `Copy` trait is required because the repeated element will be copied
-   = note: this array initializer can be evaluated at compile-time, see issue #49147 <https://github.com/rust-lang/rust/issues/49147> for more information
-   = help: add `#![feature(const_in_array_repeat_expressions)]` to the crate attributes to enable
-
-error[E0277]: the trait bound `Option<String>: Copy` is not satisfied
-  --> $DIR/feature-gate-const_in_array_repeat_expressions.rs:13:36
-   |
-LL |     let arr: [Option<String>; 2] = [Some("foo".to_string()); 2];
-   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option<String>`
-   |
-   = help: the following implementations were found:
-             <Option<T> as Copy>
-   = note: the `Copy` trait is required because the repeated element will be copied
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/issues/issue-80371.rs b/src/test/ui/issues/issue-80371.rs
deleted file mode 100644 (file)
index 25463ea..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#![crate_type = "lib"]
-
-pub struct Header<'a> {
-    pub value: &'a [u8],
-}
-
-pub fn test() {
-    let headers = [Header{value: &[]}; 128];
-    //~^ ERROR the trait bound
-}
-
-pub fn test2() {
-    let headers = [Header{value: &[0]}; 128];
-    //~^ ERROR the trait bound
-}
diff --git a/src/test/ui/issues/issue-80371.stderr b/src/test/ui/issues/issue-80371.stderr
deleted file mode 100644 (file)
index 5e2052a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied
-  --> $DIR/issue-80371.rs:8:19
-   |
-LL |     let headers = [Header{value: &[]}; 128];
-   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>`
-   |
-   = note: the `Copy` trait is required because the repeated element will be copied
-   = note: this array initializer can be evaluated at compile-time, see issue #49147 <https://github.com/rust-lang/rust/issues/49147> for more information
-   = help: add `#![feature(const_in_array_repeat_expressions)]` to the crate attributes to enable
-
-error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied
-  --> $DIR/issue-80371.rs:13:19
-   |
-LL |     let headers = [Header{value: &[0]}; 128];
-   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>`
-   |
-   = note: the `Copy` trait is required because the repeated element will be copied
-   = note: this array initializer can be evaluated at compile-time, see issue #49147 <https://github.com/rust-lang/rust/issues/49147> for more information
-   = help: add `#![feature(const_in_array_repeat_expressions)]` to the crate attributes to enable
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
index 5100636842be5c239fe59e7f6cc96afdb46d6696..c96c907318ce93c67162f579e5ef5e490fcba4d3 100644 (file)
@@ -2,7 +2,6 @@
 // edition:2018
 
 #![feature(async_closure)]
-#![feature(const_in_array_repeat_expressions)]
 #![feature(generators)]
 #![deny(unused_must_use)]
 
@@ -18,10 +17,6 @@ fn unused() {
 
     [Box::new([|| {}; 10]); 1]; //~ ERROR unused array of boxed arrays of closures that must be used
 
-    [|| { //~ ERROR unused array of generators that must be used
-        yield 42u32;
-    }; 42];
-
     vec![|| "a"].pop().unwrap(); //~ ERROR unused closure that must be used
 
     let b = false;
index f8b4cbb02c4bd57a739ceceee551064a7e5b59a3..265d3e8e075fdc71c5944ff1da06d4d78bbc2c36 100644 (file)
@@ -1,5 +1,5 @@
 error: unused closure that must be used
-  --> $DIR/unused-closure.rs:10:5
+  --> $DIR/unused-closure.rs:9:5
    |
 LL | /     || {
 LL | |         println!("Hello!");
@@ -7,14 +7,14 @@ LL | |     };
    | |______^
    |
 note: the lint level is defined here
-  --> $DIR/unused-closure.rs:7:9
+  --> $DIR/unused-closure.rs:6:9
    |
 LL | #![deny(unused_must_use)]
    |         ^^^^^^^^^^^^^^^
    = note: closures are lazy and do nothing unless called
 
 error: unused implementer of `Future` that must be used
-  --> $DIR/unused-closure.rs:14:5
+  --> $DIR/unused-closure.rs:13:5
    |
 LL |     async {};
    |     ^^^^^^^^^
@@ -22,7 +22,7 @@ LL |     async {};
    = note: futures do nothing unless you `.await` or poll them
 
 error: unused closure that must be used
-  --> $DIR/unused-closure.rs:15:5
+  --> $DIR/unused-closure.rs:14:5
    |
 LL |     || async {};
    |     ^^^^^^^^^^^^
@@ -30,7 +30,7 @@ LL |     || async {};
    = note: closures are lazy and do nothing unless called
 
 error: unused closure that must be used
-  --> $DIR/unused-closure.rs:16:5
+  --> $DIR/unused-closure.rs:15:5
    |
 LL |     async || {};
    |     ^^^^^^^^^^^^
@@ -38,25 +38,15 @@ LL |     async || {};
    = note: closures are lazy and do nothing unless called
 
 error: unused array of boxed arrays of closures that must be used
-  --> $DIR/unused-closure.rs:19:5
+  --> $DIR/unused-closure.rs:18:5
    |
 LL |     [Box::new([|| {}; 10]); 1];
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: closures are lazy and do nothing unless called
 
-error: unused array of generators that must be used
-  --> $DIR/unused-closure.rs:21:5
-   |
-LL | /     [|| {
-LL | |         yield 42u32;
-LL | |     }; 42];
-   | |___________^
-   |
-   = note: generators are lazy and do nothing unless resumed
-
 error: unused closure that must be used
-  --> $DIR/unused-closure.rs:25:5
+  --> $DIR/unused-closure.rs:20:5
    |
 LL |     vec![|| "a"].pop().unwrap();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -64,12 +54,12 @@ LL |     vec![|| "a"].pop().unwrap();
    = note: closures are lazy and do nothing unless called
 
 error: unused closure that must be used
-  --> $DIR/unused-closure.rs:28:9
+  --> $DIR/unused-closure.rs:23:9
    |
 LL |         || true;
    |         ^^^^^^^^
    |
    = note: closures are lazy and do nothing unless called
 
-error: aborting due to 8 previous errors
+error: aborting due to 7 previous errors