Ensure at least one trait bound in TyKind::DynTy

This commit is contained in:
Ryo Yoshida 2022-09-20 04:20:43 +09:00
parent 4d989b5465
commit 9845e37f58
No known key found for this signature in database
GPG key ID: E25698A930586171
3 changed files with 27 additions and 5 deletions

View file

@ -166,6 +166,8 @@ impl TyExt for Ty {
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()`.
// FIXME: dyn types may not have principal trait and we don't want to return auto trait
// here.
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),