diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index ce563c5925169..212966c4f8b19 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1918,12 +1918,11 @@ impl<'tcx> Ty<'tcx> { | ty::CoroutineClosure(..) | ty::Never | ty::Error(_) + | ty::Tuple(_) | ty::Dynamic(_, _, ty::DynStar) => true, ty::Str | ty::Slice(_) | ty::Dynamic(_, _, ty::Dyn) | ty::Foreign(..) => false, - ty::Tuple(tys) => tys.last().is_none_or(|ty| ty.is_trivially_sized(tcx)), - ty::Adt(def, args) => def .sized_constraint(tcx) .is_none_or(|ty| ty.instantiate(tcx, args).is_trivially_sized(tcx)), diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 237aa66f486f8..660952412c180 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -269,11 +269,6 @@ impl<'tcx> TyCtxt<'tcx> { } } - ty::Tuple(tys) if let Some((&last_ty, _)) = tys.split_last() => { - f(); - ty = last_ty; - } - ty::Tuple(_) => break, ty::Pat(inner, _) => { diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index 93804b14125dd..76a13a0b1aab2 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -108,6 +108,7 @@ where match ty.kind() { // impl Sized for u*, i*, bool, f*, FnDef, FnPtr, *(const/mut) T, char, &mut? T, [T; N], dyn* Trait, ! // impl Sized for Coroutine, CoroutineWitness, Closure, CoroutineClosure + // impl Sized for tuple ty::Infer(ty::IntVar(_) | ty::FloatVar(_)) | ty::Uint(_) | ty::Int(_) @@ -126,6 +127,7 @@ where | ty::CoroutineClosure(..) | ty::Never | ty::Dynamic(_, _, ty::DynStar) + | ty::Tuple(_) | ty::Error(_) => Ok(ty::Binder::dummy(vec![])), ty::Str @@ -143,10 +145,6 @@ where ty::UnsafeBinder(bound_ty) => Ok(bound_ty.map_bound(|ty| vec![ty])), - // impl Sized for () - // impl Sized for (T1, T2, .., Tn) where Tn: Sized if n >= 1 - ty::Tuple(tys) => Ok(ty::Binder::dummy(tys.last().map_or_else(Vec::new, |ty| vec![ty]))), - // impl Sized for Adt where sized_constraint(Adt): Sized // `sized_constraint(Adt)` is the deepest struct trail that can be determined // by the definition of `Adt`, independent of the generic args. 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 d180c0be9d5a7..b05a903413a09 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -2712,9 +2712,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ObligationCauseCode::ArrayLen(array_ty) => { err.note(format!("the length of array `{array_ty}` must be type `usize`")); } - ObligationCauseCode::TupleElem => { - err.note("only the last element of a tuple may have a dynamically sized type"); - } + ObligationCauseCode::TupleElem => {} ObligationCauseCode::WhereClause(item_def_id, span) | ObligationCauseCode::WhereClauseInExpr(item_def_id, span, ..) | ObligationCauseCode::HostEffectInExpr(item_def_id, span, ..) diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 77dbb43465e9e..7b26b32dfde75 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2090,6 +2090,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { | ty::CoroutineClosure(..) | ty::Never | ty::Dynamic(_, _, ty::DynStar) + | ty::Tuple(_) | ty::Error(_) => { // safe for everything Where(ty::Binder::dummy(Vec::new())) @@ -2097,10 +2098,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => None, - ty::Tuple(tys) => Where( - obligation.predicate.rebind(tys.last().map_or_else(Vec::new, |&last| vec![last])), - ), - ty::Pat(ty, _) => Where(obligation.predicate.rebind(vec![*ty])), ty::Adt(def, args) => { diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 18906a6a8ce0f..58c80a5ee453a 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -749,10 +749,8 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { } ty::Tuple(tys) => { - if let Some((_last, rest)) = tys.split_last() { - for &elem in rest { - self.require_sized(elem, ObligationCauseCode::TupleElem); - } + for elem in tys { + self.require_sized(elem, ObligationCauseCode::TupleElem); } } diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 3f60bb067d6e6..c7c8dc828e5d0 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2851,7 +2851,7 @@ macro_rules! tuple { maybe_tuple_doc! { $($name)+ @ #[stable(feature = "rust1", since = "1.0.0")] - impl<$($name:Debug),+> Debug for ($($name,)+) where last_type!($($name,)+): ?Sized { + impl<$($name:Debug),+> Debug for ($($name,)+) { #[allow(non_snake_case, unused_assignments)] fn fmt(&self, f: &mut Formatter<'_>) -> Result { let mut builder = f.debug_tuple(""); @@ -2882,11 +2882,6 @@ macro_rules! maybe_tuple_doc { }; } -macro_rules! last_type { - ($a:ident,) => { $a }; - ($a:ident, $($rest_a:ident,)+) => { last_type!($($rest_a,)+) }; -} - tuple! { E, D, C, B, A, Z, Y, X, W, V, U, T, } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index 7a6630c82d0da..00ca922fff5f7 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -886,7 +886,7 @@ mod impls { maybe_tuple_doc! { $($name)+ @ #[stable(feature = "rust1", since = "1.0.0")] - impl<$($name: Hash),+> Hash for ($($name,)+) where last_type!($($name,)+): ?Sized { + impl<$($name: Hash),+> Hash for ($($name,)+) { #[allow(non_snake_case)] #[inline] fn hash(&self, state: &mut S) { @@ -912,11 +912,6 @@ mod impls { }; } - macro_rules! last_type { - ($a:ident,) => { $a }; - ($a:ident, $($rest_a:ident,)+) => { last_type!($($rest_a,)+) }; - } - impl_hash_tuple! {} impl_hash_tuple! { T } impl_hash_tuple! { T B } diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index 1935268cda891..ad3b6439a6105 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -1211,7 +1211,7 @@ pub enum OneSidedRangeBound { /// Types that implement `OneSidedRange` must return `Bound::Unbounded` /// from one of `RangeBounds::start_bound` or `RangeBounds::end_bound`. #[unstable(feature = "one_sided_range", issue = "69780")] -pub trait OneSidedRange: RangeBounds { +pub trait OneSidedRange: RangeBounds { /// An internal-only helper function for `split_off` and /// `split_off_mut` that returns the bound of the one-sided range. fn bound(self) -> (OneSidedRangeBound, T); diff --git a/library/core/src/tuple.rs b/library/core/src/tuple.rs index 206b5b9e2c24f..4a60181679d20 100644 --- a/library/core/src/tuple.rs +++ b/library/core/src/tuple.rs @@ -22,10 +22,7 @@ macro_rules! tuple_impls { maybe_tuple_doc! { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] - impl<$($T: PartialEq),+> PartialEq for ($($T,)+) - where - last_type!($($T,)+): ?Sized - { + impl<$($T: PartialEq),+> PartialEq for ($($T,)+) { #[inline] fn eq(&self, other: &($($T,)+)) -> bool { $( ${ignore($T)} self.${index()} == other.${index()} )&&+ @@ -41,8 +38,6 @@ macro_rules! tuple_impls { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] impl<$($T: Eq),+> Eq for ($($T,)+) - where - last_type!($($T,)+): ?Sized {} } @@ -71,8 +66,6 @@ macro_rules! tuple_impls { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] impl<$($T: PartialOrd),+> PartialOrd for ($($T,)+) - where - last_type!($($T,)+): ?Sized { #[inline] fn partial_cmp(&self, other: &($($T,)+)) -> Option { @@ -101,8 +94,6 @@ macro_rules! tuple_impls { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] impl<$($T: Ord),+> Ord for ($($T,)+) - where - last_type!($($T,)+): ?Sized { #[inline] fn cmp(&self, other: &($($T,)+)) -> Ordering { @@ -205,9 +196,4 @@ macro_rules! lexical_cmp { ($a:expr, $b:expr) => { ($a).cmp(&$b) }; } -macro_rules! last_type { - ($a:ident,) => { $a }; - ($a:ident, $($rest_a:ident,)+) => { last_type!($($rest_a,)+) }; -} - tuple_impls!(E D C B A Z Y X W V U T); diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index 253e13375c73c..91efeb5b62389 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -2094,7 +2094,6 @@ ui/issues/issue-32950.rs ui/issues/issue-32995-2.rs ui/issues/issue-32995.rs ui/issues/issue-33202.rs -ui/issues/issue-33241.rs ui/issues/issue-33287.rs ui/issues/issue-33293.rs ui/issues/issue-33387.rs @@ -2247,7 +2246,6 @@ ui/issues/issue-42007.rs ui/issues/issue-4208.rs ui/issues/issue-42106.rs ui/issues/issue-42148.rs -ui/issues/issue-42210.rs ui/issues/issue-4228.rs ui/issues/issue-42312.rs ui/issues/issue-42453.rs diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index fe51231c48100..65f1e90b8e5e2 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -17,7 +17,7 @@ use ignore::Walk; const ENTRY_LIMIT: u32 = 901; // FIXME: The following limits should be reduced eventually. -const ISSUES_ENTRY_LIMIT: u32 = 1634; +const ISSUES_ENTRY_LIMIT: u32 = 1632; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index 01d90717107bb..f7b721d6ce53d 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -292,7 +292,6 @@ mod unsized_ { use super::*; test_transparent_unsized!(str_, str); test_transparent_unsized!(slice, [u8]); - test_transparent_unsized!(slice_with_prefix, (usize, [u8])); test_transparent_unsized!(dyn_trait, dyn Any); } diff --git a/tests/ui/abi/debug.stderr b/tests/ui/abi/debug.stderr index 5f73ff7d6bd58..c60c91a9fe27b 100644 --- a/tests/ui/abi/debug.stderr +++ b/tests/ui/abi/debug.stderr @@ -904,7 +904,6 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: only the last element of a tuple may have a dynamically sized type error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions --> $DIR/debug.rs:29:5 diff --git a/tests/ui/associated-types/associated-types-coherence-failure.rs b/tests/ui/associated-types/associated-types-coherence-failure.rs index c33f2ac96ba62..55c17c8d37011 100644 --- a/tests/ui/associated-types/associated-types-coherence-failure.rs +++ b/tests/ui/associated-types/associated-types-coherence-failure.rs @@ -4,7 +4,7 @@ use std::marker::PhantomData; use std::ops::Deref; -pub struct Cow<'a, B: ?Sized>(PhantomData<(&'a (),B)>); +pub struct Cow<'a, B: ?Sized>(PhantomData<&'a ()>, PhantomData); /// Trait for moving into a `Cow` pub trait IntoCow<'a, B: ?Sized> { @@ -14,7 +14,7 @@ pub trait IntoCow<'a, B: ?Sized> { impl<'a, B: ?Sized> IntoCow<'a, B> for ::Owned where B: ToOwned { fn into_cow(self) -> Cow<'a, B> { - Cow(PhantomData) + Cow(PhantomData, PhantomData) } } @@ -28,7 +28,7 @@ impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned { impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned { //~^ ERROR E0119 fn into_cow(self) -> Cow<'a, B> { - Cow(PhantomData) + Cow(PhantomData, PhantomData) } } diff --git a/tests/ui/async-await/awaiting-unsized-param.rs b/tests/ui/async-await/awaiting-unsized-param.rs index 45611eae41f5c..b00b23c1139ee 100644 --- a/tests/ui/async-await/awaiting-unsized-param.rs +++ b/tests/ui/async-await/awaiting-unsized-param.rs @@ -7,6 +7,7 @@ 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..969a1729965da 100644 --- a/tests/ui/async-await/awaiting-unsized-param.stderr +++ b/tests/ui/async-await/awaiting-unsized-param.stderr @@ -16,6 +16,14 @@ LL | async fn bug(mut f: dyn Future + Unpin) -> T { = 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 -error: aborting due to 1 previous error; 1 warning emitted +error[E0277]: the size for values of type `dyn Future + Unpin` cannot be known at compilation time + --> $DIR/awaiting-unsized-param.rs:8:1 + | +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` + +error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/box/into-boxed-slice-fail.stderr b/tests/ui/box/into-boxed-slice-fail.stderr index f102f666dc276..06e92381fa8c1 100644 --- a/tests/ui/box/into-boxed-slice-fail.stderr +++ b/tests/ui/box/into-boxed-slice-fail.stderr @@ -9,6 +9,10 @@ LL | let _ = Box::into_boxed_slice(boxed_slice); = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `Box::::into_boxed_slice` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL +help: use a unary tuple instead + | +LL | let _ = Box::into_boxed_slice((boxed_slice,)); + | + ++ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/into-boxed-slice-fail.rs:7:13 @@ -30,6 +34,10 @@ LL | let _ = Box::into_boxed_slice(boxed_trait); = help: the trait `Sized` is not implemented for `dyn Debug` note: required by a bound in `Box::::into_boxed_slice` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL +help: use a unary tuple instead + | +LL | let _ = Box::into_boxed_slice((boxed_trait,)); + | + ++ error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time --> $DIR/into-boxed-slice-fail.rs:11:13 diff --git a/tests/ui/closures/issue-111932.stderr b/tests/ui/closures/issue-111932.stderr index 93488ad2011e4..5f9bf8d5367ea 100644 --- a/tests/ui/closures/issue-111932.stderr +++ b/tests/ui/closures/issue-111932.stderr @@ -20,6 +20,10 @@ LL | println!("{:?}", foo); note: required by an implicit `Sized` bound in `core::fmt::rt::Argument::<'_>::new_debug` --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use a unary tuple instead + | +LL | println!("{:?}", (foo,)); + | + ++ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/occurs-check/unused-substs-2.rs b/tests/ui/const-generics/occurs-check/unused-substs-2.rs index 5bdd3e39806e3..9ee0a02460a28 100644 --- a/tests/ui/const-generics/occurs-check/unused-substs-2.rs +++ b/tests/ui/const-generics/occurs-check/unused-substs-2.rs @@ -9,6 +9,8 @@ struct Foo; trait Bind { fn bind() -> (T, Self); + //~^ ERROR: the size for values of type `Self` cannot be known at compilation time + //~| NOTE: doesn't have a size known at compile-time } // `N` has to be `ConstKind::Unevaluated`. diff --git a/tests/ui/const-generics/occurs-check/unused-substs-2.stderr b/tests/ui/const-generics/occurs-check/unused-substs-2.stderr index a2c4dec472439..dc99b528920cc 100644 --- a/tests/ui/const-generics/occurs-check/unused-substs-2.stderr +++ b/tests/ui/const-generics/occurs-check/unused-substs-2.stderr @@ -1,9 +1,21 @@ +error[E0277]: the size for values of type `Self` cannot be known at compilation time + --> $DIR/unused-substs-2.rs:11:18 + | +LL | fn bind() -> (T, Self); + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider further restricting `Self` + | +LL | fn bind() -> (T, Self) where Self: Sized; + | +++++++++++++++++ + error[E0308]: mismatched types - --> $DIR/unused-substs-2.rs:22:24 + --> $DIR/unused-substs-2.rs:24:24 | LL | let (mut t, foo) = Foo::bind(); | ^^^^^^^^^^^ cyclic type of infinite size -error: aborting due to 1 previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/dst/dst-bad-coerce2.rs b/tests/ui/dst/dst-bad-coerce2.rs index e7ce20b895879..13917f1b715dc 100644 --- a/tests/ui/dst/dst-bad-coerce2.rs +++ b/tests/ui/dst/dst-bad-coerce2.rs @@ -1,7 +1,7 @@ // Attempt to change the mutability as well as unsizing. struct Fat { - ptr: T + ptr: T, } struct Foo; @@ -18,14 +18,4 @@ pub fn main() { let f1 = Fat { ptr: Foo }; let f2: &Fat = &f1; let f3: &mut Fat = f2; //~ ERROR mismatched types - - // Tuple with a vec of ints. - let f1 = ([1, 2, 3],); - let f2: &([isize; 3],) = &f1; - let f3: &mut ([isize],) = f2; //~ ERROR mismatched types - - // Tuple with a trait. - let f1 = (Foo,); - let f2: &(Foo,) = &f1; - let f3: &mut (dyn Bar,) = f2; //~ ERROR mismatched types } diff --git a/tests/ui/dst/dst-bad-coerce2.stderr b/tests/ui/dst/dst-bad-coerce2.stderr index 3ded96cfb6148..f2b4ffd94ef35 100644 --- a/tests/ui/dst/dst-bad-coerce2.stderr +++ b/tests/ui/dst/dst-bad-coerce2.stderr @@ -20,28 +20,6 @@ LL | let f3: &mut Fat = f2; = note: expected mutable reference `&mut Fat` found reference `&Fat` -error[E0308]: mismatched types - --> $DIR/dst-bad-coerce2.rs:25:31 - | -LL | let f3: &mut ([isize],) = f2; - | --------------- ^^ types differ in mutability - | | - | expected due to this - | - = note: expected mutable reference `&mut ([isize],)` - found reference `&([isize; 3],)` - -error[E0308]: mismatched types - --> $DIR/dst-bad-coerce2.rs:30:31 - | -LL | let f3: &mut (dyn Bar,) = f2; - | --------------- ^^ types differ in mutability - | | - | expected due to this - | - = note: expected mutable reference `&mut (dyn Bar,)` - found reference `&(Foo,)` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/dst/dst-rvalue.stderr b/tests/ui/dst/dst-rvalue.stderr index d8c529617f75f..27a4d194b268c 100644 --- a/tests/ui/dst/dst-rvalue.stderr +++ b/tests/ui/dst/dst-rvalue.stderr @@ -9,6 +9,10 @@ LL | let _x: Box = Box::new(*"hello world"); = help: the trait `Sized` is not implemented for `str` note: required by a bound in `Box::::new` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL +help: use a unary tuple instead + | +LL | let _x: Box = Box::new((*"hello world",)); + | + ++ help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | LL - let _x: Box = Box::new(*"hello world"); @@ -26,6 +30,10 @@ LL | let _x: Box<[isize]> = Box::new(*array); = help: the trait `Sized` is not implemented for `[isize]` note: required by a bound in `Box::::new` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL +help: use a unary tuple instead + | +LL | let _x: Box<[isize]> = Box::new((*array,)); + | + ++ help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | LL - let _x: Box<[isize]> = Box::new(*array); diff --git a/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs b/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs deleted file mode 100644 index b5fbcc9ccf8c0..0000000000000 --- a/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let _ : &(dyn Send,) = &((),); - //~^ ERROR 2:28: 2:34: mismatched types [E0308] -} diff --git a/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr b/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr deleted file mode 100644 index 12847bd3c0dff..0000000000000 --- a/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/feature-gate-unsized_tuple_coercion.rs:2:28 - | -LL | let _ : &(dyn Send,) = &((),); - | ------------ ^^^^^^ expected `&(dyn Send,)`, found `&((),)` - | | - | expected due to this - | - = note: expected reference `&(dyn Send,)` - found reference `&((),)` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs index ccf0a1ad3d443..af368203de021 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs @@ -6,11 +6,9 @@ impl Trait for u32 {} fn fuz() -> (usize, Trait) { (42, Struct) } //~^ ERROR E0277 -//~| ERROR E0277 //~| ERROR E0308 fn bar() -> (usize, dyn Trait) { (42, Struct) } //~^ ERROR E0277 -//~| ERROR E0277 //~| ERROR E0308 fn bap() -> Trait { Struct } //~^ ERROR E0746 diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr index 304d7d43b78b3..1f2fecbeee6de 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr @@ -4,22 +4,18 @@ error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be know LL | fn fuz() -> (usize, Trait) { (42, Struct) } | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` - = note: required because it appears within the type `(usize, (dyn Trait + 'static))` - = note: the return type of a function must have a statically known size + = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:13 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` - = note: required because it appears within the type `(usize, (dyn Trait + 'static))` - = note: the return type of a function must have a statically known size + = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:13:13 | LL | fn bap() -> Trait { Struct } | ^^^^^ doesn't have a size known at compile-time @@ -34,7 +30,7 @@ LL | fn bap() -> Box { Box::new(Struct) } | +++++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13 | LL | fn ban() -> dyn Trait { Struct } | ^^^^^^^^^ doesn't have a size known at compile-time @@ -50,7 +46,7 @@ LL | fn ban() -> Box { Box::new(Struct) } | ++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13 | LL | fn bak() -> dyn Trait { unimplemented!() } | ^^^^^^^^^ doesn't have a size known at compile-time @@ -66,7 +62,7 @@ LL | fn bak() -> Box { Box::new(unimplemented!()) } | ++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:21:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13 | LL | fn bal() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -86,7 +82,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:25:13 | LL | fn bax() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -106,7 +102,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:62:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:60:13 | LL | fn bat() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -126,7 +122,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:68:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:66:13 | LL | fn bay() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -155,18 +151,8 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) } found struct `Struct` = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box`, you will have to change the expected type as well -error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:30 - | -LL | fn fuz() -> (usize, Trait) { (42, Struct) } - | ^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` - = note: required because it appears within the type `(usize, (dyn Trait + 'static))` - = note: tuples must have a statically known size to be initialized - error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:39 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:39 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | ^^^^^^ expected `dyn Trait`, found `Struct` @@ -175,18 +161,8 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } found struct `Struct` = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box`, you will have to change the expected type as well -error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:34 - | -LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } - | ^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` - = note: required because it appears within the type `(usize, (dyn Trait + 'static))` - = note: tuples must have a statically known size to be initialized - error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:16 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:34:16 | LL | fn bam() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -203,7 +179,7 @@ LL | return Box::new(Struct); | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:38:5 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:5 | LL | fn bam() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -220,7 +196,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:16 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:40:16 | LL | fn baq() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -237,7 +213,7 @@ LL | return Box::new(0); | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:44:5 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:5 | LL | fn baq() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -254,7 +230,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:46:9 | LL | fn baz() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -271,7 +247,7 @@ LL | Box::new(Struct) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:50:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9 | LL | fn baz() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -288,7 +264,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:53:9 | LL | fn baw() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -305,7 +281,7 @@ LL | Box::new(0) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:57:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9 | LL | fn baw() -> Box { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -321,7 +297,7 @@ help: store this in the heap by calling `Box::new` LL | Box::new(42) | +++++++++ + -error: aborting due to 21 previous errors +error: aborting due to 19 previous errors Some errors have detailed explanations: E0277, E0308, E0746. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/issues/issue-62742.rs b/tests/ui/impl-trait/issues/issue-62742.rs index c64278c2c5bec..789d62fcefdaf 100644 --- a/tests/ui/impl-trait/issues/issue-62742.rs +++ b/tests/ui/impl-trait/issues/issue-62742.rs @@ -30,7 +30,7 @@ impl Raw<[T]> for RawImpl { type Value = T; } -pub struct SafeImpl>(PhantomData<(A, T)>); +pub struct SafeImpl>(PhantomData, PhantomData); impl> SafeImpl { pub fn foo(value: A::Value) {} diff --git a/tests/ui/impl-trait/issues/issue-62742.stderr b/tests/ui/impl-trait/issues/issue-62742.stderr index ee4eb98f4eaf5..00f4ad157896d 100644 --- a/tests/ui/impl-trait/issues/issue-62742.stderr +++ b/tests/ui/impl-trait/issues/issue-62742.stderr @@ -9,7 +9,7 @@ LL | WrongImpl::foo(0i32); note: required by a bound in `SafeImpl` --> $DIR/issue-62742.rs:33:35 | -LL | pub struct SafeImpl>(PhantomData<(A, T)>); +LL | pub struct SafeImpl>(PhantomData, PhantomData); | ^^^^^^ required by this bound in `SafeImpl` error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<_, RawImpl<_>>`, but its trait bounds were not satisfied @@ -21,7 +21,7 @@ LL | WrongImpl::foo(0i32); LL | pub struct RawImpl(PhantomData); | --------------------- doesn't satisfy `RawImpl<_>: Raw<_>` ... -LL | pub struct SafeImpl>(PhantomData<(A, T)>); +LL | pub struct SafeImpl>(PhantomData, PhantomData); | ----------------------------------------- function or associated item `foo` not found for this struct | note: trait bound `RawImpl<_>: Raw<_>` was not satisfied @@ -49,7 +49,7 @@ LL | WrongImpl::<()>::foo(0i32); note: required by a bound in `SafeImpl` --> $DIR/issue-62742.rs:33:35 | -LL | pub struct SafeImpl>(PhantomData<(A, T)>); +LL | pub struct SafeImpl>(PhantomData, PhantomData); | ^^^^^^ required by this bound in `SafeImpl` error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<(), RawImpl<()>>`, but its trait bounds were not satisfied @@ -61,7 +61,7 @@ LL | WrongImpl::<()>::foo(0i32); LL | pub struct RawImpl(PhantomData); | --------------------- doesn't satisfy `RawImpl<()>: Raw<()>` ... -LL | pub struct SafeImpl>(PhantomData<(A, T)>); +LL | pub struct SafeImpl>(PhantomData, PhantomData); | ----------------------------------------- function or associated item `foo` not found for this struct | note: trait bound `RawImpl<()>: Raw<()>` was not satisfied diff --git a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs index 346a94c37dd86..6268d2ee599e3 100644 --- a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs +++ b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs @@ -8,11 +8,9 @@ #![allow(deprecated, invalid_value)] #![feature(never_type)] -use std::{ - mem::{self, MaybeUninit, ManuallyDrop}, - ptr::NonNull, - num, -}; +use std::mem::{self, ManuallyDrop, MaybeUninit}; +use std::num; +use std::ptr::NonNull; #[allow(dead_code)] struct Foo { @@ -23,7 +21,9 @@ struct Foo { enum Bar {} #[allow(dead_code)] -enum OneVariant { Variant(i32) } +enum OneVariant { + Variant(i32), +} #[allow(dead_code, non_camel_case_types)] enum OneVariant_NonZero { @@ -68,7 +68,7 @@ enum ZeroIsValid { #[track_caller] fn test_panic_msg T) + 'static>(op: F, msg: &str) { - use std::{panic, env, process}; + use std::{env, panic, process}; // The tricky part is that we can't just run `op`, as that would *abort* the process. // So instead, we reinvoke this process with the caller location as argument. @@ -91,7 +91,12 @@ fn test_panic_msg T) + 'static>(op: F, msg: &str) { let res = cmd.output().unwrap(); assert!(!res.status.success(), "test did not fail"); let stderr = String::from_utf8_lossy(&res.stderr); - assert!(stderr.contains(msg), "test did not contain expected output: looking for {:?}, output:\n{}", msg, stderr); + assert!( + stderr.contains(msg), + "test did not contain expected output: looking for {:?}, output:\n{}", + msg, + stderr + ); } } @@ -110,276 +115,258 @@ fn main() { // Uninhabited types test_panic_msg( || mem::uninitialized::(), - "attempted to instantiate uninhabited type `!`" - ); - test_panic_msg( - || mem::zeroed::(), - "attempted to instantiate uninhabited type `!`" + "attempted to instantiate uninhabited type `!`", ); + test_panic_msg(|| mem::zeroed::(), "attempted to instantiate uninhabited type `!`"); test_panic_msg( || MaybeUninit::::uninit().assume_init(), - "attempted to instantiate uninhabited type `!`" + "attempted to instantiate uninhabited type `!`", ); test_panic_msg( || mem::uninitialized::(), - "attempted to instantiate uninhabited type `Foo`" - ); - test_panic_msg( - || mem::zeroed::(), - "attempted to instantiate uninhabited type `Foo`" + "attempted to instantiate uninhabited type `Foo`", ); + test_panic_msg(|| mem::zeroed::(), "attempted to instantiate uninhabited type `Foo`"); test_panic_msg( || MaybeUninit::::uninit().assume_init(), - "attempted to instantiate uninhabited type `Foo`" + "attempted to instantiate uninhabited type `Foo`", ); test_panic_msg( || mem::uninitialized::(), - "attempted to instantiate uninhabited type `Bar`" - ); - test_panic_msg( - || mem::zeroed::(), - "attempted to instantiate uninhabited type `Bar`" + "attempted to instantiate uninhabited type `Bar`", ); + test_panic_msg(|| mem::zeroed::(), "attempted to instantiate uninhabited type `Bar`"); test_panic_msg( || MaybeUninit::::uninit().assume_init(), - "attempted to instantiate uninhabited type `Bar`" + "attempted to instantiate uninhabited type `Bar`", ); test_panic_msg( || mem::uninitialized::<[Foo; 2]>(), - "attempted to instantiate uninhabited type `[Foo; 2]`" + "attempted to instantiate uninhabited type `[Foo; 2]`", ); test_panic_msg( || mem::zeroed::<[Foo; 2]>(), - "attempted to instantiate uninhabited type `[Foo; 2]`" + "attempted to instantiate uninhabited type `[Foo; 2]`", ); test_panic_msg( || MaybeUninit::<[Foo; 2]>::uninit().assume_init(), - "attempted to instantiate uninhabited type `[Foo; 2]`" + "attempted to instantiate uninhabited type `[Foo; 2]`", ); test_panic_msg( || mem::uninitialized::<[Bar; 2]>(), - "attempted to instantiate uninhabited type `[Bar; 2]`" + "attempted to instantiate uninhabited type `[Bar; 2]`", ); test_panic_msg( || mem::zeroed::<[Bar; 2]>(), - "attempted to instantiate uninhabited type `[Bar; 2]`" + "attempted to instantiate uninhabited type `[Bar; 2]`", ); test_panic_msg( || MaybeUninit::<[Bar; 2]>::uninit().assume_init(), - "attempted to instantiate uninhabited type `[Bar; 2]`" + "attempted to instantiate uninhabited type `[Bar; 2]`", ); // Types that don't allow either. test_panic_msg( || mem::zeroed::<&i32>(), - "attempted to zero-initialize type `&i32`, which is invalid" + "attempted to zero-initialize type `&i32`, which is invalid", ); test_panic_msg( || mem::uninitialized::<&i32>(), - "attempted to leave type `&i32` uninitialized, which is invalid" + "attempted to leave type `&i32` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::>(), - "attempted to zero-initialize type `alloc::boxed::Box<[i32; 0]>`, which is invalid" + "attempted to zero-initialize type `alloc::boxed::Box<[i32; 0]>`, which is invalid", ); test_panic_msg( || mem::uninitialized::>(), - "attempted to leave type `alloc::boxed::Box<[i32; 0]>` uninitialized, which is invalid" + "attempted to leave type `alloc::boxed::Box<[i32; 0]>` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::>(), - "attempted to zero-initialize type `alloc::boxed::Box`, which is invalid" + "attempted to zero-initialize type `alloc::boxed::Box`, which is invalid", ); test_panic_msg( || mem::uninitialized::>(), - "attempted to leave type `alloc::boxed::Box` uninitialized, which is invalid" + "attempted to leave type `alloc::boxed::Box` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::<&[i32]>(), - "attempted to zero-initialize type `&[i32]`, which is invalid" + "attempted to zero-initialize type `&[i32]`, which is invalid", ); test_panic_msg( || mem::uninitialized::<&[i32]>(), - "attempted to leave type `&[i32]` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<&(u8, [u8])>(), - "attempted to zero-initialize type `&(u8, [u8])`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::<&(u8, [u8])>(), - "attempted to leave type `&(u8, [u8])` uninitialized, which is invalid" + "attempted to leave type `&[i32]` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::<&dyn Send>(), - "attempted to zero-initialize type `&dyn core::marker::Send`, which is invalid" + "attempted to zero-initialize type `&dyn core::marker::Send`, which is invalid", ); test_panic_msg( || mem::uninitialized::<&dyn Send>(), - "attempted to leave type `&dyn core::marker::Send` uninitialized, which is invalid" + "attempted to leave type `&dyn core::marker::Send` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::<*const dyn Send>(), - "attempted to zero-initialize type `*const dyn core::marker::Send`, which is invalid" + "attempted to zero-initialize type `*const dyn core::marker::Send`, which is invalid", ); test_panic_msg( || mem::uninitialized::<*const dyn Send>(), - "attempted to leave type `*const dyn core::marker::Send` uninitialized, which is invalid" + "attempted to leave type `*const dyn core::marker::Send` uninitialized, which is invalid", ); test_panic_msg( || mem::uninitialized::(), "attempted to leave type `NoNullVariant` uninitialized, \ - which is invalid" + which is invalid", ); test_panic_msg( || mem::zeroed::(), "attempted to zero-initialize type `NoNullVariant`, \ - which is invalid" + which is invalid", ); test_panic_msg( || mem::zeroed::(), "attempted to zero-initialize type `OneVariant_Ref`, \ - which is invalid" + which is invalid", ); test_panic_msg( || mem::uninitialized::(), - "attempted to leave type `OneVariant_Ref` uninitialized, which is invalid" + "attempted to leave type `OneVariant_Ref` uninitialized, which is invalid", ); // Types where both are invalid, but we allow uninit since the 0x01-filling is not LLVM UB. test_panic_msg( || mem::zeroed::(), - "attempted to zero-initialize type `fn()`, which is invalid" + "attempted to zero-initialize type `fn()`, which is invalid", ); test_panic_msg_only_if_strict( || mem::uninitialized::(), - "attempted to leave type `fn()` uninitialized, which is invalid" + "attempted to leave type `fn()` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::<&()>(), - "attempted to zero-initialize type `&()`, which is invalid" + "attempted to zero-initialize type `&()`, which is invalid", ); test_panic_msg_only_if_strict( || mem::uninitialized::<&()>(), - "attempted to leave type `&()` uninitialized, which is invalid" + "attempted to leave type `&()` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::<&[u8]>(), - "attempted to zero-initialize type `&[u8]`, which is invalid" + "attempted to zero-initialize type `&[u8]`, which is invalid", ); test_panic_msg_only_if_strict( || mem::uninitialized::<&[u8]>(), - "attempted to leave type `&[u8]` uninitialized, which is invalid" + "attempted to leave type `&[u8]` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::<&str>(), - "attempted to zero-initialize type `&str`, which is invalid" + "attempted to zero-initialize type `&str`, which is invalid", ); test_panic_msg_only_if_strict( || mem::uninitialized::<&str>(), - "attempted to leave type `&str` uninitialized, which is invalid" + "attempted to leave type `&str` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::<(NonNull, u32, u32)>(), "attempted to zero-initialize type `(core::ptr::non_null::NonNull, u32, u32)`, \ - which is invalid" + which is invalid", ); test_panic_msg_only_if_strict( || mem::uninitialized::<(NonNull, u32, u32)>(), - "attempted to leave type `(core::ptr::non_null::NonNull, u32, u32)` uninitialized, which is invalid" + "attempted to leave type `(core::ptr::non_null::NonNull, u32, u32)` uninitialized, which is invalid", ); test_panic_msg( || mem::zeroed::(), "attempted to zero-initialize type `OneVariant_NonZero`, \ - which is invalid" + which is invalid", ); test_panic_msg_only_if_strict( || mem::uninitialized::(), - "attempted to leave type `OneVariant_NonZero` uninitialized, which is invalid" + "attempted to leave type `OneVariant_NonZero` uninitialized, which is invalid", ); // Types where both are invalid but we allow the zeroed form since it is not LLVM UB. test_panic_msg_only_if_strict( || mem::zeroed::(), - "attempted to zero-initialize type `LR_NonZero`, which is invalid" + "attempted to zero-initialize type `LR_NonZero`, which is invalid", ); test_panic_msg( || mem::uninitialized::(), - "attempted to leave type `LR_NonZero` uninitialized, which is invalid" + "attempted to leave type `LR_NonZero` uninitialized, which is invalid", ); test_panic_msg_only_if_strict( || mem::zeroed::>(), "attempted to zero-initialize type `core::mem::manually_drop::ManuallyDrop`, \ - which is invalid" + which is invalid", ); test_panic_msg( || mem::uninitialized::>(), "attempted to leave type `core::mem::manually_drop::ManuallyDrop` uninitialized, \ - which is invalid" + which is invalid", ); // Some strict-only things test_panic_msg_only_if_strict( || mem::uninitialized::(), - "attempted to leave type `i32` uninitialized, which is invalid" + "attempted to leave type `i32` uninitialized, which is invalid", ); test_panic_msg_only_if_strict( || mem::uninitialized::<*const ()>(), - "attempted to leave type `*const ()` uninitialized, which is invalid" + "attempted to leave type `*const ()` uninitialized, which is invalid", ); test_panic_msg_only_if_strict( || mem::uninitialized::<[i32; 1]>(), - "attempted to leave type `[i32; 1]` uninitialized, which is invalid" + "attempted to leave type `[i32; 1]` uninitialized, which is invalid", ); test_panic_msg_only_if_strict( || mem::zeroed::<[NonNull<()>; 1]>(), - "attempted to zero-initialize type `[core::ptr::non_null::NonNull<()>; 1]`, which is invalid" + "attempted to zero-initialize type `[core::ptr::non_null::NonNull<()>; 1]`, which is invalid", ); // Types that can be zero, but not uninit (though some are mitigated). let _val = mem::zeroed::(); test_panic_msg( || mem::uninitialized::(), - "attempted to leave type `LR` uninitialized, which is invalid" + "attempted to leave type `LR` uninitialized, which is invalid", ); let _val = mem::zeroed::>(); test_panic_msg( || mem::uninitialized::>(), - "attempted to leave type `core::mem::manually_drop::ManuallyDrop` uninitialized, which is invalid" + "attempted to leave type `core::mem::manually_drop::ManuallyDrop` uninitialized, which is invalid", ); let _val = mem::zeroed::(); test_panic_msg_only_if_strict( || mem::uninitialized::(), - "attempted to leave type `bool` uninitialized, which is invalid" + "attempted to leave type `bool` uninitialized, which is invalid", ); let _val = mem::zeroed::(); test_panic_msg_only_if_strict( || mem::uninitialized::(), - "attempted to leave type `OneVariant` uninitialized, which is invalid" + "attempted to leave type `OneVariant` uninitialized, which is invalid", ); // Some things that are actually allowed. diff --git a/tests/ui/issues/issue-17651.stderr b/tests/ui/issues/issue-17651.stderr index 9519507320d82..9ff9919341de1 100644 --- a/tests/ui/issues/issue-17651.stderr +++ b/tests/ui/issues/issue-17651.stderr @@ -9,6 +9,10 @@ LL | (|| Box::new(*(&[0][..])))(); = help: the trait `Sized` is not implemented for `[{integer}]` note: required by a bound in `Box::::new` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL +help: use a unary tuple instead + | +LL | (|| Box::new((*(&[0][..]),)))(); + | + ++ help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | LL - (|| Box::new(*(&[0][..])))(); diff --git a/tests/ui/issues/issue-33241.rs b/tests/ui/issues/issue-33241.rs deleted file mode 100644 index 1c497876a90da..0000000000000 --- a/tests/ui/issues/issue-33241.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ check-pass - -use std::fmt; - -// CoerceUnsized is not implemented for tuples. You can still create -// an unsized tuple by transmuting a trait object. -fn any() -> T { unreachable!() } - -fn main() { - let t: &(u8, dyn fmt::Debug) = any(); - println!("{:?}", &t.1); -} diff --git a/tests/ui/issues/issue-42210.rs b/tests/ui/issues/issue-42210.rs deleted file mode 100644 index cec32c97375e0..0000000000000 --- a/tests/ui/issues/issue-42210.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass -// Regression test for #42210. - -//@ compile-flags: -g - -trait Foo { - fn foo() { } -} - -struct Bar; - -trait Baz { -} - -impl Foo for (Bar, dyn Baz) { } - - -fn main() { - <(Bar, dyn Baz) as Foo>::foo() -} diff --git a/tests/ui/issues/issue-88150.rs b/tests/ui/issues/issue-88150.rs index 1dadba307c0b5..821aec6e076a6 100644 --- a/tests/ui/issues/issue-88150.rs +++ b/tests/ui/issues/issue-88150.rs @@ -5,14 +5,15 @@ use core::marker::PhantomData; pub struct Foo( - PhantomData<(A, T)>, + PhantomData, + PhantomData, ); enum Never {} impl Foo { fn new_foo() -> Foo { - Foo(PhantomData) + Foo(PhantomData, PhantomData) } } diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index 07cad7766920f..13b5610398d7c 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -608,7 +608,6 @@ LL | type Impossible = (str, str); | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = note: only the last element of a tuple may have a dynamically sized type error: the type has an unknown layout --> $DIR/debug.rs:83:1 diff --git a/tests/ui/layout/invalid-unsized-const-eval.stderr b/tests/ui/layout/invalid-unsized-const-eval.stderr index a434ca9b2c7cf..c5999d8c0bbad 100644 --- a/tests/ui/layout/invalid-unsized-const-eval.stderr +++ b/tests/ui/layout/invalid-unsized-const-eval.stderr @@ -5,7 +5,6 @@ LL | data: (dyn Sync, ()), | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Sync + 'static)` - = note: only the last element of a tuple may have a dynamically sized type error[E0080]: could not evaluate static initializer --> $DIR/invalid-unsized-const-eval.rs:12:1 diff --git a/tests/ui/layout/issue-84108.stderr b/tests/ui/layout/issue-84108.stderr index e296abfc3b53b..b2ed926603609 100644 --- a/tests/ui/layout/issue-84108.stderr +++ b/tests/ui/layout/issue-84108.stderr @@ -27,7 +27,6 @@ LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/issue-84108.rs:15:13 @@ -36,7 +35,6 @@ LL | static BAZ: ([u8], usize) = ([], 0); | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/issue-84108.rs:9:12 @@ -45,7 +43,6 @@ LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: only the last element of a tuple may have a dynamically sized type = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types @@ -64,7 +61,6 @@ LL | static BAZ: ([u8], usize) = ([], 0); | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: only the last element of a tuple may have a dynamically sized type = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types diff --git a/tests/ui/methods/issues/issue-61525.stderr b/tests/ui/methods/issues/issue-61525.stderr index 7ac3d3dc0cff0..987031fbb1f0f 100644 --- a/tests/ui/methods/issues/issue-61525.stderr +++ b/tests/ui/methods/issues/issue-61525.stderr @@ -12,6 +12,10 @@ note: required by an implicit `Sized` bound in `Example::query` | LL | fn query(self, q: Q); | ^ required by the implicit `Sized` requirement on this type parameter in `Example::query` +help: use a unary tuple instead + | +LL | (1,).query::("") + | + ++ help: consider relaxing the implicit `Sized` restriction | LL | fn query(self, q: Q); diff --git a/tests/ui/offset-of/offset-of-dst-field.rs b/tests/ui/offset-of/offset-of-dst-field.rs index 2e0bdb151e180..f190ac83c266f 100644 --- a/tests/ui/offset-of/offset-of-dst-field.rs +++ b/tests/ui/offset-of/offset-of-dst-field.rs @@ -36,7 +36,7 @@ fn main() { offset_of!(Alpha, z); //~ ERROR the size for values of type offset_of!(Beta, z); //~ ERROR the size for values of type offset_of!(Gamma, z); //~ ERROR the size for values of type - offset_of!((u8, dyn Trait), 0); // ok + offset_of!((u8, dyn Trait), 0); //~ ERROR the size for values of type offset_of!((u8, dyn Trait), 1); //~ ERROR the size for values of type } diff --git a/tests/ui/offset-of/offset-of-dst-field.stderr b/tests/ui/offset-of/offset-of-dst-field.stderr index 714bf7a0266c6..59dcd26073e84 100644 --- a/tests/ui/offset-of/offset-of-dst-field.stderr +++ b/tests/ui/offset-of/offset-of-dst-field.stderr @@ -1,3 +1,11 @@ +error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:39:16 + | +LL | offset_of!((u8, dyn Trait), 0); + | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Trait` + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/offset-of-dst-field.rs:36:5 | @@ -88,8 +96,7 @@ LL | offset_of!(([u8], u8), 1); | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` - = note: only the last element of a tuple may have a dynamically sized type -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/offset-of/offset-of-slice-normalized.rs b/tests/ui/offset-of/offset-of-slice-normalized.rs index 9d1fd9dd2ee14..3ca207304c9b4 100644 --- a/tests/ui/offset-of/offset-of-slice-normalized.rs +++ b/tests/ui/offset-of/offset-of-slice-normalized.rs @@ -27,11 +27,8 @@ struct T { y: S, } -type Tup = (i16, <[i32] as Mirror>::Assoc); - fn main() { assert_eq!(offset_of!(S, c), 4); assert_eq!(offset_of!(T, y), 4); assert_eq!(offset_of!(T, y.c), 8); - assert_eq!(offset_of!(Tup, 1), 4); } diff --git a/tests/ui/offset-of/offset-of-slice.rs b/tests/ui/offset-of/offset-of-slice.rs index e6eb12abd7bbc..8d1972e1c5870 100644 --- a/tests/ui/offset-of/offset-of-slice.rs +++ b/tests/ui/offset-of/offset-of-slice.rs @@ -16,11 +16,8 @@ struct T { y: S, } -type Tup = (i16, [i32]); - fn main() { assert_eq!(offset_of!(S, c), 4); assert_eq!(offset_of!(T, y), 4); assert_eq!(offset_of!(T, y.c), 8); - assert_eq!(offset_of!(Tup, 1), 4); } diff --git a/tests/ui/offset-of/offset-of-unsized.rs b/tests/ui/offset-of/offset-of-unsized.rs index 5a84adcb9e511..2aa487e193107 100644 --- a/tests/ui/offset-of/offset-of-unsized.rs +++ b/tests/ui/offset-of/offset-of-unsized.rs @@ -10,5 +10,4 @@ trait Tr {} fn main() { let _a = core::mem::offset_of!(S, a); - let _b = core::mem::offset_of!((u64, dyn Tr), 0); } 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..045742974415d 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 @@ -23,8 +23,10 @@ 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 use a unary tuple instead S.baz(*""); //~^ 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 use a unary tuple instead } 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..2666d46e64d9e 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 @@ -43,6 +43,10 @@ note: required by a bound in `bar` | LL | fn bar(_: impl Sized) {} | ^^^^^ required by this bound in `bar` +help: use a unary tuple instead + | +LL | bar((*"",)); + | + ++ help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | LL - bar(*""); @@ -50,7 +54,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:27:11 | LL | S.baz(*""); | --- ^^^ doesn't have a size known at compile-time @@ -63,6 +67,10 @@ note: required by a bound in `S::baz` | LL | fn baz(&self, _: impl Sized) {} | ^^^^^ required by this bound in `S::baz` +help: use a unary tuple instead + | +LL | S.baz((*"",)); + | + ++ help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | LL - S.baz(*""); diff --git a/tests/ui/suggestions/issue-84973-blacklist.stderr b/tests/ui/suggestions/issue-84973-blacklist.stderr index 3db400418c711..de56ba3a2e10d 100644 --- a/tests/ui/suggestions/issue-84973-blacklist.stderr +++ b/tests/ui/suggestions/issue-84973-blacklist.stderr @@ -66,6 +66,10 @@ note: required by a bound in `f_sized` | LL | fn f_sized(t: T) {} | ^^^^^ required by this bound in `f_sized` +help: use a unary tuple instead + | +LL | f_sized((*ref_cl,)); + | + ++ help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression | LL - f_sized(*ref_cl); diff --git a/tests/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr b/tests/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr index 1cbcfbf84bcf4..7120bf8aed172 100644 --- a/tests/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr +++ b/tests/ui/suggestions/issue-85945-check-where-clause-before-suggesting-unsized.stderr @@ -12,6 +12,10 @@ note: required by a bound in `foo` | LL | fn foo(_: &T) where T: Sized {} | ^^^^^ required by this bound in `foo` +help: use a unary tuple instead + | +LL | fn bar() { foo(("",)); } + | + ++ error: aborting due to 1 previous error diff --git a/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr index 4609e02716fdc..fa3cf009e7b61 100644 --- a/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr +++ b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr @@ -20,7 +20,6 @@ LL | const TEST2: (Fn, u8) = (TEST, 0); | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)` - = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time --> $DIR/ice-unsized-tuple-const-issue-121443.rs:11:25 @@ -29,7 +28,6 @@ LL | const TEST2: (Fn, u8) = (TEST, 0); | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)` - = note: only the last element of a tuple may have a dynamically sized type error: aborting due to 4 previous errors diff --git a/tests/ui/trait-bounds/unsized-bound.stderr b/tests/ui/trait-bounds/unsized-bound.stderr index c8049ebee1173..55b74258002e9 100644 --- a/tests/ui/trait-bounds/unsized-bound.stderr +++ b/tests/ui/trait-bounds/unsized-bound.stderr @@ -1,27 +1,3 @@ -error[E0277]: the size for values of type `B` cannot be known at compilation time - --> $DIR/unsized-bound.rs:2:30 - | -LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} - | - ^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `Sized` - | - = note: required because it appears within the type `(A, B)` -note: required by an implicit `Sized` bound in `Trait` - --> $DIR/unsized-bound.rs:1:13 - | -LL | trait Trait {} - | ^ required by the implicit `Sized` requirement on this type parameter in `Trait` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} -LL + impl Trait<(A, B)> for (A, B) where A: ?Sized, {} - | -help: consider relaxing the implicit `Sized` restriction - | -LL | trait Trait {} - | ++++++++ - error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/unsized-bound.rs:2:30 | @@ -30,36 +6,25 @@ LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} | | | this type parameter needs to be `Sized` | - = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} LL + impl Trait<(A, B)> for (A, B) where B: ?Sized, {} | -error[E0277]: the size for values of type `C` cannot be known at compilation time - --> $DIR/unsized-bound.rs:5:52 - | -LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} - | - ^^^^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `Sized` +error[E0277]: the size for values of type `B` cannot be known at compilation time + --> $DIR/unsized-bound.rs:2:30 | - = note: required because it appears within the type `(A, B, C)` -note: required by an implicit `Sized` bound in `Trait` - --> $DIR/unsized-bound.rs:1:13 +LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} + | - ^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `Sized` | -LL | trait Trait {} - | ^ required by the implicit `Sized` requirement on this type parameter in `Trait` help: consider removing the `?Sized` bound to make the type parameter `Sized` | -LL - impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} -LL + impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} - | -help: consider relaxing the implicit `Sized` restriction +LL - impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} +LL + impl Trait<(A, B)> for (A, B) where A: ?Sized, {} | -LL | trait Trait {} - | ++++++++ error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/unsized-bound.rs:5:52 @@ -67,7 +32,6 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} | - this type parameter needs to be `Sized` ^^^^^^^^^ doesn't have a size known at compile-time | - = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} @@ -80,36 +44,25 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} | - this type parameter needs to be `Sized` ^^^^^^^^^ doesn't have a size known at compile-time | - = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} LL + impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} | -error[E0277]: the size for values of type `B` cannot be known at compilation time - --> $DIR/unsized-bound.rs:10:47 - | -LL | impl Trait2<(A, B)> for (A, B) {} - | - ^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `Sized` +error[E0277]: the size for values of type `C` cannot be known at compilation time + --> $DIR/unsized-bound.rs:5:52 | - = note: required because it appears within the type `(A, B)` -note: required by an implicit `Sized` bound in `Trait2` - --> $DIR/unsized-bound.rs:9:14 +LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} + | - ^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `Sized` | -LL | trait Trait2 {} - | ^ required by the implicit `Sized` requirement on this type parameter in `Trait2` help: consider removing the `?Sized` bound to make the type parameter `Sized` | -LL - impl Trait2<(A, B)> for (A, B) {} -LL + impl Trait2<(A, B)> for (A, B) {} - | -help: consider relaxing the implicit `Sized` restriction +LL - impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} +LL + impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} | -LL | trait Trait2 {} - | ++++++++ error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/unsized-bound.rs:10:47 @@ -119,13 +72,26 @@ LL | impl Trait2<(A, B)> for (A, B) {} | | | this type parameter needs to be `Sized` | - = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait2<(A, B)> for (A, B) {} LL + impl Trait2<(A, B)> for (A, B) {} | +error[E0277]: the size for values of type `B` cannot be known at compilation time + --> $DIR/unsized-bound.rs:10:47 + | +LL | impl Trait2<(A, B)> for (A, B) {} + | - ^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `Sized` + | +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl Trait2<(A, B)> for (A, B) {} +LL + impl Trait2<(A, B)> for (A, B) {} + | + error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/unsized-bound.rs:14:23 | diff --git a/tests/ui/traits/next-solver/pointee.rs b/tests/ui/traits/next-solver/pointee.rs index a861ce825162f..f3348f10656c8 100644 --- a/tests/ui/traits/next-solver/pointee.rs +++ b/tests/ui/traits/next-solver/pointee.rs @@ -15,7 +15,6 @@ fn works() { meta_is::(); meta_is::, DynMetadata>>(); meta_is::, ()>(); - meta_is::<((((([u8],),),),),), usize>(); } fn main() {} diff --git a/tests/ui/tuple/builtin.rs b/tests/ui/tuple/builtin.rs index 2678ae322e914..d87d0e95e1306 100644 --- a/tests/ui/tuple/builtin.rs +++ b/tests/ui/tuple/builtin.rs @@ -4,8 +4,6 @@ fn assert_is_tuple() {} -struct Unsized([u8]); - fn from_param_env() { assert_is_tuple::(); } @@ -13,8 +11,6 @@ fn from_param_env() { fn main() { assert_is_tuple::<()>(); assert_is_tuple::<(i32,)>(); - assert_is_tuple::<(Unsized,)>(); from_param_env::<()>(); from_param_env::<(i32,)>(); - from_param_env::<(Unsized,)>(); } 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..96f4254492cb1 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 @@ -15,6 +15,7 @@ fn example() -> Box { fn main() { let x: dyn Example = *example(); (move || { + //~^ 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..47d0fd31c08fc 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 @@ -8,16 +8,29 @@ LL | #![feature(unsized_locals)] = note: `#[warn(incomplete_features)]` on by default 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:19:18 | LL | (move || { | -- this closure captures all values by move +LL | LL | let _y = x; | ^ 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 -error: aborting due to 1 previous error; 1 warning emitted +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:17:5 + | +LL | / (move || { +LL | | +LL | | let _y = x; +LL | | +LL | | })(); + | |________^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Example` + +error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized-locals/unsized-locals-using-unsized-fn-params.rs b/tests/ui/unsized-locals/unsized-locals-using-unsized-fn-params.rs index 15263954ced77..6cc9e6c82ae76 100644 --- a/tests/ui/unsized-locals/unsized-locals-using-unsized-fn-params.rs +++ b/tests/ui/unsized-locals/unsized-locals-using-unsized-fn-params.rs @@ -7,6 +7,7 @@ fn f1(box box _b: Box>) {} fn f2((_x, _y): (i32, [i32])) {} //~^ ERROR: the size for values of type `[i32]` cannot be known at compilation time [E0277] +//~| ERROR: the size for values of type `[i32]` cannot be known at compilation time [E0277] fn main() { let foo: Box<[u8]> = Box::new(*b"foo"); 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..f54c08052bb5a 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 @@ -1,3 +1,11 @@ +error[E0277]: the size for values of type `[i32]` cannot be known at compilation time + --> $DIR/unsized-locals-using-unsized-fn-params.rs:8:17 + | +LL | fn f2((_x, _y): (i32, [i32])) {} + | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[i32]` + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/unsized-locals-using-unsized-fn-params.rs:5:15 | @@ -19,7 +27,7 @@ LL | fn f2((_x, _y): (i32, [i32])) {} = 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 + --> $DIR/unsized-locals-using-unsized-fn-params.rs:14:9 | LL | let _foo: [u8] = *foo; | ^^^^ doesn't have a size known at compile-time @@ -32,6 +40,6 @@ help: consider borrowing here LL | let _foo: &[u8] = *foo; | + -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/unsized3.rs b/tests/ui/unsized/unsized3.rs index af76aca2c2958..39b6583bc4ec4 100644 --- a/tests/ui/unsized/unsized3.rs +++ b/tests/ui/unsized/unsized3.rs @@ -44,7 +44,6 @@ fn f9(x1: Box>) { fn f10(x1: Box>) { f5(&(32, *x1)); //~^ ERROR the size for values of type - //~| ERROR the size for values of type } pub fn main() {} diff --git a/tests/ui/unsized/unsized3.stderr b/tests/ui/unsized/unsized3.stderr index c7a145b1c5171..c8c8576896598 100644 --- a/tests/ui/unsized/unsized3.stderr +++ b/tests/ui/unsized/unsized3.stderr @@ -87,7 +87,6 @@ note: required because it appears within the type `S` | LL | struct S { | ^ - = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f9(x1: Box>) { @@ -95,57 +94,24 @@ LL + fn f9(x1: Box>) { | error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized3.rs:45:9 + --> $DIR/unsized3.rs:45:5 | LL | fn f10(x1: Box>) { | - this type parameter needs to be `Sized` LL | f5(&(32, *x1)); - | ^^^^^^^^^ doesn't have a size known at compile-time - | -note: required because it appears within the type `S` - --> $DIR/unsized3.rs:28:8 - | -LL | struct S { - | ^ - = note: required because it appears within the type `({integer}, S)` - = note: tuples must have a statically known size to be initialized -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn f10(x1: Box>) { -LL + fn f10(x1: Box>) { - | - -error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized3.rs:45:8 - | -LL | fn f10(x1: Box>) { - | - this type parameter needs to be `Sized` -LL | f5(&(32, *x1)); - | -- ^^^^^^^^^^ doesn't have a size known at compile-time - | | - | required by a bound introduced by this call + | ^^ doesn't have a size known at compile-time | note: required because it appears within the type `S` --> $DIR/unsized3.rs:28:8 | LL | struct S { | ^ - = note: required because it appears within the type `({integer}, S)` -note: required by an implicit `Sized` bound in `f5` - --> $DIR/unsized3.rs:24:7 - | -LL | fn f5(x: &Y) {} - | ^ required by the implicit `Sized` requirement on this type parameter in `f5` help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f10(x1: Box>) { LL + fn f10(x1: Box>) { | -help: consider relaxing the implicit `Sized` restriction - | -LL | fn f5(x: &Y) {} - | ++++++++ -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/unsized6.stderr b/tests/ui/unsized/unsized6.stderr index de921709865bf..a3fe46c92f280 100644 --- a/tests/ui/unsized/unsized6.stderr +++ b/tests/ui/unsized/unsized6.stderr @@ -28,7 +28,6 @@ LL | let _: W; // <-- this is OK, no bindings created, no initializer. LL | let _: (isize, (X, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f1(x: &X) { @@ -44,7 +43,6 @@ LL | fn f1(x: &X) { LL | let y: (isize, (Z, usize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f1(x: &X) { @@ -80,7 +78,6 @@ LL | fn f2(x: &X) { LL | let y: (isize, (Y, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | - = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f2(x: &X) { diff --git a/tests/ui/wf/issue-87495.rs b/tests/ui/wf/issue-87495.rs index ce5c617bbbd38..dc7e07e246a0a 100644 --- a/tests/ui/wf/issue-87495.rs +++ b/tests/ui/wf/issue-87495.rs @@ -3,6 +3,7 @@ trait T { const CONST: (bool, dyn T); //~^ ERROR: the trait `T` is not dyn compatible [E0038] + //~| ERROR: the size for values of type `(dyn T + 'static)` cannot be known at compilation time } fn main() {} diff --git a/tests/ui/wf/issue-87495.stderr b/tests/ui/wf/issue-87495.stderr index 0c293e3576d64..65c59e6dd1351 100644 --- a/tests/ui/wf/issue-87495.stderr +++ b/tests/ui/wf/issue-87495.stderr @@ -14,6 +14,15 @@ LL | const CONST: (bool, dyn T); | ^^^^^ ...because it contains this associated `const` = help: consider moving `CONST` to another trait -error: aborting due to 1 previous error +error[E0277]: the size for values of type `(dyn T + 'static)` cannot be known at compilation time + --> $DIR/issue-87495.rs:4:5 + | +LL | const CONST: (bool, dyn T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn T + 'static)` + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0038`. +Some errors have detailed explanations: E0038, E0277. +For more information about an error, try `rustc --explain E0038`.