Skip to content

Commit 0cfe0b4

Browse files
committed
Make #[inline] optional on closures
1 parent 974ccc1 commit 0cfe0b4

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

compiler/rustc_middle/src/ty/instance.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,7 @@ impl<'tcx> InstanceKind<'tcx> {
295295
ty::InstanceKind::ThreadLocalShim(_) => return false,
296296
_ => return true,
297297
};
298-
matches!(
299-
tcx.def_key(def_id).disambiguated_data.data,
300-
DefPathData::Ctor | DefPathData::Closure
301-
)
298+
matches!(tcx.def_key(def_id).disambiguated_data.data, DefPathData::Ctor)
302299
}
303300

304301
/// Returns `true` if the machine code for this instance is instantiated in

compiler/rustc_mir_transform/src/cross_crate_inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
2424

2525
// This just reproduces the logic from Instance::requires_inline.
2626
match tcx.def_kind(def_id) {
27-
DefKind::Ctor(..) | DefKind::Closure | DefKind::SyntheticCoroutineBody => return true,
27+
DefKind::Ctor(..) => return true,
2828
DefKind::Fn | DefKind::AssocFn => {}
2929
_ => return false,
3030
}

tests/coverage/closure.cov-map

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,17 @@ Number of file 0 mappings: 24
3232
- Code(Counter(0)) at (prev + 1, 5) to (start + 3, 2)
3333
Highest counter ID seen: c1
3434

35-
Function name: closure::main::{closure#0}
36-
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 28, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 09, 00, 0a, 01, 01, 09, 01, 06]
35+
Function name: closure::main::{closure#0} (unused)
36+
Raw bytes (24): 0x[01, 01, 00, 04, 00, 28, 05, 02, 14, 00, 02, 15, 02, 0a, 00, 02, 09, 00, 0a, 00, 01, 09, 01, 06]
3737
Number of files: 1
3838
- file 0 => global file 1
39-
Number of expressions: 1
40-
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
39+
Number of expressions: 0
4140
Number of file 0 mappings: 4
42-
- Code(Counter(0)) at (prev + 40, 5) to (start + 2, 20)
43-
- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10)
44-
- Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10)
45-
= (c0 - c1)
46-
- Code(Counter(0)) at (prev + 1, 9) to (start + 1, 6)
47-
Highest counter ID seen: c1
41+
- Code(Zero) at (prev + 40, 5) to (start + 2, 20)
42+
- Code(Zero) at (prev + 2, 21) to (start + 2, 10)
43+
- Code(Zero) at (prev + 2, 9) to (start + 0, 10)
44+
- Code(Zero) at (prev + 1, 9) to (start + 1, 6)
45+
Highest counter ID seen: (none)
4846

4947
Function name: closure::main::{closure#10} (unused)
5048
Raw bytes (10): 0x[01, 01, 00, 01, 00, 9b, 01, 07, 00, 21]
@@ -140,19 +138,17 @@ Number of file 0 mappings: 6
140138
- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10)
141139
Highest counter ID seen: c1
142140

143-
Function name: closure::main::{closure#18}
144-
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 19, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 11, 00, 12, 01, 01, 11, 01, 0e]
141+
Function name: closure::main::{closure#18} (unused)
142+
Raw bytes (24): 0x[01, 01, 00, 04, 00, 19, 0d, 02, 1c, 00, 02, 1d, 02, 12, 00, 02, 11, 00, 12, 00, 01, 11, 01, 0e]
145143
Number of files: 1
146144
- file 0 => global file 1
147-
Number of expressions: 1
148-
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
145+
Number of expressions: 0
149146
Number of file 0 mappings: 4
150-
- Code(Counter(0)) at (prev + 25, 13) to (start + 2, 28)
151-
- Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18)
152-
- Code(Expression(0, Sub)) at (prev + 2, 17) to (start + 0, 18)
153-
= (c0 - c1)
154-
- Code(Counter(0)) at (prev + 1, 17) to (start + 1, 14)
155-
Highest counter ID seen: c1
147+
- Code(Zero) at (prev + 25, 13) to (start + 2, 28)
148+
- Code(Zero) at (prev + 2, 29) to (start + 2, 18)
149+
- Code(Zero) at (prev + 2, 17) to (start + 0, 18)
150+
- Code(Zero) at (prev + 1, 17) to (start + 1, 14)
151+
Highest counter ID seen: (none)
156152

157153
Function name: closure::main::{closure#19}
158154
Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 43, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 11, 00, 12, 01, 01, 11, 01, 0e]

0 commit comments

Comments
 (0)