You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The old solver eagerly detects unbounded recursion and forces the affected goals to be ambiguous. This check forces some goals which would not recurse to ambiguity as well. These goals now correctly result in NoSolution.
This test fails with ambiguity with old solver due to multiple candidates, and successfully compiles with new:
traitTrait<T,DUMMY>{}structW<T>(T);// To pass coherence.traitIsNotI32{}// This impl does not hold but gets forced as ambiguous due to// `fn match_fresh_trait_refs`.impl<T,DUMMY>Trait<T,DUMMY>forW<T>whereDUMMY:IsNotI32,W<u32>:Trait<i32,DUMMY>{}// This impl holds.implTrait<u32,i32>forW<u32>{}fnimpls_trait<T:Trait<U,DUMMY>,U,DUMMY>(){}fnmain(){impls_trait::<W<_>,_,_>()}
Removing this check does worsen performance by not as eagerly detecting overflow. However, correctly tracking the stack dependent behavior for this check would probably have a far greater performance impact.
This check prevents typenum from reaching the recursion limit in the old solver, cc #56
The text was updated successfully, but these errors were encountered:
traitTrait<X>{}// This impl does not hold.impl<X>Trait<X>forBox<u32>whereBox<u16>:Trait<X>{}// This impl holds.implTrait<()>forBox<u8>{}fnimpls_trait<T:Trait<X>,X>(){}fnmain(){impls_trait::<Box<_>,_>();}
traitTrait<T,DUMMY>{}structW<T>(T);// To pass coherence.traitIsNotI32{}// This impl does not hold but gets forced as ambiguous due to// `fn match_fresh_trait_refs`.impl<T,DUMMY>Trait<W<T>,W<DUMMY>>forW<T>whereDUMMY:IsNotI32,W<u32>:Trait<W<i32>,W<DUMMY>>{}// This impl holds.implTrait<W<u32>,W<i32>>forW<u32>{}traitIsNotU32{}implIsNotU32fori32{}implIsNotU32foru16{}traitCommon<U,V>{}impl<T,U,DUMMY>Common<W<U>,W<DUMMY>>forTwhereT:Trait<W<U>,W<DUMMY>>,U:IsNotU32,{}// Overlaps with old solver, compiles with newtraitDoesNotOverlap<U,DUMMY>{}impl<T,U,DUMMY>DoesNotOverlap<U,DUMMY>forTwhereT:Common<W<U>,W<DUMMY>>,{}impl<T,U,DUMMY>DoesNotOverlap<U,DUMMY>forW<T>{}fnmain(){}
should have started with @aliemjay's example to have something which is at least somewhat readable
The old solver eagerly detects unbounded recursion and forces the affected goals to be ambiguous. This check forces some goals which would not recurse to ambiguity as well. These goals now correctly result in
NoSolution
.https://github.com/rust-lang/rust/blob/b14fd2359f47fb9a14bbfe55359db4bb3af11861/compiler/rustc_trait_selection/src/traits/select/mod.rs#L1172-L1211.
This test fails with ambiguity with old solver due to multiple candidates, and successfully compiles with new:
Removing this check does worsen performance by not as eagerly detecting overflow. However, correctly tracking the stack dependent behavior for this check would probably have a far greater performance impact.
This check prevents typenum from reaching the recursion limit in the old solver, cc #56
The text was updated successfully, but these errors were encountered: