@@ -126,7 +126,7 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>,
126
126
}
127
127
128
128
pub fn trait_ref_is_knowable < ' a , ' gcx , ' tcx > ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
129
- trait_ref : & ty:: TraitRef < ' tcx > ) -> bool
129
+ trait_ref : ty:: TraitRef < ' tcx > ) -> bool
130
130
{
131
131
debug ! ( "trait_ref_is_knowable(trait_ref={:?})" , trait_ref) ;
132
132
@@ -140,10 +140,7 @@ pub fn trait_ref_is_knowable<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
140
140
// if the trait is not marked fundamental, then it's always possible that
141
141
// an ancestor crate will impl this in the future, if they haven't
142
142
// already
143
- if
144
- trait_ref. def_id . krate != LOCAL_CRATE &&
145
- !tcx. has_attr ( trait_ref. def_id , "fundamental" )
146
- {
143
+ if !trait_ref_is_local_or_fundamental ( tcx, trait_ref) {
147
144
debug ! ( "trait_ref_is_knowable: trait is neither local nor fundamental" ) ;
148
145
return false ;
149
146
}
@@ -157,6 +154,12 @@ pub fn trait_ref_is_knowable<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
157
154
orphan_check_trait_ref ( tcx, trait_ref, InferIsLocal ( true ) ) . is_err ( )
158
155
}
159
156
157
+ pub fn trait_ref_is_local_or_fundamental < ' a , ' gcx , ' tcx > ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
158
+ trait_ref : ty:: TraitRef < ' tcx > )
159
+ -> bool {
160
+ trait_ref. def_id . krate == LOCAL_CRATE || tcx. has_attr ( trait_ref. def_id , "fundamental" )
161
+ }
162
+
160
163
pub enum OrphanCheckErr < ' tcx > {
161
164
NoLocalInputType ,
162
165
UncoveredTy ( Ty < ' tcx > ) ,
@@ -186,11 +189,11 @@ pub fn orphan_check<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
186
189
return Ok ( ( ) ) ;
187
190
}
188
191
189
- orphan_check_trait_ref ( tcx, & trait_ref, InferIsLocal ( false ) )
192
+ orphan_check_trait_ref ( tcx, trait_ref, InferIsLocal ( false ) )
190
193
}
191
194
192
195
fn orphan_check_trait_ref < ' tcx > ( tcx : TyCtxt ,
193
- trait_ref : & ty:: TraitRef < ' tcx > ,
196
+ trait_ref : ty:: TraitRef < ' tcx > ,
194
197
infer_is_local : InferIsLocal )
195
198
-> Result < ( ) , OrphanCheckErr < ' tcx > >
196
199
{
0 commit comments