We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d9fe91 commit 61e30b3Copy full SHA for 61e30b3
compiler/rustc_middle/src/thir.rs
@@ -747,8 +747,12 @@ pub enum PatKind<'tcx> {
747
value: mir::Const<'tcx>,
748
},
749
750
+ /// Pattern lowered from an inline constant
751
InlineConstant {
752
+ /// Unevaluated version of the constant
753
value: mir::UnevaluatedConst<'tcx>,
754
+ /// Actual pattern that the constant lowered to. As with other constants, inline constants
755
+ /// are matched structurally where possible.
756
subpattern: Box<Pat<'tcx>>,
757
758
compiler/rustc_mir_build/src/build/mod.rs
@@ -67,7 +67,6 @@ fn mir_build<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Body<'tcx> {
67
thir::BodyTy::Const(ty) => construct_const(tcx, def, thir, expr, ty),
68
};
69
70
- tcx.ensure().check_match(def);
71
// this must run before MIR dump, because
72
// "not all control paths return a value" is reported here.
73
//
compiler/rustc_mir_build/src/check_unsafety.rs
@@ -124,7 +124,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
124
/// Handle closures/generators/inline-consts, which is unsafecked with their parent body.
125
fn visit_inner_body(&mut self, def: LocalDefId) {
126
if let Ok((inner_thir, expr)) = self.tcx.thir_body(def) {
127
- let _ = self.tcx.ensure_with_value().mir_built(def);
+ self.tcx.ensure_with_value().mir_built(def);
128
let inner_thir = &inner_thir.steal();
129
let hir_context = self.tcx.hir().local_def_id_to_hir_id(def);
130
let mut inner_visitor = UnsafetyVisitor { thir: inner_thir, hir_context, ..*self };
@@ -804,7 +804,7 @@ pub fn thir_check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
804
}
805
806
let Ok((thir, expr)) = tcx.thir_body(def) else { return };
807
- let _ = tcx.ensure_with_value().mir_built(def);
+ tcx.ensure_with_value().mir_built(def);
808
let thir = &thir.steal();
809
// If `thir` is empty, a type error occurred, skip this body.
810
if thir.exprs.is_empty() {
compiler/rustc_mir_build/src/thir/pattern/mod.rs
@@ -600,11 +600,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
600
// const eval path below.
601
// FIXME: investigate the performance impact of removing this.
602
let lit_input = match expr.kind {
603
- hir::ExprKind::Lit(ref lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }),
604
- hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => match expr.kind {
605
- hir::ExprKind::Lit(ref lit) => {
606
- Some(LitToConstInput { lit: &lit.node, ty, neg: true })
607
- }
+ hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }),
+ hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind {
+ hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: true }),
608
_ => None,
609
610
compiler/rustc_mir_build/src/thir/print.rs
@@ -692,7 +692,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
692
693
PatKind::Deref { subpattern } => {
694
print_indented!(self, "Deref { ", depth_lvl + 1);
695
- print_indented!(self, "subpattern: ", depth_lvl + 2);
+ print_indented!(self, "subpattern:", depth_lvl + 2);
696
self.print_pat(subpattern, depth_lvl + 2);
697
print_indented!(self, "}", depth_lvl + 1);
698
@@ -704,7 +704,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
704
PatKind::InlineConstant { value, subpattern } => {
705
print_indented!(self, "InlineConstant {", depth_lvl + 1);
706
print_indented!(self, format!("value: {:?}", value), depth_lvl + 2);
707
708
709
710
0 commit comments