@@ -17,6 +17,7 @@ use rustc_infer::infer::{self, InferOk, TyCtxtInferExt};
1717use rustc_middle:: infer:: unify_key:: { ConstVariableOrigin , ConstVariableOriginKind } ;
1818use rustc_middle:: middle:: stability;
1919use rustc_middle:: ty:: fast_reject:: { simplify_type, TreatParams } ;
20+ use rustc_middle:: ty:: AssocItem ;
2021use rustc_middle:: ty:: GenericParamDefKind ;
2122use rustc_middle:: ty:: { self , ParamEnvAnd , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeVisitable } ;
2223use rustc_middle:: ty:: { InternalSubsts , SubstsRef } ;
@@ -1331,6 +1332,31 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
13311332}
13321333
13331334impl < ' 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+
13341360 /// In case there were unstable name collisions, emit them as a lint.
13351361 pub fn maybe_emit_unstable_name_collision_hint (
13361362 & self ,
0 commit comments