@@ -17,11 +17,11 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
1717use rustc_hir:: def_id:: { CrateNum , DefId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
1818use rustc_index:: vec:: { Idx , IndexVec } ;
1919use rustc_infer:: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
20- use rustc_middle:: bug;
2120use rustc_middle:: middle:: resolve_lifetime as rl;
2221use rustc_middle:: ty:: fold:: TypeFolder ;
2322use rustc_middle:: ty:: subst:: { InternalSubsts , Subst } ;
2423use rustc_middle:: ty:: { self , AdtKind , Lift , Ty , TyCtxt } ;
24+ use rustc_middle:: { bug, span_bug} ;
2525use rustc_mir:: const_eval:: { is_const_fn, is_unstable_const_fn} ;
2626use rustc_span:: hygiene:: { AstPass , MacroKind } ;
2727use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -157,11 +157,14 @@ impl Clean<GenericBound> for hir::GenericBound<'_> {
157157impl Clean < Type > for ( ty:: TraitRef < ' _ > , & [ TypeBinding ] ) {
158158 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Type {
159159 let ( trait_ref, bounds) = * self ;
160- let kind = match cx. tcx . def_kind ( trait_ref. def_id ) {
161- DefKind :: Trait => ItemType :: Trait ,
162- DefKind :: TraitAlias => ItemType :: TraitAlias ,
163- other => bug ! ( "`TraitRef` had unexpected kind {:?}" , other) ,
164- } ;
160+ let kind = cx. tcx . def_kind ( trait_ref. def_id ) . into ( ) ;
161+ if !matches ! ( kind, ItemType :: Trait | ItemType :: TraitAlias ) {
162+ span_bug ! (
163+ cx. tcx. def_span( trait_ref. def_id) ,
164+ "`TraitRef` had unexpected kind {:?}" ,
165+ kind
166+ ) ;
167+ }
165168 inline:: record_extern_fqn ( cx, trait_ref. def_id , kind) ;
166169 let path = external_path (
167170 cx,
0 commit comments