rust-lang / chalk

An implementation and definition of the Rust trait system using a PROLOG-like logic solver
https://rust-lang.github.io/chalk/book/
Other
1.85k stars 182 forks source link

Split fallible infallible folding #772

Closed eggyal closed 2 years ago

eggyal commented 2 years ago

For folding operations that cannot fail, the existing fallible folding trait is a little unergonomic. This PR introduces an infallible folder trait that can be used as a more ergonomic alternative in such cases, reflecting the status quo in rustc.

Infallible folders must however also implement the fallible trait (it's a supertrait of the infallible one), but such implementation should merely delegate to the infallible trait. Coherence rules unfortunately do not permit this to be provided by blanket implementation, however delegating implementations can be simply derived on infallible folders via the chalk_derive::FallibleTypeFolder macro.

r? @jackh726

jackh726 commented 2 years ago

Let's merge this

@bors r+

bors commented 2 years ago

:pushpin: Commit 994bc59222a1c8e74728757666df89d30bc44b35 has been approved by jackh726

It is now in the queue for this repository.

bors commented 2 years ago

:hourglass: Testing commit 994bc59222a1c8e74728757666df89d30bc44b35 with merge b460e4b7bc453e56bfcc31c5bd639f4b70de82c6...

bors commented 2 years ago

:sunny: Test successful - checks-actions Approved by: jackh726 Pushing b460e4b7bc453e56bfcc31c5bd639f4b70de82c6 to master...