Introduce min_generic_const_args and directly represent paths

Co-authored-by: Boxy UwU <rust@boxyuwu.dev>
Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
This commit is contained in:
Noah Lev
2024-11-19 05:01:59 +00:00
committed by Boxy
parent b71fb5edc0
commit 59e339f766
21 changed files with 361 additions and 195 deletions

View File

@@ -46,7 +46,7 @@ use tracing::{debug, instrument};
use crate::check::intrinsic::intrinsic_operation_unsafety;
use crate::errors;
use crate::hir_ty_lowering::{HirTyLowerer, RegionInferReason};
use crate::hir_ty_lowering::{FeedConstTy, HirTyLowerer, RegionInferReason};
pub(crate) mod dump;
mod generics_of;
@@ -88,6 +88,7 @@ pub fn provide(providers: &mut Providers) {
coroutine_for_closure,
opaque_ty_origin,
rendered_precise_capturing_args,
const_param_default,
..*providers
};
}
@@ -1790,3 +1791,23 @@ fn rendered_precise_capturing_args<'tcx>(
_ => None,
})
}
fn const_param_default<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: LocalDefId,
) -> ty::EarlyBinder<'tcx, Const<'tcx>> {
let default_ct = match tcx.hir_node_by_def_id(def_id) {
hir::Node::GenericParam(hir::GenericParam {
kind: hir::GenericParamKind::Const { default: Some(ct), .. },
..
}) => ct,
_ => span_bug!(
tcx.def_span(def_id),
"`const_param_default` expected a generic parameter with a constant"
),
};
let icx = ItemCtxt::new(tcx, def_id);
// FIXME(const_generics): investigate which places do and don't need const ty feeding
let ct = icx.lowerer().lower_const_arg(default_ct, FeedConstTy::No);
ty::EarlyBinder::bind(ct)
}