Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,10 +1298,6 @@ impl<'a> CrateMetadataRef<'a> {
}
}

fn is_ctfe_mir_available(self, tcx: TyCtxt<'_>, id: DefIndex) -> bool {
self.root.tables.mir_for_ctfe.get((self, tcx), id).is_some()
}

fn is_item_mir_available(self, tcx: TyCtxt<'_>, id: DefIndex) -> bool {
self.root.tables.optimized_mir.get((self, tcx), id).is_some()
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ provide! { tcx, def_id, other, cdata,
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
attrs_for_def => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(tcx, def_id.index)) }
is_mir_available => { cdata.is_item_mir_available(tcx, def_id.index) }
is_ctfe_mir_available => { cdata.is_ctfe_mir_available(tcx, def_id.index) }
cross_crate_inlinable => { table_direct }

dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) }
Expand Down
11 changes: 3 additions & 8 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,12 +1102,8 @@ fn should_encode_mir(
def_id: LocalDefId,
) -> (bool, bool) {
match tcx.def_kind(def_id) {
// Constructors
DefKind::Ctor(_, _) => {
let mir_opt_base = tcx.sess.opts.output_types.should_codegen()
|| tcx.sess.opts.unstable_opts.always_encode_mir;
(true, mir_opt_base)
}
// instance_mir uses mir_for_ctfe rather than optimized_mir for constructors
DefKind::Ctor(_, _) => (true, false),
// Constants
DefKind::AnonConst | DefKind::InlineConst | DefKind::AssocConst | DefKind::Const => {
(true, false)
Expand All @@ -1117,11 +1113,10 @@ fn should_encode_mir(
DefKind::SyntheticCoroutineBody => (false, true),
// Full-fledged functions + closures
DefKind::AssocFn | DefKind::Fn | DefKind::Closure => {
let generics = tcx.generics_of(def_id);
let opt = tcx.sess.opts.unstable_opts.always_encode_mir
|| (tcx.sess.opts.output_types.should_codegen()
&& reachable_set.contains(&def_id)
&& (generics.requires_monomorphization(tcx)
&& (tcx.generics_of(def_id).requires_monomorphization(tcx)
|| tcx.cross_crate_inlinable(def_id)));
// The function has a `const` modifier or is in a `const trait`.
let is_const_fn = tcx.is_const_fn(def_id.to_def_id());
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_middle/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1588,11 +1588,6 @@ rustc_queries! {
separate_provide_extern
}

query is_ctfe_mir_available(key: DefId) -> bool {
desc { |tcx| "checking if item has CTFE MIR available: `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
separate_provide_extern
}
query is_mir_available(key: DefId) -> bool {
desc { |tcx| "checking if item has MIR available: `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() }
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ pub fn provide(providers: &mut Providers) {
optimized_mir,
check_liveness: liveness::check_liveness,
is_mir_available,
is_ctfe_mir_available: is_mir_available,
mir_callgraph_cyclic: inline::cycle::mir_callgraph_cyclic,
mir_inliner_callees: inline::cycle::mir_inliner_callees,
promoted_mir,
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,9 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) ->
return false;
}

if !tcx.is_mir_available(def_id) {
// See comment in should_encode_mir in rustc_metadata for why we don't report
// an error for constructors.
if !tcx.is_mir_available(def_id) && !matches!(tcx.def_kind(def_id), DefKind::Ctor(..)) {
tcx.dcx().emit_fatal(NoOptimizedMir {
span: tcx.def_span(def_id),
crate_name: tcx.crate_name(def_id.krate),
Expand Down
Loading