diff options
| author | Shoyu Vanilla <modulo641@gmail.com> | 2025-02-20 08:49:00 +0900 |
|---|---|---|
| committer | Shoyu Vanilla <modulo641@gmail.com> | 2025-02-20 08:49:00 +0900 |
| commit | 851ef81f4a4b23e191d75cd80545fd48b3ca6a4d (patch) | |
| tree | e9e71db123a2e0ea4a8333388b27689a0e41be07 | |
| parent | ceab7546935480e0b6f27d3f3036e65107d36dbd (diff) | |
| download | rust-851ef81f4a4b23e191d75cd80545fd48b3ca6a4d.tar.gz rust-851ef81f4a4b23e191d75cd80545fd48b3ca6a4d.zip | |
Explicitly compare `TypesMap` as ptrs
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs index 176c147b710..a165932ddcc 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs @@ -10,7 +10,7 @@ use hir_def::{ generics::{TypeParamProvenance, WherePredicate, WherePredicateTypeTarget}, path::{GenericArg, GenericArgs, Path, PathSegment, PathSegments}, resolver::{ResolveValueResult, TypeNs, ValueNs}, - type_ref::{TypeBound, TypeRef}, + type_ref::{TypeBound, TypeRef, TypesMap}, GenericDefId, GenericParamId, ItemContainerId, Lookup, TraitId, }; use smallvec::SmallVec; @@ -837,17 +837,22 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> { } (_, ImplTraitLoweringMode::Param | ImplTraitLoweringMode::Variable) => { // Find the generic index for the target of our `bound` - let target_param_idx = self - .ctx - .resolver - .where_predicates_in_scope() - .find_map(|(p, (_, types_map))| match p { - WherePredicate::TypeBound { - target: WherePredicateTypeTarget::TypeOrConstParam(idx), - bound: b, - } if b == bound && self.ctx.types_map == types_map => Some(idx), - _ => None, - }); + let target_param_idx = + self.ctx.resolver.where_predicates_in_scope().find_map( + |(p, (_, types_map))| match p { + WherePredicate::TypeBound { + target: WherePredicateTypeTarget::TypeOrConstParam(idx), + bound: b, + } if std::ptr::eq::<TypesMap>( + self.ctx.types_map, + types_map, + ) && bound == b => + { + Some(idx) + } + _ => None, + }, + ); let ty = if let Some(target_param_idx) = target_param_idx { let mut counter = 0; let generics = self.ctx.generics().expect("generics in scope"); |
