Closed
Description
opened on Jun 18, 2019
Rustc complains about the trait not being implemented for [(); _]
, but actually it's given a [(); 1]
literal and for that one, the trait is implemented. Turbofishing foo::<[(); 0]>([])
doesn't help.
see also #61383
Code ↓
#![feature(const_generics)]
trait Foo {}
impl<const N: usize> Foo for [(); N]
where
Self:FooImpl<{N==0}>
{}
trait FooImpl<const IS_ZERO: bool>{}
impl FooImpl<{0u8==0u8}> for [();0] {}
impl<const N:usize> FooImpl<{0u8!=0u8}> for [();N] {}
fn foo<T: Foo>(v: T) {}
fn main() {
foo([]);
foo([()]);
}
Error ↓
error[E0277]: the trait bound `[(); _]: FooImpl<{N==0}>` is not satisfied
--> src/lib.rs:18:5
|
18 | foo([]);
| ^^^ the trait `FooImpl<{N==0}>` is not implemented for `[(); _]`
|
= help: the following implementations were found:
<[(); 0] as FooImpl<true>>
<[(); _] as FooImpl<false>>
= note: required because of the requirements on the impl of `Foo` for `[(); 0]`
note: required by `foo`
--> src/lib.rs:15:1
|
15 | fn foo<T: Foo>(v: T) {}
| ^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `[(); _]: FooImpl<{N==0}>` is not satisfied
--> src/lib.rs:19:5
|
19 | foo([()]);
| ^^^ the trait `FooImpl<{N==0}>` is not implemented for `[(); _]`
|
= help: the following implementations were found:
<[(); 0] as FooImpl<true>>
<[(); _] as FooImpl<false>>
= note: required because of the requirements on the impl of `Foo` for `[(); 1]`
note: required by `foo`
--> src/lib.rs:15:1
|
15 | fn foo<T: Foo>(v: T) {}
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Lazy normalization (tracking issue: #60471)Category: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.`#![feature(const_generics)]`Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.
Activity