]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_ty_utils/src/consts.rs
Rollup merge of #103851 - viandoxdev:103816_bootstrap_fix_json_doc, r=jyn514
[rust.git] / compiler / rustc_ty_utils / src / consts.rs
index 44c4fc48d3f0f6428aceba9cb640e3570138fd4e..3cef47c0f8ba481d2b3bde2a117b38be3ae5bb18 100644 (file)
@@ -33,7 +33,7 @@ pub(crate) fn destructure_const<'tcx>(
             // construct the consts for the elements of the array/slice
             let field_consts = branches
                 .iter()
-                .map(|b| tcx.mk_const(ty::ConstS { kind: ty::ConstKind::Value(*b), ty: *inner_ty }))
+                .map(|b| tcx.mk_const(ty::ConstKind::Value(*b), *inner_ty))
                 .collect::<Vec<_>>();
             debug!(?field_consts);
 
@@ -52,10 +52,7 @@ pub(crate) fn destructure_const<'tcx>(
 
             for (field, field_valtree) in iter::zip(fields, branches) {
                 let field_ty = field.ty(tcx, substs);
-                let field_const = tcx.mk_const(ty::ConstS {
-                    kind: ty::ConstKind::Value(*field_valtree),
-                    ty: field_ty,
-                });
+                let field_const = tcx.mk_const(ty::ConstKind::Value(*field_valtree), field_ty);
                 field_consts.push(field_const);
             }
             debug!(?field_consts);
@@ -65,10 +62,7 @@ pub(crate) fn destructure_const<'tcx>(
         ty::Tuple(elem_tys) => {
             let fields = iter::zip(*elem_tys, branches)
                 .map(|(elem_ty, elem_valtree)| {
-                    tcx.mk_const(ty::ConstS {
-                        kind: ty::ConstKind::Value(*elem_valtree),
-                        ty: elem_ty,
-                    })
+                    tcx.mk_const(ty::ConstKind::Value(*elem_valtree), elem_ty)
                 })
                 .collect::<Vec<_>>();
 
@@ -135,30 +129,30 @@ struct IsThirPolymorphic<'a, 'tcx> {
 
         impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> {
             fn expr_is_poly(&mut self, expr: &thir::Expr<'tcx>) -> bool {
-                if expr.ty.has_param_types_or_consts() {
+                if expr.ty.has_non_region_param() {
                     return true;
                 }
 
                 match expr.kind {
-                    thir::ExprKind::NamedConst { substs, .. } => substs.has_param_types_or_consts(),
+                    thir::ExprKind::NamedConst { substs, .. } => substs.has_non_region_param(),
                     thir::ExprKind::ConstParam { .. } => true,
                     thir::ExprKind::Repeat { value, count } => {
                         self.visit_expr(&self.thir()[value]);
-                        count.has_param_types_or_consts()
+                        count.has_non_region_param()
                     }
                     _ => false,
                 }
             }
 
             fn pat_is_poly(&mut self, pat: &thir::Pat<'tcx>) -> bool {
-                if pat.ty.has_param_types_or_consts() {
+                if pat.ty.has_non_region_param() {
                     return true;
                 }
 
                 match pat.kind {
-                    thir::PatKind::Constant { value } => value.has_param_types_or_consts(),
+                    thir::PatKind::Constant { value } => value.has_non_region_param(),
                     thir::PatKind::Range(box thir::PatRange { lo, hi, .. }) => {
-                        lo.has_param_types_or_consts() || hi.has_param_types_or_consts()
+                        lo.has_non_region_param() || hi.has_non_region_param()
                     }
                     _ => false,
                 }
@@ -258,19 +252,16 @@ fn recurse_build(&mut self, node: thir::ExprId) -> Result<NodeId, ErrorGuarantee
                 self.nodes.push(Node::Leaf(ty::Const::from_value(self.tcx, val, node.ty)))
             }
             &ExprKind::NamedConst { def_id, substs, user_ty: _ } => {
-                let uneval = ty::Unevaluated::new(ty::WithOptConstParam::unknown(def_id), substs);
+                let uneval =
+                    ty::UnevaluatedConst::new(ty::WithOptConstParam::unknown(def_id), substs);
 
-                let constant = self
-                    .tcx
-                    .mk_const(ty::ConstS { kind: ty::ConstKind::Unevaluated(uneval), ty: node.ty });
+                let constant = self.tcx.mk_const(ty::ConstKind::Unevaluated(uneval), node.ty);
 
                 self.nodes.push(Node::Leaf(constant))
             }
 
             ExprKind::ConstParam { param, .. } => {
-                let const_param = self
-                    .tcx
-                    .mk_const(ty::ConstS { kind: ty::ConstKind::Param(*param), ty: node.ty });
+                let const_param = self.tcx.mk_const(ty::ConstKind::Param(*param), node.ty);
                 self.nodes.push(Node::Leaf(const_param))
             }