Skip to content

[ER] Partial inference for const generics too #72101

@leonardo-m

Description

@leonardo-m

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?
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions