mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Ignore type bindings in generic_predicates_for_param
This allows us to handle more cases without a query cycle, which includes certain cases that rustc accepted. That in turn means we avoid triggering salsa-rs/salsa#257 on valid code (it will still happen if the user writes an actual cycle). We actually accept more definitions than rustc now; that's because rustc only ignores bindings when looking up super traits, whereas we now also ignore them when looking for predicates to disambiguate associated type shorthand. We could introduce a separate query for super traits if necessary, but for now I think this should be fine.
This commit is contained in:
parent
0623bb4d71
commit
d8f8b495ad
6 changed files with 52 additions and 19 deletions
|
@ -940,10 +940,19 @@ impl Ty {
|
|||
let param_data = &generic_params.types[id.local_id];
|
||||
match param_data.provenance {
|
||||
hir_def::generics::TypeParamProvenance::ArgumentImplTrait => {
|
||||
let substs = Substitution::type_params(db, id.parent);
|
||||
let predicates = db
|
||||
.generic_predicates_for_param(id)
|
||||
.generic_predicates(id.parent)
|
||||
.into_iter()
|
||||
.map(|pred| pred.value.clone())
|
||||
.map(|pred| pred.clone().subst(&substs))
|
||||
.filter(|wc| match &wc {
|
||||
WhereClause::Implemented(tr) => tr.self_type_parameter() == self,
|
||||
WhereClause::AliasEq(AliasEq {
|
||||
alias: AliasTy::Projection(proj),
|
||||
ty: _,
|
||||
}) => proj.self_type_parameter() == self,
|
||||
_ => false,
|
||||
})
|
||||
.collect_vec();
|
||||
|
||||
Some(predicates)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue