Rollup merge of #129738 - nnethercote:rustc_mir_transform-cleanups, r=cjgillot
`rustc_mir_transform` cleanups A bunch of small improvements I made while looking closely at this code. r? `@saethlin`
This commit is contained in:
@@ -3,13 +3,11 @@
|
||||
#![feature(box_patterns)]
|
||||
#![feature(const_type_name)]
|
||||
#![feature(cow_is_borrowed)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(impl_trait_in_assoc_type)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(never_type)]
|
||||
#![feature(option_get_or_insert_default)]
|
||||
#![feature(round_char_boundary)]
|
||||
#![feature(try_blocks)]
|
||||
#![feature(yeet_expr)]
|
||||
@@ -17,6 +15,7 @@
|
||||
|
||||
use hir::ConstContext;
|
||||
use required_consts::RequiredConstsVisitor;
|
||||
use rustc_const_eval::check_consts::{self, ConstCx};
|
||||
use rustc_const_eval::util;
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_data_structures::steal::Steal;
|
||||
@@ -33,6 +32,7 @@ use rustc_middle::mir::{
|
||||
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::util::Providers;
|
||||
use rustc_middle::{bug, query, span_bug};
|
||||
use rustc_mir_dataflow::rustc_peek;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::{sym, DUMMY_SP};
|
||||
use rustc_trait_selection::traits;
|
||||
@@ -108,9 +108,6 @@ mod unreachable_enum_branching;
|
||||
mod unreachable_prop;
|
||||
mod validate;
|
||||
|
||||
use rustc_const_eval::check_consts::{self, ConstCx};
|
||||
use rustc_mir_dataflow::rustc_peek;
|
||||
|
||||
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
@@ -128,7 +125,7 @@ pub fn provide(providers: &mut Providers) {
|
||||
mir_coroutine_witnesses: coroutine::mir_coroutine_witnesses,
|
||||
optimized_mir,
|
||||
is_mir_available,
|
||||
is_ctfe_mir_available: |tcx, did| is_mir_available(tcx, did),
|
||||
is_ctfe_mir_available: is_mir_available,
|
||||
mir_callgraph_reachable: inline::cycle::mir_callgraph_reachable,
|
||||
mir_inliner_callees: inline::cycle::mir_inliner_callees,
|
||||
promoted_mir,
|
||||
@@ -221,10 +218,8 @@ fn is_mir_available(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||
/// Finds the full set of `DefId`s within the current crate that have
|
||||
/// MIR associated with them.
|
||||
fn mir_keys(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LocalDefId> {
|
||||
let mut set = FxIndexSet::default();
|
||||
|
||||
// All body-owners have MIR associated with them.
|
||||
set.extend(tcx.hir().body_owners());
|
||||
let mut set: FxIndexSet<_> = tcx.hir().body_owners().collect();
|
||||
|
||||
// Additionally, tuple struct/variant constructors have MIR, but
|
||||
// they don't have a BodyId, so we need to build them separately.
|
||||
@@ -249,8 +244,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs {
|
||||
|
||||
// No need to const-check a non-const `fn`.
|
||||
match const_kind {
|
||||
Some(ConstContext::Const { .. } | ConstContext::Static(_))
|
||||
| Some(ConstContext::ConstFn) => {}
|
||||
Some(ConstContext::Const { .. } | ConstContext::Static(_) | ConstContext::ConstFn) => {}
|
||||
None => span_bug!(
|
||||
tcx.def_span(def),
|
||||
"`mir_const_qualif` should only be called on const fns and const items"
|
||||
|
||||
Reference in New Issue
Block a user