rustc_hir_analysis::check::compare_impl_item

Function compare_generic_param_kinds

Source
fn compare_generic_param_kinds<'tcx>(
    tcx: TyCtxt<'tcx>,
    impl_item: AssocItem,
    trait_item: AssocItem,
    delay: bool,
) -> Result<(), ErrorGuaranteed>
Expand description

Checks that all parameters in the generics of a given assoc item in a trait impl have the same kind as the respective generic parameter in the trait def.

For example all 4 errors in the following code are emitted here:

trait Foo {
    fn foo<const N: u8>();
    type Bar<const N: u8>;
    fn baz<const N: u32>();
    type Blah<T>;
}

impl Foo for () {
    fn foo<const N: u64>() {}
    //~^ error
    type Bar<const N: u64> = ();
    //~^ error
    fn baz<T>() {}
    //~^ error
    type Blah<const N: i64> = u32;
    //~^ error
}

This function does not handle lifetime parameters