1 // revisions: rpass1 rpass2
3 // aux-build:invalid-span-helper-lib.rs
5 // This issue has several different parts. The high level idea is:
6 // 1. We create an 'invalid' span with the help of the `respan` proc-macro,
7 // The compiler attempts to prevent the creation of invalid spans by
8 // refusing to join spans with different `SyntaxContext`s. We work around
9 // this by applying the same `SyntaxContext` to the span of every token,
10 // using `Span::resolved_at`
11 // 2. We using this invalid span in the body of a function, causing it to get
12 // encoded into the `optimized_mir`
13 // 3. We call the function from a different crate - since the function is generic,
14 // monomorphization runs, causing `optimized_mir` to get called.
15 // 4. We re-run compilation using our populated incremental cache, but without
16 // making any changes. When we recompile the crate containing our generic function
17 // (`invalid_span_helper_lib`), we load the span from the incremental cache, and
18 // write it into the crate metadata.
20 extern crate invalid_span_helper_lib;
23 invalid_span_helper_lib::foo::<u8>();