Auto merge of #147231 - CrooseGit:dev/reucru01/extend_rustc_force_inl… · rust-lang/rust@8d603ef (original) (raw)

File tree

20 files changed

lines changed

20 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -72,7 +72,11 @@ impl<S: Stage> SingleAttributeParser for RustcForceInlineParser {
72 72 const PATH: &'static [Symbol] = &[sym::rustc_force_inline];
73 73 const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
74 74 const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
75 -const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
75 +const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
76 +Allow(Target::Fn),
77 +Allow(Target::Method(MethodKind::Inherent)),
78 +]);
79 +
76 80 const TEMPLATE: AttributeTemplate = template!(Word, List: &["reason"], NameValueStr: "reason");
77 81
78 82 fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1 +- // MIR for `caller::{closure#0}` before ForceInline
2 ++ // MIR for `caller::{closure#0}` after ForceInline
3 +
4 + fn caller::{closure#0}(_1: &{closure@$DIR/forced_closure_inherent.rs:14:6: 14:8}) -> () {
5 + let mut _0: ();
6 + let _2: ();
7 ++ scope 1 (inlined Foo::callee_forced) {
8 ++ }
9 +
10 + bb0: {
11 + StorageLive(_2);
12 +- _2 = Foo::callee_forced() -> [return: bb1, unwind unreachable];
13 +- }
14 +-
15 +- bb1: {
16 + StorageDead(_2);
17 + _0 = const ();
18 + return;
19 + }
20 + }
21 +
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1 +- // MIR for `caller::{closure#0}` before ForceInline
2 ++ // MIR for `caller::{closure#0}` after ForceInline
3 +
4 + fn caller::{closure#0}(_1: &{closure@$DIR/forced_closure_inherent.rs:14:6: 14:8}) -> () {
5 + let mut _0: ();
6 + let _2: ();
7 ++ scope 1 (inlined Foo::callee_forced) {
8 ++ }
9 +
10 + bb0: {
11 + StorageLive(_2);
12 +- _2 = Foo::callee_forced() -> [return: bb1, unwind continue];
13 +- }
14 +-
15 +- bb1: {
16 + StorageDead(_2);
17 + _0 = const ();
18 + return;
19 + }
20 + }
21 +
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1 +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2 +//@ compile-flags: -Copt-level=0 --crate-type=lib
3 +#![feature(rustc_attrs)]
4 +
5 +struct Foo {}
6 +
7 +impl Foo {
8 +#[rustc_force_inline]
9 +pub fn callee_forced() {}
10 +}
11 +
12 +// EMIT_MIR forced_closure_inherent.caller-{closure#0}.ForceInline.diff
13 +pub fn caller() {
14 +(|
15 +Foo::callee_forced();
16 +// CHECK-LABEL: fn caller::{closure#0}(
17 +// CHECK: (inlined Foo::callee_forced)
18 +})();
19 +}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1 +- // MIR for `caller` before ForceInline
2 ++ // MIR for `caller` after ForceInline
3 +
4 + fn caller() -> () {
5 + let mut _0: ();
6 + let _1: ();
7 ++ scope 1 (inlined Foo::bar) {
8 ++ }
9 +
10 + bb0: {
11 + StorageLive(_1);
12 +- _1 = Foo::bar() -> [return: bb1, unwind unreachable];
13 +- }
14 +-
15 +- bb1: {
16 + StorageDead(_1);
17 + _0 = const ();
18 + return;
19 + }
20 + }
21 +
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1 +- // MIR for `caller` before ForceInline
2 ++ // MIR for `caller` after ForceInline
3 +
4 + fn caller() -> () {
5 + let mut _0: ();
6 + let _1: ();
7 ++ scope 1 (inlined Foo::bar) {
8 ++ }
9 +
10 + bb0: {
11 + StorageLive(_1);
12 +- _1 = Foo::bar() -> [return: bb1, unwind continue];
13 +- }
14 +-
15 +- bb1: {
16 + StorageDead(_1);
17 + _0 = const ();
18 + return;
19 + }
20 + }
21 +
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
1 +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2 +//@ compile-flags: -Copt-level=0 --crate-type=lib
3 +#![feature(rustc_attrs)]
4 +
5 +struct Foo;
6 +
7 +impl Foo {
8 +#[rustc_force_inline]
9 +fn bar() {}
10 +}
11 +
12 +// EMIT_MIR forced_inherent.caller.ForceInline.diff
13 +fn caller() {
14 +Foo::bar();
15 +// CHECK-LABEL: fn caller(
16 +// CHECK: (inlined Foo::bar)
17 +}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1 +- // MIR for `caller` before ForceInline
2 ++ // MIR for `caller` after ForceInline
3 +
4 + fn caller() -> () {
5 + let mut _0: ();
6 + let _1: ();
7 ++ scope 1 (inlined Foo::bar) {
8 ++ }
9 +
10 + bb0: {
11 + StorageLive(_1);
12 +- _1 = Foo::bar() -> [return: bb1, unwind unreachable];
13 +- }
14 +-
15 +- bb1: {
16 + StorageDead(_1);
17 + _0 = const ();
18 + return;
19 + }
20 + }
21 +
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1 +- // MIR for `caller` before ForceInline
2 ++ // MIR for `caller` after ForceInline
3 +
4 + fn caller() -> () {
5 + let mut _0: ();
6 + let _1: ();
7 ++ scope 1 (inlined Foo::bar) {
8 ++ }
9 +
10 + bb0: {
11 + StorageLive(_1);
12 +- _1 = Foo::bar() -> [return: bb1, unwind continue];
13 +- }
14 +-
15 +- bb1: {
16 + StorageDead(_1);
17 + _0 = const ();
18 + return;
19 + }
20 + }
21 +
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1 +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2 +//@ compile-flags: -Copt-level=0 --crate-type=lib
3 +#![feature(rustc_attrs)]
4 +
5 +struct Foo;
6 +
7 +impl Foo {
8 +#[rustc_force_inline]
9 +fn bar() {}
10 +}
11 +
12 +trait Tr {
13 +fn bar();
14 +}
15 +
16 +impl Tr for Foo {
17 +fn bar() {}
18 +}
19 +
20 +// EMIT_MIR forced_inherent_ambiguous.caller.ForceInline.diff
21 +fn caller() {
22 +Foo::bar();
23 +// CHECK-LABEL: fn caller(
24 +// CHECK: (inlined Foo::bar)
25 +}