Skip to content

Commit

Permalink
Auto merge of #98402 - cjgillot:undead, r=michaelwoerister
Browse files Browse the repository at this point in the history
Rewrite dead-code pass to avoid fetching HIR.

This allows to get a more uniform handling of spans, and to simplify the grouping of diagnostics for variants and fields.
  • Loading branch information
bors committed Jul 1, 2022
2 parents ca1e68b + 2d82234 commit 5b9775f
Show file tree
Hide file tree
Showing 24 changed files with 266 additions and 397 deletions.
23 changes: 1 addition & 22 deletions compiler/rustc_mir_build/src/thir/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
use crate::thir::pattern::pat_from_hir;
use crate::thir::util::UserAnnotatedTyHelpers;

use rustc_ast as ast;
use rustc_data_structures::steal::Steal;
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::HirId;
use rustc_hir::Node;
use rustc_middle::middle::region;
use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
use rustc_middle::mir::ConstantKind;
use rustc_middle::thir::*;
use rustc_middle::ty::{self, RvalueScopes, Ty, TyCtxt};
use rustc_middle::ty::{self, RvalueScopes, TyCtxt};
use rustc_span::Span;

pub(crate) fn thir_body<'tcx>(
Expand Down Expand Up @@ -80,24 +77,6 @@ impl<'tcx> Cx<'tcx> {
}
}

#[instrument(skip(self), level = "debug")]
pub(crate) fn const_eval_literal(
&mut self,
lit: &'tcx ast::LitKind,
ty: Ty<'tcx>,
sp: Span,
neg: bool,
) -> ConstantKind<'tcx> {
match self.tcx.at(sp).lit_to_mir_constant(LitToConstInput { lit, ty, neg }) {
Ok(c) => c,
Err(LitToConstError::Reported) => {
// create a dummy value and continue compiling
ConstantKind::Ty(self.tcx.const_error(ty))
}
Err(LitToConstError::TypeError) => bug!("const_eval_literal: had type error"),
}
}

#[tracing::instrument(level = "debug", skip(self))]
pub(crate) fn pattern_from_hir(&mut self, p: &hir::Pat<'_>) -> Pat<'tcx> {
let p = match self.tcx.hir().get(p.hir_id) {
Expand Down
Loading

0 comments on commit 5b9775f

Please sign in to comment.