-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)C-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
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
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)C-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.