rust-analyzer
rust-analyzer copied to clipboard
fix: sort and deduplicate auto traits in trait object types
Fixes #12739
Chalk solver doesn't sort and deduplicate auto traits in trait object types, so we need to handle them ourselves in the lowering phase, just like rustc and chalk-integration do.
Quoting from the Chalk book:
Note that -- for this purpose -- ordering of bounds is significant. That means that if you create a
dyn Foo + Sendand adyn Send + Foo, chalk would consider them distinct types. The assumption is that bounds are ordered in some canonical fashion somewhere else.
Also, trait object types with more than one non-auto traits were previously allowed, but are now disallowed with this patch.