From fe396531167cc60605db6c51bff169b3e2fd5d55 Mon Sep 17 00:00:00 2001 From: kadmin Date: Sun, 27 Dec 2020 02:30:06 +0000 Subject: [PATCH 1/2] Check that value is explicitly none --- .../src/transform/check_consts/qualifs.rs | 3 +-- src/test/ui/issues/issue-80371.rs | 15 ++++++++++++ src/test/ui/issues/issue-80371.stderr | 23 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/issues/issue-80371.rs create mode 100644 src/test/ui/issues/issue-80371.stderr diff --git a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs index 0ce1980f10a..4d159ed3403 100644 --- a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs @@ -246,8 +246,7 @@ where }; // Check the qualifs of the value of `const` items. - if let ty::ConstKind::Unevaluated(def, _, promoted) = constant.literal.val { - assert!(promoted.is_none()); + if let ty::ConstKind::Unevaluated(def, _, None) = constant.literal.val { // 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() { diff --git a/src/test/ui/issues/issue-80371.rs b/src/test/ui/issues/issue-80371.rs new file mode 100644 index 00000000000..25463ea5ee8 --- /dev/null +++ b/src/test/ui/issues/issue-80371.rs @@ -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/issues/issue-80371.stderr b/src/test/ui/issues/issue-80371.stderr new file mode 100644 index 00000000000..5e2052abba7 --- /dev/null +++ b/src/test/ui/issues/issue-80371.stderr @@ -0,0 +1,23 @@ +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 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 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`. From 6946534d84161353b56157f65f8cdcdfb93df749 Mon Sep 17 00:00:00 2001 From: kadmin Date: Tue, 26 Jan 2021 22:49:30 +0000 Subject: [PATCH 2/2] Remove const_in_array_rep_expr --- compiler/rustc_feature/src/active.rs | 3 - compiler/rustc_feature/src/removed.rs | 3 + compiler/rustc_middle/src/traits/mod.rs | 3 +- .../src/borrow_check/type_check/mod.rs | 15 +---- .../src/transform/check_consts/qualifs.rs | 3 +- .../rustc_mir/src/transform/promote_consts.rs | 66 +------------------ .../src/traits/error_reporting/suggestions.rs | 15 +---- library/alloc/src/lib.rs | 1 - .../const-in-array-repeat-expressions.md | 11 ---- .../repeat_empty_ok.rs} | 0 .../repeat_empty_ok.stderr} | 8 +-- .../const-repeat.rs | 0 .../fn-call-in-const.rs | 6 +- .../fn-call-in-non-const.rs | 2 - .../fn-call-in-non-const.stderr | 2 +- .../migrate-fail.rs | 1 - .../migrate-fail.stderr | 4 +- .../migrate-pass.rs | 1 - .../nll-fail.rs | 1 - .../nll-fail.stderr | 4 +- .../nll-pass.rs | 1 - .../run-pass.rs | 1 - .../trait-error.rs | 2 - .../trait-error.stderr | 2 +- ...-gate-const_in_array_repeat_expressions.rs | 17 ----- ...e-const_in_array_repeat_expressions.stderr | 25 ------- src/test/ui/unused/unused-closure.rs | 5 -- src/test/ui/unused/unused-closure.stderr | 28 +++----- 28 files changed, 31 insertions(+), 199 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/const-in-array-repeat-expressions.md rename src/test/ui/{issues/issue-80371.rs => array-slice-vec/repeat_empty_ok.rs} (100%) rename src/test/ui/{issues/issue-80371.stderr => array-slice-vec/repeat_empty_ok.stderr} (56%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/const-repeat.rs (100%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/fn-call-in-const.rs (73%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/fn-call-in-non-const.rs (85%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/fn-call-in-non-const.stderr (92%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/migrate-fail.rs (92%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/migrate-fail.stderr (93%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/migrate-pass.rs (98%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/nll-fail.rs (91%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/nll-fail.stderr (93%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/nll-pass.rs (98%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/run-pass.rs (81%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/trait-error.rs (77%) rename src/test/ui/consts/{rfc-2203-const-array-repeat-exprs => const-blocks}/trait-error.stderr (94%) delete mode 100644 src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.stderr diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index cd3c8fded63..e12b533b110 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -485,9 +485,6 @@ declare_features! ( /// 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), diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 07bd1602cda..38a3a4e3d44 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -97,6 +97,9 @@ 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, diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 0a663f793aa..163b400973b 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -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 { diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index fb9820e853f..8de8b32bd64 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -43,10 +43,6 @@ use rustc_trait_selection::traits::{self, ObligationCause, PredicateObligations} 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 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { 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( diff --git a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs index 4d159ed3403..0ce1980f10a 100644 --- a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs @@ -246,7 +246,8 @@ where }; // 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() { diff --git a/compiler/rustc_mir/src/transform/promote_consts.rs b/compiler/rustc_mir/src/transform/promote_consts.rs index d8758e04544..b4504a0e223 100644 --- a/compiler/rustc_mir/src/transform/promote_consts.rs +++ b/compiler/rustc_mir/src/transform/promote_consts.rs @@ -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 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> { 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 @@ impl<'tcx> Validator<'_, 'tcx> { _ => 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 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { _ => 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 -} diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 0724a9290e9..690591930de 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1881,23 +1881,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { 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 \ - 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); diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index d7ae353282e..d8f774f723c 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -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 index 940916944bd..00000000000 --- a/src/doc/unstable-book/src/language-features/const-in-array-repeat-expressions.md +++ /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/issues/issue-80371.rs b/src/test/ui/array-slice-vec/repeat_empty_ok.rs similarity index 100% rename from src/test/ui/issues/issue-80371.rs rename to src/test/ui/array-slice-vec/repeat_empty_ok.rs diff --git a/src/test/ui/issues/issue-80371.stderr b/src/test/ui/array-slice-vec/repeat_empty_ok.stderr similarity index 56% rename from src/test/ui/issues/issue-80371.stderr rename to src/test/ui/array-slice-vec/repeat_empty_ok.stderr index 5e2052abba7..85baa1268bf 100644 --- a/src/test/ui/issues/issue-80371.stderr +++ b/src/test/ui/array-slice-vec/repeat_empty_ok.stderr @@ -1,22 +1,18 @@ error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied - --> $DIR/issue-80371.rs:8:19 + --> $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 - = note: this array initializer can be evaluated at compile-time, see issue #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 + --> $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 - = note: this array initializer can be evaluated at compile-time, see issue #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 diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-repeat.rs b/src/test/ui/consts/const-blocks/const-repeat.rs similarity index 100% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-repeat.rs rename to src/test/ui/consts/const-blocks/const-repeat.rs diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs b/src/test/ui/consts/const-blocks/fn-call-in-const.rs similarity index 73% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs rename to src/test/ui/consts/const-blocks/fn-call-in-const.rs index da1bae1be8d..7936af75d84 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs +++ b/src/test/ui/consts/const-blocks/fn-call-in-const.rs @@ -1,7 +1,7 @@ // run-pass -#![allow(unused)] -#![feature(const_in_array_repeat_expressions)] +#![feature(inline_const)] +#![allow(unused, incomplete_features)] // Some type that is not copyable. struct Bar; @@ -18,6 +18,6 @@ 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; 2] = [type_no_copy(); 2]; +const _: [Option; 2] = [const { 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/const-blocks/fn-call-in-non-const.rs similarity index 85% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.rs rename to src/test/ui/consts/const-blocks/fn-call-in-non-const.rs index d40facf232a..19217843759 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.rs +++ b/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs @@ -1,5 +1,3 @@ -#![feature(const_in_array_repeat_expressions)] - // Some type that is not copyable. struct Bar; diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.stderr b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr similarity index 92% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.stderr rename to src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr index 48092432bb1..b75452cd217 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-non-const.stderr +++ b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Option: Copy` is not satisfied - --> $DIR/fn-call-in-non-const.rs:16:31 + --> $DIR/fn-call-in-non-const.rs:14:31 | LL | let _: [Option; 2] = [no_copy(); 2]; | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option` diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs b/src/test/ui/consts/const-blocks/migrate-fail.rs similarity index 92% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs rename to src/test/ui/consts/const-blocks/migrate-fail.rs index d04b0b7e168..bb12139a7ba 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.rs +++ b/src/test/ui/consts/const-blocks/migrate-fail.rs @@ -1,6 +1,5 @@ // ignore-compare-mode-nll // compile-flags: -Z borrowck=migrate -#![feature(const_in_array_repeat_expressions)] #![allow(warnings)] // Some type that is not copyable. diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr b/src/test/ui/consts/const-blocks/migrate-fail.stderr similarity index 93% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr rename to src/test/ui/consts/const-blocks/migrate-fail.stderr index 476d48fd496..0fdbbc36288 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-fail.stderr +++ b/src/test/ui/consts/const-blocks/migrate-fail.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Option: Copy` is not satisfied - --> $DIR/migrate-fail.rs:14:37 + --> $DIR/migrate-fail.rs:13:37 | LL | let arr: [Option; 2] = [x; 2]; | ^^^^^^ the trait `Copy` is not implemented for `Option` @@ -9,7 +9,7 @@ LL | let arr: [Option; 2] = [x; 2]; = note: the `Copy` trait is required because the repeated element will be copied error[E0277]: the trait bound `Option: Copy` is not satisfied - --> $DIR/migrate-fail.rs:20:37 + --> $DIR/migrate-fail.rs:19:37 | LL | let arr: [Option; 2] = [x; 2]; | ^^^^^^ the trait `Copy` is not implemented for `Option` diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs b/src/test/ui/consts/const-blocks/migrate-pass.rs similarity index 98% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs rename to src/test/ui/consts/const-blocks/migrate-pass.rs index bfa8ebcfdd3..3195717fa38 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/migrate-pass.rs +++ b/src/test/ui/consts/const-blocks/migrate-pass.rs @@ -1,7 +1,6 @@ // 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. diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs b/src/test/ui/consts/const-blocks/nll-fail.rs similarity index 91% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs rename to src/test/ui/consts/const-blocks/nll-fail.rs index 2d5c59d112e..871387c1fd0 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.rs +++ b/src/test/ui/consts/const-blocks/nll-fail.rs @@ -1,5 +1,4 @@ // ignore-compare-mode-nll -#![feature(const_in_array_repeat_expressions, nll)] #![allow(warnings)] // Some type that is not copyable. diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr b/src/test/ui/consts/const-blocks/nll-fail.stderr similarity index 93% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr rename to src/test/ui/consts/const-blocks/nll-fail.stderr index 3aa69996ff7..81220856359 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-fail.stderr +++ b/src/test/ui/consts/const-blocks/nll-fail.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Option: Copy` is not satisfied - --> $DIR/nll-fail.rs:13:37 + --> $DIR/nll-fail.rs:12:37 | LL | let arr: [Option; 2] = [x; 2]; | ^^^^^^ the trait `Copy` is not implemented for `Option` @@ -9,7 +9,7 @@ LL | let arr: [Option; 2] = [x; 2]; = note: the `Copy` trait is required because the repeated element will be copied error[E0277]: the trait bound `Option: Copy` is not satisfied - --> $DIR/nll-fail.rs:19:37 + --> $DIR/nll-fail.rs:18:37 | LL | let arr: [Option; 2] = [x; 2]; | ^^^^^^ the trait `Copy` is not implemented for `Option` diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs b/src/test/ui/consts/const-blocks/nll-pass.rs similarity index 98% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs rename to src/test/ui/consts/const-blocks/nll-pass.rs index a304f877ab7..d8defa19483 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/nll-pass.rs +++ b/src/test/ui/consts/const-blocks/nll-pass.rs @@ -1,7 +1,6 @@ // check-pass // ignore-compare-mode-nll #![allow(warnings)] -#![feature(const_in_array_repeat_expressions, nll)] // Some type that is not copyable. struct Bar; diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs b/src/test/ui/consts/const-blocks/run-pass.rs similarity index 81% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs rename to src/test/ui/consts/const-blocks/run-pass.rs index 27bf5dabf56..e11f69babf7 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/run-pass.rs +++ b/src/test/ui/consts/const-blocks/run-pass.rs @@ -1,5 +1,4 @@ // run-pass -#![feature(const_in_array_repeat_expressions)] #[derive(Debug, Eq, PartialEq)] struct Bar; diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs b/src/test/ui/consts/const-blocks/trait-error.rs similarity index 77% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs rename to src/test/ui/consts/const-blocks/trait-error.rs index f8df7aafa60..5a614cbdd15 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.rs +++ b/src/test/ui/consts/const-blocks/trait-error.rs @@ -1,5 +1,3 @@ -#![feature(const_in_array_repeat_expressions)] - #[derive(Copy, Clone)] struct Foo(T); diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr b/src/test/ui/consts/const-blocks/trait-error.stderr similarity index 94% rename from src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr rename to src/test/ui/consts/const-blocks/trait-error.stderr index 26de67e50fa..26e2848e7f7 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/trait-error.stderr +++ b/src/test/ui/consts/const-blocks/trait-error.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied - --> $DIR/trait-error.rs:7:5 + --> $DIR/trait-error.rs:5:5 | LL | [Foo(String::new()); 4]; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Foo` 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 index 5ed302bbff3..00000000000 --- a/src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.rs +++ /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; 2] = [None::; 2]; - //~^ ERROR the trait bound `Option: 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; 2] = [Some("foo".to_string()); 2]; - //~^ ERROR the trait bound `Option: 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 index ca1706169af..00000000000 --- a/src/test/ui/feature-gates/feature-gate-const_in_array_repeat_expressions.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: the trait bound `Option: Copy` is not satisfied - --> $DIR/feature-gate-const_in_array_repeat_expressions.rs:7:36 - | -LL | let arr: [Option; 2] = [None::; 2]; - | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option` - | - = help: the following implementations were found: - 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 for more information - = help: add `#![feature(const_in_array_repeat_expressions)]` to the crate attributes to enable - -error[E0277]: the trait bound `Option: Copy` is not satisfied - --> $DIR/feature-gate-const_in_array_repeat_expressions.rs:13:36 - | -LL | let arr: [Option; 2] = [Some("foo".to_string()); 2]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option` - | - = help: the following implementations were found: - 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/unused/unused-closure.rs b/src/test/ui/unused/unused-closure.rs index 5100636842b..c96c907318c 100644 --- a/src/test/ui/unused/unused-closure.rs +++ b/src/test/ui/unused/unused-closure.rs @@ -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; diff --git a/src/test/ui/unused/unused-closure.stderr b/src/test/ui/unused/unused-closure.stderr index f8b4cbb02c4..265d3e8e075 100644 --- a/src/test/ui/unused/unused-closure.stderr +++ b/src/test/ui/unused/unused-closure.stderr @@ -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