summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_ty_utils/src/consts.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_ty_utils/src/consts.rs')
-rw-r--r--compiler/rustc_ty_utils/src/consts.rs58
1 files changed, 49 insertions, 9 deletions
diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs
index f8ff31f97..a9fbad55d 100644
--- a/compiler/rustc_ty_utils/src/consts.rs
+++ b/compiler/rustc_ty_utils/src/consts.rs
@@ -267,8 +267,8 @@ struct IsThirPolymorphic<'a, 'tcx> {
thir: &'a thir::Thir<'tcx>,
}
-fn error<'tcx>(
- tcx: TyCtxt<'tcx>,
+fn error(
+ tcx: TyCtxt<'_>,
sub: GenericConstantTooComplexSub,
root_span: Span,
) -> Result<!, ErrorGuaranteed> {
@@ -281,8 +281,8 @@ fn error<'tcx>(
Err(reported)
}
-fn maybe_supported_error<'tcx>(
- tcx: TyCtxt<'tcx>,
+fn maybe_supported_error(
+ tcx: TyCtxt<'_>,
sub: GenericConstantTooComplexSub,
root_span: Span,
) -> Result<!, ErrorGuaranteed> {
@@ -302,13 +302,53 @@ impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> {
}
match expr.kind {
- thir::ExprKind::NamedConst { substs, .. } => substs.has_non_region_param(),
+ thir::ExprKind::NamedConst { substs, .. }
+ | thir::ExprKind::ConstBlock { substs, .. } => substs.has_non_region_param(),
thir::ExprKind::ConstParam { .. } => true,
thir::ExprKind::Repeat { value, count } => {
self.visit_expr(&self.thir()[value]);
count.has_non_region_param()
}
- _ => false,
+ thir::ExprKind::Scope { .. }
+ | thir::ExprKind::Box { .. }
+ | thir::ExprKind::If { .. }
+ | thir::ExprKind::Call { .. }
+ | thir::ExprKind::Deref { .. }
+ | thir::ExprKind::Binary { .. }
+ | thir::ExprKind::LogicalOp { .. }
+ | thir::ExprKind::Unary { .. }
+ | thir::ExprKind::Cast { .. }
+ | thir::ExprKind::Use { .. }
+ | thir::ExprKind::NeverToAny { .. }
+ | thir::ExprKind::Pointer { .. }
+ | thir::ExprKind::Loop { .. }
+ | thir::ExprKind::Let { .. }
+ | thir::ExprKind::Match { .. }
+ | thir::ExprKind::Block { .. }
+ | thir::ExprKind::Assign { .. }
+ | thir::ExprKind::AssignOp { .. }
+ | thir::ExprKind::Field { .. }
+ | thir::ExprKind::Index { .. }
+ | thir::ExprKind::VarRef { .. }
+ | thir::ExprKind::UpvarRef { .. }
+ | thir::ExprKind::Borrow { .. }
+ | thir::ExprKind::AddressOf { .. }
+ | thir::ExprKind::Break { .. }
+ | thir::ExprKind::Continue { .. }
+ | thir::ExprKind::Return { .. }
+ | thir::ExprKind::Array { .. }
+ | thir::ExprKind::Tuple { .. }
+ | thir::ExprKind::Adt(_)
+ | thir::ExprKind::PlaceTypeAscription { .. }
+ | thir::ExprKind::ValueTypeAscription { .. }
+ | thir::ExprKind::Closure(_)
+ | thir::ExprKind::Literal { .. }
+ | thir::ExprKind::NonHirLiteral { .. }
+ | thir::ExprKind::ZstLiteral { .. }
+ | thir::ExprKind::StaticRef { .. }
+ | thir::ExprKind::InlineAsm(_)
+ | thir::ExprKind::ThreadLocalRef(_)
+ | thir::ExprKind::Yield { .. } => false,
}
}
fn pat_is_poly(&mut self, pat: &thir::Pat<'tcx>) -> bool {
@@ -349,10 +389,10 @@ impl<'a, 'tcx> visit::Visitor<'a, 'tcx> for IsThirPolymorphic<'a, 'tcx> {
}
/// Builds an abstract const, do not use this directly, but use `AbstractConst::new` instead.
-pub fn thir_abstract_const<'tcx>(
- tcx: TyCtxt<'tcx>,
+pub fn thir_abstract_const(
+ tcx: TyCtxt<'_>,
def: ty::WithOptConstParam<LocalDefId>,
-) -> Result<Option<ty::Const<'tcx>>, ErrorGuaranteed> {
+) -> Result<Option<ty::Const<'_>>, ErrorGuaranteed> {
if tcx.features().generic_const_exprs {
match tcx.def_kind(def.did) {
// FIXME(generic_const_exprs): We currently only do this for anonymous constants,