From 67240c8d915110fa0ad7392bb9a56e18e3bcf234 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 3 Jan 2020 14:57:11 +0100 Subject: Fix #2705 The `-` turned into a `+` during a refactoring. The original issue was caused by `Read` resolving wrongly to a trait without type parameters instead of a struct with one parameter; this only fixes the crash, not the wrong resolution. --- crates/ra_hir_ty/src/lower.rs | 2 +- crates/ra_hir_ty/src/tests/regression.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index af3db2e1d..2c2ecee9c 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -331,7 +331,7 @@ pub(super) fn substs_from_path_segment( if let Some(generic_args) = &segment.args_and_bindings { // if args are provided, it should be all of them, but we can't rely on that let self_param_correction = if add_self_param { 1 } else { 0 }; - let child_len = child_len + self_param_correction; + let child_len = child_len - self_param_correction; for arg in generic_args.args.iter().take(child_len) { match arg { GenericArg::Type(type_ref) => { diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs index 8b3aa8564..13c5f62e4 100644 --- a/crates/ra_hir_ty/src/tests/regression.rs +++ b/crates/ra_hir_ty/src/tests/regression.rs @@ -365,3 +365,20 @@ fn issue_2669() { "### ) } + +#[test] +fn issue_2705() { + assert_snapshot!( + infer(r#" +trait Trait {} +fn test() { + >::foo() +} +"#), + @r###" + [26; 53) '{ ...oo() }': () + [32; 49) '::foo': {unknown} + [32; 51) '