From 73161cc9cdcdf7b9f797d7984f2cad497a3f4553 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Tue, 27 Oct 2020 20:23:09 +0100 Subject: do not use associated types placeholder for inlay hint #6191 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/hir_ty/src/tests/traits.rs | 46 ++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'crates/hir_ty/src/tests/traits.rs') diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 41d097519..7ad8b5830 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -384,12 +384,12 @@ fn infer_project_associated_type() { 108..261 '{ ...ter; }': () 118..119 'x': u32 145..146 '1': u32 - 156..157 'y': Iterable::Item - 183..192 'no_matter': Iterable::Item - 202..203 'z': Iterable::Item - 215..224 'no_matter': Iterable::Item - 234..235 'a': Iterable::Item - 249..258 'no_matter': Iterable::Item + 156..157 'y': ::Item + 183..192 'no_matter': ::Item + 202..203 'z': ::Item + 215..224 'no_matter': ::Item + 234..235 'a': ::Item + 249..258 'no_matter': ::Item "#]], ); } @@ -908,7 +908,6 @@ fn test(t: T) { (*t); } #[test] fn associated_type_placeholder() { - // inside the generic function, the associated type gets normalized to a placeholder `ApplL::Out` [https://rust-lang.github.io/rustc-guide/traits/associated-types.html#placeholder-associated-types]. check_types( r#" pub trait ApplyL { @@ -924,7 +923,7 @@ impl ApplyL for RefMutL { fn test() { let y: as ApplyL>::Out = no_matter; y; -} //^ ApplyL::Out +} //^ ::Out "#, ); } @@ -941,7 +940,7 @@ fn foo(t: T) -> ::Out; fn test(t: T) { let y = foo(t); y; -} //^ ApplyL::Out +} //^ ::Out "#, ); } @@ -2120,7 +2119,7 @@ fn unselected_projection_on_impl_self() { "#, expect![[r#" 40..44 'self': &Self - 46..47 'x': Trait::Item + 46..47 'x': ::Item 126..130 'self': &S 132..133 'x': u32 147..161 '{ let y = x; }': () @@ -3151,3 +3150,30 @@ fn test() { "#, ); } + +#[test] +fn infer_call_method_return_associated_types_with_generic() { + check_infer( + r#" + pub trait Default { + fn default() -> Self; + } + pub trait Foo { + type Bar: Default; + } + + pub fn quux() -> T::Bar { + let y = Default::default(); + + y + } + "#, + expect![[r#" + 122..164 '{ ... y }': ::Bar + 132..133 'y': ::Bar + 136..152 'Defaul...efault': fn default<::Bar>() -> ::Bar + 136..154 'Defaul...ault()': ::Bar + 161..162 'y': ::Bar + "#]], + ); +} -- cgit v1.2.3