mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
Disallow access to free BoundVar
s outside TyLoweringContext
This commit is contained in:
parent
f9bd487708
commit
46e1486a90
3 changed files with 7 additions and 4 deletions
|
@ -1190,9 +1190,9 @@ pub fn associated_type_shorthand_candidates<R>(
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
def: GenericDefId,
|
def: GenericDefId,
|
||||||
res: TypeNs,
|
res: TypeNs,
|
||||||
cb: impl FnMut(&Name, &TraitRef, TypeAliasId) -> Option<R>,
|
mut cb: impl FnMut(&Name, TypeAliasId) -> Option<R>,
|
||||||
) -> Option<R> {
|
) -> Option<R> {
|
||||||
named_associated_type_shorthand_candidates(db, def, res, None, cb)
|
named_associated_type_shorthand_candidates(db, def, res, None, |name, _, id| cb(name, id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn named_associated_type_shorthand_candidates<R>(
|
fn named_associated_type_shorthand_candidates<R>(
|
||||||
|
@ -1202,6 +1202,9 @@ fn named_associated_type_shorthand_candidates<R>(
|
||||||
def: GenericDefId,
|
def: GenericDefId,
|
||||||
res: TypeNs,
|
res: TypeNs,
|
||||||
assoc_name: Option<Name>,
|
assoc_name: Option<Name>,
|
||||||
|
// Do NOT let `cb` touch `TraitRef` outside of `TyLoweringContext`. Its substitution contains
|
||||||
|
// free `BoundVar`s that need to be shifted and only `TyLoweringContext` knows how to do that
|
||||||
|
// properly (see `TyLoweringContext::select_associated_type()`).
|
||||||
mut cb: impl FnMut(&Name, &TraitRef, TypeAliasId) -> Option<R>,
|
mut cb: impl FnMut(&Name, &TraitRef, TypeAliasId) -> Option<R>,
|
||||||
) -> Option<R> {
|
) -> Option<R> {
|
||||||
let mut search = |t| {
|
let mut search = |t| {
|
||||||
|
|
|
@ -1600,7 +1600,7 @@ impl<'a> SemanticsScope<'a> {
|
||||||
self.db,
|
self.db,
|
||||||
def,
|
def,
|
||||||
resolution.in_type_ns()?,
|
resolution.in_type_ns()?,
|
||||||
|name, _, id| cb(name, id.into()),
|
|name, id| cb(name, id.into()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -967,7 +967,7 @@ fn resolve_hir_path_(
|
||||||
db,
|
db,
|
||||||
def,
|
def,
|
||||||
res.in_type_ns()?,
|
res.in_type_ns()?,
|
||||||
|name, _, id| (name == unresolved.name).then(|| id),
|
|name, id| (name == unresolved.name).then(|| id),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(TypeAlias::from)
|
.map(TypeAlias::from)
|
||||||
|
|
Loading…
Reference in a new issue