diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-12-13 19:25:36 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-12-15 19:45:40 +0100 |
| commit | d48dbdc080f45f36ffc756de35c1443f2e05f527 (patch) | |
| tree | 5258ce40ce154feed6bf097ee2a370023cf915ef /compiler/rustc_mir_transform/src/inline.rs | |
| parent | 4a66a704b2c3d30ff07d89380ebb9ba3de3b3182 (diff) | |
| download | rust-d48dbdc080f45f36ffc756de35c1443f2e05f527.tar.gz rust-d48dbdc080f45f36ffc756de35c1443f2e05f527.zip | |
Move generator check earlier in inlining.
Diffstat (limited to 'compiler/rustc_mir_transform/src/inline.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/inline.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 558b1ce082e..8be95b2d95a 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -68,6 +68,12 @@ fn inline<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> bool { if body.source.promoted.is_some() { return false; } + // Avoid inlining into generators, since their `optimized_mir` is used for layout computation, + // which can create a cycle, even when no attempt is made to inline the function in the other + // direction. + if body.generator.is_some() { + return false; + } let mut this = Inliner { tcx, @@ -202,14 +208,6 @@ impl<'tcx> Inliner<'tcx> { if let Some(callee_def_id) = callee.def_id().as_local() { let callee_hir_id = self.tcx.hir().local_def_id_to_hir_id(callee_def_id); - // Avoid inlining into generators, - // since their `optimized_mir` is used for layout computation, which can - // create a cycle, even when no attempt is made to inline the function - // in the other direction. - if caller_body.generator.is_some() { - return Err("local generator (query cycle avoidance)"); - } - // Avoid a cycle here by only using `instance_mir` only if we have // a lower `HirId` than the callee. This ensures that the callee will // not inline us. This trick only works without incremental compilation. |
