mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 05:13:35 +00:00 
			
		
		
		
	Merge pull request #19732 from ShoyuVanilla/issue-19730
fix: Correct assoc ty bound var starting index
This commit is contained in:
		
						commit
						3bf5d7f7f9
					
				
					 2 changed files with 27 additions and 1 deletions
				
			
		| 
						 | 
					@ -637,7 +637,10 @@ pub(crate) fn associated_ty_data_query(
 | 
				
			||||||
        .fill_with_bound_vars(crate::DebruijnIndex::INNERMOST, 0)
 | 
					        .fill_with_bound_vars(crate::DebruijnIndex::INNERMOST, 0)
 | 
				
			||||||
        .build();
 | 
					        .build();
 | 
				
			||||||
    let pro_ty = TyBuilder::assoc_type_projection(db, type_alias, Some(trait_subst))
 | 
					    let pro_ty = TyBuilder::assoc_type_projection(db, type_alias, Some(trait_subst))
 | 
				
			||||||
        .fill_with_bound_vars(crate::DebruijnIndex::INNERMOST, generic_params.len_self())
 | 
					        .fill_with_bound_vars(
 | 
				
			||||||
 | 
					            crate::DebruijnIndex::INNERMOST,
 | 
				
			||||||
 | 
					            generic_params.parent_generics().map_or(0, |it| it.len()),
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
        .build();
 | 
					        .build();
 | 
				
			||||||
    let self_ty = TyKind::Alias(AliasTy::Projection(pro_ty)).intern(Interner);
 | 
					    let self_ty = TyKind::Alias(AliasTy::Projection(pro_ty)).intern(Interner);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2278,3 +2278,26 @@ fn test(x: bool) {
 | 
				
			||||||
        "#]],
 | 
					        "#]],
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[test]
 | 
				
			||||||
 | 
					fn issue_19730() {
 | 
				
			||||||
 | 
					    check_infer(
 | 
				
			||||||
 | 
					        r#"
 | 
				
			||||||
 | 
					trait Trait<T = Self> {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					trait Foo {
 | 
				
			||||||
 | 
					    type Bar<A, B>: Trait;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fn foo<A, B>(bar: Self::Bar<A, B>) {
 | 
				
			||||||
 | 
					        let _ = bar;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					"#,
 | 
				
			||||||
 | 
					        expect![[r#"
 | 
				
			||||||
 | 
					            83..86 'bar': Foo::Bar<Self, A, B>
 | 
				
			||||||
 | 
					            105..133 '{     ...     }': ()
 | 
				
			||||||
 | 
					            119..120 '_': Foo::Bar<Self, A, B>
 | 
				
			||||||
 | 
					            123..126 'bar': Foo::Bar<Self, A, B>
 | 
				
			||||||
 | 
					        "#]],
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue