Skip to content

Commit

Permalink
add test for #116599
Browse files Browse the repository at this point in the history
Fixes #116599
  • Loading branch information
matthiaskrgr committed Mar 24, 2024
1 parent 127c36c commit db68dc2
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/ui/nll/unexpected-inference-var-ice-116599.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ICE unexpected inference var
// issue: rust-lang/rust#116599
//@ check-pass

pub trait EvaluateConstMethods {
type Trait: TraitWithConstMethods;

/// **This block breaks**
const DATA_3: Data3 = {
<<<Self::Trait as TraitWithConstMethods>::Method2 as ConstFn<_, _>>::Body<
<<Self::Trait as TraitWithConstMethods>::Method1 as ConstFn<_, _>>::Body<ContainsData1>,
> as Contains<_>>::ITEM
};
}

pub trait TraitWithConstMethods {
/// "const trait method" of signature `fn(Data1) -> Data2`
type Method1: ConstFn<Data1, Data2>;

/// "const trait method" of signature `fn(Data2) -> Data3`
type Method2: ConstFn<Data2, Data3>;
}

/// A trait which tries to implement const methods in traits
pub trait ConstFn<Arg, Ret> {
type Body<T: Contains<Arg>>: Contains<Ret>;
}

/// A ZST which represents / "contains" a const value which can be pass to a [`ConstFn`]
pub trait Contains<T> {
const ITEM: T;
}

pub struct ContainsData1;
impl Contains<Data1> for ContainsData1 {
const ITEM: Data1 = Data1 {};
}

// Arbitrary data
pub struct Data1 {}
pub struct Data2 {}
pub struct Data3 {}

pub fn main() {}

0 comments on commit db68dc2

Please sign in to comment.