Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 41 additions & 29 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
constraint.ident,
path_span,
Some(constraint),
)
.select_bound(
self,
AssocItemQSelf::Trait(trait_ref.def_id()),
assoc_tag,
constraint.ident,
path_span,
Some(constraint),
)?
};

Expand Down Expand Up @@ -806,42 +814,46 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}) =>
{
let self_ty = self.lower_ty(hir_self_ty);
let (item_def_id, bound) = match self.resolve_type_relative_path(
self_ty,
hir_self_ty,
ty::AssocTag::Fn,
segment,
hir_ty.hir_id,
hir_ty.span,
None,
) {
Ok(result) => result,
Err(guar) => return Ty::new_error(tcx, guar),
};

// FIXME(unresolved_aliases): Force a resolution here
todo!()

// let (item_def_id, bound) = match self.resolve_type_relative_path(
// self_ty,
// hir_self_ty,
// ty::AssocTag::Fn,
// segment,
// hir_ty.hir_id,
// hir_ty.span,
// None,
// ) {
// Ok(result) => result,
// Err(guar) => return Ty::new_error(tcx, guar),
// };

// Don't let `T::method` resolve to some `for<'a> <T as Tr<'a>>::method`,
// which may happen via a higher-ranked where clause or supertrait.
// This is the same restrictions as associated types; even though we could
// support it, it just makes things a lot more difficult to support in
// `resolve_bound_vars`, since we'd need to introduce those as elided
// bound vars on the where clause too.
if bound.has_bound_vars() {
return Ty::new_error(
tcx,
self.dcx().emit_err(errors::AssociatedItemTraitUninferredGenericParams {
span: hir_ty.span,
inferred_sugg: Some(hir_ty.span.with_hi(segment.ident.span.lo())),
bound: format!("{}::", tcx.anonymize_bound_vars(bound).skip_binder()),
mpart_sugg: None,
what: tcx.def_descr(item_def_id),
}),
);
}

match self.lower_return_type_notation_ty(bound, item_def_id, hir_ty.span) {
Ok(ty) => Ty::new_alias(tcx, ty::Projection, ty),
Err(guar) => Ty::new_error(tcx, guar),
}
// if bound.has_bound_vars() {
// return Ty::new_error(
// tcx,
// self.dcx().emit_err(errors::AssociatedItemTraitUninferredGenericParams {
// span: hir_ty.span,
// inferred_sugg: Some(hir_ty.span.with_hi(segment.ident.span.lo())),
// bound: format!("{}::", tcx.anonymize_bound_vars(bound).skip_binder()),
// mpart_sugg: None,
// what: tcx.def_descr(item_def_id),
// }),
// );
// }

// match self.lower_return_type_notation_ty(bound, item_def_id, hir_ty.span) {
// Ok(ty) => Ty::new_alias(tcx, ty::Projection, ty),
// Err(guar) => Ty::new_error(tcx, guar),
// }
}
_ => self.lower_ty(hir_ty),
}
Expand Down
Loading
Loading