diff options
author | Florian Diebold <[email protected]> | 2021-03-20 19:07:36 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-03-21 14:29:03 +0000 |
commit | d8f8b495ad5c9e3676ddf7af53b23bb5b7f2fde0 (patch) | |
tree | 66d68e003d7fa1b311e1b4b99c01de6ea0984372 /crates/hir | |
parent | 0623bb4d71725d6b07e8cef5665094581f951fc0 (diff) |
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.
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/lib.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index e34be7e42..568cb7eb9 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -2068,7 +2068,10 @@ impl Type { | |||
2068 | match pred { | 2068 | match pred { |
2069 | WhereClause::Implemented(trait_ref) => { | 2069 | WhereClause::Implemented(trait_ref) => { |
2070 | cb(type_.clone()); | 2070 | cb(type_.clone()); |
2071 | walk_substs(db, type_, &trait_ref.substitution, cb); | 2071 | // skip the self type. it's likely the type we just got the bounds from |
2072 | for ty in trait_ref.substitution.iter().skip(1) { | ||
2073 | walk_type(db, &type_.derived(ty.clone()), cb); | ||
2074 | } | ||
2072 | } | 2075 | } |
2073 | _ => (), | 2076 | _ => (), |
2074 | } | 2077 | } |