Skip to content

Commit 906d4de

Browse files
Merge #2734
2734: Fix #2705 r=flodiebold a=flodiebold 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. Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 parents 15d94cb + 67240c8 commit 906d4de

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

crates/ra_hir_ty/src/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ pub(super) fn substs_from_path_segment(
331331
if let Some(generic_args) = &segment.args_and_bindings {
332332
// if args are provided, it should be all of them, but we can't rely on that
333333
let self_param_correction = if add_self_param { 1 } else { 0 };
334-
let child_len = child_len + self_param_correction;
334+
let child_len = child_len - self_param_correction;
335335
for arg in generic_args.args.iter().take(child_len) {
336336
match arg {
337337
GenericArg::Type(type_ref) => {

crates/ra_hir_ty/src/tests/regression.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,20 @@ fn issue_2669() {
365365
"###
366366
)
367367
}
368+
369+
#[test]
370+
fn issue_2705() {
371+
assert_snapshot!(
372+
infer(r#"
373+
trait Trait {}
374+
fn test() {
375+
<Trait<u32>>::foo()
376+
}
377+
"#),
378+
@r###"
379+
[26; 53) '{ ...oo() }': ()
380+
[32; 49) '<Trait...>::foo': {unknown}
381+
[32; 51) '<Trait...:foo()': ()
382+
"###
383+
);
384+
}

0 commit comments

Comments
 (0)