Skip to content

Commit e9fc3b6

Browse files
ChayimFriedman2Veykril
authored andcommitted
Correctly set infer_args = true in more places
Previously this being incorrect wasn't a problem, it just meant we put an error type that then changed to infer type, so exactly what rustc does at the end. But now there is a diagnostic.
1 parent dce59ad commit e9fc3b6

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

crates/hir-ty/src/infer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ impl<'a> InferenceContext<'a> {
16751675
// `lower_partly_resolved_path()` returns `None` as type namespace unless
16761676
// `remaining_segments` is empty, which is never the case here. We don't know
16771677
// which namespace the new `ty` is in until normalized anyway.
1678-
(ty, _) = path_ctx.lower_partly_resolved_path(resolution, false);
1678+
(ty, _) = path_ctx.lower_partly_resolved_path(resolution, true);
16791679
tried_resolving_once = true;
16801680

16811681
ty = self.table.insert_type_vars(ty);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl InferenceContext<'_> {
177177
let ty = self.table.normalize_associated_types_in(ty);
178178

179179
path_ctx.ignore_last_segment();
180-
let (ty, _) = path_ctx.lower_ty_relative_path(ty, orig_ns);
180+
let (ty, _) = path_ctx.lower_ty_relative_path(ty, orig_ns, true);
181181
drop_ctx(ctx, no_diagnostics);
182182
let ty = self.table.insert_type_vars(ty);
183183
let ty = self.table.normalize_associated_types_in(ty);

crates/hir-ty/src/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ impl<'a> TyLoweringContext<'a> {
508508
if let Some(type_ref) = path.type_anchor() {
509509
let (ty, res) = self.lower_ty_ext(type_ref);
510510
let mut ctx = self.at_path(path_id);
511-
return ctx.lower_ty_relative_path(ty, res);
511+
return ctx.lower_ty_relative_path(ty, res, false);
512512
}
513513

514514
let mut ctx = self.at_path(path_id);

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
137137
ty: Ty,
138138
// We need the original resolution to lower `Self::AssocTy` correctly
139139
res: Option<TypeNs>,
140+
infer_args: bool,
140141
) -> (Ty, Option<TypeNs>) {
141142
match self.segments.len() - self.current_segment_idx {
142143
0 => (ty, res),
143144
1 => {
144145
// resolve unselected assoc types
145-
(self.select_associated_type(res), None)
146+
(self.select_associated_type(res, infer_args), None)
146147
}
147148
_ => {
148149
// FIXME report error (ambiguous associated type)
@@ -182,7 +183,7 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
182183
// this point (`trait_ref.substitution`).
183184
let substitution = self.substs_from_path_segment(
184185
associated_ty.into(),
185-
false,
186+
infer_args,
186187
None,
187188
true,
188189
);
@@ -277,7 +278,7 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
277278
};
278279

279280
self.skip_resolved_segment();
280-
self.lower_ty_relative_path(ty, Some(resolution))
281+
self.lower_ty_relative_path(ty, Some(resolution), infer_args)
281282
}
282283

283284
fn handle_type_ns_resolution(&mut self, resolution: &TypeNs) {
@@ -473,7 +474,7 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
473474
Some(res)
474475
}
475476

476-
fn select_associated_type(&mut self, res: Option<TypeNs>) -> Ty {
477+
fn select_associated_type(&mut self, res: Option<TypeNs>, infer_args: bool) -> Ty {
477478
let Some(res) = res else {
478479
return TyKind::Error.intern(Interner);
479480
};
@@ -507,7 +508,8 @@ impl<'a, 'b> PathLoweringContext<'a, 'b> {
507508
// generic params. It's inefficient to splice the `Substitution`s, so we may want
508509
// that method to optionally take parent `Substitution` as we already know them at
509510
// this point (`t.substitution`).
510-
let substs = self.substs_from_path_segment(associated_ty.into(), false, None, true);
511+
let substs =
512+
self.substs_from_path_segment(associated_ty.into(), infer_args, None, true);
511513

512514
let substs = Substitution::from_iter(
513515
Interner,

0 commit comments

Comments
 (0)