@@ -17,6 +17,7 @@ use rustc_infer::infer::{self, InferOk, TyCtxtInferExt};
17
17
use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind } ;
18
18
use rustc_middle:: middle:: stability;
19
19
use rustc_middle:: ty:: fast_reject:: { simplify_type, TreatParams } ;
20
+ use rustc_middle:: ty:: AssocItem ;
20
21
use rustc_middle:: ty:: GenericParamDefKind ;
21
22
use rustc_middle:: ty:: { self , ParamEnvAnd , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeVisitable } ;
22
23
use rustc_middle:: ty:: { InternalSubsts , SubstsRef } ;
@@ -1331,6 +1332,31 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1331
1332
}
1332
1333
1333
1334
impl < ' tcx > Pick < ' tcx > {
1335
+ /// In case there were unstable name collisions, emit them as a lint.
1336
+ /// Checks whether two picks do not refer to the same trait item for the same `Self` type.
1337
+ /// Only useful for comparisons of picks in order to improve diagnostics.
1338
+ /// Do not use for type checking.
1339
+ pub fn differs_from ( & self , other : & Self ) -> bool {
1340
+ let Self {
1341
+ item :
1342
+ AssocItem {
1343
+ def_id,
1344
+ name : _,
1345
+ kind : _,
1346
+ container : _,
1347
+ trait_item_def_id : _,
1348
+ fn_has_self_parameter : _,
1349
+ } ,
1350
+ kind : _,
1351
+ import_ids : _,
1352
+ autoderefs : _,
1353
+ autoref_or_ptr_adjustment : _,
1354
+ self_ty,
1355
+ unstable_candidates : _,
1356
+ } = * self ;
1357
+ self_ty != other. self_ty || def_id != other. item . def_id
1358
+ }
1359
+
1334
1360
/// In case there were unstable name collisions, emit them as a lint.
1335
1361
pub fn maybe_emit_unstable_name_collision_hint (
1336
1362
& self ,
0 commit comments