-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.
Description
Given the following code:
pub trait ExtraFieldHeader {
fn header_id(&self) -> u16;
}
pub trait FixedIDZIPExtraField<const ID: u16> {
const HEADER_ID: u16 = ID;
/// Gets header ID (Unique for each type of extra fields)
fn header_id(&self) -> u16 {
Self::HEADER_ID
}
}
impl<T, const ID: u16> ExtraFieldHeader for T where T: FixedIDZIPExtraField<ID> {}
The current output is:
error[E0207]: the const parameter `ID` is not constrained by the impl trait, self type, or predicates
--> src\zip_extra_field.rs:27:9
|
27 | impl<T, const ID: u16> ExtraFieldHeader for T where T: FixedIDZIPExtraField<ID> {}
| ^^^^^^^^^^^^^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported
Ideally the output should look like:
(no errors)
I believe ID
is constrained for FiexedIDZIPExtraField<ID>
and this error must not be raised. Could someone provide a solution?
rustc --version
rustc 1.62.1 (e092d0b6b 2022-07-16)
kiljacken, aDogCalledSpot, mohamed-said, tversteeg, anko and 1 more
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.