Closed
Description
We would like this to pass:
fn foo<const X: u32>() -> u32 {
fn bar() -> u32 {
X
}
bar() * 2
}
fn main() {
assert_eq!(foo::<6>(), 12);
}
See this IRLO post for motivation.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Centril commentedon May 31, 2019
This would be an implementation of
{-# LANGUAGE ScopedTypeVariables #-}
as in the Glasgow Haskell Compiler but specifically for const generic parameters.I do think we should generalize this to type parameters at least and make this work for non-impl items (possibly not for others) in general. Lifetimes are also something to consider... and likely tricky and it should also impact const generics and type parameters implicitly.
min_const_generics
#74878lcnr commentedon Jun 24, 2022
discussed this while triaging const generics issues in https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/.60F-generic_const_exprs.60.20triage/near/287352481
lcnr commentedon Jun 24, 2022
implementing this would require a lang MCP or an RFC. As such I am closing this issue.
I generally don't think we should have a special case for const parameters here. I don't think there's a meaningful difference between const and type parameters.