@@ -252,16 +252,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
252
252
let tcx = self . tcx ( ) ;
253
253
let obligations = if has_nested {
254
254
let trait_def = obligation. predicate . def_id ( ) ;
255
- let conditions = if tcx. is_lang_item ( trait_def, LangItem :: Sized ) {
256
- self . sized_conditions ( obligation)
257
- } else if tcx. is_lang_item ( trait_def, LangItem :: Copy ) {
258
- self . copy_clone_conditions ( obligation)
259
- } else if tcx. is_lang_item ( trait_def, LangItem :: Clone ) {
260
- self . copy_clone_conditions ( obligation)
261
- } else if tcx. is_lang_item ( trait_def, LangItem :: FusedIterator ) {
262
- self . fused_iterator_conditions ( obligation)
263
- } else {
264
- bug ! ( "unexpected builtin trait {:?}" , trait_def)
255
+ let conditions = match tcx. as_lang_item ( trait_def) {
256
+ Some ( LangItem :: Sized ) => self . sized_conditions ( obligation) ,
257
+ Some ( LangItem :: Copy | LangItem :: Clone ) => self . copy_clone_conditions ( obligation) ,
258
+ Some ( LangItem :: FusedIterator ) => self . fused_iterator_conditions ( obligation) ,
259
+ other => bug ! ( "unexpected builtin trait {trait_def:?} ({other:?})" ) ,
265
260
} ;
266
261
let BuiltinImplConditions :: Where ( types) = conditions else {
267
262
bug ! ( "obligation {:?} had matched a builtin impl but now doesn't" , obligation) ;
0 commit comments