Skip to content

Commit cd064e7

Browse files
committed
fix: Fix type argument mismatch incorrectly triggering on inferred trait args
1 parent c596874 commit cd064e7

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/infer/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl InferenceContext<'_> {
207207
(TypeNs::TraitId(trait_), true) => {
208208
let self_ty = self.table.new_type_var();
209209
let trait_ref =
210-
path_ctx.lower_trait_ref_from_resolved_path(trait_, self_ty);
210+
path_ctx.lower_trait_ref_from_resolved_path(trait_, self_ty, true);
211211
drop_ctx(ctx, no_diagnostics);
212212
self.resolve_trait_assoc_item(trait_ref, last_segment, id)
213213
}

src/tools/rust-analyzer/crates/hir-ty/src/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl<'a> TyLoweringContext<'a> {
538538
TypeNs::TraitId(tr) => tr,
539539
_ => return None,
540540
};
541-
Some((ctx.lower_trait_ref_from_resolved_path(resolved, explicit_self_ty), ctx))
541+
Some((ctx.lower_trait_ref_from_resolved_path(resolved, explicit_self_ty, false), ctx))
542542
}
543543

544544
fn lower_trait_ref(

src/tools/rust-analyzer/crates/hir-ty/src/lower/path.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
166166
let trait_ref = self.lower_trait_ref_from_resolved_path(
167167
trait_,
168168
TyKind::Error.intern(Interner),
169+
infer_args,
169170
);
170171

171172
self.skip_resolved_segment();
@@ -830,17 +831,19 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
830831
&mut self,
831832
resolved: TraitId,
832833
explicit_self_ty: Ty,
834+
infer_args: bool,
833835
) -> TraitRef {
834-
let substs = self.trait_ref_substs_from_path(resolved, explicit_self_ty);
836+
let substs = self.trait_ref_substs_from_path(resolved, explicit_self_ty, infer_args);
835837
TraitRef { trait_id: to_chalk_trait_id(resolved), substitution: substs }
836838
}
837839

838840
fn trait_ref_substs_from_path(
839841
&mut self,
840842
resolved: TraitId,
841843
explicit_self_ty: Ty,
844+
infer_args: bool,
842845
) -> Substitution {
843-
self.substs_from_path_segment(resolved.into(), false, Some(explicit_self_ty), false)
846+
self.substs_from_path_segment(resolved.into(), infer_args, Some(explicit_self_ty), false)
844847
}
845848

846849
pub(super) fn assoc_type_bindings_from_type_bound<'c>(

src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/incorrect_generics_len.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,16 @@ fn foo<T: Trait<Assoc<i32> = bool>>() {}
172172
"#,
173173
);
174174
}
175+
176+
#[test]
177+
fn regression_19669() {
178+
check_diagnostics(
179+
r#"
180+
//- minicore: from
181+
fn main() {
182+
let _: i32 = Into::into(0);
183+
}
184+
"#,
185+
);
186+
}
175187
}

0 commit comments

Comments
 (0)