From f1a5cc0c20b18224643799666c61c52b99a96315 Mon Sep 17 00:00:00 2001 From: Boxy Date: Tue, 4 Jun 2024 08:45:47 +0100 Subject: [PATCH] Bless tests and handle tests/crashes --- tests/crashes/119830.rs | 11 -- tests/crashes/122908.rs | 4 - tests/crashes/125556.rs | 14 --- tests/debuginfo/function-names.rs | 4 +- .../issue_99325.main.built.after.32bit.mir | 2 +- .../issue_99325.main.built.after.64bit.mir | 2 +- ..._non-universal_region_substs_ice-111911.rs | 3 +- ...-universal_region_substs_ice-111911.stderr | 16 --- ...ram-type-depends-on-type-param.full.stderr | 14 ++- ...aram-type-depends-on-type-param.min.stderr | 14 ++- .../const-param-type-depends-on-type-param.rs | 1 + .../generic_const_exprs/error_in_ty.rs | 21 ++++ .../generic_const_exprs/error_in_ty.stderr | 45 +++++++ .../generic_const_exprs/eval-privacy.rs | 6 +- .../generic_const_exprs/eval-privacy.stderr | 15 ++- .../issues/issue-71381.full.stderr | 18 ++- .../issues/issue-71381.min.stderr | 18 ++- tests/ui/const-generics/issues/issue-71381.rs | 1 + .../const-generics/not_wf_param_in_rpitit.rs | 14 +++ .../not_wf_param_in_rpitit.stderr | 113 ++++++++++++++++++ tests/ui/const-generics/transmute-fail.stderr | 2 +- tests/ui/const-generics/type_not_in_scope.rs | 3 +- .../const-generics/type_not_in_scope.stderr | 14 ++- tests/ui/consts/issue-103790.rs | 1 - tests/ui/consts/issue-103790.stderr | 23 +--- tests/ui/privacy/where-priv-type.rs | 46 +++---- tests/ui/privacy/where-priv-type.stderr | 37 ++++-- .../const_generic_type.infer.stderr | 2 +- .../const_generic_type.no_infer.stderr | 13 +- .../const_generic_type.rs | 4 +- ...ce-hir-wf-check-anon-const-issue-122199.rs | 27 ++--- ...ir-wf-check-anon-const-issue-122199.stderr | 44 +++---- ...ce-hir-wf-check-anon-const-issue-122989.rs | 16 +-- ...ir-wf-check-anon-const-issue-122989.stderr | 93 ++------------ 34 files changed, 386 insertions(+), 275 deletions(-) delete mode 100644 tests/crashes/119830.rs delete mode 100644 tests/crashes/122908.rs delete mode 100644 tests/crashes/125556.rs delete mode 100644 tests/ui/const-generics/adt_const_params/opaque_type_with_non-universal_region_substs_ice-111911.stderr create mode 100644 tests/ui/const-generics/generic_const_exprs/error_in_ty.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr create mode 100644 tests/ui/const-generics/not_wf_param_in_rpitit.rs create mode 100644 tests/ui/const-generics/not_wf_param_in_rpitit.stderr diff --git a/tests/crashes/119830.rs b/tests/crashes/119830.rs deleted file mode 100644 index 71becc04e1696..0000000000000 --- a/tests/crashes/119830.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #119830 -#![feature(effects)] -#![feature(min_specialization)] - -trait Specialize {} - -trait Foo {} - -impl const Foo for T {} - -impl const Foo for T where T: const Specialize {} diff --git a/tests/crashes/122908.rs b/tests/crashes/122908.rs deleted file mode 100644 index c9da1bc187918..0000000000000 --- a/tests/crashes/122908.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ known-bug: #122908 -trait Trait { - async fn handle(slf: &F) {} -} diff --git a/tests/crashes/125556.rs b/tests/crashes/125556.rs deleted file mode 100644 index f2e2a991b11ec..0000000000000 --- a/tests/crashes/125556.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: rust-lang/rust#125556 -//@ compile-flags: -Znext-solver=coherence - -#![feature(generic_const_exprs)] - -pub struct A {} - -impl A<2> { - pub const fn B() {} -} - -impl A<2> { - pub const fn B() {} -} diff --git a/tests/debuginfo/function-names.rs b/tests/debuginfo/function-names.rs index 2b0c2593676b4..b95216514de2d 100644 --- a/tests/debuginfo/function-names.rs +++ b/tests/debuginfo/function-names.rs @@ -37,7 +37,7 @@ // Const generic parameter // gdb-command:info functions -q function_names::const_generic_fn.* // gdb-check:[...]static fn function_names::const_generic_fn_bool(); -// gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#ad91263f6d2dd96e}>(); +// gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#a70c39591cb5f53d}>(); // gdb-check:[...]static fn function_names::const_generic_fn_signed_int<-7>(); // gdb-check:[...]static fn function_names::const_generic_fn_unsigned_int<14>(); @@ -76,7 +76,7 @@ // Const generic parameter // cdb-command:x a!function_names::const_generic_fn* // cdb-check:[...] a!function_names::const_generic_fn_bool (void) -// cdb-check:[...] a!function_names::const_generic_fn_non_int (void) +// cdb-check:[...] a!function_names::const_generic_fn_non_int (void) // cdb-check:[...] a!function_names::const_generic_fn_unsigned_int<14> (void) // cdb-check:[...] a!function_names::const_generic_fn_signed_int<-7> (void) diff --git a/tests/mir-opt/issue_99325.main.built.after.32bit.mir b/tests/mir-opt/issue_99325.main.built.after.32bit.mir index 0b0bac73e9f4b..b7a054b5d5409 100644 --- a/tests/mir-opt/issue_99325.main.built.after.32bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.32bit.mir @@ -2,7 +2,7 @@ | User Type Annotations | 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }: &'static [u8; 4_usize]], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/issue_99325.main.built.after.64bit.mir b/tests/mir-opt/issue_99325.main.built.after.64bit.mir index 0b0bac73e9f4b..b7a054b5d5409 100644 --- a/tests/mir-opt/issue_99325.main.built.after.64bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.64bit.mir @@ -2,7 +2,7 @@ | User Type Annotations | 0: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [&*b"AAAA"], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:13:16: 13:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }: &'static [u8; 4_usize]], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { value: TypeOf(DefId(0:3 ~ issue_99325[d56d]::function_with_bytes), UserArgs { args: [UnevaluatedConst { def: DefId(0:8 ~ issue_99325[d56d]::main::{constant#1}), args: [] }], user_self_ty: None }), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_99325.rs:14:16: 14:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} | fn main() -> () { let mut _0: (); diff --git a/tests/ui/const-generics/adt_const_params/opaque_type_with_non-universal_region_substs_ice-111911.rs b/tests/ui/const-generics/adt_const_params/opaque_type_with_non-universal_region_substs_ice-111911.rs index 05bd0d91168a3..c55f3dcec68ca 100644 --- a/tests/ui/const-generics/adt_const_params/opaque_type_with_non-universal_region_substs_ice-111911.rs +++ b/tests/ui/const-generics/adt_const_params/opaque_type_with_non-universal_region_substs_ice-111911.rs @@ -1,4 +1,5 @@ //@ edition:2021 +//@ check-pass // issues rust-lang/rust#111911 // test for ICE opaque type with non-universal region substs @@ -6,8 +7,6 @@ #![allow(incomplete_features)] pub async fn foo() {} -//~^ ERROR const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias -//~| ERROR const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias fn bar() -> impl Sized {} pub fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/opaque_type_with_non-universal_region_substs_ice-111911.stderr b/tests/ui/const-generics/adt_const_params/opaque_type_with_non-universal_region_substs_ice-111911.stderr deleted file mode 100644 index 1bdb9cd9501a7..0000000000000 --- a/tests/ui/const-generics/adt_const_params/opaque_type_with_non-universal_region_substs_ice-111911.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/opaque_type_with_non-universal_region_substs_ice-111911.rs:8:43 - | -LL | pub async fn foo() {} - | ^^ - -error: const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/opaque_type_with_non-universal_region_substs_ice-111911.rs:8:43 - | -LL | pub async fn foo() {} - | ^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr index 2bfa604fc5673..49cf428132355 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr @@ -6,6 +6,16 @@ LL | pub struct Dependent([(); X]); | = note: type parameters may not be used in the type of const parameters -error: aborting due to 1 previous error +error[E0392]: type parameter `T` is never used + --> $DIR/const-param-type-depends-on-type-param.rs:11:22 + | +LL | pub struct Dependent([(); X]); + | ^ unused type parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0770`. +Some errors have detailed explanations: E0392, E0770. +For more information about an error, try `rustc --explain E0392`. diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr index 2bfa604fc5673..49cf428132355 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr @@ -6,6 +6,16 @@ LL | pub struct Dependent([(); X]); | = note: type parameters may not be used in the type of const parameters -error: aborting due to 1 previous error +error[E0392]: type parameter `T` is never used + --> $DIR/const-param-type-depends-on-type-param.rs:11:22 + | +LL | pub struct Dependent([(); X]); + | ^ unused type parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0770`. +Some errors have detailed explanations: E0392, E0770. +For more information about an error, try `rustc --explain E0392`. diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.rs b/tests/ui/const-generics/const-param-type-depends-on-type-param.rs index 1583fc4ee6c8c..5503b08930b00 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.rs +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.rs @@ -10,5 +10,6 @@ pub struct Dependent([(); X]); //~^ ERROR: the type of const parameters must not depend on other generic parameters +//~| ERROR: type parameter `T` is never used fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/error_in_ty.rs b/tests/ui/const-generics/generic_const_exprs/error_in_ty.rs new file mode 100644 index 0000000000000..29ad935c0149c --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/error_in_ty.rs @@ -0,0 +1,21 @@ +//@ compile-flags: -Znext-solver=coherence + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub struct A {} +//~^ ERROR: cannot find value `x` in this scope +//~| ERROR: `[usize; x]` is forbidden as the type of a const generic parameter + +impl A<2> { + //~^ ERROR: mismatched types + pub const fn B() {} + //~^ ERROR: duplicate definitions +} + +impl A<2> { + //~^ ERROR: mismatched types + pub const fn B() {} +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr b/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr new file mode 100644 index 0000000000000..0e40255bcf59b --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr @@ -0,0 +1,45 @@ +error[E0425]: cannot find value `x` in this scope + --> $DIR/error_in_ty.rs:6:31 + | +LL | pub struct A {} + | - ^ help: a const parameter with a similar name exists: `z` + | | + | similarly named const parameter `z` defined here + +error: `[usize; x]` is forbidden as the type of a const generic parameter + --> $DIR/error_in_ty.rs:6:23 + | +LL | pub struct A {} + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` +help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + | +LL + #![feature(adt_const_params)] + | + +error[E0308]: mismatched types + --> $DIR/error_in_ty.rs:10:8 + | +LL | impl A<2> { + | ^ expected `[usize; x]`, found integer + +error[E0308]: mismatched types + --> $DIR/error_in_ty.rs:16:8 + | +LL | impl A<2> { + | ^ expected `[usize; x]`, found integer + +error[E0592]: duplicate definitions with name `B` + --> $DIR/error_in_ty.rs:12:5 + | +LL | pub const fn B() {} + | ^^^^^^^^^^^^^^^^ duplicate definitions for `B` +... +LL | pub const fn B() {} + | ---------------- other definition for `B` + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0308, E0425, E0592. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs b/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs index 8023b998a4099..b662939c27eb3 100644 --- a/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs +++ b/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs @@ -9,12 +9,14 @@ pub trait Trait { fn assoc_fn() -> Self::AssocTy; } -impl Trait for Const // OK, trait impl predicates +impl Trait for Const where - Const<{ my_const_fn(U) }>: , + // OK, trait impl predicates + Const<{ my_const_fn(U) }>:, { type AssocTy = Const<{ my_const_fn(U) }>; //~^ ERROR private type + //~| ERROR private type fn assoc_fn() -> Self::AssocTy { Const } diff --git a/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr b/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr index 043fa34d605ab..98dac313be413 100644 --- a/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr +++ b/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr @@ -1,5 +1,5 @@ error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface - --> $DIR/eval-privacy.rs:16:5 + --> $DIR/eval-privacy.rs:17:5 | LL | type AssocTy = Const<{ my_const_fn(U) }>; | ^^^^^^^^^^^^ can't leak private type @@ -7,6 +7,17 @@ LL | type AssocTy = Const<{ my_const_fn(U) }>; LL | const fn my_const_fn(val: u8) -> u8 { | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private -error: aborting due to 1 previous error +error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface + --> $DIR/eval-privacy.rs:17:5 + | +LL | type AssocTy = Const<{ my_const_fn(U) }>; + | ^^^^^^^^^^^^ can't leak private type +... +LL | const fn my_const_fn(val: u8) -> u8 { + | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/const-generics/issues/issue-71381.full.stderr b/tests/ui/const-generics/issues/issue-71381.full.stderr index 5d7800746961b..59802c9f75766 100644 --- a/tests/ui/const-generics/issues/issue-71381.full.stderr +++ b/tests/ui/const-generics/issues/issue-71381.full.stderr @@ -7,13 +7,25 @@ LL | pub fn call_me $DIR/issue-71381.rs:22:40 + --> $DIR/issue-71381.rs:23:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` | = note: type parameters may not be used in the type of const parameters -error: aborting due to 2 previous errors +error[E0594]: cannot assign to `self.0`, which is behind a `&` reference + --> $DIR/issue-71381.rs:16:9 + | +LL | self.0 = Self::trampiline:: as _ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written + | +help: consider changing this to be a mutable reference + | +LL | pub fn call_me(&mut self) { + | ~~~~~~~~~ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0770`. +Some errors have detailed explanations: E0594, E0770. +For more information about an error, try `rustc --explain E0594`. diff --git a/tests/ui/const-generics/issues/issue-71381.min.stderr b/tests/ui/const-generics/issues/issue-71381.min.stderr index 5d7800746961b..59802c9f75766 100644 --- a/tests/ui/const-generics/issues/issue-71381.min.stderr +++ b/tests/ui/const-generics/issues/issue-71381.min.stderr @@ -7,13 +7,25 @@ LL | pub fn call_me $DIR/issue-71381.rs:22:40 + --> $DIR/issue-71381.rs:23:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` | = note: type parameters may not be used in the type of const parameters -error: aborting due to 2 previous errors +error[E0594]: cannot assign to `self.0`, which is behind a `&` reference + --> $DIR/issue-71381.rs:16:9 + | +LL | self.0 = Self::trampiline:: as _ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written + | +help: consider changing this to be a mutable reference + | +LL | pub fn call_me(&mut self) { + | ~~~~~~~~~ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0770`. +Some errors have detailed explanations: E0594, E0770. +For more information about an error, try `rustc --explain E0594`. diff --git a/tests/ui/const-generics/issues/issue-71381.rs b/tests/ui/const-generics/issues/issue-71381.rs index 7f2e14944e296..9dc37c368243e 100644 --- a/tests/ui/const-generics/issues/issue-71381.rs +++ b/tests/ui/const-generics/issues/issue-71381.rs @@ -14,6 +14,7 @@ impl Test { pub fn call_me(&self) { //~^ ERROR: the type of const parameters must not depend on other generic parameters self.0 = Self::trampiline:: as _ + //~^ ERROR: cannot assign to `self.0` } unsafe extern "C" fn trampiline< diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.rs b/tests/ui/const-generics/not_wf_param_in_rpitit.rs new file mode 100644 index 0000000000000..5471dc9022f90 --- /dev/null +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.rs @@ -0,0 +1,14 @@ +//@ edition:2021 + +trait Trait { + //~^ ERROR: cannot find value `bar` in this scope + //~| ERROR: cycle detected when computing type of `Trait::N` + //~| ERROR: the trait `Trait` cannot be made into an object + //~| ERROR: the trait `Trait` cannot be made into an object + //~| ERROR: the trait `Trait` cannot be made into an object + //~| ERROR: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter + //~| ERROR: trait objects must include the `dyn` keyword + async fn a() {} +} + +fn main() {} diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr new file mode 100644 index 0000000000000..9095948d22b8a --- /dev/null +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr @@ -0,0 +1,113 @@ +error[E0425]: cannot find value `bar` in this scope + --> $DIR/not_wf_param_in_rpitit.rs:3:30 + | +LL | trait Trait { + | ^^^ not found in this scope + +error[E0391]: cycle detected when computing type of `Trait::N` + --> $DIR/not_wf_param_in_rpitit.rs:3:22 + | +LL | trait Trait { + | ^^^^^ + | + = note: ...which immediately requires computing type of `Trait::N` again +note: cycle used when computing explicit predicates of trait `Trait` + --> $DIR/not_wf_param_in_rpitit.rs:3:1 + | +LL | trait Trait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error[E0038]: the trait `Trait` cannot be made into an object + --> $DIR/not_wf_param_in_rpitit.rs:3:22 + | +LL | trait Trait { + | ^^^^^ `Trait` cannot be made into an object + | +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 + --> $DIR/not_wf_param_in_rpitit.rs:11:14 + | +LL | trait Trait { + | ----- this trait cannot be made into an object... +... +LL | async fn a() {} + | ^ ...because associated function `a` has no `self` parameter +help: consider turning `a` into a method by giving it a `&self` argument + | +LL | async fn a(&self) {} + | +++++ +help: alternatively, consider constraining `a` so it does not apply to trait objects + | +LL | async fn a() where Self: Sized {} + | +++++++++++++++++ + +error[E0038]: the trait `Trait` cannot be made into an object + --> $DIR/not_wf_param_in_rpitit.rs:3:13 + | +LL | trait Trait { + | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object + | +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 + --> $DIR/not_wf_param_in_rpitit.rs:11:14 + | +LL | trait Trait { + | ----- this trait cannot be made into an object... +... +LL | async fn a() {} + | ^ ...because associated function `a` has no `self` parameter +help: consider turning `a` into a method by giving it a `&self` argument + | +LL | async fn a(&self) {} + | +++++ +help: alternatively, consider constraining `a` so it does not apply to trait objects + | +LL | async fn a() where Self: Sized {} + | +++++++++++++++++ + +error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter + --> $DIR/not_wf_param_in_rpitit.rs:3:22 + | +LL | trait Trait { + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + +error[E0038]: the trait `Trait` cannot be made into an object + --> $DIR/not_wf_param_in_rpitit.rs:3:13 + | +LL | trait Trait { + | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object + | +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 + --> $DIR/not_wf_param_in_rpitit.rs:11:14 + | +LL | trait Trait { + | ----- this trait cannot be made into an object... +... +LL | async fn a() {} + | ^ ...because associated function `a` has no `self` parameter + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider turning `a` into a method by giving it a `&self` argument + | +LL | async fn a(&self) {} + | +++++ +help: alternatively, consider constraining `a` so it does not apply to trait objects + | +LL | async fn a() where Self: Sized {} + | +++++++++++++++++ + +error[E0782]: trait objects must include the `dyn` keyword + --> $DIR/not_wf_param_in_rpitit.rs:3:22 + | +LL | trait Trait { + | ^^^^^ + | +help: add `dyn` keyword before this trait + | +LL | trait Trait { + | +++ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0038, E0391, E0425, E0782. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/transmute-fail.stderr b/tests/ui/const-generics/transmute-fail.stderr index 1b0d1ea50d086..b76ec10bd3f21 100644 --- a/tests/ui/const-generics/transmute-fail.stderr +++ b/tests/ui/const-generics/transmute-fail.stderr @@ -13,7 +13,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently- LL | std::mem::transmute(v) | ^^^^^^^^^^^^^^^^^^^ | - = note: source type: `[[u32; H]; W]` (this type does not have a fixed size) + = note: source type: `[[u32; H]; W]` (size can vary because of [u32; H]) = note: target type: `[[u32; W]; H]` (size can vary because of [u32; W]) error[E0512]: cannot transmute between types of different sizes, or dependently-sized types diff --git a/tests/ui/const-generics/type_not_in_scope.rs b/tests/ui/const-generics/type_not_in_scope.rs index 917abaed15e06..1eb265d74d1c7 100644 --- a/tests/ui/const-generics/type_not_in_scope.rs +++ b/tests/ui/const-generics/type_not_in_scope.rs @@ -5,6 +5,7 @@ impl X { } } fn getn() -> [u8; N] {} -//~^ ERROR expected type, found built-in attribute `cfg_attr` +//~^ ERROR: expected type, found built-in attribute `cfg_attr` +//~| ERROR: mismatched types fn main() {} diff --git a/tests/ui/const-generics/type_not_in_scope.stderr b/tests/ui/const-generics/type_not_in_scope.stderr index 5eb81ca052241..5f45550a62796 100644 --- a/tests/ui/const-generics/type_not_in_scope.stderr +++ b/tests/ui/const-generics/type_not_in_scope.stderr @@ -10,7 +10,15 @@ error[E0573]: expected type, found built-in attribute `cfg_attr` LL | fn getn() -> [u8; N] {} | ^^^^^^^^ not a type -error: aborting due to 2 previous errors +error[E0308]: mismatched types + --> $DIR/type_not_in_scope.rs:7:33 + | +LL | fn getn() -> [u8; N] {} + | ---- ^^^^^^^ expected `[u8; N]`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0412, E0573. -For more information about an error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0308, E0412, E0573. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/consts/issue-103790.rs b/tests/ui/consts/issue-103790.rs index 5d130821dc8ef..869a43e4018b3 100644 --- a/tests/ui/consts/issue-103790.rs +++ b/tests/ui/consts/issue-103790.rs @@ -5,7 +5,6 @@ struct S; //~^ ERROR the name `S` is already used for a generic parameter in this item's generic parameters //~| ERROR missing generics for struct `S` //~| ERROR cycle detected when computing type of `S::S` -//~| ERROR cycle detected when computing type of `S` //~| ERROR `()` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/consts/issue-103790.stderr b/tests/ui/consts/issue-103790.stderr index eecaf5ff63a30..32481609aab0b 100644 --- a/tests/ui/consts/issue-103790.stderr +++ b/tests/ui/consts/issue-103790.stderr @@ -29,26 +29,7 @@ LL | struct S; | ^ | = note: ...which immediately requires computing type of `S::S` again -note: cycle used when computing type of `S` - --> $DIR/issue-103790.rs:4:1 - | -LL | struct S; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error[E0391]: cycle detected when computing type of `S` - --> $DIR/issue-103790.rs:4:1 - | -LL | struct S; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires computing type of `S::S`... - --> $DIR/issue-103790.rs:4:32 - | -LL | struct S; - | ^ - = note: ...which again requires computing type of `S`, completing the cycle -note: cycle used when checking that `S` is well-formed +note: cycle used when computing explicit predicates of `S` --> $DIR/issue-103790.rs:4:1 | LL | struct S; @@ -67,7 +48,7 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more LL + #![feature(adt_const_params)] | -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0107, E0391, E0403. For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/privacy/where-priv-type.rs b/tests/ui/privacy/where-priv-type.rs index cd9cce7ec3e8d..20467301ae17c 100644 --- a/tests/ui/privacy/where-priv-type.rs +++ b/tests/ui/privacy/where-priv-type.rs @@ -11,55 +11,46 @@ pub struct PubTy; pub struct PubTyGeneric(T); pub trait PubTr {} impl PubTr for PrivTy {} -pub trait PubTrWithAssocTy { type AssocTy; } -impl PubTrWithAssocTy for PrivTy { type AssocTy = PrivTy; } - +pub trait PubTrWithAssocTy { + type AssocTy; +} +impl PubTrWithAssocTy for PrivTy { + type AssocTy = PrivTy; +} pub struct S //~^ WARNING type `PrivTy` is more private than the item `S` where - PrivTy: -{} - + PrivTy:, {} pub enum E //~^ WARNING type `PrivTy` is more private than the item `E` where - PrivTy: -{} - + PrivTy:, {} pub fn f() //~^ WARNING type `PrivTy` is more private than the item `f` where - PrivTy: -{} - + PrivTy:, +{ +} impl S //~^ WARNING type `PrivTy` is more private than the item `S` where - PrivTy: + PrivTy:, { pub fn f() //~^ WARNING type `PrivTy` is more private than the item `S::f` where - PrivTy: - {} + PrivTy:, + { + } } +impl PubTr for PubTy where PrivTy: {} -impl PubTr for PubTy -where - PrivTy: -{} - - -impl PubTr for PubTyGeneric -where - T: PubTrWithAssocTy -{} - +impl PubTr for PubTyGeneric where T: PubTrWithAssocTy {} pub struct Const; @@ -70,10 +61,11 @@ pub trait Trait { impl Trait for Const where - Const<{ my_const_fn(U) }>: , + Const<{ my_const_fn(U) }>:, { type AssocTy = Const<{ my_const_fn(U) }>; //~^ ERROR private type + //~| ERROR private type fn assoc_fn() -> Self::AssocTy { Const } diff --git a/tests/ui/privacy/where-priv-type.stderr b/tests/ui/privacy/where-priv-type.stderr index 126330b14a63f..08963e07c35a3 100644 --- a/tests/ui/privacy/where-priv-type.stderr +++ b/tests/ui/privacy/where-priv-type.stderr @@ -1,5 +1,5 @@ warning: type `PrivTy` is more private than the item `S` - --> $DIR/where-priv-type.rs:18:1 + --> $DIR/where-priv-type.rs:21:1 | LL | pub struct S | ^^^^^^^^^^^^ struct `S` is reachable at visibility `pub` @@ -12,7 +12,7 @@ LL | struct PrivTy; = note: `#[warn(private_bounds)]` on by default warning: type `PrivTy` is more private than the item `E` - --> $DIR/where-priv-type.rs:25:1 + --> $DIR/where-priv-type.rs:26:1 | LL | pub enum E | ^^^^^^^^^^ enum `E` is reachable at visibility `pub` @@ -24,13 +24,13 @@ LL | struct PrivTy; | ^^^^^^^^^^^^^ warning: type `PrivTy` is more private than the item `f` - --> $DIR/where-priv-type.rs:32:1 + --> $DIR/where-priv-type.rs:31:1 | LL | / pub fn f() LL | | LL | | where -LL | | PrivTy: - | |___________^ function `f` is reachable at visibility `pub` +LL | | PrivTy:, + | |____________^ function `f` is reachable at visibility `pub` | note: but type `PrivTy` is only usable at visibility `pub(crate)` --> $DIR/where-priv-type.rs:8:1 @@ -39,13 +39,13 @@ LL | struct PrivTy; | ^^^^^^^^^^^^^ warning: type `PrivTy` is more private than the item `S` - --> $DIR/where-priv-type.rs:39:1 + --> $DIR/where-priv-type.rs:38:1 | LL | / impl S LL | | LL | | where -LL | | PrivTy: - | |___________^ implementation `S` is reachable at visibility `pub` +LL | | PrivTy:, + | |____________^ implementation `S` is reachable at visibility `pub` | note: but type `PrivTy` is only usable at visibility `pub(crate)` --> $DIR/where-priv-type.rs:8:1 @@ -54,13 +54,13 @@ LL | struct PrivTy; | ^^^^^^^^^^^^^ warning: type `PrivTy` is more private than the item `S::f` - --> $DIR/where-priv-type.rs:44:5 + --> $DIR/where-priv-type.rs:43:5 | LL | / pub fn f() LL | | LL | | where -LL | | PrivTy: - | |_______________^ associated function `S::f` is reachable at visibility `pub` +LL | | PrivTy:, + | |________________^ associated function `S::f` is reachable at visibility `pub` | note: but type `PrivTy` is only usable at visibility `pub(crate)` --> $DIR/where-priv-type.rs:8:1 @@ -69,7 +69,7 @@ LL | struct PrivTy; | ^^^^^^^^^^^^^ error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface - --> $DIR/where-priv-type.rs:75:5 + --> $DIR/where-priv-type.rs:66:5 | LL | type AssocTy = Const<{ my_const_fn(U) }>; | ^^^^^^^^^^^^ can't leak private type @@ -77,6 +77,17 @@ LL | type AssocTy = Const<{ my_const_fn(U) }>; LL | const fn my_const_fn(val: u8) -> u8 { | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private -error: aborting due to 1 previous error; 5 warnings emitted +error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface + --> $DIR/where-priv-type.rs:66:5 + | +LL | type AssocTy = Const<{ my_const_fn(U) }>; + | ^^^^^^^^^^^^ can't leak private type +... +LL | const fn my_const_fn(val: u8) -> u8 { + | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors; 5 warnings emitted For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr index 6a1a770228da7..3b6999cabc416 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr @@ -1,5 +1,5 @@ error: `Bar` is forbidden as the type of a const generic parameter - --> $DIR/const_generic_type.rs:7:24 + --> $DIR/const_generic_type.rs:8:24 | LL | async fn test() { | ^^^^^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr index a1a69bfaca372..56a1020165148 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr @@ -1,13 +1,13 @@ -error[E0283]: type annotations needed - --> $DIR/const_generic_type.rs:7:1 +error: unconstrained opaque type + --> $DIR/const_generic_type.rs:5:12 | -LL | async fn test() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type +LL | type Bar = impl std::fmt::Display; + | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: cannot satisfy `_: std::fmt::Display` + = note: `Bar` must be used in combination with a concrete type within the same module error: `Bar` is forbidden as the type of a const generic parameter - --> $DIR/const_generic_type.rs:7:24 + --> $DIR/const_generic_type.rs:8:24 | LL | async fn test() { | ^^^^^^^^^^ @@ -16,4 +16,3 @@ LL | async fn test() { error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.rs b/tests/ui/type-alias-impl-trait/const_generic_type.rs index 95a5e1c62861d..bfd06826f00cc 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.rs +++ b/tests/ui/type-alias-impl-trait/const_generic_type.rs @@ -3,10 +3,10 @@ #![feature(type_alias_impl_trait)] type Bar = impl std::fmt::Display; +//[no_infer]~^ ERROR: unconstrained opaque type async fn test() { - //[no_infer]~^ ERROR: type annotations needed - //~^^ ERROR: `Bar` is forbidden as the type of a const generic parameter + //~^ ERROR: `Bar` is forbidden as the type of a const generic parameter #[cfg(infer)] let x: u32 = N; } diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs index db155f4fa3c3b..3f43fbfc0cf41 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs @@ -1,7 +1,6 @@ trait Trait { //~^ ERROR cannot find value `bar` in this scope //~| ERROR cycle detected when computing type of `Trait::N` - //~| ERROR cycle detected when computing type of `Trait::N` //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR the trait `Trait` cannot be made into an object @@ -11,20 +10,20 @@ trait Trait { //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! fn fnc(&self) -> Trait { - //~^ ERROR the name `N` is already used for a generic parameter in this item's generic parameters - //~| ERROR expected value, found builtin type `u32` - //~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - //~| ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `Trait` cannot be made into an object - //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter - //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] - //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] - //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! - //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] - //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + //~^ ERROR the name `N` is already used for a generic parameter in this item's generic parameters + //~| ERROR expected value, found builtin type `u32` + //~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + //~| ERROR associated item referring to unboxed trait object for its own trait + //~| ERROR the trait `Trait` cannot be made into an object + //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter + //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! bar - //~^ ERROR cannot find value `bar` in this scope + //~^ ERROR cannot find value `bar` in this scope } } diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr index cf985d9d1fdf1..f2456f99e6233 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr @@ -1,5 +1,5 @@ error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:18 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:18 | LL | trait Trait { | - first use of `N` @@ -14,13 +14,13 @@ LL | trait Trait { | ^^^ not found in this scope error[E0423]: expected value, found builtin type `u32` - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:29 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:29 | LL | fn fnc(&self) -> Trait { | ^^^ not a value error[E0425]: cannot find value `bar` in this scope - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:26:9 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:25:9 | LL | bar | ^^^ not found in this scope @@ -53,28 +53,14 @@ LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error[E0391]: cycle detected when computing type of `Trait::N` - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:13 - | -LL | trait Trait { - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: ...which immediately requires computing type of `Trait::N` again -note: cycle used when computing explicit predicates of trait `Trait` - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:1 - | -LL | trait Trait { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:12 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:12 | LL | fn fnc(&self) -> Trait { | ^^^^^^^^^^^^^^^^^^^^ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 | LL | fn fnc(&self) -> Trait { | ^^^^^ @@ -87,7 +73,7 @@ LL | fn fnc(&self) -> Trait { | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:44 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:44 | LL | fn fnc(&self) -> Trait { | ^^^^^ @@ -120,7 +106,7 @@ LL | trait Trait { | ^^^^^ `Trait` cannot be made into an object | 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 - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -136,7 +122,7 @@ LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | 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 - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -154,7 +140,7 @@ LL | trait Trait { = note: the only supported types are integers, `bool` and `char` error: associated item referring to unboxed trait object for its own trait - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:44 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:44 | LL | trait Trait { | ----- in this trait @@ -168,7 +154,7 @@ LL | fn fnc(&self) -> Self { | ~~~~ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 | LL | fn fnc(&self) -> Trait { | ^^^^^ @@ -182,13 +168,13 @@ LL | fn fnc(&self) -> Trait { | +++ error[E0038]: the trait `Trait` cannot be made into an object - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 | LL | fn fnc(&self) -> Trait { | ^^^^^ `Trait` cannot be made into an object | 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 - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -204,7 +190,7 @@ LL | trait Trait { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | 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 - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 | LL | trait Trait { | ----- this trait cannot be made into an object... @@ -215,14 +201,14 @@ LL | fn fnc(&self) -> Trait { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 | LL | fn fnc(&self) -> Trait { | ^^^^^ | = note: the only supported types are integers, `bool` and `char` -error: aborting due to 14 previous errors; 5 warnings emitted +error: aborting due to 13 previous errors; 5 warnings emitted Some errors have detailed explanations: E0038, E0391, E0403, E0423, E0425. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs index 2995f26af4a61..a953f1818c580 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs @@ -1,15 +1,11 @@ // Regression test for ICE #122989 trait Foo> { -//~^ WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! -//~| ERROR cycle detected when computing type of `Foo::N` -//~| ERROR cycle detected when computing type of `Foo::N` -//~| ERROR the trait `Foo` cannot be made into an object -//~| ERROR the trait `Foo` cannot be made into an object -//~| ERROR the trait `Foo` cannot be made into an object -//~| ERROR `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic parameter - fn func() { - } + //~^ WARN trait objects without an explicit `dyn` are deprecated + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + //~| ERROR cycle detected when computing type of `Foo::N` + //~| ERROR the trait `Foo` cannot be made into an object + //~| ERROR `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic parameter + fn func() {} } trait Bar> {} diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index e6fdc44087364..a0fd11de2dc6f 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -13,7 +13,7 @@ LL | trait Foo> { | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:20 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:20 | LL | trait Bar> {} | ^^^^^^ @@ -32,7 +32,7 @@ LL | trait Foo> { | ^^^^^^^^^^^^^^^ | note: ...which requires computing type of `Bar::M`... - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:11 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:11 | LL | trait Bar> {} | ^^^^^^^^^^^^^^^ @@ -44,26 +44,6 @@ LL | trait Foo> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error[E0391]: cycle detected when computing type of `Foo::N` - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:11 - | -LL | trait Foo> { - | ^^^^^^^^^^^^^^^ - | -note: ...which requires computing type of `Bar::M`... - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:11 - | -LL | trait Bar> {} - | ^^^^^^^^^^^^^^^ - = note: ...which again requires computing type of `Foo::N`, completing the cycle -note: cycle used when computing explicit predicates of trait `Foo` - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:1 - | -LL | trait Foo> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:24 | @@ -71,43 +51,20 @@ LL | trait Foo> { | ^ `Foo` cannot be made into an object | 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 - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:8 - | -LL | trait Foo> { - | --- this trait cannot be made into an object... -... -LL | fn func() { - | ^^^^ ...because associated function `func` has no `self` parameter -help: consider turning `func` into a method by giving it a `&self` argument - | -LL | fn func(&self) { - | +++++ -help: alternatively, consider constraining `func` so it does not apply to trait objects - | -LL | fn func() where Self: Sized { - | +++++++++++++++++ - -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:11 - | -LL | trait Foo> { - | ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object - | -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 - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:8:8 | LL | trait Foo> { | --- this trait cannot be made into an object... ... -LL | fn func() { +LL | fn func() {} | ^^^^ ...because associated function `func` has no `self` parameter help: consider turning `func` into a method by giving it a `&self` argument | -LL | fn func(&self) { +LL | fn func(&self) {} | +++++ help: alternatively, consider constraining `func` so it does not apply to trait objects | -LL | fn func() where Self: Sized { +LL | fn func() where Self: Sized {} | +++++++++++++++++ error: `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic parameter @@ -119,61 +76,37 @@ LL | trait Foo> { = note: the only supported types are integers, `bool` and `char` error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:11 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:11 | LL | trait Bar> {} | ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | 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 - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:8:8 | LL | trait Foo> { | --- this trait cannot be made into an object... ... -LL | fn func() { +LL | fn func() {} | ^^^^ ...because associated function `func` has no `self` parameter help: consider turning `func` into a method by giving it a `&self` argument | -LL | fn func(&self) { +LL | fn func(&self) {} | +++++ help: alternatively, consider constraining `func` so it does not apply to trait objects | -LL | fn func() where Self: Sized { +LL | fn func() where Self: Sized {} | +++++++++++++++++ error: `(dyn Foo<2> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:15:20 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:20 | LL | trait Bar> {} | ^^^^^^ | = note: the only supported types are integers, `bool` and `char` -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:11 - | -LL | trait Foo> { - | ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object - | -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 - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:8 - | -LL | trait Foo> { - | --- this trait cannot be made into an object... -... -LL | fn func() { - | ^^^^ ...because associated function `func` has no `self` parameter - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider turning `func` into a method by giving it a `&self` argument - | -LL | fn func(&self) { - | +++++ -help: alternatively, consider constraining `func` so it does not apply to trait objects - | -LL | fn func() where Self: Sized { - | +++++++++++++++++ - -error: aborting due to 8 previous errors; 2 warnings emitted +error: aborting due to 5 previous errors; 2 warnings emitted Some errors have detailed explanations: E0038, E0391. For more information about an error, try `rustc --explain E0038`.