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_ty/src/tests | |
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_ty/src/tests')
-rw-r--r-- | crates/hir_ty/src/tests/traits.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 1bb6dff95..37cd04c6f 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs | |||
@@ -2273,8 +2273,7 @@ fn test<T, U>() where T: Trait<U::Item>, U: Trait<T::Item> { | |||
2273 | 2273 | ||
2274 | #[test] | 2274 | #[test] |
2275 | fn unselected_projection_in_trait_env_cycle_3() { | 2275 | fn unselected_projection_in_trait_env_cycle_3() { |
2276 | // this is a cycle, although it would be possible to handle if we didn't go | 2276 | // this is a cycle for rustc; we currently accept it |
2277 | // into bindings when looking for traits | ||
2278 | check_types( | 2277 | check_types( |
2279 | r#" | 2278 | r#" |
2280 | //- /main.rs | 2279 | //- /main.rs |
@@ -2285,7 +2284,7 @@ trait Trait { | |||
2285 | 2284 | ||
2286 | fn test<T>() where T: Trait<OtherItem = T::Item> { | 2285 | fn test<T>() where T: Trait<OtherItem = T::Item> { |
2287 | let x: T::Item = no_matter; | 2286 | let x: T::Item = no_matter; |
2288 | } //^ {unknown} | 2287 | } //^ Trait::Item<T> |
2289 | "#, | 2288 | "#, |
2290 | ); | 2289 | ); |
2291 | } | 2290 | } |