Skip to content

Commit 851ef81

Browse files
committed
Explicitly compare TypesMap as ptrs
1 parent ceab754 commit 851ef81

File tree

1 file changed

+17
-12
lines changed
  • src/tools/rust-analyzer/crates/hir-ty/src/lower

1 file changed

+17
-12
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs

+17-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use hir_def::{
1010
generics::{TypeParamProvenance, WherePredicate, WherePredicateTypeTarget},
1111
path::{GenericArg, GenericArgs, Path, PathSegment, PathSegments},
1212
resolver::{ResolveValueResult, TypeNs, ValueNs},
13-
type_ref::{TypeBound, TypeRef},
13+
type_ref::{TypeBound, TypeRef, TypesMap},
1414
GenericDefId, GenericParamId, ItemContainerId, Lookup, TraitId,
1515
};
1616
use smallvec::SmallVec;
@@ -837,17 +837,22 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
837837
}
838838
(_, ImplTraitLoweringMode::Param | ImplTraitLoweringMode::Variable) => {
839839
// Find the generic index for the target of our `bound`
840-
let target_param_idx = self
841-
.ctx
842-
.resolver
843-
.where_predicates_in_scope()
844-
.find_map(|(p, (_, types_map))| match p {
845-
WherePredicate::TypeBound {
846-
target: WherePredicateTypeTarget::TypeOrConstParam(idx),
847-
bound: b,
848-
} if b == bound && self.ctx.types_map == types_map => Some(idx),
849-
_ => None,
850-
});
840+
let target_param_idx =
841+
self.ctx.resolver.where_predicates_in_scope().find_map(
842+
|(p, (_, types_map))| match p {
843+
WherePredicate::TypeBound {
844+
target: WherePredicateTypeTarget::TypeOrConstParam(idx),
845+
bound: b,
846+
} if std::ptr::eq::<TypesMap>(
847+
self.ctx.types_map,
848+
types_map,
849+
) && bound == b =>
850+
{
851+
Some(idx)
852+
}
853+
_ => None,
854+
},
855+
);
851856
let ty = if let Some(target_param_idx) = target_param_idx {
852857
let mut counter = 0;
853858
let generics = self.ctx.generics().expect("generics in scope");

0 commit comments

Comments
 (0)