@@ -53,36 +53,36 @@ pub enum MethodViolationCode {
53
53
}
54
54
55
55
pub fn is_object_safe < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
56
- trait_ref : ty :: PolyTraitRef < ' tcx > )
56
+ trait_def_id : ast :: DefId )
57
57
-> bool
58
58
{
59
59
// Because we query yes/no results frequently, we keep a cache:
60
60
let cached_result =
61
- tcx. object_safety_cache . borrow ( ) . get ( & trait_ref . def_id ( ) ) . cloned ( ) ;
61
+ tcx. object_safety_cache . borrow ( ) . get ( & trait_def_id ) . cloned ( ) ;
62
62
63
63
let result =
64
64
cached_result. unwrap_or_else ( || {
65
- let result = object_safety_violations ( tcx, trait_ref . clone ( ) ) . is_empty ( ) ;
65
+ let result = object_safety_violations ( tcx, trait_def_id ) . is_empty ( ) ;
66
66
67
67
// Record just a yes/no result in the cache; this is what is
68
68
// queried most frequently. Note that this may overwrite a
69
69
// previous result, but always with the same thing.
70
- tcx. object_safety_cache . borrow_mut ( ) . insert ( trait_ref . def_id ( ) , result) ;
70
+ tcx. object_safety_cache . borrow_mut ( ) . insert ( trait_def_id , result) ;
71
71
72
72
result
73
73
} ) ;
74
74
75
- debug ! ( "is_object_safe({}) = {}" , trait_ref . repr( tcx) , result) ;
75
+ debug ! ( "is_object_safe({}) = {}" , trait_def_id . repr( tcx) , result) ;
76
76
77
77
result
78
78
}
79
79
80
80
pub fn object_safety_violations < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
81
- sub_trait_ref : ty :: PolyTraitRef < ' tcx > )
81
+ trait_def_id : ast :: DefId )
82
82
-> Vec < ObjectSafetyViolation < ' tcx > >
83
83
{
84
- supertraits ( tcx, sub_trait_ref )
85
- . flat_map ( |tr | object_safety_violations_for_trait ( tcx, tr . def_id ( ) ) . into_iter ( ) )
84
+ traits :: supertrait_def_ids ( tcx, trait_def_id )
85
+ . flat_map ( |def_id | object_safety_violations_for_trait ( tcx, def_id) . into_iter ( ) )
86
86
. collect ( )
87
87
}
88
88
0 commit comments