diff options
Diffstat (limited to 'tests')
86 files changed, 1118 insertions, 199 deletions
diff --git a/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff index dec99ff4601..01b01ea5c17 100644 --- a/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.bar.InstrumentCoverage.diff @@ -4,7 +4,7 @@ fn bar() -> bool { let mut _0: bool; -+ coverage Code(Counter(0)) => /the/src/instrument_coverage.rs:21:1 - 23:2; ++ coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:19:1 - 21:2; + bb0: { + Coverage::CounterIncrement(0); diff --git a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff index 368088d1296..3606a9e3932 100644 --- a/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff @@ -9,11 +9,11 @@ + coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Add, rhs: Counter(1) }; + coverage ExpressionId(1) => Expression { lhs: Expression(0), op: Subtract, rhs: Counter(1) }; -+ coverage Code(Counter(0)) => /the/src/instrument_coverage.rs:12:1 - 12:11; -+ coverage Code(Expression(0)) => /the/src/instrument_coverage.rs:13:5 - 14:17; -+ coverage Code(Expression(1)) => /the/src/instrument_coverage.rs:15:13 - 15:18; -+ coverage Code(Counter(1)) => /the/src/instrument_coverage.rs:16:10 - 16:11; -+ coverage Code(Expression(1)) => /the/src/instrument_coverage.rs:18:1 - 18:2; ++ coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:10:1 - 10:11; ++ coverage Code(Expression(0)) => $DIR/instrument_coverage.rs:11:5 - 12:17; ++ coverage Code(Expression(1)) => $DIR/instrument_coverage.rs:13:13 - 13:18; ++ coverage Code(Counter(1)) => $DIR/instrument_coverage.rs:14:10 - 14:11; ++ coverage Code(Expression(1)) => $DIR/instrument_coverage.rs:16:1 - 16:2; + bb0: { + Coverage::CounterIncrement(0); diff --git a/tests/mir-opt/instrument_coverage.rs b/tests/mir-opt/instrument_coverage.rs index 010f7bf4d80..ae63990f253 100644 --- a/tests/mir-opt/instrument_coverage.rs +++ b/tests/mir-opt/instrument_coverage.rs @@ -1,11 +1,9 @@ -// skip-filecheck -// Test that `-C instrument-coverage` injects Coverage statements. The Coverage Counter statements -// are later converted into LLVM instrprof.increment intrinsics, during codegen. +// Test that `-C instrument-coverage` injects Coverage statements. +// The Coverage::CounterIncrement statements are later converted into LLVM +// instrprof.increment intrinsics, during codegen. //@ unit-test: InstrumentCoverage -//@ needs-profiler-support -//@ ignore-windows -//@ compile-flags: -C instrument-coverage --remap-path-prefix={{src-base}}=/the/src +//@ compile-flags: -Cinstrument-coverage -Zno-profiler-runtime // EMIT_MIR instrument_coverage.main.InstrumentCoverage.diff // EMIT_MIR instrument_coverage.bar.InstrumentCoverage.diff @@ -22,17 +20,9 @@ fn bar() -> bool { true } -// Note that the MIR with injected coverage intrinsics includes references to source locations, -// including the source file absolute path. Typically, MIR pretty print output with file -// references are safe because the file prefixes are substituted with `$DIR`, but in this case -// the file references are encoded as function arguments, with an `Operand` type representation -// (`Slice` `Allocation` interned byte array) that cannot be normalized by simple substitution. -// -// The first workaround is to use the `SourceMap`-supported `--remap-path-prefix` option; however, -// the implementation of the `--remap-path-prefix` option currently joins the new prefix and the -// remaining source path with an OS-specific path separator (`\` on Windows). This difference still -// shows up in the byte array representation of the path, causing Windows tests to fail to match -// blessed results baselined with a `/` path separator. -// -// Since this `mir-opt` test does not have any significant platform dependencies, other than the -// path separator differences, the final workaround is to disable testing on Windows. +// CHECK: coverage ExpressionId({{[0-9]+}}) => +// CHECK-DAG: coverage Code(Counter({{[0-9]+}})) => +// CHECK-DAG: coverage Code(Expression({{[0-9]+}})) => +// CHECK: bb0: +// CHECK-DAG: Coverage::ExpressionUsed({{[0-9]+}}) +// CHECK-DAG: Coverage::CounterIncrement({{[0-9]+}}) diff --git a/tests/mir-opt/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff b/tests/mir-opt/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff index ff65ca77039..34d011540b9 100644 --- a/tests/mir-opt/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff +++ b/tests/mir-opt/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff @@ -5,15 +5,15 @@ let mut _0: (); let mut _1: bool; - coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => /the/src/instrument_coverage_cleanup.rs:15:8: 15:36 (#0) + coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0) coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Subtract, rhs: Counter(1) }; coverage ExpressionId(1) => Expression { lhs: Counter(1), op: Add, rhs: Expression(0) }; - coverage Code(Counter(0)) => /the/src/instrument_coverage_cleanup.rs:14:1 - 15:36; - coverage Code(Expression(0)) => /the/src/instrument_coverage_cleanup.rs:15:37 - 15:39; - coverage Code(Counter(1)) => /the/src/instrument_coverage_cleanup.rs:15:39 - 15:40; - coverage Code(Expression(1)) => /the/src/instrument_coverage_cleanup.rs:16:1 - 16:2; - coverage Branch { true_term: Expression(0), false_term: Counter(1) } => /the/src/instrument_coverage_cleanup.rs:15:8 - 15:36; + coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:13:1 - 14:36; + coverage Code(Expression(0)) => $DIR/instrument_coverage_cleanup.rs:14:37 - 14:39; + coverage Code(Counter(1)) => $DIR/instrument_coverage_cleanup.rs:14:39 - 14:40; + coverage Code(Expression(1)) => $DIR/instrument_coverage_cleanup.rs:15:1 - 15:2; + coverage Branch { true_term: Expression(0), false_term: Counter(1) } => $DIR/instrument_coverage_cleanup.rs:14:8 - 14:36; bb0: { Coverage::CounterIncrement(0); diff --git a/tests/mir-opt/instrument_coverage_cleanup.main.InstrumentCoverage.diff b/tests/mir-opt/instrument_coverage_cleanup.main.InstrumentCoverage.diff index 8757559149a..6756d5c1e1b 100644 --- a/tests/mir-opt/instrument_coverage_cleanup.main.InstrumentCoverage.diff +++ b/tests/mir-opt/instrument_coverage_cleanup.main.InstrumentCoverage.diff @@ -5,15 +5,15 @@ let mut _0: (); let mut _1: bool; - coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => /the/src/instrument_coverage_cleanup.rs:15:8: 15:36 (#0) + coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0) + coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Subtract, rhs: Counter(1) }; + coverage ExpressionId(1) => Expression { lhs: Counter(1), op: Add, rhs: Expression(0) }; -+ coverage Code(Counter(0)) => /the/src/instrument_coverage_cleanup.rs:14:1 - 15:36; -+ coverage Code(Expression(0)) => /the/src/instrument_coverage_cleanup.rs:15:37 - 15:39; -+ coverage Code(Counter(1)) => /the/src/instrument_coverage_cleanup.rs:15:39 - 15:40; -+ coverage Code(Expression(1)) => /the/src/instrument_coverage_cleanup.rs:16:1 - 16:2; -+ coverage Branch { true_term: Expression(0), false_term: Counter(1) } => /the/src/instrument_coverage_cleanup.rs:15:8 - 15:36; ++ coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:13:1 - 14:36; ++ coverage Code(Expression(0)) => $DIR/instrument_coverage_cleanup.rs:14:37 - 14:39; ++ coverage Code(Counter(1)) => $DIR/instrument_coverage_cleanup.rs:14:39 - 14:40; ++ coverage Code(Expression(1)) => $DIR/instrument_coverage_cleanup.rs:15:1 - 15:2; ++ coverage Branch { true_term: Expression(0), false_term: Counter(1) } => $DIR/instrument_coverage_cleanup.rs:14:8 - 14:36; + bb0: { + Coverage::CounterIncrement(0); diff --git a/tests/mir-opt/instrument_coverage_cleanup.rs b/tests/mir-opt/instrument_coverage_cleanup.rs index 8a2fd67139b..7db76339e55 100644 --- a/tests/mir-opt/instrument_coverage_cleanup.rs +++ b/tests/mir-opt/instrument_coverage_cleanup.rs @@ -7,7 +7,6 @@ //@ unit-test: InstrumentCoverage //@ compile-flags: -Cinstrument-coverage -Zcoverage-options=branch -Zno-profiler-runtime -//@ compile-flags: --remap-path-prefix={{src-base}}=/the/src // EMIT_MIR instrument_coverage_cleanup.main.InstrumentCoverage.diff // EMIT_MIR instrument_coverage_cleanup.main.CleanupPostBorrowck.diff diff --git a/tests/ui/binding/issue-53114-safety-checks.stderr b/tests/ui/binding/issue-53114-safety-checks.stderr index b7d805d9171..9d909e915c2 100644 --- a/tests/ui/binding/issue-53114-safety-checks.stderr +++ b/tests/ui/binding/issue-53114-safety-checks.stderr @@ -1,3 +1,23 @@ +error[E0793]: reference to packed field is unaligned + --> $DIR/issue-53114-safety-checks.rs:23:13 + | +LL | let _ = &p.b; + | ^^^^ + | + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) + +error[E0793]: reference to packed field is unaligned + --> $DIR/issue-53114-safety-checks.rs:28:17 + | +LL | let (_,) = (&p.b,); + | ^^^^ + | + = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses + = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) + error[E0133]: access to union field is unsafe and requires unsafe function or block --> $DIR/issue-53114-safety-checks.rs:24:13 | @@ -31,20 +51,20 @@ LL | let (_,) = (&u2.a,); = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0793]: reference to packed field is unaligned - --> $DIR/issue-53114-safety-checks.rs:23:13 + --> $DIR/issue-53114-safety-checks.rs:37:16 | -LL | let _ = &p.b; - | ^^^^ +LL | let _: _ = &p.b; + | ^^^^ | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned - --> $DIR/issue-53114-safety-checks.rs:28:17 + --> $DIR/issue-53114-safety-checks.rs:42:20 | -LL | let (_,) = (&p.b,); - | ^^^^ +LL | let (_,): _ = (&p.b,); + | ^^^^ | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) @@ -83,20 +103,20 @@ LL | let (_,): _ = (&u2.a,); = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0793]: reference to packed field is unaligned - --> $DIR/issue-53114-safety-checks.rs:37:16 + --> $DIR/issue-53114-safety-checks.rs:51:11 | -LL | let _: _ = &p.b; - | ^^^^ +LL | match &p.b { _ => { } } + | ^^^^ | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned - --> $DIR/issue-53114-safety-checks.rs:42:20 + --> $DIR/issue-53114-safety-checks.rs:56:12 | -LL | let (_,): _ = (&p.b,); - | ^^^^ +LL | match (&p.b,) { (_,) => { } } + | ^^^^ | = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) @@ -134,26 +154,6 @@ LL | match (&u2.a,) { (_,) => { } } | = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior -error[E0793]: reference to packed field is unaligned - --> $DIR/issue-53114-safety-checks.rs:51:11 - | -LL | match &p.b { _ => { } } - | ^^^^ - | - = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses - = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) - = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) - -error[E0793]: reference to packed field is unaligned - --> $DIR/issue-53114-safety-checks.rs:56:12 - | -LL | match (&p.b,) { (_,) => { } } - | ^^^^ - | - = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses - = note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) - = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) - error: aborting due to 18 previous errors Some errors have detailed explanations: E0133, E0793. diff --git a/tests/ui/const-generics/const-argument-if-length.full.stderr b/tests/ui/const-generics/const-argument-if-length.full.stderr index db3d88392bd..4de98c11d2b 100644 --- a/tests/ui/const-generics/const-argument-if-length.full.stderr +++ b/tests/ui/const-generics/const-argument-if-length.full.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | pad: [u8; is_zst::<T>()], | ^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); is_zst::<T>()]:` +help: try adding a `where` bound + | +LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: { + | ++++++++++++++++++++++++++ error[E0277]: the size for values of type `T` cannot be known at compilation time --> $DIR/const-argument-if-length.rs:16:12 diff --git a/tests/ui/const-generics/defaults/generic-expr-default.stderr b/tests/ui/const-generics/defaults/generic-expr-default.stderr index ada1498d1c8..909edada4cb 100644 --- a/tests/ui/const-generics/defaults/generic-expr-default.stderr +++ b/tests/ui/const-generics/defaults/generic-expr-default.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> { | ^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:` +help: try adding a `where` bound + | +LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> where [(); { N + 1 }]: { + | ++++++++++++++++++++++ error: unconstrained generic constant --> $DIR/generic-expr-default.rs:14:58 @@ -12,7 +15,10 @@ error: unconstrained generic constant LL | fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N> | ^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:` +help: try adding a `where` bound + | +LL | fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N> where [(); { N + 1 }]: + | ++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/ensure_is_evaluatable.stderr b/tests/ui/const-generics/ensure_is_evaluatable.stderr index b9bd9160b13..62f8bc34f2e 100644 --- a/tests/ui/const-generics/ensure_is_evaluatable.stderr +++ b/tests/ui/const-generics/ensure_is_evaluatable.stderr @@ -4,7 +4,6 @@ error: unconstrained generic constant LL | bar() | ^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); N + 1]:` note: required by a bound in `bar` --> $DIR/ensure_is_evaluatable.rs:15:10 | @@ -13,6 +12,10 @@ LL | fn bar<const N: usize>() -> [(); N] LL | where LL | [(); N + 1]:, | ^^^^^ required by this bound in `bar` +help: try adding a `where` bound + | +LL | [(); M + 1]:, [(); N + 1]: + | ~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/fn_with_two_const_inputs.stderr b/tests/ui/const-generics/fn_with_two_const_inputs.stderr index ec31e02f144..c0a913a21fd 100644 --- a/tests/ui/const-generics/fn_with_two_const_inputs.stderr +++ b/tests/ui/const-generics/fn_with_two_const_inputs.stderr @@ -4,7 +4,6 @@ error: unconstrained generic constant LL | bar() | ^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); N + 1]:` note: required by a bound in `bar` --> $DIR/fn_with_two_const_inputs.rs:18:10 | @@ -13,6 +12,10 @@ LL | fn bar<const N: usize>() -> [(); N] LL | where LL | [(); N + 1]:, | ^^^^^ required by this bound in `bar` +help: try adding a `where` bound + | +LL | [(); both(N + 1, M + 1)]:, [(); N + 1]: + | ~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.fixed b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.fixed new file mode 100644 index 00000000000..929282f40e6 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.fixed @@ -0,0 +1,21 @@ +//@ run-rustfix +#![feature(generic_const_exprs)] +#![allow(incomplete_features, dead_code)] + +struct Evaluatable<const N: u128> {} + +struct Foo<const N: u8>([u8; N as usize]) +//~^ ERROR unconstrained generic constant +where + Evaluatable<{N as u128}>:, [(); N as usize]:; +//~^ HELP try adding a `where` bound + +struct Foo2<const N: u8>(Evaluatable::<{N as u128}>) where Evaluatable<{N as usize as u128 }>:, [(); {N as u128} as usize]:; +//~^ ERROR unconstrained generic constant +//~| HELP try adding a `where` bound + +struct Bar<const N: u8>([u8; (N + 2) as usize]) where [(); (N + 1) as usize]:, [(); (N + 2) as usize]:; +//~^ ERROR unconstrained generic constant +//~| HELP try adding a `where` bound + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs index 3b5b87b2b3d..3a6c4d35451 100644 --- a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs +++ b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs @@ -1,20 +1,21 @@ +//@ run-rustfix #![feature(generic_const_exprs)] -#![allow(incomplete_features)] +#![allow(incomplete_features, dead_code)] struct Evaluatable<const N: u128> {} struct Foo<const N: u8>([u8; N as usize]) -//~^ Error: unconstrained generic constant -//~| help: try adding a `where` bound using this expression: `where [(); N as usize]:` +//~^ ERROR unconstrained generic constant where Evaluatable<{N as u128}>:; +//~^ HELP try adding a `where` bound struct Foo2<const N: u8>(Evaluatable::<{N as u128}>) where Evaluatable<{N as usize as u128 }>:; -//~^ Error: unconstrained generic constant -//~| help: try adding a `where` bound using this expression: `where [(); {N as u128}]:` +//~^ ERROR unconstrained generic constant +//~| HELP try adding a `where` bound struct Bar<const N: u8>([u8; (N + 2) as usize]) where [(); (N + 1) as usize]:; -//~^ Error: unconstrained generic constant -//~| help: try adding a `where` bound using this expression: `where [(); (N + 2) as usize]:` +//~^ ERROR unconstrained generic constant +//~| HELP try adding a `where` bound fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr index 5ca04d25e55..ce8eca8d25e 100644 --- a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr +++ b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr @@ -1,26 +1,35 @@ error: unconstrained generic constant - --> $DIR/abstract-const-as-cast-2.rs:6:25 + --> $DIR/abstract-const-as-cast-2.rs:7:25 | LL | struct Foo<const N: u8>([u8; N as usize]) | ^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); N as usize]:` +help: try adding a `where` bound + | +LL | Evaluatable<{N as u128}>:, [(); N as usize]:; + | +++++++++++++++++++ error: unconstrained generic constant - --> $DIR/abstract-const-as-cast-2.rs:12:26 + --> $DIR/abstract-const-as-cast-2.rs:13:26 | LL | struct Foo2<const N: u8>(Evaluatable::<{N as u128}>) where Evaluatable<{N as usize as u128 }>:; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); {N as u128}]:` +help: try adding a `where` bound + | +LL | struct Foo2<const N: u8>(Evaluatable::<{N as u128}>) where Evaluatable<{N as usize as u128 }>:, [(); {N as u128} as usize]:; + | +++++++++++++++++++++++++++++ error: unconstrained generic constant - --> $DIR/abstract-const-as-cast-2.rs:16:25 + --> $DIR/abstract-const-as-cast-2.rs:17:25 | LL | struct Bar<const N: u8>([u8; (N + 2) as usize]) where [(); (N + 1) as usize]:; | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); (N + 2) as usize]:` +help: try adding a `where` bound + | +LL | struct Bar<const N: u8>([u8; (N + 2) as usize]) where [(); (N + 1) as usize]:, [(); (N + 2) as usize]:; + | +++++++++++++++++++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr index bd6fd67b89d..3622ef16a96 100644 --- a/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr +++ b/tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr @@ -4,7 +4,6 @@ error: unconstrained generic constant LL | assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as u128 }>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { O as u128 }]:` note: required for `HasCastInTraitImpl<{ N + 1 }, { N as u128 }>` to implement `Trait` --> $DIR/abstract-const-as-cast-3.rs:8:22 | @@ -15,6 +14,10 @@ note: required by a bound in `use_trait_impl::assert_impl` | LL | fn assert_impl<T: Trait>() {} | ^^^^^ required by this bound in `assert_impl` +help: try adding a `where` bound + | +LL | EvaluatableU128<{N as u128}>:, [(); { O as u128 } as usize]: { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0308]: mismatched types --> $DIR/abstract-const-as-cast-3.rs:17:5 @@ -36,7 +39,6 @@ error: unconstrained generic constant LL | assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as _ }>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { O as u128 }]:` note: required for `HasCastInTraitImpl<{ N + 1 }, { N as _ }>` to implement `Trait` --> $DIR/abstract-const-as-cast-3.rs:8:22 | @@ -47,6 +49,10 @@ note: required by a bound in `use_trait_impl::assert_impl` | LL | fn assert_impl<T: Trait>() {} | ^^^^^ required by this bound in `assert_impl` +help: try adding a `where` bound + | +LL | EvaluatableU128<{N as u128}>:, [(); { O as u128 } as usize]: { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0308]: mismatched types --> $DIR/abstract-const-as-cast-3.rs:20:5 @@ -96,7 +102,6 @@ error: unconstrained generic constant LL | assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as u128 }>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { O as u128 }]:` note: required for `HasCastInTraitImpl<{ N + 1 }, { N as u128 }>` to implement `Trait` --> $DIR/abstract-const-as-cast-3.rs:8:22 | @@ -107,6 +112,10 @@ note: required by a bound in `use_trait_impl_2::assert_impl` | LL | fn assert_impl<T: Trait>() {} | ^^^^^ required by this bound in `assert_impl` +help: try adding a `where` bound + | +LL | EvaluatableU128<{N as _}>:, [(); { O as u128 } as usize]: { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0308]: mismatched types --> $DIR/abstract-const-as-cast-3.rs:35:5 @@ -128,7 +137,6 @@ error: unconstrained generic constant LL | assert_impl::<HasCastInTraitImpl<{ N + 1 }, { N as _ }>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { O as u128 }]:` note: required for `HasCastInTraitImpl<{ N + 1 }, { N as _ }>` to implement `Trait` --> $DIR/abstract-const-as-cast-3.rs:8:22 | @@ -139,6 +147,10 @@ note: required by a bound in `use_trait_impl_2::assert_impl` | LL | fn assert_impl<T: Trait>() {} | ^^^^^ required by this bound in `assert_impl` +help: try adding a `where` bound + | +LL | EvaluatableU128<{N as _}>:, [(); { O as u128 } as usize]: { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0308]: mismatched types --> $DIR/abstract-const-as-cast-3.rs:38:5 diff --git a/tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr b/tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr index 4b76ae6cfd5..5fc36ebc929 100644 --- a/tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr +++ b/tests/ui/const-generics/generic_const_exprs/abstract-consts-as-cast-5.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | bar::<{ N as usize as usize }>(); | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { N as usize as usize }]:` +help: try adding a `where` bound + | +LL | fn foo<const N: u8>(a: [(); N as usize]) where [(); { N as usize as usize }]: { + | ++++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr index c478718b4cc..471b850d8d5 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]); | ^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); 0 + N]:` +help: try adding a `where` bound + | +LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]) where [(); 0 + N]:; + | ++++++++++++++++++ error: overly complex generic constant --> $DIR/array-size-in-generic-struct-param.rs:23:15 diff --git a/tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr b/tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr index a8657bf5263..f3a38fcc005 100644 --- a/tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr +++ b/tests/ui/const-generics/generic_const_exprs/assoc_const_unification/doesnt_unify_evaluatable.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | bar::<{ T::ASSOC }>(); | ^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { T::ASSOC }]:` +help: try adding a `where` bound + | +LL | fn foo<T: Trait, U: Trait>() where [(); U::ASSOC]:, [(); { T::ASSOC }]: { + | ~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr index 9a8aa222dc1..0c29d94ed5b 100644 --- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr @@ -24,7 +24,10 @@ error: unconstrained generic constant LL | foo::<_, L>([(); L + 1 + L]); | ^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:` +help: try adding a `where` bound + | +LL | [(); (L - 1) + 1 + L]:, [(); L + 1 + L]: + | ~~~~~~~~~~~~~~~~~~ error: unconstrained generic constant --> $DIR/issue_114151.rs:17:17 @@ -34,11 +37,6 @@ LL | foo::<_, L>([(); L + 1 + L]); | | | required by a bound introduced by this call | - = help: try adding a `where` bound using this expression: `where [(); { - { - N - } - }]:` note: required by a bound in `foo` --> $DIR/issue_114151.rs:5:13 | @@ -51,6 +49,14 @@ LL | | N LL | | } LL | | }], | |_____^ required by this bound in `foo` +help: try adding a `where` bound + | +LL ~ [(); (L - 1) + 1 + L]:, [(); { +LL + { +LL + N +LL + } +LL + }]: + | error: unconstrained generic constant `L + 1 + L` --> $DIR/issue_114151.rs:17:5 diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr index ba824e84a5a..6a62c0b4778 100644 --- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_binop_arg_tys.stderr @@ -13,7 +13,10 @@ error: unconstrained generic constant LL | Bar::<{ make_generic(N, 1_u8 == 0_u8) }> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { make_generic(N, 1_u8 == 0_u8) }]:` +help: try adding a `where` bound + | +LL | fn foo<const N: usize>() -> Bar<{ make_generic(N, true == false) }> where [(); { make_generic(N, 1_u8 == 0_u8) } as usize]: { + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr index d3ba870a2d7..fba8b9e7784 100644 --- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/relate_cast_arg_ty.stderr @@ -13,7 +13,10 @@ error: unconstrained generic constant LL | [(); (1_u8 as usize) + N] | ^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); (1_u8 as usize) + N]:` +help: try adding a `where` bound + | +LL | fn foo<const N: usize>() -> [(); (true as usize) + N] where [(); (1_u8 as usize) + N]: { + | ++++++++++++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr index da5194696e6..99eab935a09 100644 --- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/wf_obligation.stderr @@ -13,7 +13,10 @@ error: unconstrained generic constant LL | foo::<_, L>([(); L + 1 + L]); | ^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); L + 1 + L]:` +help: try adding a `where` bound + | +LL | [(); (L - 1) + 1 + L]:, [(); L + 1 + L]: + | ~~~~~~~~~~~~~~~~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.rs b/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.rs new file mode 100644 index 00000000000..f58fd12e4d3 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.rs @@ -0,0 +1,17 @@ +// ICE cannot convert Refree.. to a region vid +// issue: rust-lang/rust#114464 + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn test<const N: usize>() {} + +fn wow<'a>() { + test::<{ + let _: &'a (); + //~^ ERROR cannot capture late-bound lifetime in constant + 3 + }>(); +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.stderr b/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.stderr new file mode 100644 index 00000000000..a234c5e129d --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/convert-refree-region-vid-ice-114464.stderr @@ -0,0 +1,11 @@ +error: cannot capture late-bound lifetime in constant + --> $DIR/convert-refree-region-vid-ice-114464.rs:11:17 + | +LL | fn wow<'a>() { + | -- lifetime defined here +LL | test::<{ +LL | let _: &'a (); + | ^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr index 921314f0c50..a05aaf2af64 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr @@ -4,7 +4,6 @@ error: unconstrained generic constant LL | let _ = const_evaluatable_lib::test1::<T>(); | ^ | - = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:` note: required by a bound in `test1` --> $DIR/auxiliary/const_evaluatable_lib.rs:5:10 | @@ -13,6 +12,10 @@ LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1] LL | where LL | [u8; std::mem::size_of::<T>() - 1]: Sized, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` +help: try adding a `where` bound + | +LL | fn user<T>() where [(); std::mem::size_of::<T>() - 1]: { + | +++++++++++++++++++++++++++++++++++++++++ error: unconstrained generic constant --> $DIR/cross_crate_predicate.rs:7:44 @@ -20,12 +23,15 @@ error: unconstrained generic constant LL | let _ = const_evaluatable_lib::test1::<T>(); | ^ | - = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:` note: required by a bound in `test1` --> $DIR/auxiliary/const_evaluatable_lib.rs:3:27 | LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` +help: try adding a `where` bound + | +LL | fn user<T>() where [(); std::mem::size_of::<T>() - 1]: { + | +++++++++++++++++++++++++++++++++++++++++ error: unconstrained generic constant --> $DIR/cross_crate_predicate.rs:7:13 @@ -33,7 +39,6 @@ error: unconstrained generic constant LL | let _ = const_evaluatable_lib::test1::<T>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:` note: required by a bound in `test1` --> $DIR/auxiliary/const_evaluatable_lib.rs:5:10 | @@ -42,6 +47,10 @@ LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1] LL | where LL | [u8; std::mem::size_of::<T>() - 1]: Sized, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` +help: try adding a `where` bound + | +LL | fn user<T>() where [(); std::mem::size_of::<T>() - 1]: { + | +++++++++++++++++++++++++++++++++++++++++ error: unconstrained generic constant --> $DIR/cross_crate_predicate.rs:7:13 @@ -49,12 +58,15 @@ error: unconstrained generic constant LL | let _ = const_evaluatable_lib::test1::<T>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:` note: required by a bound in `test1` --> $DIR/auxiliary/const_evaluatable_lib.rs:3:27 | LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` +help: try adding a `where` bound + | +LL | fn user<T>() where [(); std::mem::size_of::<T>() - 1]: { + | +++++++++++++++++++++++++++++++++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr index 74111ef1d38..632ece0ddcb 100644 --- a/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dependence_lint.gce.stderr @@ -20,7 +20,10 @@ error: unconstrained generic constant LL | let _: [u8; size_of::<*mut T>()]; // error on stable, error with gce | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); size_of::<*mut T>()]:` +help: try adding a `where` bound + | +LL | fn foo<T>() where [(); size_of::<*mut T>()]: { + | ++++++++++++++++++++++++++++++++ error: unconstrained generic constant --> $DIR/dependence_lint.rs:10:9 @@ -28,7 +31,10 @@ error: unconstrained generic constant LL | [0; size_of::<*mut T>()]; // lint on stable, error with `generic_const_exprs` | ^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); size_of::<*mut T>()]:` +help: try adding a `where` bound + | +LL | fn foo<T>() where [(); size_of::<*mut T>()]: { + | ++++++++++++++++++++++++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/different-fn.stderr b/tests/ui/const-generics/generic_const_exprs/different-fn.stderr index 83a2f3740b1..52917df0da1 100644 --- a/tests/ui/const-generics/generic_const_exprs/different-fn.stderr +++ b/tests/ui/const-generics/generic_const_exprs/different-fn.stderr @@ -13,7 +13,10 @@ error: unconstrained generic constant LL | [0; size_of::<Foo<T>>()] | ^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); size_of::<Foo<T>>()]:` +help: try adding a `where` bound + | +LL | fn test<T>() -> [u8; size_of::<T>()] where [(); size_of::<Foo<T>>()]: { + | ++++++++++++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr b/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr index 87e26ce85dc..f27d52a1437 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr @@ -13,7 +13,10 @@ error: unconstrained generic constant LL | ArrayHolder([0; Self::SIZE]) | ^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); Self::SIZE]:` +help: try adding a `where` bound + | +LL | pub const fn new() -> Self where [(); Self::SIZE]: { + | +++++++++++++++++++++++ error[E0282]: type annotations needed for `ArrayHolder<X>` --> $DIR/issue-62504.rs:26:9 diff --git a/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr b/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr index b693023f125..ca6681b635a 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr @@ -13,12 +13,15 @@ error: unconstrained generic constant LL | self.reference.size() | ^^^^ | - = help: try adding a `where` bound using this expression: `where [(); Self::DIM]:` note: required by a bound in `TensorSize::size` --> $DIR/issue-83765.rs:9:31 | LL | fn size(&self) -> [usize; Self::DIM]; | ^^^^^^^^^ required by this bound in `TensorSize::size` +help: try adding a `where` bound + | +LL | fn size(&self) -> [usize; DIM] where [(); Self::DIM]: { + | ++++++++++++++++++++++ error[E0308]: mismatched types --> $DIR/issue-83765.rs:32:9 diff --git a/tests/ui/const-generics/generic_const_exprs/issue-85848.stderr b/tests/ui/const-generics/generic_const_exprs/issue-85848.stderr index 3acccba026f..4abe39eb598 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-85848.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-85848.stderr @@ -35,7 +35,6 @@ LL | writes_to_specific_path(&cap); | | | required by a bound introduced by this call | - = help: try adding a `where` bound using this expression: `where [(); { contains::<T, U>() }]:` note: required for `&C` to implement `Contains<(), true>` --> $DIR/issue-85848.rs:21:12 | @@ -53,6 +52,10 @@ note: required by a bound in `writes_to_specific_path` | LL | fn writes_to_specific_path<C: Delegates<()>>(cap: &C) {} | ^^^^^^^^^^^^^ required by this bound in `writes_to_specific_path` +help: try adding a `where` bound + | +LL | fn writes_to_path<C>(cap: &C) where [(); { contains::<T, U>() } as usize]: { + | ++++++++++++++++++++++++++++++++++++++++++++ error[E0308]: mismatched types --> $DIR/issue-85848.rs:24:5 diff --git a/tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr b/tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr index 395088bf2f2..c83e859ac79 100644 --- a/tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr +++ b/tests/ui/const-generics/generic_const_exprs/needs_where_clause.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | b: [f32; complex_maths::<T>(N)], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); complex_maths::<T>(N)]:` +help: try adding a `where` bound + | +LL | struct Example<T, const N: usize> where [(); complex_maths::<T>(N)]: { + | ++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.rs b/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.rs new file mode 100644 index 00000000000..5673f1dd073 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.rs @@ -0,0 +1,13 @@ +// ICE no entry found for key generics_of +// issue: rust-lang/rust#113133 + +#![allow(incomplete_features)] +#![feature(generic_const_exprs, non_lifetime_binders)] + +pub fn foo() +where + for<const N: usize = { const fn bar() {} bar(); 1 }> ():, + //~^ ERROR defaults for generic parameters are not allowed in `for<...>` binders +{} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.stderr b/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.stderr new file mode 100644 index 00000000000..5924a673da9 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/no-entry-found-for-key-ice-gce-nlb-113133.stderr @@ -0,0 +1,8 @@ +error: defaults for generic parameters are not allowed in `for<...>` binders + --> $DIR/no-entry-found-for-key-ice-gce-nlb-113133.rs:9:9 + | +LL | for<const N: usize = { const fn bar() {} bar(); 1 }> ():, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr b/tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr index 4a87649f43d..a2680eac039 100644 --- a/tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr +++ b/tests/ui/const-generics/generic_const_exprs/no_where_clause.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | b: [f32; complex_maths(N)], | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); complex_maths(N)]:` +help: try adding a `where` bound + | +LL | pub struct Example<const N: usize> where [(); complex_maths(N)]: { + | +++++++++++++++++++++++++++++ error: unconstrained generic constant --> $DIR/no_where_clause.rs:18:15 @@ -12,7 +15,10 @@ error: unconstrained generic constant LL | b: [0.; complex_maths(N)], | ^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); complex_maths(N)]:` +help: try adding a `where` bound + | +LL | pub fn new() -> Self where [(); complex_maths(N)]: { + | +++++++++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs new file mode 100644 index 00000000000..51cae20df84 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs @@ -0,0 +1,39 @@ +// rust-lang/rust#119731 +// ICE ... unevaluated constant UnevaluatedConst + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +mod v20 { + const v4: usize = 512; + pub type v11 = [[usize; v4]; v4]; + //~^ WARN type `v11` should have an upper camel case name + const v2: v11 = [[256; v4]; v4]; + + const v0: [[usize; v4]; v4] = v6(v8); + //~^ ERROR cannot find value `v8` in this scope + //~| ERROR cannot find function `v6` in this scope + pub struct v17<const v10: usize, const v7: v11> { + //~^ WARN type `v17` should have an upper camel case name + //~| ERROR `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter + _p: (), + } + + impl v17<512, v0> { + pub const fn v21() -> v18 {} + //~^ ERROR cannot find type `v18` in this scope + } + + impl<const v10: usize> v17<v10, v2> { + //~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1} + //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1} + pub const fn v21() -> v18 { + //~^ ERROR cannot find type `v18` in this scope + v18 { _p: () } + //~^ ERROR cannot find struct, variant or union type `v18` in this scope + } + } +} +pub use v20::{v13, v17}; +//~^ ERROR unresolved import `v20::v13` +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr new file mode 100644 index 00000000000..39f022fbee9 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -0,0 +1,92 @@ +error[E0432]: unresolved import `v20::v13` + --> $DIR/unevaluated-const-ice-119731.rs:37:15 + | +LL | pub use v20::{v13, v17}; + | ^^^ + | | + | no `v13` in `v20` + | help: a similar name exists in the module: `v11` + +error[E0425]: cannot find value `v8` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:13:38 + | +LL | const v0: [[usize; v4]; v4] = v6(v8); + | ^^ not found in this scope + +error[E0412]: cannot find type `v18` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:23:31 + | +LL | pub type v11 = [[usize; v4]; v4]; + | --------------------------------- similarly named type alias `v11` defined here +... +LL | pub const fn v21() -> v18 {} + | ^^^ help: a type alias with a similar name exists: `v11` + +error[E0412]: cannot find type `v18` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:30:31 + | +LL | pub type v11 = [[usize; v4]; v4]; + | --------------------------------- similarly named type alias `v11` defined here +... +LL | pub const fn v21() -> v18 { + | ^^^ help: a type alias with a similar name exists: `v11` + +error[E0422]: cannot find struct, variant or union type `v18` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:32:13 + | +LL | pub type v11 = [[usize; v4]; v4]; + | --------------------------------- similarly named type alias `v11` defined here +... +LL | v18 { _p: () } + | ^^^ help: a type alias with a similar name exists: `v11` + +warning: type `v11` should have an upper camel case name + --> $DIR/unevaluated-const-ice-119731.rs:9:14 + | +LL | pub type v11 = [[usize; v4]; v4]; + | ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V11` + | + = note: `#[warn(non_camel_case_types)]` on by default + +warning: type `v17` should have an upper camel case name + --> $DIR/unevaluated-const-ice-119731.rs:16:16 + | +LL | pub struct v17<const v10: usize, const v7: v11> { + | ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V17` + +error[E0425]: cannot find function `v6` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:13:35 + | +LL | const v0: [[usize; v4]; v4] = v6(v8); + | ^^ not found in this scope + +error: `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter + --> $DIR/unevaluated-const-ice-119731.rs:16:48 + | +LL | pub struct v17<const v10: usize, const v7: v11> { + | ^^^ + | + = 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: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1} + --> $DIR/unevaluated-const-ice-119731.rs:27:37 + | +LL | impl<const v10: usize> v17<v10, v2> { + | ^^ + +error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1} + --> $DIR/unevaluated-const-ice-119731.rs:27:37 + | +LL | impl<const v10: usize> v17<v10, v2> { + | ^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 9 previous errors; 2 warnings emitted + +Some errors have detailed explanations: E0412, E0422, E0425, E0432. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr index 0bf99bb8b26..335130c958f 100644 --- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr @@ -40,7 +40,10 @@ error: unconstrained generic constant LL | bar2::<{ std::ops::Add::add(N, N) }>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { std::ops::Add::add(N, N) }]:` +help: try adding a `where` bound + | +LL | fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) where [(); { std::ops::Add::add(N, N) }]: { + | +++++++++++++++++++++++++++++++++++++++++ error[E0015]: cannot call non-const operator in constants --> $DIR/unify-op-with-fn-call.rs:20:39 diff --git a/tests/ui/const-generics/issues/issue-67739.full.stderr b/tests/ui/const-generics/issues/issue-67739.full.stderr index bdf05023d5f..99368a66148 100644 --- a/tests/ui/const-generics/issues/issue-67739.full.stderr +++ b/tests/ui/const-generics/issues/issue-67739.full.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | [0u8; mem::size_of::<Self::Associated>()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); mem::size_of::<Self::Associated>()]:` +help: try adding a `where` bound + | +LL | fn associated_size(&self) -> usize where [(); mem::size_of::<Self::Associated>()]: { + | +++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-71202.stderr b/tests/ui/const-generics/issues/issue-71202.stderr index 437b808c893..a2d38221852 100644 --- a/tests/ui/const-generics/issues/issue-71202.stderr +++ b/tests/ui/const-generics/issues/issue-71202.stderr @@ -10,24 +10,27 @@ LL | | <IsCopy<T>>::VALUE LL | | } as usize] = []; | |_____________________^ | - = help: try adding a `where` bound using this expression: `where [(); 1 - { - trait NotCopy { - const VALUE: bool = false; - } - - impl<__Type: ?Sized> NotCopy for __Type {} - - struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); - - impl<__Type> IsCopy<__Type> - where - __Type: Sized + Copy, - { - const VALUE: bool = true; - } - - <IsCopy<T>>::VALUE - } as usize]:` +help: try adding a `where` bound + | +LL ~ } as usize] where [(); 1 - { +LL + trait NotCopy { +LL + const VALUE: bool = false; +LL + } +LL + +LL + impl<__Type: ?Sized> NotCopy for __Type {} +LL + +LL + struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); +LL + +LL + impl<__Type> IsCopy<__Type> +LL + where +LL + __Type: Sized + Copy, +LL + { +LL + const VALUE: bool = true; +LL + } +LL + +LL + <IsCopy<T>>::VALUE +LL ~ } as usize]: = []; + | error: unconstrained generic constant --> $DIR/issue-71202.rs:28:19 @@ -35,24 +38,27 @@ error: unconstrained generic constant LL | } as usize] = []; | ^^ | - = help: try adding a `where` bound using this expression: `where [(); 1 - { - trait NotCopy { - const VALUE: bool = false; - } - - impl<__Type: ?Sized> NotCopy for __Type {} - - struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); - - impl<__Type> IsCopy<__Type> - where - __Type: Sized + Copy, - { - const VALUE: bool = true; - } - - <IsCopy<T>>::VALUE - } as usize]:` +help: try adding a `where` bound + | +LL ~ } as usize] where [(); 1 - { +LL + trait NotCopy { +LL + const VALUE: bool = false; +LL + } +LL + +LL + impl<__Type: ?Sized> NotCopy for __Type {} +LL + +LL + struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); +LL + +LL + impl<__Type> IsCopy<__Type> +LL + where +LL + __Type: Sized + Copy, +LL + { +LL + const VALUE: bool = true; +LL + } +LL + +LL + <IsCopy<T>>::VALUE +LL ~ } as usize]: = []; + | error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-84659.fixed b/tests/ui/const-generics/issues/issue-84659.fixed new file mode 100644 index 00000000000..85f1adc5c19 --- /dev/null +++ b/tests/ui/const-generics/issues/issue-84659.fixed @@ -0,0 +1,13 @@ +//@ run-rustfix +#![allow(incomplete_features, dead_code, unused_braces)] +#![feature(generic_const_exprs)] + +trait Bar<const N: usize> {} + +trait Foo<'a> { + const N: usize; + type Baz: Bar<{ Self::N }> where [(); { Self::N }]:; + //~^ ERROR: unconstrained generic constant +} + +fn main() {} diff --git a/tests/ui/const-generics/issues/issue-84659.rs b/tests/ui/const-generics/issues/issue-84659.rs index 440ca740af2..b2ea6320f73 100644 --- a/tests/ui/const-generics/issues/issue-84659.rs +++ b/tests/ui/const-generics/issues/issue-84659.rs @@ -1,4 +1,5 @@ -#![allow(incomplete_features)] +//@ run-rustfix +#![allow(incomplete_features, dead_code, unused_braces)] #![feature(generic_const_exprs)] trait Bar<const N: usize> {} diff --git a/tests/ui/const-generics/issues/issue-84659.stderr b/tests/ui/const-generics/issues/issue-84659.stderr index 796c5515e04..82e80603c7f 100644 --- a/tests/ui/const-generics/issues/issue-84659.stderr +++ b/tests/ui/const-generics/issues/issue-84659.stderr @@ -1,10 +1,13 @@ error: unconstrained generic constant - --> $DIR/issue-84659.rs:8:15 + --> $DIR/issue-84659.rs:9:15 | LL | type Baz: Bar<{ Self::N }>; | ^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { Self::N }]:` +help: try adding a `where` bound + | +LL | type Baz: Bar<{ Self::N }> where [(); { Self::N }]:; + | ++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-90455.fixed b/tests/ui/const-generics/issues/issue-90455.fixed new file mode 100644 index 00000000000..2502d47eb46 --- /dev/null +++ b/tests/ui/const-generics/issues/issue-90455.fixed @@ -0,0 +1,13 @@ +//@ run-rustfix +#![feature(generic_const_exprs, adt_const_params)] +#![allow(incomplete_features, dead_code)] + +struct FieldElement<const N: &'static str> where [(); num_limbs(N)]: { + n: [u64; num_limbs(N)], + //~^ ERROR unconstrained generic constant +} +const fn num_limbs(_: &str) -> usize { + 0 +} + +fn main() {} diff --git a/tests/ui/const-generics/issues/issue-90455.rs b/tests/ui/const-generics/issues/issue-90455.rs index a580410cf37..794c7d76cb1 100644 --- a/tests/ui/const-generics/issues/issue-90455.rs +++ b/tests/ui/const-generics/issues/issue-90455.rs @@ -1,5 +1,6 @@ +//@ run-rustfix #![feature(generic_const_exprs, adt_const_params)] -#![allow(incomplete_features)] +#![allow(incomplete_features, dead_code)] struct FieldElement<const N: &'static str> { n: [u64; num_limbs(N)], diff --git a/tests/ui/const-generics/issues/issue-90455.stderr b/tests/ui/const-generics/issues/issue-90455.stderr index 1db90609572..1fcc08db579 100644 --- a/tests/ui/const-generics/issues/issue-90455.stderr +++ b/tests/ui/const-generics/issues/issue-90455.stderr @@ -1,10 +1,13 @@ error: unconstrained generic constant - --> $DIR/issue-90455.rs:5:8 + --> $DIR/issue-90455.rs:6:8 | LL | n: [u64; num_limbs(N)], | ^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); num_limbs(N)]:` +help: try adding a `where` bound + | +LL | struct FieldElement<const N: &'static str> where [(); num_limbs(N)]: { + | +++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-needs_drop-monomorphic.stderr b/tests/ui/consts/const-needs_drop-monomorphic.stderr index 0874a70ce39..446d34810c5 100644 --- a/tests/ui/consts/const-needs_drop-monomorphic.stderr +++ b/tests/ui/consts/const-needs_drop-monomorphic.stderr @@ -13,7 +13,10 @@ error: unconstrained generic constant LL | Bool::<{ std::mem::needs_drop::<T>() }>::assert(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); { std::mem::needs_drop::<T>() }]:` +help: try adding a `where` bound + | +LL | fn f<T>() where [(); { std::mem::needs_drop::<T>() } as usize]: { + | +++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/coroutine/clone-rpit.next.stderr b/tests/ui/coroutine/clone-rpit.next.stderr index 02d3390496a..41aa2d63af0 100644 --- a/tests/ui/coroutine/clone-rpit.next.stderr +++ b/tests/ui/coroutine/clone-rpit.next.stderr @@ -14,11 +14,6 @@ note: ...which requires promoting constants in MIR for `foo::{closure#0}`... | LL | move |_: ()| { | ^^^^^^^^^^^^ -note: ...which requires preparing `foo::{closure#0}` for borrow checking... - --> $DIR/clone-rpit.rs:14:5 - | -LL | move |_: ()| { - | ^^^^^^^^^^^^ note: ...which requires checking if `foo::{closure#0}` contains FFI-unwind calls... --> $DIR/clone-rpit.rs:14:5 | diff --git a/tests/ui/delegation/ice-issue-122550.rs b/tests/ui/delegation/ice-issue-122550.rs new file mode 100644 index 00000000000..92c0dda9605 --- /dev/null +++ b/tests/ui/delegation/ice-issue-122550.rs @@ -0,0 +1,18 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +trait Trait { + fn description(&self) -> &str {} + //~^ ERROR mismatched types +} + +struct F; +struct S(F); + +impl S { + reuse <S as Trait>::description { &self.0 } + //~^ ERROR mismatched types + //~| ERROR the trait bound `S: Trait` is not satisfied +} + +fn main() {} diff --git a/tests/ui/delegation/ice-issue-122550.stderr b/tests/ui/delegation/ice-issue-122550.stderr new file mode 100644 index 00000000000..c92170644e7 --- /dev/null +++ b/tests/ui/delegation/ice-issue-122550.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/ice-issue-122550.rs:5:35 + | +LL | fn description(&self) -> &str {} + | ^^ expected `&str`, found `()` + +error[E0308]: mismatched types + --> $DIR/ice-issue-122550.rs:13:39 + | +LL | reuse <S as Trait>::description { &self.0 } + | ^^^^^^^ expected `&S`, found `&F` + | + = note: expected reference `&S` + found reference `&F` + +error[E0277]: the trait bound `S: Trait` is not satisfied + --> $DIR/ice-issue-122550.rs:13:12 + | +LL | reuse <S as Trait>::description { &self.0 } + | ^ the trait `Trait` is not implemented for `S` + | +help: this trait has no implementations, consider adding one + --> $DIR/ice-issue-122550.rs:4:1 + | +LL | trait Trait { + | ^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs b/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs new file mode 100644 index 00000000000..f5babb67b56 --- /dev/null +++ b/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs @@ -0,0 +1,35 @@ +// ICE assertion failed: matches!(self.def_kind(ct.def.did), DefKind :: AnonConst) +// issue: rust-lang/rust#108220 +//@ check-pass + +#![feature(associated_const_equality)] +#![allow(unused)] + +use std::marker::PhantomData; + +pub struct NoPin; + +pub trait SetAlternate<const A: u8> {} + +impl SetAlternate<0> for NoPin {} + +pub trait PinA<PER> { + const A: u8; +} + +impl<PER> PinA<PER> for NoPin { + const A: u8 = 0; +} + +pub trait Pins<USART> {} + +impl<USART, T, const TA: u8> Pins<USART> for T where + T: PinA<USART, A = { TA }> + SetAlternate<TA> +{ +} + +struct Serial<USART>(PhantomData<USART>); + +impl<USART> Serial<USART> where NoPin: Pins<USART> {} + +fn main() {} diff --git a/tests/ui/generic-const-items/evaluatable-bounds.fixed b/tests/ui/generic-const-items/evaluatable-bounds.fixed new file mode 100644 index 00000000000..de1baffbcdb --- /dev/null +++ b/tests/ui/generic-const-items/evaluatable-bounds.fixed @@ -0,0 +1,25 @@ +// This is a regression test for issue #104400. + +//@ run-rustfix + +// Test that we can constrain generic const items that appear inside associated consts by +// adding a (makeshift) "evaluatable"-bound to the item, after applying the suggestion. + +#![feature(generic_const_items, generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait { + const LEN: usize; + + const ARRAY: [i32; Self::LEN] where [(); Self::LEN]:; //~ ERROR unconstrained generic constant + +} + +impl Trait for () { + const LEN: usize = 2; + const ARRAY: [i32; Self::LEN] = [360, 720]; +} + +fn main() { + let [_, _] = <() as Trait>::ARRAY; +} diff --git a/tests/ui/generic-const-items/evaluatable-bounds.rs b/tests/ui/generic-const-items/evaluatable-bounds.rs index 1a858f41999..b47801360f9 100644 --- a/tests/ui/generic-const-items/evaluatable-bounds.rs +++ b/tests/ui/generic-const-items/evaluatable-bounds.rs @@ -1,10 +1,9 @@ // This is a regression test for issue #104400. -//@ revisions: unconstrained constrained -//@[constrained] check-pass +//@ run-rustfix // Test that we can constrain generic const items that appear inside associated consts by -// adding a (makeshift) "evaluatable"-bound to the item. +// adding a (makeshift) "evaluatable"-bound to the item, after applying the suggestion. #![feature(generic_const_items, generic_const_exprs)] #![allow(incomplete_features)] @@ -12,13 +11,8 @@ trait Trait { const LEN: usize; - #[cfg(unconstrained)] - const ARRAY: [i32; Self::LEN]; //[unconstrained]~ ERROR unconstrained generic constant + const ARRAY: [i32; Self::LEN]; //~ ERROR unconstrained generic constant - #[cfg(constrained)] - const ARRAY: [i32; Self::LEN] - where - [(); Self::LEN]:; } impl Trait for () { diff --git a/tests/ui/generic-const-items/evaluatable-bounds.stderr b/tests/ui/generic-const-items/evaluatable-bounds.stderr new file mode 100644 index 00000000000..ca26d633658 --- /dev/null +++ b/tests/ui/generic-const-items/evaluatable-bounds.stderr @@ -0,0 +1,13 @@ +error: unconstrained generic constant + --> $DIR/evaluatable-bounds.rs:14:5 + | +LL | const ARRAY: [i32; Self::LEN]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try adding a `where` bound + | +LL | const ARRAY: [i32; Self::LEN] where [(); Self::LEN]:; + | ++++++++++++++++++++++ + +error: aborting due to 1 previous error + diff --git a/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr b/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr index 1475d988ea4..b6f9bdce1cb 100644 --- a/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr +++ b/tests/ui/generic-const-items/evaluatable-bounds.unconstrained.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | const ARRAY: [i32; Self::LEN]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); Self::LEN]:` +help: try adding a `where` bound + | +LL | const ARRAY: [i32; Self::LEN] where [(); Self::LEN]:; + | ++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.rs b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.rs new file mode 100644 index 00000000000..bb10701cf6f --- /dev/null +++ b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.rs @@ -0,0 +1,16 @@ +// ICE expected ReFree to map to ReEarlyBound +// issue: rust-lang/rust#108580 +//@ check-pass + +trait Foo { + fn bar(&self) -> impl Iterator<Item = impl Sized> + '_; +} + +impl Foo for () { + fn bar(&self) -> impl Iterator + '_ { + //~^ WARN impl trait in impl method signature does not match trait method signature + vec![()].into_iter() + } +} + +pub fn main() {} diff --git a/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr new file mode 100644 index 00000000000..94f068cabaa --- /dev/null +++ b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr @@ -0,0 +1,19 @@ +warning: impl trait in impl method signature does not match trait method signature + --> $DIR/expeced-refree-to-map-to-reearlybound-ice-108580.rs:10:22 + | +LL | fn bar(&self) -> impl Iterator<Item = impl Sized> + '_; + | ------------------------------------- return type from trait method defined here +... +LL | fn bar(&self) -> impl Iterator + '_ { + | ^^^^^^^^^^^^^^^^^^ + | + = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate + = note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information + = note: `#[warn(refining_impl_trait_internal)]` on by default +help: replace the return type so that it matches the trait + | +LL | fn bar(&self) -> impl Iterator<Item = impl Sized> + '_ { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +warning: 1 warning emitted + diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs new file mode 100644 index 00000000000..0b2e63bfcf7 --- /dev/null +++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.rs @@ -0,0 +1,18 @@ +// ICE in mir building with captured value of unresolved type +// None in compiler/rustc_mir_build/src/build/expr/as_place.rs +// issue: rust-lang/rust#110453 +//@ edition:2021 + +#![crate_type="lib"] + +pub struct B; +pub fn a() -> B { B } + +mod handlers { + pub struct C(B); + //~^ ERROR cannot find type `B` in this scope + pub fn c() -> impl Fn() -> C { + let a1 = (); + || C((crate::a(), a1).into()) + } +} diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr new file mode 100644 index 00000000000..468da0227d3 --- /dev/null +++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-1.stderr @@ -0,0 +1,14 @@ +error[E0412]: cannot find type `B` in this scope + --> $DIR/mir-build-2021-closure-capture-ice-110453-1.rs:12:18 + | +LL | pub struct C(B); + | ^ not found in this scope + | +help: consider importing this struct + | +LL + use crate::B; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs new file mode 100644 index 00000000000..d63ccc6651c --- /dev/null +++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.rs @@ -0,0 +1,11 @@ +// ICE in mir building with captured value of unresolved type +// None in compiler/rustc_mir_build/src/build/expr/as_place.rs +// issue: rust-lang/rust#110453 +//@ edition:2021 + +#![crate_type="lib"] + +pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 { +//~^ ERROR cannot find type `as_str` in this scope + move |a| f(a * 2) +} diff --git a/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr new file mode 100644 index 00000000000..8fe4981eb3f --- /dev/null +++ b/tests/ui/mir/mir-build-2021-closure-capture-ice-110453-2.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `as_str` in this scope + --> $DIR/mir-build-2021-closure-capture-ice-110453-2.rs:8:47 + | +LL | pub fn dup(f: impl Fn(i32) -> i32) -> impl Fn(as_str) -> i32 { + | ^^^^^^ not found in this scope + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/nll/unexpected-inference-var-ice-116599.rs b/tests/ui/nll/unexpected-inference-var-ice-116599.rs new file mode 100644 index 00000000000..53eeba23224 --- /dev/null +++ b/tests/ui/nll/unexpected-inference-var-ice-116599.rs @@ -0,0 +1,44 @@ +// ICE unexpected inference var +// issue: rust-lang/rust#116599 +//@ check-pass + +pub trait EvaluateConstMethods { + type Trait: TraitWithConstMethods; + + /// **This block breaks** + const DATA_3: Data3 = { + <<<Self::Trait as TraitWithConstMethods>::Method2 as ConstFn<_, _>>::Body< + <<Self::Trait as TraitWithConstMethods>::Method1 as ConstFn<_, _>>::Body<ContainsData1>, + > as Contains<_>>::ITEM + }; +} + +pub trait TraitWithConstMethods { + /// "const trait method" of signature `fn(Data1) -> Data2` + type Method1: ConstFn<Data1, Data2>; + + /// "const trait method" of signature `fn(Data2) -> Data3` + type Method2: ConstFn<Data2, Data3>; +} + +/// A trait which tries to implement const methods in traits +pub trait ConstFn<Arg, Ret> { + type Body<T: Contains<Arg>>: Contains<Ret>; +} + +/// A ZST which represents / "contains" a const value which can be pass to a [`ConstFn`] +pub trait Contains<T> { + const ITEM: T; +} + +pub struct ContainsData1; +impl Contains<Data1> for ContainsData1 { + const ITEM: Data1 = Data1 {}; +} + +// Arbitrary data +pub struct Data1 {} +pub struct Data2 {} +pub struct Data3 {} + +pub fn main() {} diff --git a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs index aeccd0d9f76..ada10fcda27 100644 --- a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs +++ b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs @@ -4,12 +4,12 @@ impl S { fn foo(&mur Self) {} //~^ ERROR expected identifier, found keyword `Self` //~| ERROR expected one of `:`, `@` - //~| ERROR the `Self` constructor can only be used with + //~| ERROR expected unit struct, found self constructor `Self` fn bar(&'static mur Self) {} //~^ ERROR unexpected lifetime //~| ERROR expected identifier, found keyword `Self` //~| ERROR expected one of `:`, `@` - //~| ERROR the `Self` constructor can only be used with + //~| ERROR expected unit struct, found self constructor `Self` fn baz(&mur Self @ _) {} //~^ ERROR expected one of `:`, `@` diff --git a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr index 421f1454036..ec0af9a6caf 100644 --- a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr +++ b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr @@ -40,17 +40,18 @@ error: expected one of `:`, `@`, or `|`, found keyword `Self` LL | fn baz(&mur Self @ _) {} | ^^^^ expected one of `:`, `@`, or `|` -error: the `Self` constructor can only be used with tuple or unit structs +error[E0533]: expected unit struct, found self constructor `Self` --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17 | LL | fn foo(&mur Self) {} - | ^^^^ help: use curly brackets: `Self { /* fields */ }` + | ^^^^ not a unit struct -error: the `Self` constructor can only be used with tuple or unit structs +error[E0533]: expected unit struct, found self constructor `Self` --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25 | LL | fn bar(&'static mur Self) {} - | ^^^^ help: use curly brackets: `Self { /* fields */ }` + | ^^^^ not a unit struct error: aborting due to 8 previous errors +For more information about this error, try `rustc --explain E0533`. diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs b/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs new file mode 100644 index 00000000000..7c2821e77ab --- /dev/null +++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs @@ -0,0 +1,37 @@ +//@ revisions: tuple unit struct_ +//@[unit] check-pass + +#[cfg(unit)] +mod unit { + struct S; + impl S { + fn foo() { + let Self = S; + } + } +} + +#[cfg(tuple)] +mod tuple { + struct S(()); + impl S { + fn foo() { + let Self = S; + //[tuple]~^ ERROR expected unit struct + } + } +} + +#[cfg(struct_)] +mod struct_ { + struct S {} + impl S { + fn foo() { + let Self = S; + //[struct_]~^ ERROR expected value, found struct `S` + //[struct_]~| ERROR expected unit struct, found self constructor `Self` + } + } +} + +fn main() {} diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr b/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr new file mode 100644 index 00000000000..5ed3979feb8 --- /dev/null +++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr @@ -0,0 +1,19 @@ +error[E0423]: expected value, found struct `S` + --> $DIR/no-match-tuple-variant-self-ctor.rs:30:24 + | +LL | struct S {} + | ----------- `S` defined here +... +LL | let Self = S; + | ^ help: use struct literal syntax instead: `S {}` + +error[E0533]: expected unit struct, found self constructor `Self` + --> $DIR/no-match-tuple-variant-self-ctor.rs:30:17 + | +LL | let Self = S; + | ^^^^ not a unit struct + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0423, E0533. +For more information about an error, try `rustc --explain E0423`. diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.tuple.stderr b/tests/ui/pattern/no-match-tuple-variant-self-ctor.tuple.stderr new file mode 100644 index 00000000000..d31a4a79189 --- /dev/null +++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.tuple.stderr @@ -0,0 +1,9 @@ +error[E0533]: expected unit struct, found self constructor `Self` + --> $DIR/no-match-tuple-variant-self-ctor.rs:19:17 + | +LL | let Self = S; + | ^^^^ not a unit struct + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0533`. diff --git a/tests/ui/resolve/multiple_definitions_attribute_merging.stderr b/tests/ui/resolve/multiple_definitions_attribute_merging.stderr index b2d20af883a..98cad18d442 100644 --- a/tests/ui/resolve/multiple_definitions_attribute_merging.stderr +++ b/tests/ui/resolve/multiple_definitions_attribute_merging.stderr @@ -18,8 +18,8 @@ LL | struct Dealigned<T>(u8, T); | = Box<dyn Any> query stack during panic: -#0 [mir_const] preparing `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq` for borrow checking -#1 [mir_promoted] promoting constants in MIR for `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq` +#0 [mir_built] building MIR for `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq` +#1 [check_unsafety] unsafety-checking `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq` end of query stack error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/proc_macro_generated_packed.stderr b/tests/ui/resolve/proc_macro_generated_packed.stderr index 507e5867c90..4e716704610 100644 --- a/tests/ui/resolve/proc_macro_generated_packed.stderr +++ b/tests/ui/resolve/proc_macro_generated_packed.stderr @@ -9,8 +9,8 @@ LL | struct Dealigned<T>(u8, T); | = Box<dyn Any> query stack during panic: -#0 [mir_const] preparing `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq` for borrow checking -#1 [mir_promoted] promoting constants in MIR for `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq` +#0 [mir_built] building MIR for `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq` +#1 [check_unsafety] unsafety-checking `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq` end of query stack error: aborting due to 1 previous error diff --git a/tests/ui/sanitizer/cfi-complex-receiver.rs b/tests/ui/sanitizer/cfi-complex-receiver.rs new file mode 100644 index 00000000000..c3e59258db2 --- /dev/null +++ b/tests/ui/sanitizer/cfi-complex-receiver.rs @@ -0,0 +1,42 @@ +// Check that more complex receivers work: +// * Arc<dyn Foo> as for custom receivers +// * &dyn Bar<T=Baz> for type constraints + +//@ needs-sanitizer-cfi +// FIXME(#122848) Remove only-linux once OSX CFI binaries work +//@ only-linux +//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi +//@ compile-flags: -C target-feature=-crt-static -C codegen-units=1 -C opt-level=0 +//@ run-pass + +use std::sync::Arc; + +trait Foo { + fn foo(self: Arc<Self>); +} + +struct FooImpl; + +impl Foo for FooImpl { + fn foo(self: Arc<Self>) {} +} + +trait Bar { + type T; + fn bar(&self) -> Self::T; +} + +struct BarImpl; + +impl Bar for BarImpl { + type T = i32; + fn bar(&self) -> Self::T { 7 } +} + +fn main() { + let foo: Arc<dyn Foo> = Arc::new(FooImpl); + foo.foo(); + + let bar: &dyn Bar<T=i32> = &BarImpl; + assert_eq!(bar.bar(), 7); +} diff --git a/tests/ui/sanitizer/cfi-drop-no-principal.rs b/tests/ui/sanitizer/cfi-drop-no-principal.rs new file mode 100644 index 00000000000..c1c88c8c71c --- /dev/null +++ b/tests/ui/sanitizer/cfi-drop-no-principal.rs @@ -0,0 +1,21 @@ +// Check that dropping a trait object without a principal trait succeeds + +//@ needs-sanitizer-cfi +// FIXME(#122848) Remove only-linux once OSX CFI binaries works +//@ only-linux +//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi +//@ compile-flags: -C target-feature=-crt-static -C codegen-units=1 -C opt-level=0 +// FIXME(#118761) Should be run-pass once the labels on drop are compatible. +// This test is being landed ahead of that to test that the compiler doesn't ICE while labeling the +// callsite for a drop, but the vtable doesn't have the correct label yet. +//@ build-pass + +struct CustomDrop; + +impl Drop for CustomDrop { + fn drop(&mut self) {} +} + +fn main() { + let _ = Box::new(CustomDrop) as Box<dyn Send>; +} diff --git a/tests/ui/simd/array-trait.stderr b/tests/ui/simd/array-trait.stderr index 16ff732396d..a63dbf37959 100644 --- a/tests/ui/simd/array-trait.stderr +++ b/tests/ui/simd/array-trait.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | pub struct T<S: Simd>([S::Lane; S::SIZE]); | ^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); S::SIZE]:` +help: try adding a `where` bound + | +LL | pub struct T<S: Simd>([S::Lane; S::SIZE]) where [(); S::SIZE]:; + | ++++++++++++++++++++ error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type --> $DIR/array-trait.rs:23:1 @@ -20,7 +23,6 @@ LL | #[derive(Copy, Clone)] LL | pub struct T<S: Simd>([S::Lane; S::SIZE]); | ^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); S::SIZE]:` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/specialization/issue-51892.stderr b/tests/ui/specialization/issue-51892.stderr index 9553a04c8f6..b1cabc0ac0e 100644 --- a/tests/ui/specialization/issue-51892.stderr +++ b/tests/ui/specialization/issue-51892.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<<T as Trait>::Type>()]:` +help: try adding a `where` bound + | +LL | type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()] where [(); std::mem::size_of::<<T as Trait>::Type>()]:; + | ++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.rs b/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.rs new file mode 100644 index 00000000000..6f0f233b870 --- /dev/null +++ b/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.rs @@ -0,0 +1,15 @@ +// ICE min_specialization: +// Ok(['?0, Const { ty: usize, kind: Leaf(0x0000000000000000) }]) is not fully resolved +// issue: rust-lang/rust#113045 + +#![feature(min_specialization)] + +trait X {} + +impl<'a, const N: usize> X for [(); N] {} + +impl<'a, Unconstrained> X for [(); 0] {} +//~^ ERROR the type parameter `Unconstrained` is not constrained by the impl trait, self type, or predicates +//~| ERROR specialization impl does not specialize any associated items + +fn main() {} diff --git a/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.stderr b/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.stderr new file mode 100644 index 00000000000..acbdb9b0a30 --- /dev/null +++ b/tests/ui/specialization/min_specialization/ice-const-not-fully-resolved-113045.stderr @@ -0,0 +1,21 @@ +error[E0207]: the type parameter `Unconstrained` is not constrained by the impl trait, self type, or predicates + --> $DIR/ice-const-not-fully-resolved-113045.rs:11:10 + | +LL | impl<'a, Unconstrained> X for [(); 0] {} + | ^^^^^^^^^^^^^ unconstrained type parameter + +error: specialization impl does not specialize any associated items + --> $DIR/ice-const-not-fully-resolved-113045.rs:11:1 + | +LL | impl<'a, Unconstrained> X for [(); 0] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: impl is a specialization of this impl + --> $DIR/ice-const-not-fully-resolved-113045.rs:9:1 + | +LL | impl<'a, const N: usize> X for [(); N] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs new file mode 100644 index 00000000000..5cccda62608 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs @@ -0,0 +1,21 @@ +// ICE 'broken MIR: bad assignment: NoSolution' +// on trait with default method and no impls +// issue: rust-lang/rust#109869 + +type Spanned<T> = (T, ()); + +trait Span<T> {} + +impl<T> Span<T> for (T, ()) {} + +impl<F, T: From<F>> From<Spanned<F>> for dyn Span<T> +where + Self: Sized +{ + fn from((from, ()): Spanned<F>) -> Self { + (T::from(from), ()) + //~^ ERROR mismatched types + } +} + +pub fn main() {} diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.stderr b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.stderr new file mode 100644 index 00000000000..d43c9c01821 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-1.rs:16:9 + | +LL | fn from((from, ()): Spanned<F>) -> Self { + | ---- expected `(dyn Span<T> + 'static)` because of return type +LL | (T::from(from), ()) + | ^^^^^^^^^^^^^^^^^^^ expected `dyn Span`, found `(T, ())` + | + = note: expected trait object `(dyn Span<T> + 'static)` + found tuple `(T, ())` + = help: `(T, ())` implements `Span` so you could box the found value and coerce it to the trait object `Box<dyn Span>`, you will have to change the expected type as well +help: call `Into::into` on this expression to convert `(T, ())` into `(dyn Span<T> + 'static)` + | +LL | (T::from(from), ()).into() + | +++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs new file mode 100644 index 00000000000..2e0179fb164 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs @@ -0,0 +1,17 @@ +// ICE 'broken MIR: bad assignment: NoSolution' +// on trait with default method and no impls +// issue: rust-lang/rust#109869 + +trait Empty<T> {} + +impl<T> Default for dyn Empty<T> +where + Self: Sized, +{ + fn default() -> Self { + () + //~^ ERROR mismatched types + } +} + +pub fn main() {} diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.stderr b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.stderr new file mode 100644 index 00000000000..5f00ced09b8 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-2.rs:12:9 + | +LL | fn default() -> Self { + | ---- expected `(dyn Empty<T> + 'static)` because of return type +LL | () + | ^^ expected `dyn Empty`, found `()` + | + = note: expected trait object `(dyn Empty<T> + 'static)` + found unit type `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs new file mode 100644 index 00000000000..d8bc2a4321e --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs @@ -0,0 +1,18 @@ +// ICE 'broken MIR: bad assignment: NoSolution' +// on trait with default method and no impls +// issue: rust-lang/rust#109869 + +#![feature(trivial_bounds)] +trait Empty {} + +impl Default for dyn Empty +where + Self: Sized, +{ + fn default() -> Self { + () + //~^ ERROR mismatched types + } +} + +pub fn main() {} diff --git a/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.stderr b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.stderr new file mode 100644 index 00000000000..872b7f5cee1 --- /dev/null +++ b/tests/ui/traits/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/ice-trait-with-default-method-but-no-impl-broken-mir-109869-trivial-bounds.rs:13:9 + | +LL | fn default() -> Self { + | ---- expected `(dyn Empty + 'static)` because of return type +LL | () + | ^^ expected `dyn Empty`, found `()` + | + = note: expected trait object `(dyn Empty + 'static)` + found unit type `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr index df466609a12..084008d8b2a 100644 --- a/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr +++ b/tests/ui/type-alias-enum-variants/self-in-enum-definition.stderr @@ -34,11 +34,6 @@ note: ...which requires const checking `Alpha::V3::{constant#0}`... | LL | V3 = Self::V1 {} as u8 + 2, | ^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires preparing `Alpha::V3::{constant#0}` for borrow checking... - --> $DIR/self-in-enum-definition.rs:5:10 - | -LL | V3 = Self::V1 {} as u8 + 2, - | ^^^^^^^^^^^^^^^^^^^^^ note: ...which requires building MIR for `Alpha::V3::{constant#0}`... --> $DIR/self-in-enum-definition.rs:5:10 | diff --git a/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs b/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs new file mode 100644 index 00000000000..c5ee46024f9 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/closure-normalization-ice-109020.rs @@ -0,0 +1,41 @@ +// ICE Failed to normalize closure with TAIT +// issue: rust-lang/rust#109020 +//@ check-pass + +#![feature(type_alias_impl_trait)] + +use std::marker::PhantomData; + +type WithEmplacableForFn<'a> = impl EmplacableFn + 'a; + +fn with_emplacable_for<'a, F, R>(mut f: F) -> R +where + F: for<'b> FnMut(Emplacable<WithEmplacableForFn<'b>>) -> R, +{ + fn with_emplacable_for_inner<'a, R>( + _: &'a (), + _: &mut dyn FnMut(Emplacable<WithEmplacableForFn<'a>>) -> R, + ) -> R { + fn _constrain(_: &mut ()) -> WithEmplacableForFn<'_> { + () + } + loop {} + } + + with_emplacable_for_inner(&(), &mut f) +} + +trait EmplacableFn {} + +impl EmplacableFn for () {} + +struct Emplacable<F> +where + F: EmplacableFn, +{ + phantom: PhantomData<F>, +} + +fn main() { + with_emplacable_for(|_| {}); +} diff --git a/tests/ui/unpretty/avoid-crash.rs b/tests/ui/unpretty/avoid-crash.rs index 94aa7e77dcb..2105068617b 100644 --- a/tests/ui/unpretty/avoid-crash.rs +++ b/tests/ui/unpretty/avoid-crash.rs @@ -1,4 +1,4 @@ //@ normalize-stderr-test "error `.*`" -> "$$ERROR_MESSAGE" -//@ compile-flags: -o/tmp/ -Zunpretty=ast-tree +//@ compile-flags: -o. -Zunpretty=ast-tree fn main() {} diff --git a/tests/ui/unpretty/avoid-crash.stderr b/tests/ui/unpretty/avoid-crash.stderr index 6fa3e8ca630..1c966754e94 100644 --- a/tests/ui/unpretty/avoid-crash.stderr +++ b/tests/ui/unpretty/avoid-crash.stderr @@ -1,4 +1,4 @@ -error: failed to write `/tmp/` due to $ERROR_MESSAGE +error: failed to write `.` due to $ERROR_MESSAGE error: aborting due to 1 previous error diff --git a/tests/ui/variance/variance-associated-consts.stderr b/tests/ui/variance/variance-associated-consts.stderr index f41574ca3a3..b955a7686c2 100644 --- a/tests/ui/variance/variance-associated-consts.stderr +++ b/tests/ui/variance/variance-associated-consts.stderr @@ -4,7 +4,10 @@ error: unconstrained generic constant LL | field: [u8; <T as Trait>::Const] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: try adding a `where` bound using this expression: `where [(); <T as Trait>::Const]:` +help: try adding a `where` bound + | +LL | struct Foo<T: Trait> where [(); <T as Trait>::Const]: { + | ++++++++++++++++++++++++++++++++ error: [o] --> $DIR/variance-associated-consts.rs:13:1 diff --git a/tests/ui/warnings/no-explicit-path-issue-122509.rs b/tests/ui/warnings/no-explicit-path-issue-122509.rs new file mode 100644 index 00000000000..4e8eefde5da --- /dev/null +++ b/tests/ui/warnings/no-explicit-path-issue-122509.rs @@ -0,0 +1,23 @@ +//@ build-pass +//@ compile-flags: -C codegen-units=2 --emit asm + +fn one() -> usize { + 1 +} + +pub mod a { + pub fn two() -> usize { + ::one() + ::one() + } +} + +pub mod b { + pub fn three() -> usize { + ::one() + ::a::two() + } +} + +fn main() { + a::two(); + b::three(); +} |
