diff options
| author | Shoyu Vanilla <modulo641@gmail.com> | 2024-08-05 00:06:29 +0900 |
|---|---|---|
| committer | Shoyu Vanilla <modulo641@gmail.com> | 2024-08-05 00:06:29 +0900 |
| commit | fbe7233c0a17d23b0035112259a7b37cda2d419b (patch) | |
| tree | 4f518b9fdc3e6252fe4a279a328ddaba357b3943 | |
| parent | 6da26c15580d5c41ee2bb29ae4372b8c52f96174 (diff) | |
| download | rust-fbe7233c0a17d23b0035112259a7b37cda2d419b.tar.gz rust-fbe7233c0a17d23b0035112259a7b37cda2d419b.zip | |
fix: Insert a generic arg for `impl Trait` when lowering generic args
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-def/src/path/lower.rs | 5 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/path/lower.rs b/src/tools/rust-analyzer/crates/hir-def/src/path/lower.rs index 7c39773aa68..70918a9358e 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/path/lower.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/path/lower.rs @@ -194,6 +194,11 @@ pub(super) fn lower_generic_args( match generic_arg { ast::GenericArg::TypeArg(type_arg) => { let type_ref = TypeRef::from_ast_opt(lower_ctx, type_arg.ty()); + type_ref.walk(&mut |tr| { + if let TypeRef::ImplTrait(bounds) = tr { + lower_ctx.update_impl_traits_bounds(bounds.clone()); + } + }); args.push(GenericArg::Type(type_ref)); } ast::GenericArg::AssocTypeArg(assoc_type_arg) => { diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs index ac2dfea1010..28198386120 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs @@ -2122,3 +2122,22 @@ fn test() { "#, ) } + +#[test] +fn issue_17191() { + check_types( + r#" +trait A { + type Item; +} + +trait B<T> {} + +fn foo<T: B<impl A>>() {} + +fn test() { + let f = foo; + //^ fn foo<{unknown}>() +}"#, + ); +} |
