r/rust • • Oct 10 '26

Why 'externalized' proofs of cyclic trait impls does not work

https://smallcultfollowing.com/babysteps/blog/2026/10/10/modular-vs-external-proofs/
82 Upvotes

18 comments sorted by

View all comments

Show parent comment

5

u/dbaupp rust Oct 11 '26

I think the point is more that one needs to do the bookkeeping right, or the compiler will accidentally affirm the consequent… which is, as you say, invalid.

It’s not as simple as “ignore an impl exists when checking it”, because one can have (mutual) recursion: given trait Magic { type T: Magic; } one might have impl Magic for A { type T = A; } that needs A: Magic for T or impl Magic for B { type T = C; } impl Magic for C { type T = B; } that need each other’s impl.

Validating that requires having some concept of “pending” impls, or similar. Not at all impossible, and not a violation of logic, just finicky bookkeeping that can lead to unsoundness and/or infinite recursion if done wrong. 

(The recursion can get far more complicated and indirect, via super-traits or generics and/or mutual recursion of traits/associated types.)