Skip to content
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

Allow the use of const parameters from outer definitions #61414

Closed
varkor opened this issue May 31, 2019 · 3 comments
Closed

Allow the use of const parameters from outer definitions #61414

varkor opened this issue May 31, 2019 · 3 comments
Labels
A-const-generics Area: const generics (parameters and arguments) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@varkor
Copy link
Member

varkor commented May 31, 2019

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.

@jonas-schievink jonas-schievink added A-const-generics Area: const generics (parameters and arguments) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels May 31, 2019
@Centril
Copy link
Contributor

Centril commented 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.

@Centril Centril added F-const_generics `#![feature(const_generics)]` requires-nightly This issue requires a nightly compiler in some way. labels Aug 6, 2019
@lcnr
Copy link
Contributor

lcnr commented Jun 24, 2022

@BoxyUwU BoxyUwU removed requires-nightly This issue requires a nightly compiler in some way. F-const_generics `#![feature(const_generics)]` labels Jun 24, 2022
@lcnr
Copy link
Contributor

lcnr commented 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.

@lcnr lcnr closed this as completed Jun 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants