Skip to content

Commit af61d30

Browse files
Infer generic args for trait ref and its assoc type
This was already there before the switch to the new solver, but it was reverted during the switch for some reason.
1 parent 6aa169d commit af61d30

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

crates/hir-ty/src/lower/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'a, 'b, 'db> PathLoweringContext<'a, 'b, 'db> {
183183
let trait_ref = self.lower_trait_ref_from_resolved_path(
184184
trait_,
185185
Ty::new_error(self.ctx.interner, ErrorGuaranteed),
186-
false,
186+
infer_args,
187187
);
188188
tracing::debug!(?trait_ref);
189189
self.skip_resolved_segment();
@@ -201,7 +201,7 @@ impl<'a, 'b, 'db> PathLoweringContext<'a, 'b, 'db> {
201201
// this point (`trait_ref.substitution`).
202202
let substitution = self.substs_from_path_segment(
203203
associated_ty.into(),
204-
false,
204+
infer_args,
205205
None,
206206
true,
207207
);

crates/ide-diagnostics/src/handlers/incorrect_generics_len.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,23 @@ type Result<T, E = Error> = core::result::Result<T, E>;
220220
221221
fn main() {
222222
let _ = Result::<()>::Ok(());
223+
}
224+
"#,
225+
);
226+
}
227+
228+
#[test]
229+
fn type_as_trait_does_not_count() {
230+
check_diagnostics(
231+
r#"
232+
pub trait Lock<T> {
233+
fn new(b: T) -> Self;
234+
}
235+
pub trait LockChoice {
236+
type Lock<T>: Lock<T>;
237+
}
238+
fn f<L: LockChoice>() {
239+
<L as LockChoice>::Lock::new(());
223240
}
224241
"#,
225242
);

0 commit comments

Comments
 (0)