Use existing query feeding workarounds
This commit is contained in:
parent
8bb49e22b5
commit
b94498a378
6 changed files with 10 additions and 46 deletions
|
@ -434,11 +434,20 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
|||
|
||||
// Provide the resolved type of the associated constant to `type_of(AnonConst)`.
|
||||
if !speculative && let ty::AssocKind::Const = assoc_kind {
|
||||
let hir::TypeBindingKind::Equality { term: hir::Term::Const(anon_const) } =
|
||||
binding.kind
|
||||
else {
|
||||
bug!()
|
||||
};
|
||||
let ty = alias_ty.map_bound(|ty| tcx.type_of(ty.def_id).instantiate(tcx, ty.args));
|
||||
// Since the arguments passed to the alias type above may contain early-bound
|
||||
// generic parameters, the instantiated type may contain some as well.
|
||||
// Therefore wrap it in `EarlyBinder`.
|
||||
tcx.feed_type_of_assoc_const_binding(binding.hir_id, ty::EarlyBinder::bind(ty));
|
||||
// FIXME(fmease): Reject escaping late-bound vars.
|
||||
tcx.feed_anon_const_type(
|
||||
anon_const.def_id,
|
||||
ty::EarlyBinder::bind(ty.skip_binder()),
|
||||
);
|
||||
}
|
||||
|
||||
alias_ty
|
||||
|
|
|
@ -63,7 +63,6 @@ pub fn provide(providers: &mut Providers) {
|
|||
*providers = Providers {
|
||||
type_of: type_of::type_of,
|
||||
type_of_opaque: type_of::type_of_opaque,
|
||||
type_of_assoc_const_binding: type_of::type_of_assoc_const_binding,
|
||||
type_alias_is_lazy: type_of::type_alias_is_lazy,
|
||||
item_bounds: item_bounds::item_bounds,
|
||||
explicit_item_bounds: item_bounds::explicit_item_bounds,
|
||||
|
|
|
@ -78,12 +78,6 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
|||
.expect("const parameter types cannot be generic");
|
||||
}
|
||||
|
||||
Node::TypeBinding(&TypeBinding { hir_id, .. }) => {
|
||||
// FIXME(fmease): Reject “escaping” early-bound generic parameters.
|
||||
// FIXME(fmease): Reject escaping late-bound vars.
|
||||
return tcx.type_of_assoc_const_binding(hir_id).skip_binder().skip_binder();
|
||||
}
|
||||
|
||||
// This match arm is for when the def_id appears in a GAT whose
|
||||
// path can't be resolved without typechecking e.g.
|
||||
//
|
||||
|
@ -290,18 +284,6 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn type_of_assoc_const_binding<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
hir_id: HirId,
|
||||
) -> ty::EarlyBinder<ty::Binder<'tcx, Ty<'tcx>>> {
|
||||
let reported = tcx.dcx().delayed_bug(format!(
|
||||
"attempt to obtain type of assoc const binding `{hir_id}` before \
|
||||
it was resolved by `add_predicates_for_ast_type_binding`"
|
||||
));
|
||||
|
||||
ty::EarlyBinder::bind(ty::Binder::dummy(Ty::new_error(tcx, reported)))
|
||||
}
|
||||
|
||||
fn get_path_containing_arg_in_pat<'hir>(
|
||||
pat: &'hir hir::Pat<'hir>,
|
||||
arg_id: HirId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue