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
Cannot use generic const argument without {}, despite no conflict #68257
Compiling playground v0.0.1 (/playground)
error: type arguments must be declared prior to const arguments
--> src/main.rs:14:29
|
14 | impl<const B: usize> Foo<1, B> {
| ^
error: aborting due to previous error
error: could not compile `playground`.
To learn more, run the command again with --verbose.
________________________________
From: Marcel Hellwig <notifications@github.com>
Sent: Wednesday, January 15, 2020 6:21:10 PM
To: rust-lang/rust <rust@noreply.github.com>
Cc: DrGabble <jub777@hotmail.co.uk>; Author <author@noreply.github.com>
Subject: Re: [rust-lang/rust] Const Generics Not Compiling (#68257)
impl<const B: usize> Foo<1, {B}>
works
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#68257?email_source=notifications&email_token=ADTUJ2MD2EVFVGVKLIX6MHTQ55HZNA5CNFSM4KHHTA4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJBJAGQ#issuecomment-574787610>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADTUJ2JSYVJEYCPI6QCJJM3Q55HZNANCNFSM4KHHTA4A>.
Looks like the check for if consts are before types in argument lists happens before we do our fancy lowering magic that turns consts args that had been parsed as type args into their true selves. Why wasn't this caught earlier? We just didn't test it.
As for how to fix it? We could just remove parameter ordering or at least slightly relax it. Otherwise, we might have to just move this check later on after things have been lowered to HIR.
I don't think there's a strong reason for parameter ordering to be enforced and was mainly intended to be conservative. However, it is a small language change, so it might be easier to move this check later on for now.
Activity
hellow554 commentedon Jan 15, 2020
works
DrGabble commentedon Jan 15, 2020
[-]Const Generics Not Compiling[/-][+]Cannot use generic const argument without `{}`, despite no conflict[/+]varkor commentedon Jan 15, 2020
I'm surprised this doesn't work, actually, as
Bshouldn't conflict with anything, so should be inferrable as a const. cc @yodaldevoidDrGabble commentedon Jan 17, 2020
Yeah it confused be how it could figure it out the other way, but not this way round...
yodaldevoid commentedon Jan 17, 2020
Hmm, I'll try taking a poke at this this weekend.
yodaldevoid commentedon Jan 19, 2020
Looks like the check for if consts are before types in argument lists happens before we do our fancy lowering magic that turns consts args that had been parsed as type args into their true selves. Why wasn't this caught earlier? We just didn't test it.
As for how to fix it? We could just remove parameter ordering or at least slightly relax it. Otherwise, we might have to just move this check later on after things have been lowered to HIR.
varkor commentedon Jan 20, 2020
I don't think there's a strong reason for parameter ordering to be enforced and was mainly intended to be conservative. However, it is a small language change, so it might be easier to move this check later on for now.
Auto merge of #68434 - varkor:astconv-mismatch-error, r=nikomatsakis