You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Const parameter defaults are not used as a fallback during type inference #96300
structA<constN:usize = 64>{}// impl A { // Works because it's specialized to 64impl<constN:usize>A<N>{// Failsfnnew() -> Self{todo!();}}pubfnblah(){A::new();}
I expected to see this happen: the const generic would be inferred to 64.
Instead, this happened: fails to compile. An attempt to fix it by doing impl<const N: usize = 64> doesn't work because it's disallowed.
This has nothing to do with “specialization” (#![feature(specialization)]) but with the known issue of type / const parameter defaults not being used as a fallback for failed inference. Duplicate of the closed issue #83687.
changed the title [-]Lack of impl specialization causes failed const generic inference[/-][+]Const parameter defaults are not used as a fallbacks during type inference[/+]on Jan 23, 2024
changed the title [-]Const parameter defaults are not used as a fallbacks during type inference[/-][+]Const parameter defaults are not used as a fallback during type inference[/+]on Jan 23, 2024
Activity
fmease commentedon Apr 22, 2022
This has nothing to do with “specialization” (
#![feature(specialization)]) but with the known issue of type / const parameter defaults not being used as a fallback for failed inference. Duplicate of the closed issue #83687.SUPERCILEX commentedon Apr 22, 2022
Whoops, is there more accurate terminology?
About that issue, why was it closed? This seems like something worth fixing.
[-]Lack of impl specialization causes failed const generic inference[/-][+]Const parameter defaults are not used as a fallbacks during type inference[/+][-]Const parameter defaults are not used as a fallbacks during type inference[/-][+]Const parameter defaults are not used as a fallback during type inference[/+]fmease commentedon Jan 23, 2024
Closing in favor of #98931 which contains a bit more discussion.