diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 3c95ebf9ffabc..658a14bf00945 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -377,8 +377,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } fn unsized_feature_enabled(&self) -> bool { - let features = self.tcx().features(); - features.unsized_locals() || features.unsized_fn_params() + self.tcx().features().unsized_fn_params() } /// Equate the inferred type and the annotated type for user type annotations @@ -961,7 +960,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } } - // When `unsized_fn_params` or `unsized_locals` is enabled, only function calls + // When `unsized_fn_params` is enabled, only function calls // and nullary ops are checked in `check_call_dest`. if !self.unsized_feature_enabled() { match self.body.local_kind(local) { @@ -1951,7 +1950,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); } - // When `unsized_fn_params` and `unsized_locals` are both not enabled, + // When `unsized_fn_params` is not enabled, // this check is done at `check_local`. if self.unsized_feature_enabled() { let span = term.source_info.span; diff --git a/compiler/rustc_codegen_cranelift/example/arbitrary_self_types_pointers_and_wrappers.rs b/compiler/rustc_codegen_cranelift/example/arbitrary_self_types_pointers_and_wrappers.rs index 5479b0c617bfb..f0d1f6e221572 100644 --- a/compiler/rustc_codegen_cranelift/example/arbitrary_self_types_pointers_and_wrappers.rs +++ b/compiler/rustc_codegen_cranelift/example/arbitrary_self_types_pointers_and_wrappers.rs @@ -32,10 +32,6 @@ impl, U> CoerceUnsized> for Wrapper {} impl, U> DispatchFromDyn> for Wrapper {} trait Trait { - // This method isn't object-safe yet. Unsized by-value `self` is object-safe (but not callable - // without unsized_locals), but wrappers around `Self` currently are not. - // FIXME (mikeyhew) uncomment this when unsized rvalues object-safety is implemented - // fn wrapper(self: Wrapper) -> i32; fn ptr_wrapper(self: Ptr>) -> i32; fn wrapper_ptr(self: Wrapper>) -> i32; fn wrapper_ptr_wrapper(self: Wrapper>>) -> i32; diff --git a/compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs b/compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs index b299aa879740a..c26606f0bdd5c 100644 --- a/compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs +++ b/compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs @@ -37,10 +37,6 @@ impl, U> DispatchFromDyn> for Wrapper {} trait Trait { - // This method isn't object-safe yet. Unsized by-value `self` is object-safe (but not callable - // without unsized_locals), but wrappers around `Self` currently are not. - // FIXME (mikeyhew) uncomment this when unsized rvalues object-safety is implemented - // fn wrapper(self: Wrapper) -> i32; fn ptr_wrapper(self: Ptr>) -> i32; fn wrapper_ptr(self: Wrapper>) -> i32; fn wrapper_ptr_wrapper(self: Wrapper>>) -> i32; diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 687d859df5359..0ea1116e22eca 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -247,6 +247,8 @@ declare_features! ( /// Allows unnamed fields of struct and union type (removed, unnamed_fields, "1.83.0", Some(49804), Some("feature needs redesign")), (removed, unsafe_no_drop_flag, "1.0.0", None, None), + /// Allows unsized rvalues at arguments and parameters. + (removed, unsized_locals, "CURRENT_RUSTC_VERSION", Some(48055), Some("removed due to soundness issues; see https://github.com/rust-lang/rust/issues/111942")), (removed, unsized_tuple_coercion, "1.87.0", Some(42877), Some("The feature restricts possible layouts for tuples, and this restriction is not worth it.")), /// Allows `union` fields that don't implement `Copy` as long as they don't have any drop glue. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index b46eac6d8a602..167214d67c5f8 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -669,8 +669,6 @@ declare_features! ( (incomplete, unsized_const_params, "1.82.0", Some(95174)), /// Allows unsized fn parameters. (internal, unsized_fn_params, "1.49.0", Some(48055)), - /// Allows unsized rvalues at arguments and parameters. - (incomplete, unsized_locals, "1.30.0", Some(48055)), /// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute. (unstable, used_with_arg, "1.60.0", Some(93798)), /// Allows use of attributes in `where` clauses. diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index ddc80fab2ce18..63c423cef7040 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1663,9 +1663,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { blk_id, expression, ); - if !fcx.tcx.features().unsized_locals() { - unsized_return = self.is_return_ty_definitely_unsized(fcx); - } + unsized_return = self.is_return_ty_definitely_unsized(fcx); } ObligationCauseCode::ReturnValue(return_expr_id) => { err = self.report_return_mismatched_types( @@ -1677,9 +1675,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { return_expr_id, expression, ); - if !fcx.tcx.features().unsized_locals() { - unsized_return = self.is_return_ty_definitely_unsized(fcx); - } + unsized_return = self.is_return_ty_definitely_unsized(fcx); } ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause { arm_span, diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 082ddac7e5ae2..c2feb7a0de8fe 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -809,9 +809,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } } - // Here we want to prevent struct constructors from returning unsized types. - // There were two cases this happened: fn pointer coercion in stable - // and usual function call in presence of unsized_locals. + // Here we want to prevent struct constructors from returning unsized types, + // which can happen with fn pointer coercion on stable. // Also, as we just want to check sizedness, instead of introducing // placeholder lifetimes with probing, we just replace higher lifetimes // with fresh vars. diff --git a/compiler/rustc_hir_typeck/src/gather_locals.rs b/compiler/rustc_hir_typeck/src/gather_locals.rs index 7d99b0e78694e..f1d6476a0f363 100644 --- a/compiler/rustc_hir_typeck/src/gather_locals.rs +++ b/compiler/rustc_hir_typeck/src/gather_locals.rs @@ -202,7 +202,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { ), ); } - } else if !self.fcx.tcx.features().unsized_locals() { + } else { self.fcx.require_type_is_sized( var_ty, p.span, diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 4b2e87f5674a6..61785f9985c42 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -492,7 +492,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let final_upvar_tys = self.final_upvar_tys(closure_def_id); debug!(?closure_hir_id, ?args, ?final_upvar_tys); - if self.tcx.features().unsized_locals() || self.tcx.features().unsized_fn_params() { + if self.tcx.features().unsized_fn_params() { for capture in self.typeck_results.borrow().closure_min_captures_flattened(closure_def_id) { diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index bb068f3821db8..6bb9cc6528027 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1133,13 +1133,6 @@ pub type AssertMessage<'tcx> = AssertKind>; /// Each local naturally corresponds to the place `Place { local, projection: [] }`. This place has /// the address of the local's allocation and the type of the local. /// -/// **Needs clarification:** Unsized locals seem to present a bit of an issue. Their allocation -/// can't actually be created on `StorageLive`, because it's unclear how big to make the allocation. -/// Furthermore, MIR produces assignments to unsized locals, although that is not permitted under -/// `#![feature(unsized_locals)]` in Rust. Besides just putting "unsized locals are special and -/// different" in a bunch of places, I (JakobDegen) don't know how to incorporate this behavior into -/// the current MIR semantics in a clean way - possibly this needs some design work first. -/// /// For places that are not locals, ie they have a non-empty list of projections, we define the /// values as a function of the parent place, that is the place with its last [`ProjectionElem`] /// stripped. The way this is computed of course depends on the kind of that last projection diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 0d99a1b51499a..d0ae1fad9af0e 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -79,7 +79,7 @@ pub enum InstanceKind<'tcx> { Intrinsic(DefId), /// `::method` where `method` receives unsizeable `self: Self` (part of the - /// `unsized_locals` feature). + /// `unsized_fn_params` feature). /// /// The generated shim will take `Self` via `*mut Self` - conceptually this is `&owned Self` - /// and dereference the argument to call the original function. diff --git a/compiler/rustc_mir_build/src/builder/expr/as_operand.rs b/compiler/rustc_mir_build/src/builder/expr/as_operand.rs index 2059610ee47d7..982e7aa8246b6 100644 --- a/compiler/rustc_mir_build/src/builder/expr/as_operand.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_operand.rs @@ -55,9 +55,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// local variable of unsized type. For example, consider this program: /// /// ``` - /// #![feature(unsized_locals, unsized_fn_params)] + /// #![feature(unsized_fn_params)] /// # use core::fmt::Debug; - /// fn foo(p: dyn Debug) { dbg!(p); } + /// fn foo(_p: dyn Debug) { /* ... */ } /// /// fn bar(box_p: Box) { foo(*box_p); } /// ``` @@ -84,7 +84,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// will actually provide a pointer to the interior of the box, and not move the `dyn Debug` /// value to the stack. /// - /// See #68304 for more details. + /// See for more details. pub(crate) fn as_local_call_operand( &mut self, block: BasicBlock, diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index cddb2f8477858..441649cafa689 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -1414,9 +1414,9 @@ fn check_field_tys_sized<'tcx>( coroutine_layout: &CoroutineLayout<'tcx>, def_id: LocalDefId, ) { - // No need to check if unsized_locals/unsized_fn_params is disabled, + // No need to check if unsized_fn_params is disabled, // since we will error during typeck. - if !tcx.features().unsized_locals() && !tcx.features().unsized_fn_params() { + if !tcx.features().unsized_fn_params() { return; } diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index a91d46ec406e7..d9880a28e8322 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -240,8 +240,6 @@ struct VnState<'body, 'tcx> { next_opaque: usize, /// Cache the deref values. derefs: Vec, - /// Cache the value of the `unsized_locals` features, to avoid fetching it repeatedly in a loop. - feature_unsized_locals: bool, ssa: &'body SsaLocals, dominators: Dominators, reused_locals: DenseBitSet, @@ -273,7 +271,6 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { evaluated: IndexVec::with_capacity(num_values), next_opaque: 1, derefs: Vec::new(), - feature_unsized_locals: tcx.features().unsized_locals(), ssa, dominators, reused_locals: DenseBitSet::new_empty(local_decls.len()), @@ -329,13 +326,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { fn assign(&mut self, local: Local, value: VnIndex) { debug_assert!(self.ssa.is_ssa(local)); self.locals[local] = Some(value); - - // Only register the value if its type is `Sized`, as we will emit copies of it. - let is_sized = !self.feature_unsized_locals - || self.local_decls[local].ty.is_sized(self.tcx, self.typing_env()); - if is_sized { - self.rev_locals[value].push(local); - } + self.rev_locals[value].push(local); } fn insert_constant(&mut self, value: Const<'tcx>) -> VnIndex { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 6863857f9ecb8..659a2f8e2b7ac 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -2993,9 +2993,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { if local { err.note("all local variables must have a statically known size"); } - if !tcx.features().unsized_locals() { - err.help("unsized locals are gated as an unstable feature"); - } } ObligationCauseCode::SizedArgumentType(hir_id) => { let mut ty = None; diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index 220a847cc230f..47d207e8d41b3 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -414,8 +414,8 @@ fn virtual_call_violations_for_method<'tcx>( let receiver_ty = tcx.liberate_late_bound_regions(method.def_id, sig.input(0)); - // Until `unsized_locals` is fully implemented, `self: Self` can't be dispatched on. - // However, this is already considered dyn compatible. We allow it as a special case here. + // `self: Self` can't be dispatched on. + // However, this is considered dyn compatible. We allow it as a special case here. // FIXME(mikeyhew) get rid of this `if` statement once `receiver_is_dispatchable` allows // `Receiver: Unsize dyn Trait]>`. if receiver_ty != tcx.types.self_param { diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 0a5f3ee35b105..a30f74b732089 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -149,8 +149,32 @@ pub const fn forget(t: T) { /// Like [`forget`], but also accepts unsized values. /// -/// This function is just a shim intended to be removed when the `unsized_locals` feature gets -/// stabilized. +/// While Rust does not permit unsized locals since its removal in [#111942] it is +/// still possible to call functions with unsized values from a function argument +/// or in-place construction. +/// +/// ```rust +/// #![feature(unsized_fn_params, forget_unsized)] +/// #![allow(internal_features)] +/// +/// use std::mem::forget_unsized; +/// +/// pub fn in_place() { +/// forget_unsized(*Box::new("str")); +/// } +/// +/// pub fn param(x: str) { +/// forget_unsized(x); +/// } +/// ``` +/// +/// This works because the compiler will alter these functions to pass the parameter +/// by reference instead. This trick is necessary to support `Box: FnOnce()`. +/// See [#68304] and [#71170] for more information. +/// +/// [#111942]: https://github.com/rust-lang/rust/issues/111942 +/// [#68304]: https://github.com/rust-lang/rust/issues/68304 +/// [#71170]: https://github.com/rust-lang/rust/pull/71170 #[inline] #[unstable(feature = "forget_unsized", issue = "none")] pub fn forget_unsized(t: T) { diff --git a/library/coretests/tests/ptr.rs b/library/coretests/tests/ptr.rs index bb60fb07468f9..197a14423b59d 100644 --- a/library/coretests/tests/ptr.rs +++ b/library/coretests/tests/ptr.rs @@ -653,7 +653,6 @@ fn thin_box() { // if `{size,align}_of_for_meta(T::Metadata)` are added. // * Constructing a `ThinBox` without consuming and deallocating a `Box` // requires either the unstable `Unsize` marker trait, - // or the unstable `unsized_locals` language feature, // or taking `&dyn T` and restricting to `T: Copy`. use std::alloc::*; diff --git a/src/doc/rustc-dev-guide/src/implementing_new_features.md b/src/doc/rustc-dev-guide/src/implementing_new_features.md index d7561bbbad22a..5d0e875cbc18c 100644 --- a/src/doc/rustc-dev-guide/src/implementing_new_features.md +++ b/src/doc/rustc-dev-guide/src/implementing_new_features.md @@ -156,8 +156,8 @@ a new unstable feature: [`incomplete_features` lint]: https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#incomplete-features ```rust ignore - /// Allows unsized rvalues at arguments and parameters. - (incomplete, unsized_locals, "CURRENT_RUSTC_VERSION", Some(48055), None), + /// Allows deref patterns. + (incomplete, deref_patterns, "CURRENT_RUSTC_VERSION", Some(87121), None), ``` To avoid [semantic merge conflicts], please use `CURRENT_RUSTC_VERSION` instead of `1.70` or diff --git a/src/doc/unstable-book/src/language-features/unsized-locals.md b/src/doc/unstable-book/src/language-features/unsized-locals.md deleted file mode 100644 index d5b01a3d6168e..0000000000000 --- a/src/doc/unstable-book/src/language-features/unsized-locals.md +++ /dev/null @@ -1,175 +0,0 @@ -# `unsized_locals` - -The tracking issue for this feature is: [#48055] - -[#48055]: https://github.com/rust-lang/rust/issues/48055 - ------------------------- - -This implements [RFC1909]. When turned on, you can have unsized arguments and locals: - -[RFC1909]: https://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md - -```rust -#![allow(incomplete_features)] -#![feature(unsized_locals, unsized_fn_params)] - -use std::any::Any; - -fn main() { - let x: Box = Box::new(42); - let x: dyn Any = *x; - // ^ unsized local variable - // ^^ unsized temporary - foo(x); -} - -fn foo(_: dyn Any) {} -// ^^^^^^ unsized argument -``` - -The RFC still forbids the following unsized expressions: - -```rust,compile_fail -#![feature(unsized_locals)] - -use std::any::Any; - -struct MyStruct { - content: T, -} - -struct MyTupleStruct(T); - -fn answer() -> Box { - Box::new(42) -} - -fn main() { - // You CANNOT have unsized statics. - static X: dyn Any = *answer(); // ERROR - const Y: dyn Any = *answer(); // ERROR - - // You CANNOT have struct initialized unsized. - MyStruct { content: *answer() }; // ERROR - MyTupleStruct(*answer()); // ERROR - (42, *answer()); // ERROR - - // You CANNOT have unsized return types. - fn my_function() -> dyn Any { *answer() } // ERROR - - // You CAN have unsized local variables... - let mut x: dyn Any = *answer(); // OK - // ...but you CANNOT reassign to them. - x = *answer(); // ERROR - - // You CANNOT even initialize them separately. - let y: dyn Any; // OK - y = *answer(); // ERROR - - // Not mentioned in the RFC, but by-move captured variables are also Sized. - let x: dyn Any = *answer(); - (move || { // ERROR - let y = x; - })(); - - // You CAN create a closure with unsized arguments, - // but you CANNOT call it. - // This is an implementation detail and may be changed in the future. - let f = |x: dyn Any| {}; - f(*answer()); // ERROR -} -``` - -## By-value trait objects - -With this feature, you can have by-value `self` arguments without `Self: Sized` bounds. - -```rust -#![feature(unsized_fn_params)] - -trait Foo { - fn foo(self) {} -} - -impl Foo for T {} - -fn main() { - let slice: Box<[i32]> = Box::new([1, 2, 3]); - <[i32] as Foo>::foo(*slice); -} -``` - -And `Foo` will also be object-safe. - -```rust -#![feature(unsized_fn_params)] - -trait Foo { - fn foo(self) {} -} - -impl Foo for T {} - -fn main () { - let slice: Box = Box::new([1, 2, 3]); - // doesn't compile yet - ::foo(*slice); -} -``` - -One of the objectives of this feature is to allow `Box`. - -## Variable length arrays - -The RFC also describes an extension to the array literal syntax: `[e; dyn n]`. In the syntax, `n` isn't necessarily a constant expression. The array is dynamically allocated on the stack and has the type of `[T]`, instead of `[T; n]`. - -```rust,ignore (not-yet-implemented) -#![feature(unsized_locals)] - -fn mergesort(a: &mut [T]) { - let mut tmp = [T; dyn a.len()]; - // ... -} - -fn main() { - let mut a = [3, 1, 5, 6]; - mergesort(&mut a); - assert_eq!(a, [1, 3, 5, 6]); -} -``` - -VLAs are not implemented yet. The syntax isn't final, either. We may need an alternative syntax for Rust 2015 because, in Rust 2015, expressions like `[e; dyn(1)]` would be ambiguous. One possible alternative proposed in the RFC is `[e; n]`: if `n` captures one or more local variables, then it is considered as `[e; dyn n]`. - -## Advisory on stack usage - -It's advised not to casually use the `#![feature(unsized_locals)]` feature. Typical use-cases are: - -- When you need a by-value trait objects. -- When you really need a fast allocation of small temporary arrays. - -Another pitfall is repetitive allocation and temporaries. Currently the compiler simply extends the stack frame every time it encounters an unsized assignment. So for example, the code - -```rust -#![feature(unsized_locals)] - -fn main() { - let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]); - let _x = {{{{{{{{{{*x}}}}}}}}}}; -} -``` - -and the code - -```rust -#![feature(unsized_locals)] - -fn main() { - for _ in 0..10 { - let x: Box<[i32]> = Box::new([1, 2, 3, 4, 5]); - let _x = *x; - } -} -``` - -will unnecessarily extend the stack frame. diff --git a/src/tools/clippy/tests/ui/large_stack_frames.rs b/src/tools/clippy/tests/ui/large_stack_frames.rs index 3ed124f69ef35..132f1450b6ded 100644 --- a/src/tools/clippy/tests/ui/large_stack_frames.rs +++ b/src/tools/clippy/tests/ui/large_stack_frames.rs @@ -1,8 +1,7 @@ //@ normalize-stderr-test: "\b10000(08|16|32)\b" -> "100$$PTR" //@ normalize-stderr-test: "\b2500(060|120)\b" -> "250$$PTR" -#![allow(unused, incomplete_features)] +#![allow(unused)] #![warn(clippy::large_stack_frames)] -#![feature(unsized_locals)] use std::hint::black_box; @@ -11,11 +10,6 @@ fn generic() { black_box(&x); } -fn unsized_local() { - let x: dyn std::fmt::Display = *(Box::new(1) as Box); - black_box(&x); -} - struct ArrayDefault([u8; N]); impl Default for ArrayDefault { diff --git a/src/tools/clippy/tests/ui/large_stack_frames.stderr b/src/tools/clippy/tests/ui/large_stack_frames.stderr index 0ff49e9f5b372..79482e65c3e62 100644 --- a/src/tools/clippy/tests/ui/large_stack_frames.stderr +++ b/src/tools/clippy/tests/ui/large_stack_frames.stderr @@ -1,5 +1,5 @@ error: this function may allocate 250$PTR bytes on the stack - --> tests/ui/large_stack_frames.rs:27:4 + --> tests/ui/large_stack_frames.rs:21:4 | LL | fn many_small_arrays() { | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | let x5 = [0u8; 500_000]; = help: to override `-D warnings` add `#[allow(clippy::large_stack_frames)]` error: this function may allocate 1000000 bytes on the stack - --> tests/ui/large_stack_frames.rs:38:4 + --> tests/ui/large_stack_frames.rs:32:4 | LL | fn large_return_value() -> ArrayDefault<1_000_000> { | ^^^^^^^^^^^^^^^^^^ ----------------------- this is the largest part, at 1000000 bytes for type `ArrayDefault<1000000>` @@ -21,7 +21,7 @@ LL | fn large_return_value() -> ArrayDefault<1_000_000> { = note: 1000000 bytes is larger than Clippy's configured `stack-size-threshold` of 512000 error: this function may allocate 100$PTR bytes on the stack - --> tests/ui/large_stack_frames.rs:44:4 + --> tests/ui/large_stack_frames.rs:38:4 | LL | fn large_fn_arg(x: ArrayDefault<1_000_000>) { | ^^^^^^^^^^^^ - `x` is the largest part, at 1000000 bytes for type `ArrayDefault<1000000>` @@ -29,7 +29,7 @@ LL | fn large_fn_arg(x: ArrayDefault<1_000_000>) { = note: 100$PTR bytes is larger than Clippy's configured `stack-size-threshold` of 512000 error: this function may allocate 100$PTR bytes on the stack - --> tests/ui/large_stack_frames.rs:51:13 + --> tests/ui/large_stack_frames.rs:45:13 | LL | let f = || black_box(&[0u8; 1_000_000]); | ^^^^^^^^^^^^^^----------------^ diff --git a/src/tools/miri/tests/fail/unsized-local.rs b/src/tools/miri/tests/fail/unsized-local.rs deleted file mode 100644 index ceccae4e3e76f..0000000000000 --- a/src/tools/miri/tests/fail/unsized-local.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![feature(unsized_locals)] -#![allow(incomplete_features)] - -fn main() { - pub trait Foo { - fn foo(self) -> String; - } - - struct A; - - impl Foo for A { - fn foo(self) -> String { - format!("hello") - } - } - - let x = *(Box::new(A) as Box); //~ERROR: unsized locals are not supported - assert_eq!(x.foo(), format!("hello")); - - // I'm not sure whether we want this to work - let x = Box::new(A) as Box; - assert_eq!(x.foo(), format!("hello")); -} diff --git a/src/tools/miri/tests/fail/unsized-local.stderr b/src/tools/miri/tests/fail/unsized-local.stderr deleted file mode 100644 index 548f3d66c7338..0000000000000 --- a/src/tools/miri/tests/fail/unsized-local.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unsupported operation: unsized locals are not supported - --> tests/fail/unsized-local.rs:LL:CC - | -LL | let x = *(Box::new(A) as Box); - | ^ unsized locals are not supported - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support - = note: BACKTRACE: - = note: inside `main` at tests/fail/unsized-local.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to 1 previous error - diff --git a/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs b/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs index 2a8251785e77d..3287e018b4044 100644 --- a/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs +++ b/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs @@ -10,8 +10,8 @@ //@ compile-flags: -C opt-level=2 -Z merge-functions=disabled #![crate_type = "lib"] -#![allow(incomplete_features)] -#![feature(unsized_locals, unsized_fn_params)] +#![allow(internal_features)] +#![feature(unsized_fn_params)] // CHECK-LABEL: emptyfn: #[no_mangle] @@ -357,27 +357,3 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie } - -// CHECK-LABEL: unsized_local -#[no_mangle] -pub fn unsized_local(s: &[u8], l: bool, f: fn(&mut [u8])) { - let n = if l { 1 } else { 2 }; - let mut a: [u8] = *Box::<[u8]>::from(&s[0..n]); // slice-copy with Box::from - f(&mut a); - - // This function allocates a slice as a local variable in its stack - // frame. Since the size is not a compile-time constant, an array - // alloca is required, and the function is protected by both the - // `strong` and `basic` heuristic. - - // We should have a __security_check_cookie call in `all`, `strong` and `basic` modes but - // LLVM does not support generating stack protectors in functions with funclet - // based EH personalities. - // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 - // all-NOT: __security_check_cookie - // strong-NOT: __security_check_cookie - // basic-NOT: __security_check_cookie - - // none-NOT: __security_check_cookie - // missing-NOT: __security_check_cookie -} diff --git a/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs b/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs index 9729da4e5d25a..9a3dabc74dded 100644 --- a/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs +++ b/tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs @@ -10,8 +10,7 @@ //@ compile-flags: -C opt-level=2 -Z merge-functions=disabled #![crate_type = "lib"] -#![allow(incomplete_features)] -#![feature(unsized_locals, unsized_fn_params)] +#![feature(unsized_fn_params)] // CHECK-LABEL: emptyfn: #[no_mangle] @@ -365,27 +364,3 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { // none-NOT: __security_check_cookie // missing-NOT: __security_check_cookie } - -// CHECK-LABEL: unsized_local -#[no_mangle] -pub fn unsized_local(s: &[u8], l: bool, f: fn(&mut [u8])) { - let n = if l { 1 } else { 2 }; - let mut a: [u8] = *Box::<[u8]>::from(&s[0..n]); // slice-copy with Box::from - f(&mut a); - - // This function allocates a slice as a local variable in its stack - // frame. Since the size is not a compile-time constant, an array - // alloca is required, and the function is protected by both the - // `strong` and `basic` heuristic. - - // We should have a __security_check_cookie call in `all`, `strong` and `basic` modes but - // LLVM does not support generating stack protectors in functions with funclet - // based EH personalities. - // https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4 - // all-NOT: __security_check_cookie - // strong-NOT: __security_check_cookie - // basic-NOT: __security_check_cookie - - // none-NOT: __security_check_cookie - // missing-NOT: __security_check_cookie -} diff --git a/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs b/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs index 91c83fa2f5ba9..ae281cb95da5f 100644 --- a/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs +++ b/tests/assembly/stack-protector/stack-protector-heuristics-effect.rs @@ -16,8 +16,8 @@ // See comments on https://github.com/rust-lang/rust/issues/114903. #![crate_type = "lib"] -#![allow(incomplete_features)] -#![feature(unsized_locals, unsized_fn_params)] +#![allow(internal_features)] +#![feature(unsized_fn_params)] // CHECK-LABEL: emptyfn{{:|\[}} #[no_mangle] @@ -343,22 +343,3 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) { // none-NOT: __stack_chk_fail // missing-NOT: __stack_chk_fail } - -// CHECK-LABEL: unsized_local{{:|\[}} -#[no_mangle] -pub fn unsized_local(s: &[u8], l: bool, f: fn(&mut [u8])) { - let n = if l { 1 } else { 2 }; - let mut a: [u8] = *Box::<[u8]>::from(&s[0..n]); // slice-copy with Box::from - f(&mut a); - - // This function allocates a slice as a local variable in its stack - // frame. Since the size is not a compile-time constant, an array - // alloca is required, and the function is protected by both the - // `strong` and `basic` heuristic. - - // all: __stack_chk_fail - // strong: __stack_chk_fail - // basic: __stack_chk_fail - // none-NOT: __stack_chk_fail - // missing-NOT: __stack_chk_fail -} diff --git a/tests/codegen/deduced-param-attrs.rs b/tests/codegen/deduced-param-attrs.rs index 22db090d4d889..34504c80fad1b 100644 --- a/tests/codegen/deduced-param-attrs.rs +++ b/tests/codegen/deduced-param-attrs.rs @@ -1,8 +1,8 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] -#![allow(incomplete_features)] -#![feature(unsized_locals, unsized_fn_params)] +#![allow(internal_features)] +#![feature(unsized_fn_params)] use std::cell::Cell; use std::hint; diff --git a/tests/codegen/virtual-function-elimination.rs b/tests/codegen/virtual-function-elimination.rs index d2d0c4b78abd1..26604478c11a2 100644 --- a/tests/codegen/virtual-function-elimination.rs +++ b/tests/codegen/virtual-function-elimination.rs @@ -6,8 +6,6 @@ // CHECK: @vtable.2 = {{.*}}, !type ![[TYPE2:[0-9]+]], !vcall_visibility ![[VCALL_VIS2:[0-9]+]] #![crate_type = "lib"] -#![allow(incomplete_features)] -#![feature(unsized_locals)] use std::rc::Rc; diff --git a/tests/crashes/79409.rs b/tests/crashes/79409.rs deleted file mode 100644 index 98b5f60633627..0000000000000 --- a/tests/crashes/79409.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ known-bug: #79409 - -#![feature(extern_types)] -#![feature(unsized_locals)] - -extern { - type Device; -} - -unsafe fn make_device() -> Box { - Box::from_raw(0 as *mut _) -} - -fn main() { - let d: Device = unsafe { *make_device() }; -} diff --git a/tests/ui/associated-types/associated-types-unsized.stderr b/tests/ui/associated-types/associated-types-unsized.stderr index e46b2a394640b..5a55e0341c1a2 100644 --- a/tests/ui/associated-types/associated-types-unsized.stderr +++ b/tests/ui/associated-types/associated-types-unsized.stderr @@ -6,7 +6,6 @@ LL | let x = t.get(); | = help: the trait `Sized` is not implemented for `::Value` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider further restricting the associated type | LL | fn foo(t: T) where ::Value: Sized { diff --git a/tests/ui/async-await/awaiting-unsized-param.rs b/tests/ui/async-await/awaiting-unsized-param.rs index 45611eae41f5c..d957e5bd9b7c9 100644 --- a/tests/ui/async-await/awaiting-unsized-param.rs +++ b/tests/ui/async-await/awaiting-unsized-param.rs @@ -1,12 +1,11 @@ //@ edition: 2021 -#![feature(unsized_fn_params, unsized_locals)] -//~^ WARN the feature `unsized_locals` is incomplete +#![feature(unsized_fn_params)] use std::future::Future; async fn bug(mut f: dyn Future + Unpin) -> T { - //~^ ERROR the size for values of type `(dyn Future + Unpin + 'static)` cannot be known at compilation time + //~^ ERROR the size for values of type `dyn Future + Unpin` cannot be known at compilation time (&mut f).await } diff --git a/tests/ui/async-await/awaiting-unsized-param.stderr b/tests/ui/async-await/awaiting-unsized-param.stderr index 0104736976d5d..bcb0bcdf71ae4 100644 --- a/tests/ui/async-await/awaiting-unsized-param.stderr +++ b/tests/ui/async-await/awaiting-unsized-param.stderr @@ -1,21 +1,12 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/awaiting-unsized-param.rs:3:31 - | -LL | #![feature(unsized_fn_params, unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: the size for values of type `(dyn Future + Unpin + 'static)` cannot be known at compilation time - --> $DIR/awaiting-unsized-param.rs:8:17 +error[E0277]: the size for values of type `dyn Future + Unpin` cannot be known at compilation time + --> $DIR/awaiting-unsized-param.rs:7:17 | LL | async fn bug(mut f: dyn Future + Unpin) -> T { | ^^^^^ doesn't have a size known at compile-time | - = help: the trait `Sized` is not implemented for `(dyn Future + Unpin + 'static)` - = note: all values captured by value by a closure must have a statically known size + = help: the trait `Sized` is not implemented for `dyn Future + Unpin` + = note: all local variables must have a statically known size -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/unsized-across-await.rs b/tests/ui/async-await/unsized-across-await.rs index b6bd5567fb221..3e8d58d42438b 100644 --- a/tests/ui/async-await/unsized-across-await.rs +++ b/tests/ui/async-await/unsized-across-await.rs @@ -1,8 +1,5 @@ //@ edition: 2021 -#![feature(unsized_locals)] -//~^ WARN the feature `unsized_locals` is incomplete - async fn f() {} async fn g(x: Box) { diff --git a/tests/ui/async-await/unsized-across-await.stderr b/tests/ui/async-await/unsized-across-await.stderr index 5bb2b7f479177..f06c390ae1684 100644 --- a/tests/ui/async-await/unsized-across-await.stderr +++ b/tests/ui/async-await/unsized-across-await.stderr @@ -1,21 +1,17 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unsized-across-await.rs:3:12 - | -LL | #![feature(unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time - --> $DIR/unsized-across-await.rs:9:9 + --> $DIR/unsized-across-await.rs:6:9 | LL | let _x = *x; | ^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn std::fmt::Display` - = note: all values live across `await` must have a statically known size + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let _x = *x; +LL + let _x = x; + | -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/coroutine/unsized-capture-across-yield.rs b/tests/ui/coroutine/unsized-capture-across-yield.rs index c86b1823aafff..ee27ea064ec23 100644 --- a/tests/ui/coroutine/unsized-capture-across-yield.rs +++ b/tests/ui/coroutine/unsized-capture-across-yield.rs @@ -1,16 +1,13 @@ #![feature(coroutine_trait)] #![feature(coroutines)] -#![feature(unsized_locals)] -//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes use std::ops::Coroutine; fn capture() -> impl Coroutine { - let b: [u8] = *(Box::new([]) as Box<[u8]>); + let b: [u8] = *(Box::new([]) as Box<[u8]>); //~ERROR he size for values of type `[u8]` cannot be known at compilation time #[coroutine] move || { println!("{:?}", &b); - //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time yield; diff --git a/tests/ui/coroutine/unsized-capture-across-yield.stderr b/tests/ui/coroutine/unsized-capture-across-yield.stderr index 03551f1bbff51..c46c08ff53e8c 100644 --- a/tests/ui/coroutine/unsized-capture-across-yield.stderr +++ b/tests/ui/coroutine/unsized-capture-across-yield.stderr @@ -1,23 +1,16 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unsized-capture-across-yield.rs:3:12 - | -LL | #![feature(unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-capture-across-yield.rs:12:27 + --> $DIR/unsized-capture-across-yield.rs:7:9 | -LL | move || { - | -- this closure captures all values by move -LL | println!("{:?}", &b); - | ^ doesn't have a size known at compile-time +LL | let b: [u8] = *(Box::new([]) as Box<[u8]>); + | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: all values captured by value by a closure must have a statically known size + = note: all local variables must have a statically known size +help: consider borrowing here + | +LL | let b: &[u8] = *(Box::new([]) as Box<[u8]>); + | + -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/coroutine/unsized-local-across-yield.rs b/tests/ui/coroutine/unsized-local-across-yield.rs index cb8ced13a111a..4c688e5b99790 100644 --- a/tests/ui/coroutine/unsized-local-across-yield.rs +++ b/tests/ui/coroutine/unsized-local-across-yield.rs @@ -1,7 +1,5 @@ #![feature(coroutine_trait)] #![feature(coroutines)] -#![feature(unsized_locals)] -//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes use std::ops::Coroutine; diff --git a/tests/ui/coroutine/unsized-local-across-yield.stderr b/tests/ui/coroutine/unsized-local-across-yield.stderr index 4fe0f135a9d62..fd6cd4676c2b2 100644 --- a/tests/ui/coroutine/unsized-local-across-yield.stderr +++ b/tests/ui/coroutine/unsized-local-across-yield.stderr @@ -1,21 +1,16 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/unsized-local-across-yield.rs:3:12 - | -LL | #![feature(unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/unsized-local-across-yield.rs:11:13 + --> $DIR/unsized-local-across-yield.rs:9:13 | LL | let b: [u8] = *(Box::new([]) as Box<[u8]>); | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: all values live across `yield` must have a statically known size + = note: all local variables must have a statically known size +help: consider borrowing here + | +LL | let b: &[u8] = *(Box::new([]) as Box<[u8]>); + | + -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/error-codes/E0161.rs b/tests/ui/error-codes/E0161.rs index 3a9b93d24303f..1ae2a67d60e9a 100644 --- a/tests/ui/error-codes/E0161.rs +++ b/tests/ui/error-codes/E0161.rs @@ -1,12 +1,7 @@ // Check that E0161 is a hard error in all possible configurations that might // affect it. -//@ revisions: base ul -//@[base] check-fail -//@[ul] check-pass - -#![allow(incomplete_features)] -#![cfg_attr(ul, feature(unsized_locals))] +#![crate_type = "lib"] trait Bar { fn f(self); @@ -14,7 +9,5 @@ trait Bar { fn foo(x: Box) { x.f(); - //[base]~^ ERROR E0161 + //~^ ERROR E0161 } - -fn main() {} diff --git a/tests/ui/error-codes/E0161.base.stderr b/tests/ui/error-codes/E0161.stderr similarity index 90% rename from tests/ui/error-codes/E0161.base.stderr rename to tests/ui/error-codes/E0161.stderr index d80de66b24733..f84f348459bf1 100644 --- a/tests/ui/error-codes/E0161.base.stderr +++ b/tests/ui/error-codes/E0161.stderr @@ -1,5 +1,5 @@ error[E0161]: cannot move a value of type `dyn Bar` - --> $DIR/E0161.rs:16:5 + --> $DIR/E0161.rs:11:5 | LL | x.f(); | ^ the size of `dyn Bar` cannot be statically determined diff --git a/tests/ui/extern/unsized-extern-derefmove.rs b/tests/ui/extern/unsized-extern-derefmove.rs new file mode 100644 index 0000000000000..4ec9e53f49d87 --- /dev/null +++ b/tests/ui/extern/unsized-extern-derefmove.rs @@ -0,0 +1,15 @@ +//! Regression test for #79409 + +#![feature(extern_types)] + +unsafe extern "C" { + type Device; +} + +unsafe fn make_device() -> Box { + Box::from_raw(0 as *mut _) +} + +fn main() { + let d: Device = unsafe { *make_device() }; //~ERROR the size for values of type `Device` cannot be known at compilation time +} diff --git a/tests/ui/extern/unsized-extern-derefmove.stderr b/tests/ui/extern/unsized-extern-derefmove.stderr new file mode 100644 index 0000000000000..c43184d94e177 --- /dev/null +++ b/tests/ui/extern/unsized-extern-derefmove.stderr @@ -0,0 +1,16 @@ +error[E0277]: the size for values of type `Device` cannot be known at compilation time + --> $DIR/unsized-extern-derefmove.rs:14:9 + | +LL | let d: Device = unsafe { *make_device() }; + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `Device` + = note: all local variables must have a statically known size +help: consider borrowing here + | +LL | let d: &Device = unsafe { *make_device() }; + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-15756.stderr b/tests/ui/issues/issue-15756.stderr index af50fe467d17c..a487d360bef98 100644 --- a/tests/ui/issues/issue-15756.stderr +++ b/tests/ui/issues/issue-15756.stderr @@ -6,7 +6,6 @@ LL | &mut something | = help: the trait `Sized` is not implemented for `[T]` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature error: aborting due to 1 previous error diff --git a/tests/ui/iterators/collect-into-slice.stderr b/tests/ui/iterators/collect-into-slice.stderr index 56f1bf770607e..e5729a2badc71 100644 --- a/tests/ui/iterators/collect-into-slice.stderr +++ b/tests/ui/iterators/collect-into-slice.stderr @@ -16,7 +16,6 @@ LL | let some_generated_vec = (0..10).collect(); | = help: the trait `Sized` is not implemented for `[i32]` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `[i32]` cannot be known at compilation time --> $DIR/collect-into-slice.rs:6:38 diff --git a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs index 5ef1d0c6dc9b5..6ceec11930833 100644 --- a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs +++ b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs @@ -1,8 +1,7 @@ //@ dont-require-annotations: NOTE #![feature(arbitrary_self_types, coerce_unsized, dispatch_from_dyn, unsize)] -#![feature(unsized_locals, unsized_fn_params)] -//~^ WARN the feature `unsized_locals` is incomplete +#![feature(unsized_fn_params)] // This tests a few edge-cases around `arbitrary_self_types`. Most specifically, // it checks that the `ObjectCandidate` you get from method matching can't diff --git a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr index 213139a9b0b6d..32cff62284e09 100644 --- a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr +++ b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr @@ -1,14 +1,5 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:4:12 - | -LL | #![feature(unsized_locals, unsized_fn_params)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:89:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:88:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` @@ -16,7 +7,7 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:106:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:105:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u64` @@ -24,23 +15,23 @@ LL | let _seetype: () = z; | expected due to this error[E0034]: multiple applicable items in scope - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:124:15 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:123:15 | LL | let z = x.foo(); | ^^^ multiple `foo` found | note: candidate #1 is defined in the trait `FinalFoo` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:61:5 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:60:5 | LL | fn foo(&self) -> u8; | ^^^^^^^^^^^^^^^^^^^^ note: candidate #2 is defined in an impl of the trait `NuisanceFoo` for the type `T` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:74:9 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:73:9 | LL | fn foo(self) {} | ^^^^^^^^^^^^ note: candidate #3 is defined in an impl of the trait `X` for the type `T` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:47:9 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:46:9 | LL | fn foo(self: Smaht) -> u64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +52,7 @@ LL + let z = X::foo(x); | error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:141:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:140:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u8` @@ -69,7 +60,7 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:159:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:158:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` @@ -77,14 +68,14 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:176:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:175:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` | | | expected due to this -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 6 previous errors Some errors have detailed explanations: E0034, E0308. For more information about an error, try `rustc --explain E0034`. diff --git a/tests/ui/moves/move-out-of-slice-2.rs b/tests/ui/moves/move-out-of-slice-2.rs index 2f7394fbfd36c..6428dc4b711a6 100644 --- a/tests/ui/moves/move-out-of-slice-2.rs +++ b/tests/ui/moves/move-out-of-slice-2.rs @@ -1,5 +1,3 @@ -#![feature(unsized_locals)] -//~^ WARN the feature `unsized_locals` is incomplete #![allow(unused)] struct A; @@ -9,28 +7,24 @@ struct C; fn main() { let a: Box<[A]> = Box::new([A]); match *a { - //~^ ERROR cannot move out of type `[A]`, a non-copy slice - [a @ ..] => {} + [a @ ..] => {} //~ERROR the size for values of type `[A]` cannot be known at compilation time [E0277] _ => {} } let b: Box<[A]> = Box::new([A, A, A]); match *b { - //~^ ERROR cannot move out of type `[A]`, a non-copy slice - [_, _, b @ .., _] => {} + [_, _, b @ .., _] => {} //~ERROR the size for values of type `[A]` cannot be known at compilation time [E0277] _ => {} } // `[C]` isn't `Copy`, even if `C` is. let c: Box<[C]> = Box::new([C]); match *c { - //~^ ERROR cannot move out of type `[C]`, a non-copy slice - [c @ ..] => {} + [c @ ..] => {} //~ERROR the size for values of type `[C]` cannot be known at compilation time [E0277] _ => {} } let d: Box<[C]> = Box::new([C, C, C]); match *d { - //~^ ERROR cannot move out of type `[C]`, a non-copy slice - [_, _, d @ .., _] => {} + [_, _, d @ .., _] => {} //~ERROR the size for values of type `[C]` cannot be known at compilation time [E0277] _ => {} } } diff --git a/tests/ui/moves/move-out-of-slice-2.stderr b/tests/ui/moves/move-out-of-slice-2.stderr index b46854cd6b458..207194611c521 100644 --- a/tests/ui/moves/move-out-of-slice-2.stderr +++ b/tests/ui/moves/move-out-of-slice-2.stderr @@ -1,80 +1,39 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/move-out-of-slice-2.rs:1:12 +error[E0277]: the size for values of type `[A]` cannot be known at compilation time + --> $DIR/move-out-of-slice-2.rs:10:10 | -LL | #![feature(unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:11:11 - | -LL | match *a { - | ^^ cannot move out of here -LL | LL | [a @ ..] => {} - | - - | | - | data moved here - | move occurs because `a` has type `[A]`, which does not implement the `Copy` trait - | -help: consider borrowing the pattern binding + | ^^^^^^ doesn't have a size known at compile-time | -LL | [ref a @ ..] => {} - | +++ + = help: the trait `Sized` is not implemented for `[A]` + = note: all local variables must have a statically known size -error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:17:11 +error[E0277]: the size for values of type `[A]` cannot be known at compilation time + --> $DIR/move-out-of-slice-2.rs:15:16 | -LL | match *b { - | ^^ cannot move out of here -LL | LL | [_, _, b @ .., _] => {} - | - - | | - | data moved here - | move occurs because `b` has type `[A]`, which does not implement the `Copy` trait + | ^^^^^^ doesn't have a size known at compile-time | -help: consider borrowing the pattern binding - | -LL | [_, _, ref b @ .., _] => {} - | +++ + = help: the trait `Sized` is not implemented for `[A]` + = note: all local variables must have a statically known size -error[E0508]: cannot move out of type `[C]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:25:11 +error[E0277]: the size for values of type `[C]` cannot be known at compilation time + --> $DIR/move-out-of-slice-2.rs:22:10 | -LL | match *c { - | ^^ cannot move out of here -LL | LL | [c @ ..] => {} - | - - | | - | data moved here - | move occurs because `c` has type `[C]`, which does not implement the `Copy` trait - | -help: consider borrowing the pattern binding + | ^^^^^^ doesn't have a size known at compile-time | -LL | [ref c @ ..] => {} - | +++ + = help: the trait `Sized` is not implemented for `[C]` + = note: all local variables must have a statically known size -error[E0508]: cannot move out of type `[C]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:31:11 +error[E0277]: the size for values of type `[C]` cannot be known at compilation time + --> $DIR/move-out-of-slice-2.rs:27:16 | -LL | match *d { - | ^^ cannot move out of here -LL | LL | [_, _, d @ .., _] => {} - | - - | | - | data moved here - | move occurs because `d` has type `[C]`, which does not implement the `Copy` trait - | -help: consider borrowing the pattern binding + | ^^^^^^ doesn't have a size known at compile-time | -LL | [_, _, ref d @ .., _] => {} - | +++ + = help: the trait `Sized` is not implemented for `[C]` + = note: all local variables must have a statically known size -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0508`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/self/arbitrary_self_types_pointers_and_wrappers.rs b/tests/ui/self/arbitrary_self_types_pointers_and_wrappers.rs index 76d7754384ebe..4dc170c3a65a1 100644 --- a/tests/ui/self/arbitrary_self_types_pointers_and_wrappers.rs +++ b/tests/ui/self/arbitrary_self_types_pointers_and_wrappers.rs @@ -50,10 +50,6 @@ impl, U> DispatchFromDyn> for Wrapper {} trait Trait { - // This method isn't dyn-compatible yet. Unsized by-value `self` is dyn-compatible (but not - // callable without unsized_locals), but wrappers arond `Self` currently are not. - // FIXME (mikeyhew) uncomment this when unsized rvalues dyn-compatibility is implemented - // fn wrapper(self: Wrapper) -> i32; fn ptr_wrapper(self: Ptr>) -> i32; fn wrapper_ptr(self: Wrapper>) -> i32; fn wrapper_ptr_wrapper(self: Wrapper>>) -> i32; diff --git a/tests/ui/sized/unsized-binding.stderr b/tests/ui/sized/unsized-binding.stderr index 8de236cd0b6e0..da3ba53b0bf5f 100644 --- a/tests/ui/sized/unsized-binding.stderr +++ b/tests/ui/sized/unsized-binding.stderr @@ -6,7 +6,6 @@ LL | let x = *""; | = help: the trait `Sized` is not implemented for `str` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | LL - let x = *""; diff --git a/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.rs b/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.rs index 35abbb80d99e5..fff6806e9a4be 100644 --- a/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.rs +++ b/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.rs @@ -16,7 +16,6 @@ fn main() { //~^ ERROR the size for values of type `str` cannot be known at compilation time //~| HELP consider not dereferencing the expression //~| HELP the trait `Sized` is not implemented for `str` - //~| HELP unsized locals are gated as an unstable feature bar(x); S.baz(x); bar(*""); diff --git a/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.stderr b/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.stderr index 9b7258aff1261..29cedf3ecfdd0 100644 --- a/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.stderr +++ b/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.stderr @@ -22,7 +22,6 @@ LL | let x = *""; | = help: the trait `Sized` is not implemented for `str` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | LL - let x = *""; @@ -30,7 +29,7 @@ LL + let x = ""; | error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized-str-in-return-expr-arg-and-local.rs:22:9 + --> $DIR/unsized-str-in-return-expr-arg-and-local.rs:21:9 | LL | bar(*""); | --- ^^^ doesn't have a size known at compile-time @@ -50,7 +49,7 @@ LL + bar(""); | error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized-str-in-return-expr-arg-and-local.rs:26:11 + --> $DIR/unsized-str-in-return-expr-arg-and-local.rs:25:11 | LL | S.baz(*""); | --- ^^^ doesn't have a size known at compile-time diff --git a/tests/ui/str/str-array-assignment.stderr b/tests/ui/str/str-array-assignment.stderr index 515cb9e12f858..76eb7833225a8 100644 --- a/tests/ui/str/str-array-assignment.stderr +++ b/tests/ui/str/str-array-assignment.stderr @@ -25,7 +25,6 @@ LL | let v = s[..2]; | = help: the trait `Sized` is not implemented for `str` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider borrowing here | LL | let v = &s[..2]; diff --git a/tests/ui/unsized-locals/align.rs b/tests/ui/unsized-locals/align.rs index a3820e3e6dcf3..fdb83a848bc42 100644 --- a/tests/ui/unsized-locals/align.rs +++ b/tests/ui/unsized-locals/align.rs @@ -1,8 +1,5 @@ // Test that unsized locals uphold alignment requirements. // Regression test for #71416. -//@ run-pass -#![feature(unsized_locals)] -#![allow(incomplete_features)] use std::any::Any; #[repr(align(256))] @@ -23,7 +20,7 @@ fn mk() -> Box { } fn main() { - let x = *mk(); + let x = *mk(); //~ERROR the size for values of type `dyn Any` cannot be known at compilation time let dwncst = x.downcast_ref::().unwrap(); let addr = dwncst.f(); assert_eq!(addr as usize % 256, 0); diff --git a/tests/ui/unsized-locals/align.stderr b/tests/ui/unsized-locals/align.stderr new file mode 100644 index 0000000000000..7a48ad1107eb4 --- /dev/null +++ b/tests/ui/unsized-locals/align.stderr @@ -0,0 +1,17 @@ +error[E0277]: the size for values of type `dyn Any` cannot be known at compilation time + --> $DIR/align.rs:23:9 + | +LL | let x = *mk(); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Any` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let x = *mk(); +LL + let x = mk(); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/autoderef.rs b/tests/ui/unsized-locals/autoderef.rs index 31b58ba4002b4..24f8a4c5d0801 100644 --- a/tests/ui/unsized-locals/autoderef.rs +++ b/tests/ui/unsized-locals/autoderef.rs @@ -1,7 +1,4 @@ -//@ run-pass - -#![allow(incomplete_features)] -#![feature(unsized_locals, unsized_fn_params)] +#![feature(unsized_fn_params)] pub trait Foo { fn foo(self) -> String; @@ -26,7 +23,7 @@ impl Foo for dyn FnMut() -> String { } fn main() { - let x = *(Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>); + let x = *(Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>); //~ERROR the size for values of type `[char]` cannot be known at compilation time assert_eq!(&x.foo() as &str, "hello"); let x = Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>; @@ -35,13 +32,13 @@ fn main() { let x = "hello".to_owned().into_boxed_str(); assert_eq!(&x.foo() as &str, "hello"); - let x = *("hello".to_owned().into_boxed_str()); + let x = *("hello".to_owned().into_boxed_str()); //~ERROR the size for values of type `str` cannot be known at compilation time assert_eq!(&x.foo() as &str, "hello"); let x = "hello".to_owned().into_boxed_str(); assert_eq!(&x.foo() as &str, "hello"); - let x = *(Box::new(|| "hello".to_owned()) as Box String>); + let x = *(Box::new(|| "hello".to_owned()) as Box String>); //~ERROR the size for values of type `dyn FnMut() -> String` cannot be known at compilation time assert_eq!(&x.foo() as &str, "hello"); let x = Box::new(|| "hello".to_owned()) as Box String>; diff --git a/tests/ui/unsized-locals/autoderef.stderr b/tests/ui/unsized-locals/autoderef.stderr new file mode 100644 index 0000000000000..785badce19913 --- /dev/null +++ b/tests/ui/unsized-locals/autoderef.stderr @@ -0,0 +1,45 @@ +error[E0277]: the size for values of type `[char]` cannot be known at compilation time + --> $DIR/autoderef.rs:26:9 + | +LL | let x = *(Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[char]` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let x = *(Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>); +LL + let x = (Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>); + | + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/autoderef.rs:35:9 + | +LL | let x = *("hello".to_owned().into_boxed_str()); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let x = *("hello".to_owned().into_boxed_str()); +LL + let x = ("hello".to_owned().into_boxed_str()); + | + +error[E0277]: the size for values of type `dyn FnMut() -> String` cannot be known at compilation time + --> $DIR/autoderef.rs:41:9 + | +LL | let x = *(Box::new(|| "hello".to_owned()) as Box String>); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn FnMut() -> String` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let x = *(Box::new(|| "hello".to_owned()) as Box String>); +LL + let x = (Box::new(|| "hello".to_owned()) as Box String>); + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/auxiliary/ufuncs.rs b/tests/ui/unsized-locals/auxiliary/ufuncs.rs index 5954abf3a1fc5..78534182e8dc1 100644 --- a/tests/ui/unsized-locals/auxiliary/ufuncs.rs +++ b/tests/ui/unsized-locals/auxiliary/ufuncs.rs @@ -1,3 +1,3 @@ -#![feature(unsized_locals, unsized_fn_params)] +#![feature(unsized_fn_params)] pub fn udrop(_x: T) {} diff --git a/tests/ui/unsized-locals/borrow-after-move.rs b/tests/ui/unsized-locals/borrow-after-move.rs index ad73b720fa39d..6c510911f8957 100644 --- a/tests/ui/unsized-locals/borrow-after-move.rs +++ b/tests/ui/unsized-locals/borrow-after-move.rs @@ -1,5 +1,4 @@ -#![feature(unsized_locals, unsized_fn_params)] -//~^ WARN the feature `unsized_locals` is incomplete +#![feature(unsized_fn_params)] pub trait Foo { fn foo(self) -> String; @@ -16,28 +15,23 @@ fn drop_unsized(_: T) {} fn main() { { let x = "hello".to_owned().into_boxed_str(); - let y = *x; + let y = *x; //~ERROR the size for values of type `str` cannot be known at compilation time [E0277] drop_unsized(y); println!("{}", &x); - //~^ERROR borrow of moved value println!("{}", &y); - //~^ERROR borrow of moved value } { let x = "hello".to_owned().into_boxed_str(); - let y = *x; + let y = *x; //~ERROR the size for values of type `str` cannot be known at compilation time [E0277] y.foo(); println!("{}", &x); - //~^ERROR borrow of moved value println!("{}", &y); - //~^ERROR borrow of moved value } { let x = "hello".to_owned().into_boxed_str(); x.foo(); println!("{}", &x); - //~^ERROR borrow of moved value } } diff --git a/tests/ui/unsized-locals/borrow-after-move.stderr b/tests/ui/unsized-locals/borrow-after-move.stderr index 9e3c345dd8001..1a4ce39fa7b31 100644 --- a/tests/ui/unsized-locals/borrow-after-move.stderr +++ b/tests/ui/unsized-locals/borrow-after-move.stderr @@ -1,85 +1,31 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/borrow-after-move.rs:1:12 - | -LL | #![feature(unsized_locals, unsized_fn_params)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:21:24 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/borrow-after-move.rs:18:13 | LL | let y = *x; - | -- value moved here -LL | drop_unsized(y); -LL | println!("{}", &x); - | ^^ value borrowed here after move + | ^ doesn't have a size known at compile-time | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `y` - --> $DIR/borrow-after-move.rs:23:24 + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | drop_unsized(y); - | - value moved here -... -LL | println!("{}", &y); - | ^^ value borrowed here after move - | -note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary - --> $DIR/borrow-after-move.rs:14:31 +LL - let y = *x; +LL + let y = x; | -LL | fn drop_unsized(_: T) {} - | ------------ ^ this parameter takes ownership of the value - | | - | in this function -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:31:24 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/borrow-after-move.rs:26:13 | LL | let y = *x; - | -- value moved here -LL | y.foo(); -LL | println!("{}", &x); - | ^^ value borrowed here after move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `y` - --> $DIR/borrow-after-move.rs:33:24 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | y.foo(); - | ----- `y` moved due to this method call -... -LL | println!("{}", &y); - | ^^ value borrowed here after move - | -note: `Foo::foo` takes ownership of the receiver `self`, which moves `y` - --> $DIR/borrow-after-move.rs:5:12 - | -LL | fn foo(self) -> String; - | ^^^^ - -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:40:24 + | ^ doesn't have a size known at compile-time | -LL | let x = "hello".to_owned().into_boxed_str(); - | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait -LL | x.foo(); - | - value moved here -LL | println!("{}", &x); - | ^^ value borrowed here after move + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | -help: consider cloning the value if the performance cost is acceptable +LL - let y = *x; +LL + let y = x; | -LL | x.clone().foo(); - | ++++++++ -error: aborting due to 5 previous errors; 1 warning emitted +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0382`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-rpass.rs b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-rpass.rs index 7ccea43d182e9..26d2bc6c8e0c5 100644 --- a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-rpass.rs +++ b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-rpass.rs @@ -1,8 +1,3 @@ -//@ run-pass - -#![allow(incomplete_features)] -#![feature(unsized_locals)] - pub trait Foo { fn foo(self) -> String; } @@ -16,7 +11,7 @@ impl Foo for A { } fn main() { - let x = *(Box::new(A) as Box); + let x = *(Box::new(A) as Box); //~ERROR the size for values of type `dyn Foo` cannot be known at compilation time assert_eq!(x.foo(), format!("hello")); // I'm not sure whether we want this to work diff --git a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-rpass.stderr b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-rpass.stderr new file mode 100644 index 0000000000000..231cc051f7acd --- /dev/null +++ b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-rpass.stderr @@ -0,0 +1,17 @@ +error[E0277]: the size for values of type `dyn Foo` cannot be known at compilation time + --> $DIR/by-value-trait-dyn-compatibility-rpass.rs:14:9 + | +LL | let x = *(Box::new(A) as Box); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Foo` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let x = *(Box::new(A) as Box); +LL + let x = (Box::new(A) as Box); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-with-default.rs b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-with-default.rs index 1f9b5f11fb507..554c2706e1eb4 100644 --- a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-with-default.rs +++ b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-with-default.rs @@ -1,7 +1,5 @@ -//@ run-pass - -#![allow(incomplete_features)] -#![feature(unsized_locals, unsized_fn_params)] +#![allow(internal_features)] +#![feature(unsized_fn_params)] pub trait Foo { fn foo(self) -> String { @@ -14,7 +12,7 @@ struct A; impl Foo for A {} fn main() { - let x = *(Box::new(A) as Box); + let x = *(Box::new(A) as Box); //~ERROR the size for values of type `dyn Foo` cannot be known at compilation time assert_eq!(x.foo(), format!("hello")); // I'm not sure whether we want this to work diff --git a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-with-default.stderr b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-with-default.stderr new file mode 100644 index 0000000000000..6d8370fac630a --- /dev/null +++ b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-with-default.stderr @@ -0,0 +1,17 @@ +error[E0277]: the size for values of type `dyn Foo` cannot be known at compilation time + --> $DIR/by-value-trait-dyn-compatibility-with-default.rs:15:9 + | +LL | let x = *(Box::new(A) as Box); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Foo` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let x = *(Box::new(A) as Box); +LL + let x = (Box::new(A) as Box); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.rs b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.rs index d0ba6944a1e81..d390f18c69f5b 100644 --- a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.rs +++ b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.rs @@ -1,6 +1,3 @@ -#![feature(unsized_locals)] -//~^ WARN the feature `unsized_locals` is incomplete - pub trait Foo { fn foo(self) -> String where @@ -16,7 +13,7 @@ impl Foo for A { } fn main() { - let x = *(Box::new(A) as Box); + let x = *(Box::new(A) as Box); //~ERROR the size for values of type `dyn Foo` cannot be known at compilation time [E0277] x.foo(); //~^ERROR the `foo` method cannot be invoked on a trait object } diff --git a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.stderr b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.stderr index 223624cfca4dd..1c681ba1215f9 100644 --- a/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.stderr +++ b/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.stderr @@ -1,14 +1,5 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/by-value-trait-dyn-compatibility.rs:1:12 - | -LL | #![feature(unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - error: the `foo` method cannot be invoked on a trait object - --> $DIR/by-value-trait-dyn-compatibility.rs:20:7 + --> $DIR/by-value-trait-dyn-compatibility.rs:17:7 | LL | Self: Sized; | ----- this has a `Sized` requirement @@ -16,5 +7,20 @@ LL | Self: Sized; LL | x.foo(); | ^^^ -error: aborting due to 1 previous error; 1 warning emitted +error[E0277]: the size for values of type `dyn Foo` cannot be known at compilation time + --> $DIR/by-value-trait-dyn-compatibility.rs:16:9 + | +LL | let x = *(Box::new(A) as Box); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Foo` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let x = *(Box::new(A) as Box); +LL + let x = (Box::new(A) as Box); + | + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/double-move.rs b/tests/ui/unsized-locals/double-move.rs index 9e46ef9be487c..254528abfb40c 100644 --- a/tests/ui/unsized-locals/double-move.rs +++ b/tests/ui/unsized-locals/double-move.rs @@ -1,5 +1,4 @@ -#![feature(unsized_locals, unsized_fn_params)] -//~^ WARN the feature `unsized_locals` is incomplete +#![feature(unsized_fn_params)] pub trait Foo { fn foo(self) -> String; @@ -16,39 +15,39 @@ fn drop_unsized(_: T) {} fn main() { { let x = "hello".to_owned().into_boxed_str(); - let y = *x; + let y = *x; //~ERROR the size for values of type `str` cannot be known at compilation time [E0277] + drop_unsized(y); drop_unsized(y); - drop_unsized(y); //~ERROR use of moved value } { let x = "hello".to_owned().into_boxed_str(); - let _y = *x; - drop_unsized(x); //~ERROR use of moved value + let _y = *x; //~ERROR the size for values of type `str` cannot be known at compilation time [E0277] + drop_unsized(x); } { let x = "hello".to_owned().into_boxed_str(); drop_unsized(x); - let _y = *x; //~ERROR use of moved value + let _y = *x; //~ERROR the size for values of type `str` cannot be known at compilation time [E0277] } { let x = "hello".to_owned().into_boxed_str(); - let y = *x; + let y = *x; //~ERROR the size for values of type `str` cannot be known at compilation time [E0277] + y.foo(); y.foo(); - y.foo(); //~ERROR use of moved value } { let x = "hello".to_owned().into_boxed_str(); - let _y = *x; - x.foo(); //~ERROR use of moved value + let _y = *x; //~ERROR the size for values of type `str` cannot be known at compilation time [E0277] + x.foo(); } { let x = "hello".to_owned().into_boxed_str(); x.foo(); - let _y = *x; //~ERROR use of moved value + let _y = *x; //~ERROR the size for values of type `str` cannot be known at compilation time [E0277] } } diff --git a/tests/ui/unsized-locals/double-move.stderr b/tests/ui/unsized-locals/double-move.stderr index 49b906bbe02b7..8d97b16d00c5d 100644 --- a/tests/ui/unsized-locals/double-move.stderr +++ b/tests/ui/unsized-locals/double-move.stderr @@ -1,86 +1,87 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/double-move.rs:1:12 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/double-move.rs:18:13 | -LL | #![feature(unsized_locals, unsized_fn_params)] - | ^^^^^^^^^^^^^^ +LL | let y = *x; + | ^ doesn't have a size known at compile-time | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0382]: use of moved value: `y` - --> $DIR/double-move.rs:21:22 + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let y = *x; +LL + let y = x; | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | drop_unsized(y); - | - value moved here -LL | drop_unsized(y); - | ^ value used here after move - | -note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary - --> $DIR/double-move.rs:14:31 - | -LL | fn drop_unsized(_: T) {} - | ------------ ^ this parameter takes ownership of the value - | | - | in this function -error[E0382]: use of moved value: `x` - --> $DIR/double-move.rs:27:22 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/double-move.rs:25:13 | LL | let _y = *x; - | -- value moved here -LL | drop_unsized(x); - | ^ value used here after move + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let _y = *x; +LL + let _y = x; | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:33:18 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/double-move.rs:32:13 | -LL | let x = "hello".to_owned().into_boxed_str(); - | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait -LL | drop_unsized(x); - | - value moved here LL | let _y = *x; - | ^^ value used here after move + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let _y = *x; +LL + let _y = x; + | -error[E0382]: use of moved value: `y` - --> $DIR/double-move.rs:40:9 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/double-move.rs:37:13 | LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | y.foo(); - | ----- `y` moved due to this method call -LL | y.foo(); - | ^ value used here after move + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | -note: `Foo::foo` takes ownership of the receiver `self`, which moves `y` - --> $DIR/double-move.rs:5:12 +LL - let y = *x; +LL + let y = x; | -LL | fn foo(self) -> String; - | ^^^^ -error[E0382]: use of moved value: `x` - --> $DIR/double-move.rs:46:9 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/double-move.rs:44:13 | LL | let _y = *x; - | -- value moved here -LL | x.foo(); - | ^ value used here after move + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let _y = *x; +LL + let _y = x; | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:52:18 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/double-move.rs:51:13 | -LL | let x = "hello".to_owned().into_boxed_str(); - | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait -LL | x.foo(); - | - value moved here LL | let _y = *x; - | ^^ value used here after move + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: all local variables must have a statically known size +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - let _y = *x; +LL + let _y = x; + | -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0382`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.rs b/tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.rs index ec475673d0d84..4b15e191a0ba6 100644 --- a/tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.rs +++ b/tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.rs @@ -1,7 +1,5 @@ // ICE size_and_align_of::<[closure@test.rs:15:5: 17:7]> not supported #88212 // issue: rust-lang/rust#88212 -#![feature(unsized_locals)] -//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes trait Example {} struct Foo(); @@ -13,9 +11,8 @@ fn example() -> Box { } fn main() { - let x: dyn Example = *example(); + let x: dyn Example = *example(); //~ERROR the size for values of type `dyn Example` cannot be known at compilation time (move || { - let _y = x; - //~^ ERROR the size for values of type `dyn Example` cannot be known at compilation time + let _y = x; //~ERROR the size for values of type `dyn Example` cannot be known at compilation time })(); } diff --git a/tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.stderr b/tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.stderr index a0253ac1f35aa..ffee9852c2a37 100644 --- a/tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.stderr +++ b/tests/ui/unsized-locals/ice-size_and_align_of-closure-not-supported-88212.stderr @@ -1,23 +1,25 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:3:12 +error[E0277]: the size for values of type `dyn Example` cannot be known at compilation time + --> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:14:9 + | +LL | let x: dyn Example = *example(); + | ^ doesn't have a size known at compile-time | -LL | #![feature(unsized_locals)] - | ^^^^^^^^^^^^^^ + = help: the trait `Sized` is not implemented for `dyn Example` + = note: all local variables must have a statically known size +help: consider borrowing here | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default +LL | let x: &dyn Example = *example(); + | + error[E0277]: the size for values of type `dyn Example` cannot be known at compilation time - --> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:18:18 + --> $DIR/ice-size_and_align_of-closure-not-supported-88212.rs:16:13 | -LL | (move || { - | -- this closure captures all values by move LL | let _y = x; - | ^ doesn't have a size known at compile-time + | ^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Example` - = note: all values captured by value by a closure must have a statically known size + = note: all local variables must have a statically known size -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/issue-30276-feature-flagged.rs b/tests/ui/unsized-locals/issue-30276-feature-flagged.rs index 8b5b321ec4989..6b67ebbec1c0c 100644 --- a/tests/ui/unsized-locals/issue-30276-feature-flagged.rs +++ b/tests/ui/unsized-locals/issue-30276-feature-flagged.rs @@ -1,6 +1,3 @@ -#![feature(unsized_locals)] -//~^ WARN the feature `unsized_locals` is incomplete - struct Test([i32]); fn main() { diff --git a/tests/ui/unsized-locals/issue-30276-feature-flagged.stderr b/tests/ui/unsized-locals/issue-30276-feature-flagged.stderr index ee8e4f3eee26b..a7bf27a0c4acc 100644 --- a/tests/ui/unsized-locals/issue-30276-feature-flagged.stderr +++ b/tests/ui/unsized-locals/issue-30276-feature-flagged.stderr @@ -1,14 +1,5 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-30276-feature-flagged.rs:1:12 - | -LL | #![feature(unsized_locals)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0277]: the size for values of type `[i32]` cannot be known at compilation time - --> $DIR/issue-30276-feature-flagged.rs:7:29 + --> $DIR/issue-30276-feature-flagged.rs:4:29 | LL | let _x: fn(_) -> Test = Test; | ^^^^ doesn't have a size known at compile-time @@ -17,6 +8,6 @@ LL | let _x: fn(_) -> Test = Test; = note: all function arguments must have a statically known size = help: unsized fn params are gated as an unstable feature -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/issue-50940-with-feature.rs b/tests/ui/unsized-locals/issue-50940-with-feature.rs index 63b0e830be4ed..9a1ba7af19156 100644 --- a/tests/ui/unsized-locals/issue-50940-with-feature.rs +++ b/tests/ui/unsized-locals/issue-50940-with-feature.rs @@ -1,5 +1,4 @@ -#![feature(unsized_locals, unsized_fn_params)] -//~^ WARN the feature `unsized_locals` is incomplete +#![feature(unsized_fn_params)] fn main() { struct A(X); diff --git a/tests/ui/unsized-locals/issue-50940-with-feature.stderr b/tests/ui/unsized-locals/issue-50940-with-feature.stderr index b39eb2e70bbae..f3fb3ac1a09ff 100644 --- a/tests/ui/unsized-locals/issue-50940-with-feature.stderr +++ b/tests/ui/unsized-locals/issue-50940-with-feature.stderr @@ -1,26 +1,17 @@ -warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-50940-with-feature.rs:1:12 - | -LL | #![feature(unsized_locals, unsized_fn_params)] - | ^^^^^^^^^^^^^^ - | - = note: see issue #48055 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/issue-50940-with-feature.rs:6:5 + --> $DIR/issue-50940-with-feature.rs:5:5 | LL | A as fn(str) -> A; | ^ doesn't have a size known at compile-time | = help: within `A`, the trait `Sized` is not implemented for `str` note: required because it appears within the type `A` - --> $DIR/issue-50940-with-feature.rs:5:12 + --> $DIR/issue-50940-with-feature.rs:4:12 | LL | struct A(X); | ^ = note: the return type of a function must have a statically known size -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/reference-unsized-locals.rs b/tests/ui/unsized-locals/reference-unsized-locals.rs index 5b5fca22a0124..757bae4bb914d 100644 --- a/tests/ui/unsized-locals/reference-unsized-locals.rs +++ b/tests/ui/unsized-locals/reference-unsized-locals.rs @@ -1,10 +1,5 @@ -//@ run-pass - -#![allow(incomplete_features)] -#![feature(unsized_locals)] - fn main() { let foo: Box<[u8]> = Box::new(*b"foo"); - let foo: [u8] = *foo; + let foo: [u8] = *foo; //~ERROR the size for values of type `[u8]` cannot be known at compilation time [E0277] assert_eq!(&foo, b"foo" as &[u8]); } diff --git a/tests/ui/unsized-locals/reference-unsized-locals.stderr b/tests/ui/unsized-locals/reference-unsized-locals.stderr new file mode 100644 index 0000000000000..d1cba9ba79e4f --- /dev/null +++ b/tests/ui/unsized-locals/reference-unsized-locals.stderr @@ -0,0 +1,16 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/reference-unsized-locals.rs:3:9 + | +LL | let foo: [u8] = *foo; + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all local variables must have a statically known size +help: consider borrowing here + | +LL | let foo: &[u8] = *foo; + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/simple-unsized-locals.rs b/tests/ui/unsized-locals/simple-unsized-locals.rs index 374031b80bd28..e6c8bdc7a8851 100644 --- a/tests/ui/unsized-locals/simple-unsized-locals.rs +++ b/tests/ui/unsized-locals/simple-unsized-locals.rs @@ -1,9 +1,4 @@ -//@ run-pass - -#![allow(incomplete_features)] -#![feature(unsized_locals)] - fn main() { let foo: Box<[u8]> = Box::new(*b"foo"); - let _foo: [u8] = *foo; + let _foo: [u8] = *foo; //~ERROR the size for values of type `[u8]` cannot be known at compilation time [E0277] } diff --git a/tests/ui/unsized-locals/simple-unsized-locals.stderr b/tests/ui/unsized-locals/simple-unsized-locals.stderr new file mode 100644 index 0000000000000..83a64bd0711c9 --- /dev/null +++ b/tests/ui/unsized-locals/simple-unsized-locals.stderr @@ -0,0 +1,16 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/simple-unsized-locals.rs:3:9 + | +LL | let _foo: [u8] = *foo; + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all local variables must have a statically known size +help: consider borrowing here + | +LL | let _foo: &[u8] = *foo; + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/suggest-borrow.stderr b/tests/ui/unsized-locals/suggest-borrow.stderr index 8741b35cdcff8..a3b4403cf9bcb 100644 --- a/tests/ui/unsized-locals/suggest-borrow.stderr +++ b/tests/ui/unsized-locals/suggest-borrow.stderr @@ -6,7 +6,6 @@ LL | let x: [u8] = vec!(1, 2, 3)[..]; | = help: the trait `Sized` is not implemented for `[u8]` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider borrowing here | LL | let x: &[u8] = vec!(1, 2, 3)[..]; @@ -51,7 +50,6 @@ LL | let x: [u8] = &vec!(1, 2, 3)[..]; | = help: the trait `Sized` is not implemented for `[u8]` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider borrowing here | LL | let x: &[u8] = &vec!(1, 2, 3)[..]; diff --git a/tests/ui/unsized-locals/unsized-exprs-rpass.rs b/tests/ui/unsized-locals/unsized-exprs-rpass.rs index 861583efc401d..54ecd00034365 100644 --- a/tests/ui/unsized-locals/unsized-exprs-rpass.rs +++ b/tests/ui/unsized-locals/unsized-exprs-rpass.rs @@ -1,6 +1,6 @@ //@ run-pass -#![allow(incomplete_features, unused_braces, unused_parens)] -#![feature(unsized_locals, unsized_fn_params)] +#![allow(internal_features, unused_braces, unused_parens)] +#![feature(unsized_fn_params)] struct A(#[allow(dead_code)] X); diff --git a/tests/ui/unsized-locals/unsized-locals-using-unsized-fn-params.stderr b/tests/ui/unsized-locals/unsized-locals-using-unsized-fn-params.stderr index ace5a87187b8d..fe6780c438c96 100644 --- a/tests/ui/unsized-locals/unsized-locals-using-unsized-fn-params.stderr +++ b/tests/ui/unsized-locals/unsized-locals-using-unsized-fn-params.stderr @@ -6,7 +6,6 @@ LL | fn f1(box box _b: Box>) {} | = help: the trait `Sized` is not implemented for `[u8]` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `[i32]` cannot be known at compilation time --> $DIR/unsized-locals-using-unsized-fn-params.rs:8:12 @@ -16,7 +15,6 @@ LL | fn f2((_x, _y): (i32, [i32])) {} | = help: the trait `Sized` is not implemented for `[i32]` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/unsized-locals-using-unsized-fn-params.rs:13:9 @@ -26,7 +24,6 @@ LL | let _foo: [u8] = *foo; | = help: the trait `Sized` is not implemented for `[u8]` = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider borrowing here | LL | let _foo: &[u8] = *foo; diff --git a/tests/ui/unsized-locals/yote.rs b/tests/ui/unsized-locals/yote.rs new file mode 100644 index 0000000000000..1de75a6ce6171 --- /dev/null +++ b/tests/ui/unsized-locals/yote.rs @@ -0,0 +1,2 @@ +#![feature(unsized_locals)] //~ERROR feature has been removed +#![crate_type = "lib"] diff --git a/tests/ui/unsized-locals/yote.stderr b/tests/ui/unsized-locals/yote.stderr new file mode 100644 index 0000000000000..395aa0cafa6be --- /dev/null +++ b/tests/ui/unsized-locals/yote.stderr @@ -0,0 +1,11 @@ +error[E0557]: feature has been removed + --> $DIR/yote.rs:1:12 + | +LL | #![feature(unsized_locals)] + | ^^^^^^^^^^^^^^ feature has been removed + | + = note: removed due to soundness issues; see https://github.com/rust-lang/rust/issues/111942 + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0557`. diff --git a/tests/ui/unsized/unsized6.stderr b/tests/ui/unsized/unsized6.stderr index de921709865bf..2dcdd3c3c0be9 100644 --- a/tests/ui/unsized/unsized6.stderr +++ b/tests/ui/unsized/unsized6.stderr @@ -8,7 +8,6 @@ LL | let y: Y; | ^ doesn't have a size known at compile-time | = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f1(x: &X) { @@ -60,7 +59,6 @@ LL | let y: X; | ^ doesn't have a size known at compile-time | = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f2(x: &X) { @@ -96,7 +94,6 @@ LL | let y: X = *x1; | ^ doesn't have a size known at compile-time | = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f3(x1: Box, x2: Box, x3: Box) { @@ -117,7 +114,6 @@ LL | let y = *x2; | ^ doesn't have a size known at compile-time | = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f3(x1: Box, x2: Box, x3: Box) { @@ -139,7 +135,6 @@ LL | let (y, z) = (*x3, 4); | ^ doesn't have a size known at compile-time | = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f3(x1: Box, x2: Box, x3: Box) { @@ -155,7 +150,6 @@ LL | let y: X = *x1; | ^ doesn't have a size known at compile-time | = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f4(x1: Box, x2: Box, x3: Box) { @@ -176,7 +170,6 @@ LL | let y = *x2; | ^ doesn't have a size known at compile-time | = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f4(x1: Box, x2: Box, x3: Box) { @@ -198,7 +191,6 @@ LL | let (y, z) = (*x3, 4); | ^ doesn't have a size known at compile-time | = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f4(x1: Box, x2: Box, x3: Box) {