Skip to content

Commit dea9eb7

Browse files
committed
wip
1 parent 6956d2c commit dea9eb7

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,11 +2651,11 @@ rustc_queries! {
26512651
}
26522652

26532653
query generics_require_sized_self(def_id: DefId) -> bool {
2654-
desc { "check whether the item has a `where Self: Sized` bound" }
2654+
desc { |tcx| "check whether `{}` has a `where Self: Sized` bound", tcx.def_path_str(def_id) }
26552655
}
26562656

26572657
query cross_crate_inlinable(def_id: DefId) -> bool {
2658-
desc { "whether the item should be made inlinable across crates" }
2658+
desc { |tcx| "whether `{}` should be made inlinable across crates", tcx.def_path_str(def_id) }
26592659
separate_provide_extern
26602660
}
26612661

compiler/rustc_mir_transform/src/cross_crate_inline.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
9292
InliningThreshold::Never => return false,
9393
};
9494

95+
// Avoid inlining coroutines, since that does not make any sense.
96+
if tcx.is_coroutine(def_id.to_def_id()) {
97+
return false;
98+
}
99+
95100
let mir = tcx.optimized_mir(def_id);
96101
let mut checker =
97102
CostChecker { tcx, callee_body: mir, calls: 0, statements: 0, landing_pads: 0, resumes: 0 };

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,7 @@ impl<'tcx> Inliner<'tcx> for NormalInliner<'tcx> {
349349
}
350350
}
351351

352-
fn check_caller_mir_body(&self, body: &Body<'tcx>) -> bool {
353-
// Avoid inlining into coroutines, since their `optimized_mir` is used for layout computation,
354-
// which can create a cycle, even when no attempt is made to inline the function in the other
355-
// direction.
356-
if body.coroutine.is_some() {
357-
return false;
358-
}
359-
352+
fn check_caller_mir_body(&self, _: &Body<'tcx>) -> bool {
360353
true
361354
}
362355

@@ -709,6 +702,11 @@ fn check_mir_is_available<'tcx, I: Inliner<'tcx>>(
709702
return Err("self-recursion");
710703
}
711704

705+
// Avoid inlining coroutines, since that does not make any sense.
706+
if inliner.tcx().is_coroutine(callee_def_id) {
707+
return Err("coroutine");
708+
}
709+
712710
match callee.def {
713711
InstanceKind::Item(_) => {
714712
// If there is no MIR available (either because it was not in metadata or

compiler/rustc_mir_transform/src/inline/cycle.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ fn process<'tcx>(
9494
continue;
9595
}
9696

97+
// Avoid inlining into coroutines, since their `optimized_mir` is used for layout computation,
98+
// which can create a cycle, even when no attempt is made to inline the function in the other
99+
// direction.
100+
if tcx.is_coroutine(callee.def_id()) {
101+
reaches_root = true;
102+
seen.insert(callee, true);
103+
continue;
104+
}
105+
97106
if tcx.is_constructor(callee.def_id()) {
98107
trace!("constructors always have MIR");
99108
// Constructor functions cannot cause a query cycle.

0 commit comments

Comments
 (0)