@@ -28,7 +28,7 @@ use rustc_data_structures::captures::Captures;
2828use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexSet } ;
2929use rustc_errors:: { struct_span_err, Applicability } ;
3030use rustc_hir as hir;
31- use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
31+ use rustc_hir:: def:: { CtorKind , DefKind } ;
3232use rustc_hir:: def_id:: { DefId , LocalDefId , LOCAL_CRATE } ;
3333use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
3434use rustc_hir:: weak_lang_items;
@@ -668,6 +668,7 @@ impl ItemCtxt<'tcx> {
668668 } )
669669 . flat_map ( |b| predicates_from_bound ( self , ty, b) ) ;
670670
671+ let param_def_id = self . tcx . hir ( ) . local_def_id ( param_id) . to_def_id ( ) ;
671672 let from_where_clauses = ast_generics
672673 . where_clause
673674 . predicates
@@ -677,7 +678,7 @@ impl ItemCtxt<'tcx> {
677678 _ => None ,
678679 } )
679680 . flat_map ( |bp| {
680- let bt = if is_param ( self . tcx , bp. bounded_ty , param_id ) {
681+ let bt = if bp. is_param_bound ( param_def_id ) {
681682 Some ( ty)
682683 } else if !only_self_bounds. 0 {
683684 Some ( self . to_ty ( bp. bounded_ty ) )
@@ -714,23 +715,6 @@ impl ItemCtxt<'tcx> {
714715 }
715716}
716717
717- /// Tests whether this is the AST for a reference to the type
718- /// parameter with ID `param_id`. We use this so as to avoid running
719- /// `ast_ty_to_ty`, because we want to avoid triggering an all-out
720- /// conversion of the type to avoid inducing unnecessary cycles.
721- fn is_param ( tcx : TyCtxt < ' _ > , ast_ty : & hir:: Ty < ' _ > , param_id : hir:: HirId ) -> bool {
722- if let hir:: TyKind :: Path ( hir:: QPath :: Resolved ( None , path) ) = ast_ty. kind {
723- match path. res {
724- Res :: SelfTy ( Some ( def_id) , None ) | Res :: Def ( DefKind :: TyParam , def_id) => {
725- def_id == tcx. hir ( ) . local_def_id ( param_id) . to_def_id ( )
726- }
727- _ => false ,
728- }
729- } else {
730- false
731- }
732- }
733-
734718fn convert_item ( tcx : TyCtxt < ' _ > , item_id : hir:: ItemId ) {
735719 let it = tcx. hir ( ) . item ( item_id) ;
736720 debug ! ( "convert: item {} with id {}" , it. ident, it. hir_id( ) ) ;
0 commit comments