fix: sort all bounds on trait object types

This commit is contained in:
Ryo Yoshida 2022-09-05 18:35:50 +09:00
parent 67920f7975
commit 265c75c53f
No known key found for this signature in database
GPG key ID: E25698A930586171
3 changed files with 81 additions and 22 deletions

View file

@ -164,6 +164,8 @@ impl TyExt for Ty {
fn dyn_trait(&self) -> Option<TraitId> {
let trait_ref = match self.kind(Interner) {
// The principal trait bound should be the first element of the bounds. This is an
// invariant ensured by `TyLoweringContext::lower_dyn_trait()`.
TyKind::Dyn(dyn_ty) => dyn_ty.bounds.skip_binders().interned().get(0).and_then(|b| {
match b.skip_binders() {
WhereClause::Implemented(trait_ref) => Some(trait_ref),