Skip to content

Commit 80cb3f7

Browse files
Auto merge of #147351 - Noratrieb:avoid-localcopy-for-inline-on-o0, r=<try>
Avoid `LocalCopy` instantiation for `#[inline]` on `-Copt-level=0`
2 parents ed1d943 + 53579fc commit 80cb3f7

File tree

19 files changed

+166
-153
lines changed

19 files changed

+166
-153
lines changed

compiler/rustc_builtin_macros/src/deriving/clone.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub(crate) fn expand_deriving_clone(
8181
explicit_self: true,
8282
nonself_args: Vec::new(),
8383
ret_ty: Self_,
84-
attributes: thin_vec![cx.attr_word(sym::inline, span)],
84+
attributes: thin_vec![cx.attr_word(sym::rustc_defer_codegen, span)],
8585
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
8686
combine_substructure: substructure,
8787
}],

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(crate) fn expand_deriving_eq(
3232
nonself_args: vec![],
3333
ret_ty: Unit,
3434
attributes: thin_vec![
35-
cx.attr_word(sym::inline, span),
35+
cx.attr_word(sym::rustc_defer_codegen, span),
3636
cx.attr_nested_word(sym::doc, sym::hidden, span),
3737
cx.attr_nested_word(sym::coverage, sym::off, span)
3838
],

compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn expand_deriving_ord(
2828
explicit_self: true,
2929
nonself_args: vec![(self_ref(), sym::other)],
3030
ret_ty: Path(path_std!(cmp::Ordering)),
31-
attributes: thin_vec![cx.attr_word(sym::inline, span)],
31+
attributes: thin_vec![cx.attr_word(sym::rustc_defer_codegen, span)],
3232
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
3333
combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))),
3434
}],

compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(crate) fn expand_deriving_partial_eq(
4141
explicit_self: true,
4242
nonself_args: vec![(self_ref(), sym::other)],
4343
ret_ty: Path(path_local!(bool)),
44-
attributes: thin_vec![cx.attr_word(sym::inline, span)],
44+
attributes: thin_vec![cx.attr_word(sym::rustc_defer_codegen, span)],
4545
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
4646
combine_substructure: combine_substructure(Box::new(|a, b, c| {
4747
BlockOrExpr::new_expr(get_substructure_equality_expr(a, b, c))

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub(crate) fn expand_deriving_partial_ord(
4747
explicit_self: true,
4848
nonself_args: vec![(self_ref(), sym::other)],
4949
ret_ty,
50-
attributes: thin_vec![cx.attr_word(sym::inline, span)],
50+
attributes: thin_vec![cx.attr_word(sym::rustc_defer_codegen, span)],
5151
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
5252
combine_substructure: combine_substructure(Box::new(|cx, span, substr| {
5353
cs_partial_cmp(cx, span, substr, discr_then_data)

compiler/rustc_builtin_macros/src/deriving/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(crate) fn expand_deriving_debug(
3232
explicit_self: true,
3333
nonself_args: vec![(fmtr, sym::f)],
3434
ret_ty: Path(path_std!(fmt::Result)),
35-
attributes: thin_vec![cx.attr_word(sym::inline, span)],
35+
attributes: thin_vec![cx.attr_word(sym::rustc_defer_codegen, span)],
3636
fieldless_variants_strategy:
3737
FieldlessVariantsStrategy::SpecializeIfAllVariantsFieldless,
3838
combine_substructure: combine_substructure(Box::new(|a, b, c| {

compiler/rustc_builtin_macros/src/deriving/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub(crate) fn expand_deriving_default(
3535
explicit_self: false,
3636
nonself_args: Vec::new(),
3737
ret_ty: Self_,
38-
attributes: thin_vec![cx.attr_word(sym::inline, span)],
38+
attributes: thin_vec![cx.attr_word(sym::rustc_defer_codegen, span)],
3939
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
4040
combine_substructure: combine_substructure(Box::new(|cx, trait_span, substr| {
4141
match substr.fields {

compiler/rustc_builtin_macros/src/deriving/from.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub(crate) fn expand_deriving_from(
8686
explicit_self: false,
8787
nonself_args: vec![(from_type, sym::value)],
8888
ret_ty: Ty::Self_,
89-
attributes: thin_vec![cx.attr_word(sym::inline, span)],
89+
attributes: thin_vec![cx.attr_word(sym::rustc_defer_codegen, span)],
9090
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
9191
combine_substructure: combine_substructure(Box::new(|cx, span, substructure| {
9292
let field = match field {

compiler/rustc_builtin_macros/src/deriving/hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(crate) fn expand_deriving_hash(
3333
explicit_self: true,
3434
nonself_args: vec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)],
3535
ret_ty: Unit,
36-
attributes: thin_vec![cx.attr_word(sym::inline, span)],
36+
attributes: thin_vec![cx.attr_word(sym::rustc_defer_codegen, span)],
3737
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
3838
combine_substructure: combine_substructure(Box::new(|a, b, c| {
3939
hash_substructure(a, b, c)

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
13781378
rustc_force_inline, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing, EncodeCrossCrate::Yes,
13791379
"`#[rustc_force_inline]` forces a free function to be inlined"
13801380
),
1381+
rustc_attr!(
1382+
rustc_defer_codegen, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
1383+
"`#[rustc_defer_codegen]` makes a non-generic function instantiated in crates that use it instead of the defining crates"
1384+
),
13811385

13821386
// ==========================================================================
13831387
// Internal attributes, Testing:

0 commit comments

Comments
 (0)