diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-02-21 10:28:20 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-02-21 10:52:15 +0000 |
| commit | b94498a3788699f839ee690d96d3288148c756d5 (patch) | |
| tree | 9fd009f248d224e707fdd2f10b5ef9f58d8ac41d /compiler/rustc_hir_analysis/src | |
| parent | 8bb49e22b550b9ccdca3a1f9bc1e52532ec39635 (diff) | |
| download | rust-b94498a3788699f839ee690d96d3288148c756d5.tar.gz rust-b94498a3788699f839ee690d96d3288148c756d5.zip | |
Use existing query feeding workarounds
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/astconv/bounds.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect/type_of.rs | 18 |
3 files changed, 10 insertions, 20 deletions
diff --git a/compiler/rustc_hir_analysis/src/astconv/bounds.rs b/compiler/rustc_hir_analysis/src/astconv/bounds.rs index a9b4dca08d4..117df5482e6 100644 --- a/compiler/rustc_hir_analysis/src/astconv/bounds.rs +++ b/compiler/rustc_hir_analysis/src/astconv/bounds.rs @@ -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 diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index d82d3eccfc6..a5ef1490bce 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -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, diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 57bcf7602ea..ddb02247d16 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -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, |
