-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add const generics #11688
Add const generics #11688
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good. If you haven't done so, maybe try running rust-analyzer analysis-stats
on some const-generics-heavy codebases? (nalgebra?)
bors d+
✌️ HKalbasi can now approve this pull request. To approve and merge a pull request, simply reply with |
Add missing fold_free_var_const This causes panic in rust-lang/rust-analyzer#11688 when `Sized` trait is in tests.
1f450d9
to
765593b
Compare
bors r+ |
Build succeeded:
|
This seems to have broken |
11718: Fix const generic panic r=lnicola a=HKalbasi fix #11688 (comment) Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
impl std::fmt::Display for ConstScalarOrPath { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
ConstScalarOrPath::Scalar(s) => write!(f, "{}", s), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
ConstScalarOrPath::Scalar(s) => write!(f, "{}", s), | |
ConstScalarOrPath::Scalar(s) => s.fmt(f), | |
ConstScalarOrPath::Path(n) => n.fmt(f), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, this was already merged 🤦. I'll file a PR to clean these up.
#7434 is not in this PR, so there is no evaluation of constants and no default const argument. But the rest (type inference and method resolution with chalk) should work.
Chalk is pedantic about kind of generic arguments, and will panic in case of mixing type and const arguments. I tried to add test that, but I'm not sure if it covers all cases.