-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unsatisfied trait bound uses _
for unevaluated constants
#82934
Comments
new repro #![allow(incomplete_features)]
#![feature(generic_const_exprs)]
struct ArrayVec<T: Array>(Option<T>);
impl<T: Array> ArrayVec<T> {
fn new() -> Self {
Self(None)
}
fn push(&mut self, v: T::Value) {}
fn into_inner(self) -> Result<T, ()> {
todo!()
}
}
trait Array {
type Value;
}
impl<T> Array for [T; 0] {
type Value = T;
}
impl<T> Array for [T; 1] {
type Value = T;
}
fn append<T, const N: usize>(start: [T; N], v: T) -> [T; N + 1] {
let mut xs = ArrayVec::new();
for _ in 0..N {
xs.push(v);
}
xs.push(v);
match xs.into_inner() {
Ok(xs) => xs,
_ => unreachable!()
}
} Error message is still bad, but at least somewhat sensible now error[E0277]: the trait bound `[T; _]: Array` is not satisfied
--> src/lib.rs:33:14
|
33 | match xs.into_inner() {
| ^^^^^^^^^^ the trait `Array` is not implemented for `[T; _]`
|
note: required by a bound in `ArrayVec::<T>::into_inner`
--> src/lib.rs:5:9
|
5 | impl<T: Array> ArrayVec<T> {
| ^^^^^ required by this bound in `ArrayVec::<T>::into_inner`
...
12 | fn into_inner(self) -> Result<T, ()> {
| ---------- required by a bound in this
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
27 | fn append<T, const N: usize>(start: [T; N], v: T) -> [T; N + 1] where [T; _]: Array {
| +++++++++++++++++++
error[E0277]: the trait bound `[T; _]: Array` is not satisfied
--> src/lib.rs:30:12
|
30 | xs.push(v);
| ^^^^ the trait `Array` is not implemented for `[T; _]`
|
note: required by a bound in `ArrayVec::<T>::push`
--> src/lib.rs:5:9
|
5 | impl<T: Array> ArrayVec<T> {
| ^^^^^ required by this bound in `ArrayVec::<T>::push`
...
10 | fn push(&mut self, v: T::Value) {}
| ---- required by a bound in this
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
27 | fn append<T, const N: usize>(start: [T; N], v: T) -> [T; N + 1] where [T; _]: Array {
| +++++++++++++++++++
error[E0277]: the trait bound `[T; _]: Array` is not satisfied
--> src/lib.rs:32:8
|
32 | xs.push(v);
| ^^^^ the trait `Array` is not implemented for `[T; _]`
|
note: required by a bound in `ArrayVec::<T>::push`
--> src/lib.rs:5:9
|
5 | impl<T: Array> ArrayVec<T> {
| ^^^^^ required by this bound in `ArrayVec::<T>::push`
...
10 | fn push(&mut self, v: T::Value) {}
| ---- required by a bound in this
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
27 | fn append<T, const N: usize>(start: [T; N], v: T) -> [T; N + 1] where [T; _]: Array {
| +++++++++++++++++++
error[E0277]: the trait bound `[T; _]: Array` is not satisfied
--> src/lib.rs:28:18
|
28 | let mut xs = ArrayVec::new();
| ^^^^^^^^^^^^^ the trait `Array` is not implemented for `[T; _]`
|
note: required by a bound in `ArrayVec::<T>::new`
--> src/lib.rs:5:9
|
5 | impl<T: Array> ArrayVec<T> {
| ^^^^^ required by this bound in `ArrayVec::<T>::new`
6 | fn new() -> Self {
| --- required by a bound in this
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
27 | fn append<T, const N: usize>(start: [T; N], v: T) -> [T; N + 1] where [T; _]: Array {
| +++++++++++++++++++
error[E0277]: the trait bound `[T; _]: Array` is not satisfied
--> src/lib.rs:28:18
|
28 | let mut xs = ArrayVec::new();
| ^^^^^^^^ the trait `Array` is not implemented for `[T; _]`
|
note: required by a bound in `ArrayVec`
--> src/lib.rs:4:20
|
4 | struct ArrayVec<T: Array>(Option<T>);
| ^^^^^ required by this bound in `ArrayVec`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
27 | fn append<T, const N: usize>(start: [T; N], v: T) -> [T; N + 1] where [T; _]: Array {
| +++++++++++++++++++ +++++++++++++++++++ |
We do have to issue that unevaluated constants are printed as Maybe it makes sense to look at that again, but as we are slowly working towards a new const generics implementation, it might also not be worth the effort 😅 |
_
for unevaluated constants
This seems to be fixed now, I suspect #106873 did it |
Given the following code:
The current output is:
Ideally the output should:
N
.The text was updated successfully, but these errors were encountered: