Skip to content

Commit 38f68dc

Browse files
committed
Add the codegen-source-order option
1 parent 32e7a4b commit 38f68dc

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,8 @@ options! {
21722172
"emit runtime checks for contract pre- and post-conditions (default: no)"),
21732173
coverage_options: CoverageOptions = (CoverageOptions::default(), parse_coverage_options, [TRACKED],
21742174
"control details of coverage instrumentation"),
2175+
codegen_source_order: bool = (false, parse_bool, [UNTRACKED],
2176+
"emit mono items in the order of spans in source files (default: no)"),
21752177
crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
21762178
"inject the given attribute in the crate"),
21772179
cross_crate_inline_threshold: InliningThreshold = (InliningThreshold::Sometimes(100), parse_inlining_threshold, [TRACKED],
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `codegen-source-order`
2+
3+
---
4+
5+
This feature allows you to have a predictive and
6+
deterministic order for items after codegen.
7+
8+
For every `CodegenUnit`, local `MonoItem`s would
9+
be sorted by `(Span, DefPath, SymbolName)`, which
10+
makes codegen tests rely on the order of items in
11+
source files work.
12+
13+
Note: If you would like to use it, you have to
14+
manually sort items that are generated by a macro
15+
in lexicographical order in source files, because
16+
of the same spans owned by all items of a macro.
17+
So we have to distinguish them by `DefPath`s.

0 commit comments

Comments
 (0)