Change:
Error message: Commit that reproduces the issue: I get the same error (except for the exact line number) on 1.38, 1.40, beta, and a couple of nightlies. The other issues reachable via the query ( and ) are both about the invocation at , this invocation is at , so this is unlikely to be a duplicate. I haven't yet tried to minimize this: The commit beforehand (1 line difference) on the same nalgebra branch is a compile-fail due to a trait method not being found, and I'm still trying to figure out if that one's a bug in my code.
It would be nice if you could post the backtrace next time :)
Something small-ish:
This is an issue with how performs caching. Predicates are "freshened" before being used as cache keys, which replaces each distinct type variable with a deterministic . This is supposed to allow us to cache predicates across different . Unfortunately, this doesn't take into account relationships between type variables. This leads to the following scenario: tries to select the predicate , where and are distinct type variables (there is no relationship between them). This succeeds, and we cache the result under the key enter a different , and create the type variables and . These region variables end up getting equated to each other - although we don't know the concrete type, it is the same for both of them. try to select the predicate . We try to lookup the cached result under the key . However, this is wrong: we cached the result assuming that and are different types. However, we now have the same type for both substs, so we have no guarantee that our cached result is valid. In the minimized example, we end up caching under . We then try to use this cached result when searching through inherent methods in the impl - we lookup where == == . We get a cached result of , which does not actually apply here. I think we either need to either: much more conservative about the caching we perform incorporate extra knowledge about inference variable relationships into the cache key. It's not obvious to me whether this could be done by unifying 'equivalent' inference variables, or if we would need to somehow store actual constraints from the . This may have soundness implications, especially when it comes to regions. I don't think we're guaranteed to always ICE on a cache entry that's actually inapplicable.
cc I believe this may have been exposed by , since without it we wouldn't be caching the , However, I think the underlying issue would still exist without that PR.
Can't freshening try to resolve every variable it's replacing, on the fly? Assuming we're still using union-find, one of and should get redirected to the other. cc
I got another ICE with the same codebase, after tweaking it to pass trait resolution. Commit that reproduces the ICE is at . Should I file this as a separate issue, or treat it as related for now? I'll probably try and create a minimal testcase for this next. Backtrace is as follows:
a new issue would be great
Issue gives an error message with very similar strings ("broken MIR in DefId"/"NoSolution") and their minimized example looks like it was minimized from a type that's also used by nalgebra, so I'll try to figure out whether the second ICE is a duplicate of that before filing an issue/adding to that thread.
triage: P-high, removing nomination
cc
I'm familiar with this bug, I can try to dig in and make a recommendation for a fix.
No longer ICEs since

Discussion:
<ins> // check-pass // // regression test for #88071 #![feature(const_btree_new)] #![feature(const_fn_trait_bound)] use std::collections::BTreeMap; pub struct CustomMap<K, V>(BTreeMap<K, V>); impl<K, V> CustomMap<K, V> where K: Ord, { pub const fn new() -> Self { CustomMap(BTreeMap::new()) } } fn main() {} </ins>

<ins> #![feature(generic_associated_types)] trait PointerFamily { type Pointer<T>; } struct Rc<T>(Box<T>); struct RcFamily; impl PointerFamily for RcFamily { type Pointer<T> = Rc<T>; } #[allow(dead_code)] enum Node<T, P: PointerFamily> where P::Pointer<Node<T, P>>: Sized { Cons(P::Pointer<Node<T, P>>), } fn main() { let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>; //~^ ERROR overflow evaluating the requirement `Node<i32, RcFamily>: Sized` } </ins>

<ins> error[E0275]: overflow evaluating the requirement `Node<i32, RcFamily>: Sized` --> $DIR/issue-87750.rs:20:16 | LL |     let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>; |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0275`. </ins>

<ins> // check-fail // // regression test for issue 52893 trait At<Name> { type AtRes; fn at(self) -> Self::AtRes; } trait Push<T> { type PushRes; fn push(self, other: T) -> Self::PushRes; } trait AddClass<Name, F> { type AddRes; fn init(self, func: F); } trait ToRef { type RefRes; fn to_ref(&self) -> Self::RefRes; } struct Class<P>(P); impl<P> Class<P> { fn with<Name, F>(self) -> <Self as AddClass<Name, F>>::AddRes where Self: AddClass<Name, F>, { todo!() } fn from<F>(self) -> <Self as AddClass<P, F>>::AddRes where Self: AddClass<P, F>, { todo!() } } impl<F, Name, P> AddClass<Name, F> for Class<P> where Self: At<Name>, <Self as At<Name>>::AtRes: Push<F>, <<Self as At<Name>>::AtRes as Push<F>>::PushRes: ToRef<RefRes = Self> + Push<F>, { type AddRes = (); fn init(self, func: F) { let builder = self.at().push(func); let output = builder.to_ref(); builder.push(output); //~ ERROR mismatched types [E0308] } } fn main() {} </ins>

<ins> error[E0308]: mismatched types --> $DIR/issue-52893.rs:53:22 | LL | impl<F, Name, P> AddClass<Name, F> for Class<P> |      - this type parameter ... LL |         builder.push(output); |                      ^^^^^^ expected type parameter `F`, found struct `Class` | = note: expected type parameter `F` found struct `Class<P>` error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>

<ins> // check-fail // // regression test for #68295 struct Matrix<R, C, S>(R, C, S); impl<R, C, S> Matrix<R, C, S> { fn into_owned(self) -> Matrix<R, C, Owned<R, C, ()>> where (): Allocator<R, C>, { unimplemented!() } } impl<D, S> Matrix<D, D, S> { fn hermitian_part(&self) -> Matrix<D, D, Owned<D, D, ()>> where (): Allocator<D, D>, { unimplemented!() } } trait Allocator<R, C> { type Buffer; } trait Trait<R, C, A> { type Power; } impl<R, C, A: Allocator<R, C>> Trait<R, C, A> for () { type Power = A::Buffer; } type Owned<R, C, G> = <G as Trait<R, C, ()>>::Power; fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32> where (): Allocator<R, C>, { input.into_owned() //~^ ERROR mismatched types [E0308] } fn main() {} </ins>

<ins> error[E0308]: mismatched types --> $DIR/issue-68295.rs:43:5 | LL | fn crash<R, C>(input: Matrix<R, C, ()>) -> Matrix<R, C, u32> |                                            ----------------- expected `Matrix<R, C, u32>` because of return type ... LL |     input.into_owned() |     ^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type | = note: expected struct `Matrix<_, _, u32>` found struct `Matrix<_, _, <() as Allocator<R, C>>::Buffer>` = help: consider constraining the associated type `<() as Allocator<R, C>>::Buffer` to `u32` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>