diff options
| author | Ben Kimock <kimockb@gmail.com> | 2023-12-09 00:48:17 -0500 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2023-12-14 08:30:36 -0500 |
| commit | e559172249af514ab2c3be6340d557dcbb6347eb (patch) | |
| tree | 137b802a4be73cc8f8e92f41553322e28bb82c55 /compiler/rustc_mir_transform/src | |
| parent | 2b399b52753eac351067e73f4ff0de829443b9a7 (diff) | |
| download | rust-e559172249af514ab2c3be6340d557dcbb6347eb.tar.gz rust-e559172249af514ab2c3be6340d557dcbb6347eb.zip | |
Fix cases where std accidentally relied on inline(never)
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/cross_crate_inline.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/compiler/rustc_mir_transform/src/cross_crate_inline.rs b/compiler/rustc_mir_transform/src/cross_crate_inline.rs index 261d9dd448d..5f01b841867 100644 --- a/compiler/rustc_mir_transform/src/cross_crate_inline.rs +++ b/compiler/rustc_mir_transform/src/cross_crate_inline.rs @@ -22,6 +22,18 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { return false; } + // This just reproduces the logic from Instance::requires_inline. + match tcx.def_kind(def_id) { + DefKind::Ctor(..) | DefKind::Closure => return true, + DefKind::Fn | DefKind::AssocFn => {} + _ => return false, + } + + // From this point on, it is valid to return true or false. + if tcx.sess.opts.unstable_opts.cross_crate_inline_threshold == InliningThreshold::Always { + return true; + } + // Obey source annotations first; this is important because it means we can use // #[inline(never)] to force code generation. match codegen_fn_attrs.inline { @@ -30,13 +42,6 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { _ => {} } - // This just reproduces the logic from Instance::requires_inline. - match tcx.def_kind(def_id) { - DefKind::Ctor(..) | DefKind::Closure => return true, - DefKind::Fn | DefKind::AssocFn => {} - _ => return false, - } - // Don't do any inference when incremental compilation is enabled; the additional inlining that // inference permits also creates more work for small edits. if tcx.sess.opts.incremental.is_some() { |
