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

[ER] Partial inference for const generics too #72101

Closed
leonardo-m opened this issue May 11, 2020 · 2 comments
Closed

[ER] Partial inference for const generics too #72101

leonardo-m opened this issue May 11, 2020 · 2 comments
Labels
F-const_generics `#![feature(const_generics)]`

Comments

@leonardo-m
Copy link

This is an enhancement request. I think it's good to accept partial generic arguments, allowing all this code to compile:

#![feature(const_generics)]
#![allow(incomplete_features)]

fn foo<T, const N: usize>(_: [T; N]) {}

fn bar<T, const N: usize, const K: u32>(_: [T; N]) {}

fn main() {
    let data = [1_u8, 2];
    
    foo::<u8, 2>(data);     // OK
    foo::<_, 2>(data);      // OK
    foo::<u8, _>(data);     // Error?
    foo::<_, _>(data);      // Error?
    foo(data);              // OK
    
    bar::<u8, 2, 10>(data); // OK
    bar::<_, 2, 10>(data);  // OK
    bar::<_, _, 3>(data);   // Error?
}
@lcnr lcnr added the F-const_generics `#![feature(const_generics)]` label May 11, 2020
@lcnr
Copy link
Contributor

lcnr commented May 11, 2020

This is fairly similar to #70754, which already has some discussion on what needs to change in order to support this.

@leonardo-m
Copy link
Author

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-const_generics `#![feature(const_generics)]`
Projects
None yet
Development

No branches or pull requests

2 participants