diff options
Diffstat (limited to 'src/test')
90 files changed, 621 insertions, 189 deletions
diff --git a/src/test/run-pass-valgrind/unsized-locals/long-live-the-unsized-temporary.rs b/src/test/run-pass-valgrind/unsized-locals/long-live-the-unsized-temporary.rs index 2f275f88d96..a7b9052617f 100644 --- a/src/test/run-pass-valgrind/unsized-locals/long-live-the-unsized-temporary.rs +++ b/src/test/run-pass-valgrind/unsized-locals/long-live-the-unsized-temporary.rs @@ -1,4 +1,5 @@ -#![feature(unsized_locals)] +#![allow(incomplete_features)] +#![feature(unsized_locals, unsized_fn_params)] use std::fmt; @@ -45,11 +46,7 @@ fn main() { { let x: fmt::Display = *gen_foo(); - let x = if true { - x - } else { - *gen_foo() - }; + let x = if true { x } else { *gen_foo() }; foo(x); } } diff --git a/src/test/ui/ast-json/issue-78398-foreign-ice.rs b/src/test/ui/ast-json/issue-78398-foreign-ice.rs new file mode 100644 index 00000000000..a1a20f95681 --- /dev/null +++ b/src/test/ui/ast-json/issue-78398-foreign-ice.rs @@ -0,0 +1,18 @@ +// Regression test for issue #78398 +// Tests that we don't ICE when trying to print the AST json +// when we have capturd tokens for a foreign item + +// check-pass +// compile-flags: -Zast-json + +fn main() {} + +macro_rules! mac_extern { + ($i:item) => { + extern "C" { $i } + } +} + +mac_extern! { + fn foo(); +} diff --git a/src/test/ui/ast-json/issue-78398-foreign-ice.stdout b/src/test/ui/ast-json/issue-78398-foreign-ice.stdout new file mode 100644 index 00000000000..f1d0e44e9fc --- /dev/null +++ b/src/test/ui/ast-json/issue-78398-foreign-ice.stdout @@ -0,0 +1 @@ +{"module":{"inner":{"lo":192,"hi":315},"unsafety":"No","items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":3,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":4,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":5,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":6,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":7,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":8,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":9,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":10,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":11,"span":{"lo":192,"hi":204},"vis":{"kind":"Inherited","span":{"lo":192,"hi":192},"tokens":null},"ident":{"name":"main","span":{"lo":195,"hi":199}},"kind":{"variant":"Fn","fields":["Final",{"header":{"unsafety":"No","asyncness":"No","constness":"No","ext":"None"},"decl":{"inputs":[],"output":{"variant":"Default","fields":[{"lo":202,"hi":202}]}},"span":{"lo":192,"hi":201}},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":201,"hi":201}},"span":{"lo":199,"hi":199}},{"stmts":[],"id":12,"rules":"Default","span":{"lo":202,"hi":204},"tokens":null}]},"tokens":null},{"attrs":[],"id":13,"span":{"lo":206,"hi":284},"vis":{"kind":"Inherited","span":{"lo":206,"hi":206},"tokens":null},"ident":{"name":"mac_extern","span":{"lo":219,"hi":229}},"kind":{"variant":"MacroDef","fields":[{"body":{"variant":"Delimited","fields":[{"open":{"lo":230,"hi":231},"close":{"lo":283,"hi":284}},"Brace",{"0":[[{"variant":"Delimited","fields":[{"open":{"lo":236,"hi":237},"close":{"lo":244,"hi":245}},"Paren",{"0":[[{"variant":"Token","fields":[{"kind":"Dollar","span":{"lo":237,"hi":238}}]},"Alone"],[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["i",false]},"span":{"lo":238,"hi":239}}]},"Joint"],[{"variant":"Token","fields":[{"kind":"Colon","span":{"lo":239,"hi":240}}]},"Alone"],[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["item",false]},"span":{"lo":240,"hi":244}}]},"Alone"]]}]},"Alone"],[{"variant":"Token","fields":[{"kind":"FatArrow","span":{"lo":246,"hi":248}}]},"Alone"],[{"variant":"Delimited","fields":[{"open":{"lo":249,"hi":250},"close":{"lo":281,"hi":282}},"Brace",{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["extern",false]},"span":{"lo":259,"hi":265}}]},"Alone"],[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"C","suffix":null}]},"span":{"lo":266,"hi":269}}]},"Alone"],[{"variant":"Delimited","fields":[{"open":{"lo":270,"hi":271},"close":{"lo":275,"hi":276}},"Brace",{"0":[[{"variant":"Token","fields":[{"kind":"Dollar","span":{"lo":272,"hi":273}}]},"Alone"],[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["i",false]},"span":{"lo":273,"hi":274}}]},"Alone"]]}]},"Alone"]]}]},"Alone"]]}]},"macro_rules":true}]},"tokens":null},{"attrs":[],"id":14,"span":{"lo":259,"hi":276},"vis":{"kind":"Inherited","span":{"lo":259,"hi":259},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"ForeignMod","fields":[{"unsafety":"No","abi":{"style":"Cooked","symbol":"C","suffix":null,"span":{"lo":266,"hi":269},"symbol_unescaped":"C"},"items":[{"attrs":[],"id":15,"span":{"lo":304,"hi":313},"vis":{"kind":"Inherited","span":{"lo":304,"hi":304},"tokens":null},"ident":{"name":"foo","span":{"lo":307,"hi":310}},"kind":{"variant":"Fn","fields":["Final",{"header":{"unsafety":"No","asyncness":"No","constness":"No","ext":"None"},"decl":{"inputs":[],"output":{"variant":"Default","fields":[{"lo":312,"hi":312}]}},"span":{"lo":304,"hi":313}},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":312,"hi":312}},"span":{"lo":310,"hi":310}},null]},"tokens":null}]}]},"tokens":null}],"inline":true},"attrs":[],"span":{"lo":192,"hi":315},"proc_macros":[]} diff --git a/src/test/ui/async-await/issue-61076.rs b/src/test/ui/async-await/issue-61076.rs index b1216ff4c45..8a7b166cb15 100644 --- a/src/test/ui/async-await/issue-61076.rs +++ b/src/test/ui/async-await/issue-61076.rs @@ -40,6 +40,14 @@ async fn foo() -> Result<(), ()> { async fn bar() -> Result<(), ()> { foo()?; //~ ERROR the `?` operator can only be applied to values that implement `Try` + //~^ NOTE the `?` operator cannot be applied to type `impl Future` + //~| HELP the trait `Try` is not implemented for `impl Future` + //~| NOTE required by `into_result` + //~| HELP consider `await`ing on the `Future` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` Ok(()) } @@ -48,25 +56,42 @@ async fn struct_() -> Struct { } async fn tuple() -> Tuple { + //~^ NOTE the `Output` of this `async fn`'s expected opaque type Tuple(1i32) } async fn baz() -> Result<(), ()> { let t = T; t?; //~ ERROR the `?` operator can only be applied to values that implement `Try` + //~^ NOTE the `?` operator cannot be applied to type `T` + //~| HELP the trait `Try` is not implemented for `T` + //~| NOTE required by `into_result` + //~| HELP consider `await`ing on the `Future` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + //~| NOTE in this expansion of desugaring of operator `?` + let _: i32 = tuple().0; //~ ERROR no field `0` + //~^ HELP consider `await`ing on the `Future` + //~| NOTE field not available in `impl Future` let _: i32 = struct_().a; //~ ERROR no field `a` + //~^ HELP consider `await`ing on the `Future` + //~| NOTE field not available in `impl Future` struct_().method(); //~ ERROR no method named - + //~^ NOTE method not found in `impl Future` + //~| HELP consider `await`ing on the `Future` Ok(()) } async fn match_() { - match tuple() { + match tuple() { //~ HELP consider `await`ing on the `Future` Tuple(_) => {} //~ ERROR mismatched types + //~^ NOTE expected opaque type, found struct `Tuple` + //~| NOTE expected opaque type `impl Future` } } diff --git a/src/test/ui/async-await/issue-61076.stderr b/src/test/ui/async-await/issue-61076.stderr index df54ac88ace..db6dc3ea00a 100644 --- a/src/test/ui/async-await/issue-61076.stderr +++ b/src/test/ui/async-await/issue-61076.stderr @@ -12,7 +12,7 @@ LL | foo().await?; | ^^^^^^ error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/issue-61076.rs:56:5 + --> $DIR/issue-61076.rs:65:5 | LL | t?; | ^^ the `?` operator cannot be applied to type `T` @@ -25,25 +25,40 @@ LL | t.await?; | ^^^^^^ error[E0609]: no field `0` on type `impl Future` - --> $DIR/issue-61076.rs:58:26 + --> $DIR/issue-61076.rs:76:26 | LL | let _: i32 = tuple().0; - | ^ + | ^ field not available in `impl Future`, but it is available in its `Output` + | +help: consider `await`ing on the `Future` and access the field of its `Output` + | +LL | let _: i32 = tuple().await.0; + | ^^^^^^ error[E0609]: no field `a` on type `impl Future` - --> $DIR/issue-61076.rs:60:28 + --> $DIR/issue-61076.rs:80:28 | LL | let _: i32 = struct_().a; - | ^ + | ^ field not available in `impl Future`, but it is available in its `Output` + | +help: consider `await`ing on the `Future` and access the field of its `Output` + | +LL | let _: i32 = struct_().await.a; + | ^^^^^^ error[E0599]: no method named `method` found for opaque type `impl Future` in the current scope - --> $DIR/issue-61076.rs:62:15 + --> $DIR/issue-61076.rs:84:15 | LL | struct_().method(); | ^^^^^^ method not found in `impl Future` + | +help: consider `await`ing on the `Future` and calling the method on its `Output` + | +LL | struct_().await.method(); + | ^^^^^^ error[E0308]: mismatched types - --> $DIR/issue-61076.rs:69:9 + --> $DIR/issue-61076.rs:92:9 | LL | async fn tuple() -> Tuple { | ----- the `Output` of this `async fn`'s expected opaque type diff --git a/src/test/ui/async-await/issue-72590-type-error-sized.stderr b/src/test/ui/async-await/issue-72590-type-error-sized.stderr index 785fe21dd31..0f90a4c336c 100644 --- a/src/test/ui/async-await/issue-72590-type-error-sized.stderr +++ b/src/test/ui/async-await/issue-72590-type-error-sized.stderr @@ -18,7 +18,7 @@ LL | async fn frob(self) {} | = help: within `Foo`, the trait `Sized` is not implemented for `str` = note: required because it appears within the type `Foo` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | LL | async fn frob(&self) {} diff --git a/src/test/ui/closures/issue-41366.stderr b/src/test/ui/closures/issue-41366.stderr index 200d411b511..72ef5b3b962 100644 --- a/src/test/ui/closures/issue-41366.stderr +++ b/src/test/ui/closures/issue-41366.stderr @@ -16,7 +16,7 @@ LL | (&|_| ()) as &dyn for<'x> Fn(<u32 as T<'x>>::V); | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `<u32 as T<'_>>::V` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: consider further restricting the associated type | LL | fn main() where <u32 as T<'_>>::V: Sized { diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.rs b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.rs new file mode 100644 index 00000000000..5be4b41784c --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.rs @@ -0,0 +1,21 @@ +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] + + +const fn bar<T: ?Sized>() -> usize { 7 } + +trait Foo { + fn test(&self) -> [u8; bar::<Self>()]; +} + +impl Foo for () { + fn test(&self) -> [u8; bar::<Self>()] { + [0; bar::<Self>()] + } +} + +fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` cannot be made into an object + v.test(); +} + +fn main() {} diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.stderr b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.stderr new file mode 100644 index 00000000000..e0e6029252c --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.stderr @@ -0,0 +1,18 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety-err-ret.rs:17:15 + | +LL | fn use_dyn(v: &dyn Foo) { + | ^^^^^^^^ `Foo` cannot be made into an object + | + = help: consider moving `test` to another trait +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/object-safety-err-ret.rs:8:23 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn test(&self) -> [u8; bar::<Self>()]; + | ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.rs b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.rs new file mode 100644 index 00000000000..5fbd4a5fa2e --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.rs @@ -0,0 +1,22 @@ +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] +#![deny(where_clauses_object_safety)] + + +const fn bar<T: ?Sized>() -> usize { 7 } + +trait Foo { + fn test(&self) where [u8; bar::<Self>()]: Sized; + //~^ ERROR the trait `Foo` cannot be made into an object + //~| WARN this was previously accepted by the compiler but is being phased out +} + +impl Foo for () { + fn test(&self) where [u8; bar::<Self>()]: Sized {} +} + +fn use_dyn(v: &dyn Foo) { + v.test(); +} + +fn main() {} diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.stderr b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.stderr new file mode 100644 index 00000000000..45c7d835f33 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.stderr @@ -0,0 +1,24 @@ +error: the trait `Foo` cannot be made into an object + --> $DIR/object-safety-err-where-bounds.rs:9:8 + | +LL | fn test(&self) where [u8; bar::<Self>()]: Sized; + | ^^^^ + | +note: the lint level is defined here + --> $DIR/object-safety-err-where-bounds.rs:3:9 + | +LL | #![deny(where_clauses_object_safety)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #51443 <https://github.com/rust-lang/rust/issues/51443> +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/object-safety-err-where-bounds.rs:9:8 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn test(&self) where [u8; bar::<Self>()]: Sized; + | ^^^^ ...because method `test` references the `Self` type in its `where` clause + = help: consider moving `test` to another trait + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.rs b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.rs new file mode 100644 index 00000000000..9a95908d59d --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.rs @@ -0,0 +1,22 @@ +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] + +trait Foo<const N: usize> { + fn test(&self) -> [u8; N + 1]; +} + +impl<const N: usize> Foo<N> for () { + fn test(&self) -> [u8; N + 1] { + [0; N + 1] + } +} + +fn use_dyn<const N: usize>(v: &dyn Foo<N>) where [u8; N + 1]: Sized { + assert_eq!(v.test(), [0; N + 1]); +} + +fn main() { + // FIXME(const_evaluatable_checked): Improve the error message here. + use_dyn(&()); + //~^ ERROR type annotations needed +} diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.stderr b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.stderr new file mode 100644 index 00000000000..dd2c11e42c5 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.stderr @@ -0,0 +1,12 @@ +error[E0284]: type annotations needed: cannot satisfy `the constant `use_dyn::<{_: usize}>::{constant#0}` can be evaluated` + --> $DIR/object-safety-ok-infer-err.rs:20:5 + | +LL | fn use_dyn<const N: usize>(v: &dyn Foo<N>) where [u8; N + 1]: Sized { + | ----- required by this bound in `use_dyn` +... +LL | use_dyn(&()); + | ^^^^^^^ cannot satisfy `the constant `use_dyn::<{_: usize}>::{constant#0}` can be evaluated` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0284`. diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok.rs b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok.rs new file mode 100644 index 00000000000..ae78b7936a2 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok.rs @@ -0,0 +1,21 @@ +// run-pass +#![feature(const_generics, const_evaluatable_checked)] +#![allow(incomplete_features)] + +trait Foo<const N: usize> { + fn test(&self) -> [u8; N + 1]; +} + +impl<const N: usize> Foo<N> for () { + fn test(&self) -> [u8; N + 1] { + [0; N + 1] + } +} + +fn use_dyn<const N: usize>(v: &dyn Foo<N>) where [u8; N + 1]: Sized { + assert_eq!(v.test(), [0; N + 1]); +} + +fn main() { + use_dyn::<3>(&()); +} diff --git a/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs b/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs new file mode 100644 index 00000000000..3370666cc5c --- /dev/null +++ b/src/test/ui/const-generics/min_const_generics/const_fn_in_generics.rs @@ -0,0 +1,17 @@ +// run-pass + +#![feature(min_const_generics)] + +const fn identity<const T: u32>() -> u32 { T } + +#[derive(Eq, PartialEq, Debug)] +pub struct ConstU32<const U: u32>; + +pub fn new() -> ConstU32<{ identity::<3>() }> { + ConstU32::<{ identity::<3>() }> +} + +fn main() { + let v = new(); + assert_eq!(v, ConstU32::<3>); +} diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_err.rs b/src/test/ui/consts/miri_unleashed/mutable_references_err.rs index 06fb27bcff8..195414dbad9 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_err.rs +++ b/src/test/ui/consts/miri_unleashed/mutable_references_err.rs @@ -13,7 +13,7 @@ unsafe impl Sync for Meh {} // the following will never be ok! no interior mut behind consts, because // all allocs interned here will be marked immutable. -const MUH: Meh = Meh { //~ ERROR: mutable memory (`UnsafeCell`) is not allowed in constant +const MUH: Meh = Meh { //~ ERROR: it is undefined behavior to use this value x: &UnsafeCell::new(42), }; @@ -24,11 +24,11 @@ unsafe impl Sync for Synced {} // Make sure we also catch this behind a type-erased `dyn Trait` reference. const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; -//~^ ERROR: mutable memory (`UnsafeCell`) is not allowed in constant +//~^ ERROR: it is undefined behavior to use this value // Make sure we also catch mutable references. const BLUNT: &mut i32 = &mut 42; -//~^ ERROR: mutable memory (`&mut`) is not allowed in constant +//~^ ERROR: it is undefined behavior to use this value fn main() { unsafe { diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_err.stderr b/src/test/ui/consts/miri_unleashed/mutable_references_err.stderr index 7647a9ff4f6..0c206dd51aa 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_err.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references_err.stderr @@ -1,22 +1,28 @@ -error: mutable memory (`UnsafeCell`) is not allowed in constant +error[E0080]: it is undefined behavior to use this value --> $DIR/mutable_references_err.rs:16:1 | LL | / const MUH: Meh = Meh { LL | | x: &UnsafeCell::new(42), LL | | }; - | |__^ + | |__^ type validation failed: encountered `UnsafeCell` in a `const` at .x.<deref> + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. -error: mutable memory (`UnsafeCell`) is not allowed in constant +error[E0080]: it is undefined behavior to use this value --> $DIR/mutable_references_err.rs:26:1 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered `UnsafeCell` in a `const` at .<deref>.<dyn-downcast>.x + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. -error: mutable memory (`&mut`) is not allowed in constant +error[E0080]: it is undefined behavior to use this value --> $DIR/mutable_references_err.rs:30:1 | LL | const BLUNT: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered mutable reference in a `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. warning: skipping const checks | @@ -38,3 +44,4 @@ LL | const BLUNT: &mut i32 = &mut 42; error: aborting due to 3 previous errors; 1 warning emitted +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/error-codes/E0161.rs b/src/test/ui/error-codes/E0161.rs index 58217ff74b8..e0f5776424e 100644 --- a/src/test/ui/error-codes/E0161.rs +++ b/src/test/ui/error-codes/E0161.rs @@ -9,13 +9,13 @@ //[zflagsul]compile-flags: -Z borrowck=migrate //[editionul]edition:2018 +#![allow(incomplete_features)] #![cfg_attr(nll, feature(nll))] #![cfg_attr(nllul, feature(nll))] #![cfg_attr(migrateul, feature(unsized_locals))] #![cfg_attr(zflagsul, feature(unsized_locals))] #![cfg_attr(nllul, feature(unsized_locals))] #![cfg_attr(editionul, feature(unsized_locals))] - #![feature(box_syntax)] fn foo(x: Box<[i32]>) { diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index c2e15007cf9..647e0c7d76f 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -6,11 +6,11 @@ LL | fn f(p: Path) { } | = help: within `Path`, the trait `Sized` is not implemented for `[u8]` = note: required because it appears within the type `Path` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn f(p: &Path) { } - | ^ +LL | fn f(&p: Path) { } + | ^ error[E0277]: the trait bound `i32: Foo` is not satisfied --> $DIR/E0277.rs:17:15 diff --git a/src/test/ui/feature-gates/feature-gate-unsized_fn_params.rs b/src/test/ui/feature-gates/feature-gate-unsized_fn_params.rs new file mode 100644 index 00000000000..9b868ed7a9e --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-unsized_fn_params.rs @@ -0,0 +1,26 @@ +#[repr(align(256))] +#[allow(dead_code)] +struct A { + v: u8, +} + +trait Foo { + fn foo(&self); +} + +impl Foo for A { + fn foo(&self) { + assert_eq!(self as *const A as usize % 256, 0); + } +} + +fn foo(x: dyn Foo) { + //~^ ERROR [E0277] + x.foo() +} + +fn main() { + let x: Box<dyn Foo> = Box::new(A { v: 22 }); + foo(*x); + //~^ ERROR [E0277] +} diff --git a/src/test/ui/feature-gates/feature-gate-unsized_fn_params.stderr b/src/test/ui/feature-gates/feature-gate-unsized_fn_params.stderr new file mode 100644 index 00000000000..71acbb174ac --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-unsized_fn_params.stderr @@ -0,0 +1,26 @@ +error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:17:8 + | +LL | fn foo(x: dyn Foo) { + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Foo + 'static)` + = help: unsized fn params are gated as an unstable feature +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn foo(&x: dyn Foo) { + | ^ + +error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:24:5 + | +LL | foo(*x); + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Foo + 'static)` + = note: all function arguments must have a statically known size + = help: unsized fn params are gated as an unstable feature + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr index 29595c92376..52254220872 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr @@ -5,11 +5,11 @@ LL | fn f(f: dyn FnOnce()) {} | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn FnOnce() + 'static)` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn f(f: &dyn FnOnce()) {} - | ^ +LL | fn f(&f: dyn FnOnce()) {} + | ^ error: aborting due to previous error diff --git a/src/test/ui/fn/dyn-fn-alignment.rs b/src/test/ui/fn/dyn-fn-alignment.rs index 125f44bbf00..cedfd1cf2dc 100644 --- a/src/test/ui/fn/dyn-fn-alignment.rs +++ b/src/test/ui/fn/dyn-fn-alignment.rs @@ -1,6 +1,5 @@ // run-pass -#![feature(unsized_locals)] #![allow(dead_code)] #[repr(align(256))] struct A { diff --git a/src/test/ui/issues/issue-17651.stderr b/src/test/ui/issues/issue-17651.stderr index 987f4e97f36..69817f10c9f 100644 --- a/src/test/ui/issues/issue-17651.stderr +++ b/src/test/ui/issues/issue-17651.stderr @@ -15,7 +15,7 @@ LL | (|| Box::new(*(&[0][..])))(); | = help: the trait `Sized` is not implemented for `[{integer}]` = note: all function arguments must have a statically known size - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-27078.stderr b/src/test/ui/issues/issue-27078.stderr index 006389f7537..021a08696de 100644 --- a/src/test/ui/issues/issue-27078.stderr +++ b/src/test/ui/issues/issue-27078.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation LL | fn foo(self) -> &'static i32 { | ^^^^ doesn't have a size known at compile-time | - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: consider further restricting `Self` | LL | fn foo(self) -> &'static i32 where Self: Sized { diff --git a/src/test/ui/issues/issue-30355.stderr b/src/test/ui/issues/issue-30355.stderr index db7a5a7f6dc..79f5db650d9 100644 --- a/src/test/ui/issues/issue-30355.stderr +++ b/src/test/ui/issues/issue-30355.stderr @@ -6,7 +6,7 @@ LL | &X(*Y) | = help: the trait `Sized` is not implemented for `[u8]` = note: all function arguments must have a statically known size - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/issues/issue-38412.rs b/src/test/ui/issues/issue-38412.rs index 058e1be7565..96bd93af514 100644 --- a/src/test/ui/issues/issue-38412.rs +++ b/src/test/ui/issues/issue-38412.rs @@ -1,6 +1,6 @@ fn main() { let Box(a) = loop { }; - //~^ ERROR expected tuple struct or tuple variant, found struct `Box` + //~^ ERROR cannot match against a tuple struct which contains private fields // (The below is a trick to allow compiler to infer a type for // variable `a` without attempting to ascribe a type to the diff --git a/src/test/ui/issues/issue-38412.stderr b/src/test/ui/issues/issue-38412.stderr index 318c92ad35f..610696f84d5 100644 --- a/src/test/ui/issues/issue-38412.stderr +++ b/src/test/ui/issues/issue-38412.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct or tuple variant, found struct `Box` +error[E0532]: cannot match against a tuple struct which contains private fields --> $DIR/issue-38412.rs:2:9 | LL | let Box(a) = loop { }; diff --git a/src/test/ui/issues/issue-38954.stderr b/src/test/ui/issues/issue-38954.stderr index bc40fd07c5a..f76063fc558 100644 --- a/src/test/ui/issues/issue-38954.stderr +++ b/src/test/ui/issues/issue-38954.stderr @@ -5,7 +5,7 @@ LL | fn _test(ref _p: str) {} | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | LL | fn _test(ref _p: &str) {} diff --git a/src/test/ui/issues/issue-39616.rs b/src/test/ui/issues/issue-39616.rs index 428856a36b4..46b5aa334ca 100644 --- a/src/test/ui/issues/issue-39616.rs +++ b/src/test/ui/issues/issue-39616.rs @@ -1,4 +1,3 @@ fn foo(a: [0; 1]) {} //~ ERROR expected type, found `0` -//~| ERROR expected `;` or `{`, found `]` fn main() {} diff --git a/src/test/ui/issues/issue-39616.stderr b/src/test/ui/issues/issue-39616.stderr index ced58274661..393d1f2e2ce 100644 --- a/src/test/ui/issues/issue-39616.stderr +++ b/src/test/ui/issues/issue-39616.stderr @@ -4,11 +4,5 @@ error: expected type, found `0` LL | fn foo(a: [0; 1]) {} | ^ expected type -error: expected `;` or `{`, found `]` - --> $DIR/issue-39616.rs:1:16 - | -LL | fn foo(a: [0; 1]) {} - | ^ expected `;` or `{` - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/issues/issue-41229-ref-str.stderr b/src/test/ui/issues/issue-41229-ref-str.stderr index c5c848e63e6..8b37e5e9774 100644 --- a/src/test/ui/issues/issue-41229-ref-str.stderr +++ b/src/test/ui/issues/issue-41229-ref-str.stderr @@ -5,7 +5,7 @@ LL | pub fn example(ref s: str) {} | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | LL | pub fn example(ref s: &str) {} diff --git a/src/test/ui/issues/issue-42312.stderr b/src/test/ui/issues/issue-42312.stderr index b55a724c0db..f69c2a9925d 100644 --- a/src/test/ui/issues/issue-42312.stderr +++ b/src/test/ui/issues/issue-42312.stderr @@ -5,7 +5,7 @@ LL | fn baz(_: Self::Target) where Self: Deref {} | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `<Self as Deref>::Target` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: consider further restricting the associated type | LL | fn baz(_: Self::Target) where Self: Deref, <Self as Deref>::Target: Sized {} @@ -22,7 +22,7 @@ LL | pub fn f(_: dyn ToString) {} | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn ToString + 'static)` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | LL | pub fn f(_: &dyn ToString) {} diff --git a/src/test/ui/issues/issue-42944.rs b/src/test/ui/issues/issue-42944.rs index a088f91554d..a4404857a56 100644 --- a/src/test/ui/issues/issue-42944.rs +++ b/src/test/ui/issues/issue-42944.rs @@ -7,7 +7,7 @@ mod bar { fn foo() { Bx(()); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `Bx` [E0423] + //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423] } } diff --git a/src/test/ui/issues/issue-42944.stderr b/src/test/ui/issues/issue-42944.stderr index 9fad43757ba..008492529d1 100644 --- a/src/test/ui/issues/issue-42944.stderr +++ b/src/test/ui/issues/issue-42944.stderr @@ -1,8 +1,14 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `Bx` +error[E0423]: cannot initialize a tuple struct which contains private fields --> $DIR/issue-42944.rs:9:9 | LL | Bx(()); - | ^^ constructor is not visible here due to private fields + | ^^ + | +note: constructor is not visible here due to private fields + --> $DIR/issue-42944.rs:2:19 + | +LL | pub struct Bx(()); + | ^^ private field error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this scope --> $DIR/issue-42944.rs:16:9 diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index 8d639304ab6..5798733e04b 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -5,11 +5,11 @@ LL | fn new_struct(r: dyn A + 'static) | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn A + 'static)` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn new_struct(r: &dyn A + 'static) - | ^ +LL | fn new_struct(&r: dyn A + 'static) + | ^ error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time --> $DIR/issue-5883.rs:8:8 diff --git a/src/test/ui/issues/issue-58856-1.rs b/src/test/ui/issues/issue-58856-1.rs index 8b1a39a94e6..332a3014416 100644 --- a/src/test/ui/issues/issue-58856-1.rs +++ b/src/test/ui/issues/issue-58856-1.rs @@ -2,7 +2,7 @@ impl A { //~^ ERROR cannot find type `A` in this scope fn b(self> //~^ ERROR expected one of `)`, `,`, or `:`, found `>` - //~| ERROR expected `;` or `{`, found `>` + //~| ERROR expected one of `->`, `;`, `where`, or `{`, found `>` } fn main() {} diff --git a/src/test/ui/issues/issue-58856-1.stderr b/src/test/ui/issues/issue-58856-1.stderr index a8db8e8b41a..f1abb40ed7a 100644 --- a/src/test/ui/issues/issue-58856-1.stderr +++ b/src/test/ui/issues/issue-58856-1.stderr @@ -6,14 +6,14 @@ LL | fn b(self> | | | unclosed delimiter -error: expected `;` or `{`, found `>` +error: expected one of `->`, `;`, `where`, or `{`, found `>` --> $DIR/issue-58856-1.rs:3:14 | LL | impl A { | - while parsing this item list starting here LL | LL | fn b(self> - | ^ expected `;` or `{` + | ^ expected one of `->`, `;`, `where`, or `{` ... LL | } | - the item list ends here diff --git a/src/test/ui/issues/issue-75906.rs b/src/test/ui/issues/issue-75906.rs new file mode 100644 index 00000000000..710039d79e7 --- /dev/null +++ b/src/test/ui/issues/issue-75906.rs @@ -0,0 +1,13 @@ +mod m { + pub struct Foo { x: u8 } + + pub struct Bar(u8); +} + +use m::{Foo, Bar}; + +fn main() { + let x = Foo { x: 12 }; + let y = Bar(12); + //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423] +} diff --git a/src/test/ui/issues/issue-75906.stderr b/src/test/ui/issues/issue-75906.stderr new file mode 100644 index 00000000000..4c6a68646ad --- /dev/null +++ b/src/test/ui/issues/issue-75906.stderr @@ -0,0 +1,15 @@ +error[E0423]: cannot initialize a tuple struct which contains private fields + --> $DIR/issue-75906.rs:11:13 + | +LL | let y = Bar(12); + | ^^^ + | +note: constructor is not visible here due to private fields + --> $DIR/issue-75906.rs:4:20 + | +LL | pub struct Bar(u8); + | ^^ private field + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0423`. diff --git a/src/test/ui/issues/issue-75907.rs b/src/test/ui/issues/issue-75907.rs index 8c155d9be35..1534b6d07de 100644 --- a/src/test/ui/issues/issue-75907.rs +++ b/src/test/ui/issues/issue-75907.rs @@ -13,6 +13,6 @@ use foo::{make_bar, Bar, Foo}; fn main() { let Bar(x, y, Foo(z)) = make_bar(); - //~^ ERROR expected tuple struct - //~| ERROR expected tuple struct + //~^ ERROR cannot match against a tuple struct which contains private fields + //~| ERROR cannot match against a tuple struct which contains private fields } diff --git a/src/test/ui/issues/issue-75907.stderr b/src/test/ui/issues/issue-75907.stderr index 65b9a51e01d..2f89e31a31a 100644 --- a/src/test/ui/issues/issue-75907.stderr +++ b/src/test/ui/issues/issue-75907.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct or tuple variant, found struct `Bar` +error[E0532]: cannot match against a tuple struct which contains private fields --> $DIR/issue-75907.rs:15:9 | LL | let Bar(x, y, Foo(z)) = make_bar(); @@ -12,7 +12,7 @@ LL | let Bar(x, y, Foo(z)) = make_bar(); | | | private field -error[E0532]: expected tuple struct or tuple variant, found struct `Foo` +error[E0532]: cannot match against a tuple struct which contains private fields --> $DIR/issue-75907.rs:15:19 | LL | let Bar(x, y, Foo(z)) = make_bar(); diff --git a/src/test/ui/issues/issue-75907_b.rs b/src/test/ui/issues/issue-75907_b.rs index fdd3bc6d724..a775845279e 100644 --- a/src/test/ui/issues/issue-75907_b.rs +++ b/src/test/ui/issues/issue-75907_b.rs @@ -7,5 +7,5 @@ use a::{make_bar, Bar}; fn main() { let Bar(x, y, z) = make_bar(); - //~^ ERROR expected tuple struct + //~^ ERROR cannot match against a tuple struct which contains private fields } diff --git a/src/test/ui/issues/issue-75907_b.stderr b/src/test/ui/issues/issue-75907_b.stderr index cdd21de6c33..8884484e18d 100644 --- a/src/test/ui/issues/issue-75907_b.stderr +++ b/src/test/ui/issues/issue-75907_b.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct or tuple variant, found struct `Bar` +error[E0532]: cannot match against a tuple struct which contains private fields --> $DIR/issue-75907_b.rs:9:9 | LL | let Bar(x, y, z) = make_bar(); diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs index 5ceba646784..9e53ff07917 100644 --- a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs +++ b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs @@ -1,4 +1,6 @@ -#![feature(arbitrary_self_types, coerce_unsized, dispatch_from_dyn, unsize, unsized_locals)] +#![feature(arbitrary_self_types, coerce_unsized, dispatch_from_dyn, unsize)] +#![feature(unsized_locals, unsized_fn_params)] +//~^ WARN the feature `unsized_locals` is incomplete // 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/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr index 08be7ee155e..0a516c89a8b 100644 --- a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr +++ b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr @@ -1,5 +1,14 @@ +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:2:12 + | +LL | #![feature(unsized_locals, unsized_fn_params)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:85:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:87:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` @@ -7,7 +16,7 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:102:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:104:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u64` @@ -15,23 +24,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:120:15 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:122:15 | LL | let z = x.foo(); | ^^^ multiple `foo` found | note: candidate #1 is defined in an impl of the trait `X` for the type `T` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:43:9 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:45:9 | LL | fn foo(self: Smaht<Self, u64>) -> u64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:70:9 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:72:9 | LL | fn foo(self) {} | ^^^^^^^^^^^^ note: candidate #3 is defined in the trait `FinalFoo` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:57:5 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:59:5 | LL | fn foo(&self) -> u8; | ^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +58,7 @@ LL | let z = FinalFoo::foo(x); | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:137:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:139:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u8` @@ -57,7 +66,7 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:155:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:157:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` @@ -65,14 +74,14 @@ LL | let _seetype: () = z; | expected due to this error[E0308]: mismatched types - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:172:24 + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:174:24 | LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` | | | expected due to this -error: aborting due to 6 previous errors +error: aborting due to 6 previous errors; 1 warning emitted Some errors have detailed explanations: E0034, E0308. For more information about an error, try `rustc --explain E0034`. diff --git a/src/test/ui/moves/move-out-of-slice-2.rs b/src/test/ui/moves/move-out-of-slice-2.rs index 5c1a61eb375..59c02d42bf1 100644 --- a/src/test/ui/moves/move-out-of-slice-2.rs +++ b/src/test/ui/moves/move-out-of-slice-2.rs @@ -1,4 +1,5 @@ #![feature(unsized_locals)] +//~^ WARN the feature `unsized_locals` is incomplete struct A; #[derive(Clone, Copy)] @@ -8,13 +9,13 @@ fn main() { let a: Box<[A]> = Box::new([A]); match *a { //~^ ERROR cannot move out of type `[A]`, a non-copy slice - [a @ ..] => {}, + [a @ ..] => {} _ => {} } let b: Box<[A]> = Box::new([A, A, A]); match *b { //~^ ERROR cannot move out of type `[A]`, a non-copy slice - [_, _, b @ .., _] => {}, + [_, _, b @ .., _] => {} _ => {} } @@ -22,13 +23,13 @@ fn main() { let c: Box<[C]> = Box::new([C]); match *c { //~^ ERROR cannot move out of type `[C]`, a non-copy slice - [c @ ..] => {}, + [c @ ..] => {} _ => {} } let d: Box<[C]> = Box::new([C, C, C]); match *d { //~^ ERROR cannot move out of type `[C]`, a non-copy slice - [_, _, d @ .., _] => {}, + [_, _, d @ .., _] => {} _ => {} } } diff --git a/src/test/ui/moves/move-out-of-slice-2.stderr b/src/test/ui/moves/move-out-of-slice-2.stderr index 058f34b24a3..9a863bf31a7 100644 --- a/src/test/ui/moves/move-out-of-slice-2.stderr +++ b/src/test/ui/moves/move-out-of-slice-2.stderr @@ -1,51 +1,60 @@ +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 + | +LL | #![feature(unsized_locals)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:9:11 + --> $DIR/move-out-of-slice-2.rs:10:11 | LL | match *a { | ^^ cannot move out of here LL | -LL | [a @ ..] => {}, +LL | [a @ ..] => {} | ------ | | | data moved here | move occurs because `a` has type `[A]`, which does not implement the `Copy` trait error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:15:11 + --> $DIR/move-out-of-slice-2.rs:16:11 | LL | match *b { | ^^ cannot move out of here LL | -LL | [_, _, b @ .., _] => {}, +LL | [_, _, b @ .., _] => {} | ------ | | | data moved here | move occurs because `b` has type `[A]`, which does not implement the `Copy` trait error[E0508]: cannot move out of type `[C]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:23:11 + --> $DIR/move-out-of-slice-2.rs:24:11 | LL | match *c { | ^^ cannot move out of here LL | -LL | [c @ ..] => {}, +LL | [c @ ..] => {} | ------ | | | data moved here | move occurs because `c` has type `[C]`, which does not implement the `Copy` trait error[E0508]: cannot move out of type `[C]`, a non-copy slice - --> $DIR/move-out-of-slice-2.rs:29:11 + --> $DIR/move-out-of-slice-2.rs:30:11 | LL | match *d { | ^^ cannot move out of here LL | -LL | [_, _, d @ .., _] => {}, +LL | [_, _, d @ .., _] => {} | ------ | | | data moved here | move occurs because `d` has type `[C]`, which does not implement the `Copy` trait -error: aborting due to 4 previous errors +error: aborting due to 4 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/parser/fn-colon-return-type.rs b/src/test/ui/parser/fn-colon-return-type.rs new file mode 100644 index 00000000000..c791fb3ae67 --- /dev/null +++ b/src/test/ui/parser/fn-colon-return-type.rs @@ -0,0 +1,5 @@ +fn foo(x: i32): i32 { //~ ERROR expected one of `->`, `;`, `where`, or `{`, found `:` + x +} + +fn main() {} diff --git a/src/test/ui/parser/fn-colon-return-type.stderr b/src/test/ui/parser/fn-colon-return-type.stderr new file mode 100644 index 00000000000..92df9bc60bd --- /dev/null +++ b/src/test/ui/parser/fn-colon-return-type.stderr @@ -0,0 +1,8 @@ +error: expected one of `->`, `;`, `where`, or `{`, found `:` + --> $DIR/fn-colon-return-type.rs:1:15 + | +LL | fn foo(x: i32): i32 { + | ^ expected one of `->`, `;`, `where`, or `{` + +error: aborting due to previous error + diff --git a/src/test/ui/parser/issue-24780.rs b/src/test/ui/parser/issue-24780.rs index 8b46aa2bf22..20665b549d2 100644 --- a/src/test/ui/parser/issue-24780.rs +++ b/src/test/ui/parser/issue-24780.rs @@ -1,8 +1,9 @@ // Verify that '>' is not both expected and found at the same time, as it used // to happen in #24780. For example, following should be an error: -// expected one of ..., `>`, ... found `>` +// expected one of ..., `>`, ... found `>`. No longer exactly this, but keeping for posterity. -fn foo() -> Vec<usize>> { - //~^ ERROR expected `;` or `{`, found `>` +fn foo() -> Vec<usize>> { //~ ERROR unmatched angle bracket Vec::new() } + +fn main() {} diff --git a/src/test/ui/parser/issue-24780.stderr b/src/test/ui/parser/issue-24780.stderr index d65a5f44873..d12b13d35f8 100644 --- a/src/test/ui/parser/issue-24780.stderr +++ b/src/test/ui/parser/issue-24780.stderr @@ -1,8 +1,8 @@ -error: expected `;` or `{`, found `>` +error: unmatched angle bracket --> $DIR/issue-24780.rs:5:23 | LL | fn foo() -> Vec<usize>> { - | ^ expected `;` or `{` + | ^^ help: remove extra angle bracket error: aborting due to previous error diff --git a/src/test/ui/parser/issue-6610.rs b/src/test/ui/parser/issue-6610.rs index 2dfa08fe82d..9ed5a61220b 100644 --- a/src/test/ui/parser/issue-6610.rs +++ b/src/test/ui/parser/issue-6610.rs @@ -1,3 +1,3 @@ -trait Foo { fn a() } //~ ERROR expected `;` or `{`, found `}` +trait Foo { fn a() } //~ ERROR expected one of `->`, `;`, `where`, or `{`, found `}` fn main() {} diff --git a/src/test/ui/parser/issue-6610.stderr b/src/test/ui/parser/issue-6610.stderr index a9804208946..4a3bc752553 100644 --- a/src/test/ui/parser/issue-6610.stderr +++ b/src/test/ui/parser/issue-6610.stderr @@ -1,12 +1,10 @@ -error: expected `;` or `{`, found `}` +error: expected one of `->`, `;`, `where`, or `{`, found `}` --> $DIR/issue-6610.rs:1:20 | LL | trait Foo { fn a() } - | - ^ - | | | - | | expected `;` or `{` - | | the item list ends here - | while parsing this item list starting here + | - ^ expected one of `->`, `;`, `where`, or `{` + | | + | while parsing this `fn` error: aborting due to previous error diff --git a/src/test/ui/parser/missing_right_paren.stderr b/src/test/ui/parser/missing_right_paren.stderr index c1ceb81a07c..22e1c2f97e7 100644 --- a/src/test/ui/parser/missing_right_paren.stderr +++ b/src/test/ui/parser/missing_right_paren.stderr @@ -22,11 +22,11 @@ error: expected one of `:` or `|`, found `)` LL | fn main((ؼ | ^ expected one of `:` or `|` -error: expected `;` or `{`, found `<eof>` +error: expected one of `->`, `;`, `where`, or `{`, found `<eof>` --> $DIR/missing_right_paren.rs:3:11 | LL | fn main((ؼ - | ^ expected `;` or `{` + | ^ expected one of `->`, `;`, `where`, or `{` error: aborting due to 4 previous errors diff --git a/src/test/ui/parser/not-a-pred.rs b/src/test/ui/parser/not-a-pred.rs index e6a02d5fc56..1b3d9bf66bb 100644 --- a/src/test/ui/parser/not-a-pred.rs +++ b/src/test/ui/parser/not-a-pred.rs @@ -1,6 +1,5 @@ -// error-pattern: lt - fn f(a: isize, b: isize) : lt(a, b) { } +//~^ ERROR expected one of `->`, `;`, `where`, or `{`, found `:` fn lt(a: isize, b: isize) { } diff --git a/src/test/ui/parser/not-a-pred.stderr b/src/test/ui/parser/not-a-pred.stderr index dce54655fa0..ec413c5594c 100644 --- a/src/test/ui/parser/not-a-pred.stderr +++ b/src/test/ui/parser/not-a-pred.stderr @@ -1,8 +1,8 @@ -error: expected `;` or `{`, found `:` - --> $DIR/not-a-pred.rs:3:26 +error: expected one of `->`, `;`, `where`, or `{`, found `:` + --> $DIR/not-a-pred.rs:1:26 | LL | fn f(a: isize, b: isize) : lt(a, b) { } - | ^ expected `;` or `{` + | ^ expected one of `->`, `;`, `where`, or `{` error: aborting due to previous error diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index 5078ffbec73..b2084a7a426 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -5,11 +5,11 @@ LL | fn foo(_x: K) {} | ^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn I + 'static)` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn foo(_x: &K) {} - | ^ +LL | fn foo(&_x: K) {} + | ^ error: aborting due to previous error diff --git a/src/test/ui/rfc-2008-non-exhaustive/struct.rs b/src/test/ui/rfc-2008-non-exhaustive/struct.rs index 8cff35c4bc5..07e093c152d 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/struct.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/struct.rs @@ -18,7 +18,7 @@ fn main() { //~^ ERROR `..` required with struct marked as non-exhaustive let ts = TupleStruct(640, 480); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `TupleStruct` [E0423] + //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423] let ts_explicit = structs::TupleStruct(640, 480); //~^ ERROR tuple struct constructor `TupleStruct` is private [E0603] diff --git a/src/test/ui/rfc-2008-non-exhaustive/struct.stderr b/src/test/ui/rfc-2008-non-exhaustive/struct.stderr index 3bc38830537..e2ee8d6a6fe 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/struct.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/struct.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `TupleStruct` +error[E0423]: cannot initialize a tuple struct which contains private fields --> $DIR/struct.rs:20:14 | LL | let ts = TupleStruct(640, 480); diff --git a/src/test/ui/suggestions/path-by-value.stderr b/src/test/ui/suggestions/path-by-value.stderr index ea0c63ac257..19fc3406ccf 100644 --- a/src/test/ui/suggestions/path-by-value.stderr +++ b/src/test/ui/suggestions/path-by-value.stderr @@ -6,11 +6,11 @@ LL | fn f(p: Path) { } | = help: within `Path`, the trait `Sized` is not implemented for `[u8]` = note: required because it appears within the type `Path` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn f(p: &Path) { } - | ^ +LL | fn f(&p: Path) { } + | ^ error: aborting due to previous error diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr index b403fb4184d..48eedc0b0ea 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr @@ -13,11 +13,11 @@ LL | fn foo(_x: Foo + Send) { | ^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Foo + Send + 'static)` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn foo(_x: &Foo + Send) { - | ^ +LL | fn foo(&_x: Foo + Send) { + | ^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/unboxed-closures/issue-53448.stderr b/src/test/ui/unboxed-closures/issue-53448.stderr index bece9eedc7f..29273a5babe 100644 --- a/src/test/ui/unboxed-closures/issue-53448.stderr +++ b/src/test/ui/unboxed-closures/issue-53448.stderr @@ -5,7 +5,7 @@ LL | let f: &mut dyn FnMut<(_,), Output = ()> = &mut |_: <() as Lt<'_>>::T| | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `<() as Lt<'_>>::T` - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: consider further restricting the associated type | LL | fn main() where <() as Lt<'_>>::T: Sized { diff --git a/src/test/ui/unsized-locals/autoderef.rs b/src/test/ui/unsized-locals/autoderef.rs index 7f2d2f9c7ef..5dd5898c12e 100644 --- a/src/test/ui/unsized-locals/autoderef.rs +++ b/src/test/ui/unsized-locals/autoderef.rs @@ -1,6 +1,7 @@ // run-pass -#![feature(unsized_locals)] +#![allow(incomplete_features)] +#![feature(unsized_locals, unsized_fn_params)] pub trait Foo { fn foo(self) -> String; @@ -24,7 +25,6 @@ impl Foo for dyn FnMut() -> String { } } - fn main() { let x = *(Box::new(['h', 'e', 'l', 'l', 'o']) as Box<[char]>); assert_eq!(&x.foo() as &str, "hello"); diff --git a/src/test/ui/unsized-locals/auxiliary/ufuncs.rs b/src/test/ui/unsized-locals/auxiliary/ufuncs.rs index 065563d45a4..5954abf3a1f 100644 --- a/src/test/ui/unsized-locals/auxiliary/ufuncs.rs +++ b/src/test/ui/unsized-locals/auxiliary/ufuncs.rs @@ -1,3 +1,3 @@ -#![feature(unsized_locals)] +#![feature(unsized_locals, unsized_fn_params)] pub fn udrop<T: ?Sized>(_x: T) {} diff --git a/src/test/ui/unsized-locals/borrow-after-move.rs b/src/test/ui/unsized-locals/borrow-after-move.rs index 3299fdf3a9c..ad73b720fa3 100644 --- a/src/test/ui/unsized-locals/borrow-after-move.rs +++ b/src/test/ui/unsized-locals/borrow-after-move.rs @@ -1,4 +1,5 @@ -#![feature(unsized_locals)] +#![feature(unsized_locals, unsized_fn_params)] +//~^ WARN the feature `unsized_locals` is incomplete pub trait Foo { fn foo(self) -> String; diff --git a/src/test/ui/unsized-locals/borrow-after-move.stderr b/src/test/ui/unsized-locals/borrow-after-move.stderr index b49c32f5f80..5934276cc1d 100644 --- a/src/test/ui/unsized-locals/borrow-after-move.stderr +++ b/src/test/ui/unsized-locals/borrow-after-move.stderr @@ -1,5 +1,14 @@ +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: `#[warn(incomplete_features)]` on by default + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:20:24 + --> $DIR/borrow-after-move.rs:21:24 | LL | let y = *x; | -- value moved here @@ -10,7 +19,7 @@ LL | println!("{}", &x); = 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:22:24 + --> $DIR/borrow-after-move.rs:23:24 | LL | let y = *x; | - move occurs because `y` has type `str`, which does not implement the `Copy` trait @@ -21,7 +30,7 @@ LL | println!("{}", &y); | ^^ value borrowed here after move error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:30:24 + --> $DIR/borrow-after-move.rs:31:24 | LL | let y = *x; | -- value moved here @@ -32,7 +41,7 @@ LL | println!("{}", &x); = 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:32:24 + --> $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 @@ -43,13 +52,13 @@ LL | println!("{}", &y); | ^^ value borrowed here after move | note: this function consumes the receiver `self` by taking ownership of it, which moves `y` - --> $DIR/borrow-after-move.rs:4:12 + --> $DIR/borrow-after-move.rs:5:12 | LL | fn foo(self) -> String; | ^^^^ error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:39:24 + --> $DIR/borrow-after-move.rs:40:24 | LL | let x = "hello".to_owned().into_boxed_str(); | - move occurs because `x` has type `Box<str>`, which does not implement the `Copy` trait @@ -58,6 +67,6 @@ LL | x.foo(); LL | println!("{}", &x); | ^^ value borrowed here after move -error: aborting due to 5 previous errors +error: aborting due to 5 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/unsized-locals/by-value-trait-object-safety-rpass.rs b/src/test/ui/unsized-locals/by-value-trait-object-safety-rpass.rs index b07d1a571b2..b9881defac3 100644 --- a/src/test/ui/unsized-locals/by-value-trait-object-safety-rpass.rs +++ b/src/test/ui/unsized-locals/by-value-trait-object-safety-rpass.rs @@ -1,5 +1,6 @@ // run-pass +#![allow(incomplete_features)] #![feature(unsized_locals)] pub trait Foo { @@ -14,7 +15,6 @@ impl Foo for A { } } - fn main() { let x = *(Box::new(A) as Box<dyn Foo>); assert_eq!(x.foo(), format!("hello")); diff --git a/src/test/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs b/src/test/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs index 8b39a99da58..957991f853b 100644 --- a/src/test/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs +++ b/src/test/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs @@ -1,6 +1,7 @@ // run-pass -#![feature(unsized_locals)] +#![allow(incomplete_features)] +#![feature(unsized_locals, unsized_fn_params)] pub trait Foo { fn foo(self) -> String { @@ -12,7 +13,6 @@ struct A; impl Foo for A {} - fn main() { let x = *(Box::new(A) as Box<dyn Foo>); assert_eq!(x.foo(), format!("hello")); diff --git a/src/test/ui/unsized-locals/by-value-trait-object-safety.rs b/src/test/ui/unsized-locals/by-value-trait-object-safety.rs index 8b24328bd38..d0ba6944a1e 100644 --- a/src/test/ui/unsized-locals/by-value-trait-object-safety.rs +++ b/src/test/ui/unsized-locals/by-value-trait-object-safety.rs @@ -1,7 +1,10 @@ #![feature(unsized_locals)] +//~^ WARN the feature `unsized_locals` is incomplete pub trait Foo { - fn foo(self) -> String where Self: Sized; + fn foo(self) -> String + where + Self: Sized; } struct A; @@ -12,7 +15,6 @@ impl Foo for A { } } - fn main() { let x = *(Box::new(A) as Box<dyn Foo>); x.foo(); diff --git a/src/test/ui/unsized-locals/by-value-trait-object-safety.stderr b/src/test/ui/unsized-locals/by-value-trait-object-safety.stderr index 4cd2098eef2..59d91bc0cfd 100644 --- a/src/test/ui/unsized-locals/by-value-trait-object-safety.stderr +++ b/src/test/ui/unsized-locals/by-value-trait-object-safety.stderr @@ -1,11 +1,20 @@ +warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/by-value-trait-object-safety.rs:1:12 + | +LL | #![feature(unsized_locals)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + error: the `foo` method cannot be invoked on a trait object - --> $DIR/by-value-trait-object-safety.rs:18:7 + --> $DIR/by-value-trait-object-safety.rs:20:7 | -LL | fn foo(self) -> String where Self: Sized; - | ----- this has a `Sized` requirement +LL | Self: Sized; + | ----- this has a `Sized` requirement ... LL | x.foo(); | ^^^ -error: aborting due to previous error +error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/unsized-locals/double-move.rs b/src/test/ui/unsized-locals/double-move.rs index c3a50341bc9..9e46ef9be48 100644 --- a/src/test/ui/unsized-locals/double-move.rs +++ b/src/test/ui/unsized-locals/double-move.rs @@ -1,4 +1,5 @@ -#![feature(unsized_locals)] +#![feature(unsized_locals, unsized_fn_params)] +//~^ WARN the feature `unsized_locals` is incomplete pub trait Foo { fn foo(self) -> String; diff --git a/src/test/ui/unsized-locals/double-move.stderr b/src/test/ui/unsized-locals/double-move.stderr index 36fb32ae09c..b897dbbc9a3 100644 --- a/src/test/ui/unsized-locals/double-move.stderr +++ b/src/test/ui/unsized-locals/double-move.stderr @@ -1,5 +1,14 @@ +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 + | +LL | #![feature(unsized_locals, unsized_fn_params)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + error[E0382]: use of moved value: `y` - --> $DIR/double-move.rs:20:22 + --> $DIR/double-move.rs:21:22 | LL | let y = *x; | - move occurs because `y` has type `str`, which does not implement the `Copy` trait @@ -9,7 +18,7 @@ LL | drop_unsized(y); | ^ value used here after move error[E0382]: use of moved value: `x` - --> $DIR/double-move.rs:26:22 + --> $DIR/double-move.rs:27:22 | LL | let _y = *x; | -- value moved here @@ -19,7 +28,7 @@ LL | drop_unsized(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:32:18 + --> $DIR/double-move.rs:33:18 | LL | let x = "hello".to_owned().into_boxed_str(); | - move occurs because `x` has type `Box<str>`, which does not implement the `Copy` trait @@ -29,7 +38,7 @@ LL | let _y = *x; | ^^ value used here after move error[E0382]: use of moved value: `y` - --> $DIR/double-move.rs:39:9 + --> $DIR/double-move.rs:40:9 | LL | let y = *x; | - move occurs because `y` has type `str`, which does not implement the `Copy` trait @@ -39,13 +48,13 @@ LL | y.foo(); | ^ value used here after move | note: this function consumes the receiver `self` by taking ownership of it, which moves `y` - --> $DIR/double-move.rs:4:12 + --> $DIR/double-move.rs:5:12 | LL | fn foo(self) -> String; | ^^^^ error[E0382]: use of moved value: `x` - --> $DIR/double-move.rs:45:9 + --> $DIR/double-move.rs:46:9 | LL | let _y = *x; | -- value moved here @@ -55,7 +64,7 @@ LL | x.foo(); = 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:51:18 + --> $DIR/double-move.rs:52:18 | LL | let x = "hello".to_owned().into_boxed_str(); | - move occurs because `x` has type `Box<str>`, which does not implement the `Copy` trait @@ -64,6 +73,6 @@ LL | x.foo(); LL | let _y = *x; | ^^ value used here after move -error: aborting due to 6 previous errors +error: aborting due to 6 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/unsized-locals/issue-30276-feature-flagged.rs b/src/test/ui/unsized-locals/issue-30276-feature-flagged.rs index 4193210b8bd..635d34f8229 100644 --- a/src/test/ui/unsized-locals/issue-30276-feature-flagged.rs +++ b/src/test/ui/unsized-locals/issue-30276-feature-flagged.rs @@ -1,4 +1,5 @@ #![feature(unsized_locals)] +//~^ WARN the feature `unsized_locals` is incomplete struct Test([i32]); diff --git a/src/test/ui/unsized-locals/issue-30276-feature-flagged.stderr b/src/test/ui/unsized-locals/issue-30276-feature-flagged.stderr index 46e381611a1..0f0ff579377 100644 --- a/src/test/ui/unsized-locals/issue-30276-feature-flagged.stderr +++ b/src/test/ui/unsized-locals/issue-30276-feature-flagged.stderr @@ -1,13 +1,22 @@ +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: `#[warn(incomplete_features)]` on by default + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + error[E0277]: the size for values of type `[i32]` cannot be known at compilation time - --> $DIR/issue-30276-feature-flagged.rs:6:29 + --> $DIR/issue-30276-feature-flagged.rs:7:29 | LL | let _x: fn(_) -> Test = Test; | ^^^^ doesn't have a size known at compile-time | - = help: within `Test`, the trait `Sized` is not implemented for `[i32]` - = note: required because it appears within the type `Test` - = note: the return type of a function must have a statically known size + = help: the trait `Sized` is not implemented for `[i32]` + = note: all function arguments must have a statically known size + = help: unsized fn params are gated as an unstable feature -error: aborting due to previous error +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/unsized-locals/issue-30276.stderr b/src/test/ui/unsized-locals/issue-30276.stderr index e9258a61c32..8cccbd792da 100644 --- a/src/test/ui/unsized-locals/issue-30276.stderr +++ b/src/test/ui/unsized-locals/issue-30276.stderr @@ -6,7 +6,7 @@ LL | let _x: fn(_) -> Test = Test; | = help: the trait `Sized` is not implemented for `[i32]` = note: all function arguments must have a statically known size - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/unsized-locals/issue-50940-with-feature.rs b/src/test/ui/unsized-locals/issue-50940-with-feature.rs index 3e5d39ab311..63b0e830be4 100644 --- a/src/test/ui/unsized-locals/issue-50940-with-feature.rs +++ b/src/test/ui/unsized-locals/issue-50940-with-feature.rs @@ -1,4 +1,5 @@ -#![feature(unsized_locals)] +#![feature(unsized_locals, unsized_fn_params)] +//~^ WARN the feature `unsized_locals` is incomplete fn main() { struct A<X: ?Sized>(X); diff --git a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr index dc20b92b423..1b1a584a01f 100644 --- a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr +++ b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr @@ -1,5 +1,14 @@ +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: `#[warn(incomplete_features)]` on by default + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/issue-50940-with-feature.rs:5:5 + --> $DIR/issue-50940-with-feature.rs:6:5 | LL | A as fn(str) -> A<str>; | ^ doesn't have a size known at compile-time @@ -8,6 +17,6 @@ LL | A as fn(str) -> A<str>; = note: required because it appears within the type `A<str>` = note: the return type of a function must have a statically known size -error: aborting due to previous error +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/unsized-locals/issue-50940.stderr b/src/test/ui/unsized-locals/issue-50940.stderr index c602fae883c..8f09b460e00 100644 --- a/src/test/ui/unsized-locals/issue-50940.stderr +++ b/src/test/ui/unsized-locals/issue-50940.stderr @@ -6,7 +6,7 @@ LL | A as fn(str) -> A<str>; | = help: the trait `Sized` is not implemented for `str` = note: all function arguments must have a statically known size - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/unsized-locals/reference-unsized-locals.rs b/src/test/ui/unsized-locals/reference-unsized-locals.rs index 1560d25d4b0..4e887f32753 100644 --- a/src/test/ui/unsized-locals/reference-unsized-locals.rs +++ b/src/test/ui/unsized-locals/reference-unsized-locals.rs @@ -1,5 +1,6 @@ // run-pass +#![allow(incomplete_features)] #![feature(unsized_locals)] fn main() { diff --git a/src/test/ui/unsized-locals/simple-unsized-locals.rs b/src/test/ui/unsized-locals/simple-unsized-locals.rs index 05955919245..02b7c299aa4 100644 --- a/src/test/ui/unsized-locals/simple-unsized-locals.rs +++ b/src/test/ui/unsized-locals/simple-unsized-locals.rs @@ -1,5 +1,6 @@ // run-pass +#![allow(incomplete_features)] #![feature(unsized_locals)] fn main() { diff --git a/src/test/ui/unsized-locals/unsized-exprs-rpass.rs b/src/test/ui/unsized-locals/unsized-exprs-rpass.rs index 24c2758a0a2..8fcb6d93d39 100644 --- a/src/test/ui/unsized-locals/unsized-exprs-rpass.rs +++ b/src/test/ui/unsized-locals/unsized-exprs-rpass.rs @@ -1,6 +1,6 @@ // run-pass -#![allow(unused_braces, unused_parens)] -#![feature(unsized_tuple_coercion, unsized_locals)] +#![allow(incomplete_features, unused_braces, unused_parens)] +#![feature(unsized_tuple_coercion, unsized_locals, unsized_fn_params)] struct A<X: ?Sized>(X); @@ -24,12 +24,8 @@ fn main() { udrop::<[u8]>(loop { break *foo(); }); - udrop::<[u8]>(if true { - *foo() - } else { - *foo() - }); - udrop::<[u8]>({*foo()}); + udrop::<[u8]>(if true { *foo() } else { *foo() }); + udrop::<[u8]>({ *foo() }); udrop::<[u8]>((*foo())); udrop::<[u8]>((*tfoo()).1); *afoo() + 42; diff --git a/src/test/ui/unsized-locals/unsized-exprs.rs b/src/test/ui/unsized-locals/unsized-exprs.rs index 8ca88edcb6a..1729b9ffa86 100644 --- a/src/test/ui/unsized-locals/unsized-exprs.rs +++ b/src/test/ui/unsized-locals/unsized-exprs.rs @@ -1,4 +1,4 @@ -#![feature(unsized_tuple_coercion, unsized_locals)] +#![feature(unsized_tuple_coercion, unsized_fn_params)] struct A<X: ?Sized>(X); diff --git a/src/test/ui/unsized-locals/unsized-exprs2.rs b/src/test/ui/unsized-locals/unsized-exprs2.rs index 534439aa6c4..127d8717e58 100644 --- a/src/test/ui/unsized-locals/unsized-exprs2.rs +++ b/src/test/ui/unsized-locals/unsized-exprs2.rs @@ -1,4 +1,4 @@ -#![feature(unsized_tuple_coercion, unsized_locals)] +#![feature(unsized_tuple_coercion, unsized_fn_params)] struct A<X: ?Sized>(X); diff --git a/src/test/ui/unsized-locals/unsized-exprs3.stderr b/src/test/ui/unsized-locals/unsized-exprs3.stderr index 426262e82b7..57d9978225a 100644 --- a/src/test/ui/unsized-locals/unsized-exprs3.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs3.stderr @@ -6,7 +6,7 @@ LL | udrop as fn([u8]); | = help: the trait `Sized` is not implemented for `[u8]` = note: all function arguments must have a statically known size - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature error: aborting due to previous error diff --git a/src/test/ui/unsized-locals/unsized-index.rs b/src/test/ui/unsized-locals/unsized-index.rs index 19ad97a853e..e8782e89481 100644 --- a/src/test/ui/unsized-locals/unsized-index.rs +++ b/src/test/ui/unsized-locals/unsized-index.rs @@ -1,23 +1,27 @@ -// build-pass (FIXME(62277): could be check-pass?) +// run-pass -// `std::ops::Index` has an `: ?Sized` bound on the `Idx` type param. This is -// an accidental left-over from the times when it `Index` was by-reference. -// Tightening the bound now could be a breaking change. Although no crater -// regression were observed (https://github.com/rust-lang/rust/pull/59527), -// let's be conservative and just add a test for this. -#![feature(unsized_locals)] +#![feature(unsized_fn_params)] use std::ops; +use std::ops::Index; pub struct A; impl ops::Index<str> for A { type Output = (); - fn index(&self, _: str) -> &Self::Output { panic!() } + fn index(&self, _: str) -> &Self::Output { + &() + } } impl ops::IndexMut<str> for A { - fn index_mut(&mut self, _: str) -> &mut Self::Output { panic!() } + fn index_mut(&mut self, _: str) -> &mut Self::Output { + panic!() + } } -fn main() {} +fn main() { + let a = A {}; + let s = String::new().into_boxed_str(); + assert_eq!(&(), a.index(*s)); +} diff --git a/src/test/ui/unsized-locals/unsized-locals-using-unsized-fn-params.rs b/src/test/ui/unsized-locals/unsized-locals-using-unsized-fn-params.rs new file mode 100644 index 00000000000..15263954ced --- /dev/null +++ b/src/test/ui/unsized-locals/unsized-locals-using-unsized-fn-params.rs @@ -0,0 +1,15 @@ +#![feature(box_patterns)] +#![feature(unsized_fn_params)] + +#[allow(dead_code)] +fn f1(box box _b: Box<Box<[u8]>>) {} +//~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time [E0277] + +fn f2((_x, _y): (i32, [i32])) {} +//~^ 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"); + let _foo: [u8] = *foo; + //~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time [E0277] +} diff --git a/src/test/ui/unsized-locals/unsized-locals-using-unsized-fn-params.stderr b/src/test/ui/unsized-locals/unsized-locals-using-unsized-fn-params.stderr new file mode 100644 index 00000000000..da77026673d --- /dev/null +++ b/src/test/ui/unsized-locals/unsized-locals-using-unsized-fn-params.stderr @@ -0,0 +1,33 @@ +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 + | +LL | fn f1(box box _b: Box<Box<[u8]>>) {} + | ^^ 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: 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 + | +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]` + = 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 + | +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: unsized locals are gated as an unstable feature + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/unsized-locals/unsized-parameters.rs b/src/test/ui/unsized-locals/unsized-parameters.rs index 3624154d5c4..a1b772a7eb6 100644 --- a/src/test/ui/unsized-locals/unsized-parameters.rs +++ b/src/test/ui/unsized-locals/unsized-parameters.rs @@ -1,10 +1,11 @@ // run-pass -#![feature(unsized_locals)] +#![allow(incomplete_features)] +#![feature(unsized_fn_params)] pub fn f0(_f: dyn FnOnce()) {} pub fn f1(_s: str) {} -pub fn f2((_x, _y): (i32, [i32])) {} +pub fn f2(_x: i32, _y: [i32]) {} fn main() { let foo = "foo".to_string().into_boxed_str(); diff --git a/src/test/ui/unsized6.stderr b/src/test/ui/unsized6.stderr index e85b73355e9..71dac236fa3 100644 --- a/src/test/ui/unsized6.stderr +++ b/src/test/ui/unsized6.stderr @@ -132,11 +132,11 @@ LL | fn g1<X: ?Sized>(x: X) {} | | | this type parameter needs to be `Sized` | - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn g1<X: ?Sized>(x: &X) {} - | ^ +LL | fn g1<X: ?Sized>(&x: X) {} + | ^ error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:40:22 @@ -146,11 +146,11 @@ LL | fn g2<X: ?Sized + T>(x: X) {} | | | this type parameter needs to be `Sized` | - = help: unsized locals are gated as an unstable feature + = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn g2<X: ?Sized + T>(x: &X) {} - | ^ +LL | fn g2<X: ?Sized + T>(&x: X) {} + | ^ error: aborting due to 13 previous errors |
