From d8f8b495ad5c9e3676ddf7af53b23bb5b7f2fde0 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 20 Mar 2021 20:07:36 +0100 Subject: 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. --- crates/hir_ty/src/tests/traits.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/hir_ty/src/tests') 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() where T: Trait, U: Trait { #[test] fn unselected_projection_in_trait_env_cycle_3() { - // this is a cycle, although it would be possible to handle if we didn't go - // into bindings when looking for traits + // this is a cycle for rustc; we currently accept it check_types( r#" //- /main.rs @@ -2285,7 +2284,7 @@ trait Trait { fn test() where T: Trait { let x: T::Item = no_matter; -} //^ {unknown} +} //^ Trait::Item "#, ); } -- cgit v1.2.3