Share inline(never) generics across crates
This reduces code sizes and better respects programmer intent when marking inline(never). Previously such a marking was essentially ignored for generic functions, as we'd still inline them in remote crates.
This commit is contained in:
parent
39cb3386dd
commit
4a216a25d1
26 changed files with 127 additions and 52 deletions
|
@ -282,7 +282,7 @@ fn exported_symbols_provider_local(
|
|||
}));
|
||||
}
|
||||
|
||||
if tcx.sess.opts.share_generics() && tcx.local_crate_exports_generics() {
|
||||
if tcx.local_crate_exports_generics() {
|
||||
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
|
||||
use rustc_middle::ty::InstanceKind;
|
||||
|
||||
|
@ -310,6 +310,16 @@ fn exported_symbols_provider_local(
|
|||
continue;
|
||||
}
|
||||
|
||||
if !tcx.sess.opts.share_generics() {
|
||||
if tcx.codegen_fn_attrs(mono_item.def_id()).inline == rustc_attr::InlineAttr::Never
|
||||
{
|
||||
// this is OK, we explicitly allow sharing inline(never) across crates even
|
||||
// without share-generics.
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
match *mono_item {
|
||||
MonoItem::Fn(Instance { def: InstanceKind::Item(def), args }) => {
|
||||
if args.non_erasable_generics().next().is_some() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue