diff options
| author | lcnr <rust@lcnr.de> | 2025-08-21 15:45:40 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-08-21 15:49:02 +0200 |
| commit | e8ae1dab12bc1388cd5f6545ccc88297b779f511 (patch) | |
| tree | 884c838cddbacdf9fda7396fb1f090392aa308e6 /tests | |
| parent | 57e620e56b718abaf47f18e1e20a3cc3480b258b (diff) | |
| download | rust-e8ae1dab12bc1388cd5f6545ccc88297b779f511.tar.gz rust-e8ae1dab12bc1388cd5f6545ccc88297b779f511.zip | |
next-solver fix const_trait_impl bootstrap
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/traits/const-traits/constructor-const-fn.rs | 15 | ||||
| -rw-r--r-- | tests/ui/traits/const-traits/reservation-impl-ice.rs | 13 | ||||
| -rw-r--r-- | tests/ui/traits/const-traits/reservation-impl-ice.stderr | 25 |
3 files changed, 53 insertions, 0 deletions
diff --git a/tests/ui/traits/const-traits/constructor-const-fn.rs b/tests/ui/traits/const-traits/constructor-const-fn.rs new file mode 100644 index 00000000000..4a7bf531df2 --- /dev/null +++ b/tests/ui/traits/const-traits/constructor-const-fn.rs @@ -0,0 +1,15 @@ +//@ check-pass +//@ compile-flags: -Znext-solver +#![feature(const_trait_impl)] +const fn impls_fn<F: ~const Fn(u32) -> Foo>(_: &F) {} + +struct Foo(u32); + +const fn foo() { + // This previously triggered an incorrect assert + // when checking whether the constructor of `Foo` + // is const. + impls_fn(&Foo) +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/reservation-impl-ice.rs b/tests/ui/traits/const-traits/reservation-impl-ice.rs new file mode 100644 index 00000000000..efaea1cc6b2 --- /dev/null +++ b/tests/ui/traits/const-traits/reservation-impl-ice.rs @@ -0,0 +1,13 @@ +//@ compile-flags: -Znext-solver +#![feature(const_from, never_type, const_trait_impl)] + +const fn impls_from<T: ~const From<!>>() {} + +const fn foo() { + // This previously ICE'd when encountering the reservation impl + // from the standard library. + impls_from::<()>(); + //~^ ERROR the trait bound `(): From<!>` is not satisfied +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/reservation-impl-ice.stderr b/tests/ui/traits/const-traits/reservation-impl-ice.stderr new file mode 100644 index 00000000000..a3fdcbac69e --- /dev/null +++ b/tests/ui/traits/const-traits/reservation-impl-ice.stderr @@ -0,0 +1,25 @@ +error[E0277]: the trait bound `(): From<!>` is not satisfied + --> $DIR/reservation-impl-ice.rs:9:18 + | +LL | impls_from::<()>(); + | ^^ the trait `From<!>` is not implemented for `()` + | + = help: the following other types implement trait `From<T>`: + `(T, T)` implements `From<[T; 2]>` + `(T, T, T)` implements `From<[T; 3]>` + `(T, T, T, T)` implements `From<[T; 4]>` + `(T, T, T, T, T)` implements `From<[T; 5]>` + `(T, T, T, T, T, T)` implements `From<[T; 6]>` + `(T, T, T, T, T, T, T)` implements `From<[T; 7]>` + `(T, T, T, T, T, T, T, T)` implements `From<[T; 8]>` + `(T, T, T, T, T, T, T, T, T)` implements `From<[T; 9]>` + and 4 others +note: required by a bound in `impls_from` + --> $DIR/reservation-impl-ice.rs:4:24 + | +LL | const fn impls_from<T: ~const From<!>>() {} + | ^^^^^^^^^^^^^^ required by this bound in `impls_from` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. |
