diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 0bf181a92a6..822ef4477eb 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -332,7 +332,11 @@ impl HirDisplay for ApplicationTy { let ret_display = if f.omit_verbose_types() { ret.display_truncated(f.db, f.max_size) } else { - ret.display(f.db) + if f.display_target.is_test() { + ret.display_test(f.db) + } else { + ret.display(f.db) + } }; write!(f, " -> {}", ret_display)?; } @@ -472,7 +476,11 @@ impl HirDisplay for ApplicationTy { let ret_display = if f.omit_verbose_types() { sig.ret().display_truncated(f.db, f.max_size) } else { - sig.ret().display(f.db) + if f.display_target.is_test() { + sig.ret().display_test(f.db) + } else { + sig.ret().display(f.db) + } }; write!(f, " -> {}", ret_display)?; } else { diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs index 29b178ec126..104ef334c68 100644 --- a/crates/hir_ty/src/tests.rs +++ b/crates/hir_ty/src/tests.rs @@ -74,7 +74,7 @@ fn check_types_impl(ra_fixture: &str, display_source: bool) { let module = db.module_for_file(file_id); ty.display_source_code(&db, module).unwrap() } else { - ty.display(&db).to_string() + ty.display_test(&db).to_string() }; assert_eq!(expected, actual); checked_one = true; diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 42d08f12c7f..94d86b0d1f2 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -832,7 +832,7 @@ fn issue_4966() { 365..390 'Repeat...nner }': Repeat f64>> 383..388 'inner': Map<|&f64| -> f64> 401..404 'vec': Vec f64>>>> - 407..416 'from_iter': fn from_iter f64>>>, Repeat f64>>>(Repeat f64>>) -> Vec< f64>> as IntoIterator>::Item> + 407..416 'from_iter': fn from_iter f64>>>, Repeat f64>>>(Repeat f64>>) -> Vec f64>>>> 407..424 'from_i...epeat)': Vec f64>>>> 417..423 'repeat': Repeat f64>> 431..434 'vec': Vec f64>>>> diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 4d193dea99b..41d0975197b 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -907,7 +907,8 @@ fn test(t: T) { (*t); } } #[test] -fn associated_type_inlay_hints() { +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 { @@ -923,13 +924,13 @@ impl ApplyL for RefMutL { fn test() { let y: as ApplyL>::Out = no_matter; y; -} //^ ::Out +} //^ ApplyL::Out "#, ); } #[test] -fn associated_type_inlay_hints_2() { +fn associated_type_placeholder_2() { check_types( r#" pub trait ApplyL { @@ -940,7 +941,7 @@ fn foo(t: T) -> ::Out; fn test(t: T) { let y = foo(t); y; -} //^ ::Out +} //^ ApplyL::Out "#, ); }