|
| 1 | +// revisions:rpass1 rpass2 |
| 2 | +// compile-flags: -Z query-dep-graph |
| 3 | +// aux-build:cached_hygiene.rs |
| 4 | + |
| 5 | +// This tests the folllowing scenario |
| 6 | +// 1. A foreign crate is compiled with incremental compilation. |
| 7 | +// This causes hygiene information to be saved to the incr cache. |
| 8 | +// 2. One function is the foreign crate is modified. This causes the |
| 9 | +// optimized mir for an unmodified function to be loaded from the |
| 10 | +// incremental cache and written out to the crate metadata. |
| 11 | +// 3. In the process of loading and writing out this function's MIR, |
| 12 | +// we load hygiene information from the incremental cache and |
| 13 | +// write it to our metadata. |
| 14 | +// 4. This hygiene information is loaded by another crate (this file) |
| 15 | + |
| 16 | +// Previously, this situation would cause hygiene identifiers |
| 17 | +// (SyntaxContexts and ExpnIds) to get corrupted when we tried to |
| 18 | +// serialize the hygiene information loaded from the incr cache into |
| 19 | +// the metadata. Specifically, we were not resetting `orig_id` |
| 20 | +// for an `EpxnData` generate in the current crate, which would cause |
| 21 | +// us to serialize the `ExpnId` pointing to a garbage location in |
| 22 | +// the metadata. |
| 23 | + |
| 24 | +#![feature(rustc_attrs)] |
| 25 | + |
| 26 | +#![rustc_partition_reused(module="load_cached_hygiene-call_unchanged_function", cfg="rpass2")] |
| 27 | +#![rustc_partition_codegened(module="load_cached_hygiene-call_changed_function", cfg="rpass2")] |
| 28 | + |
| 29 | + |
| 30 | +extern crate cached_hygiene; |
| 31 | + |
| 32 | +pub mod call_unchanged_function { |
| 33 | + |
| 34 | + pub fn unchanged() { |
| 35 | + cached_hygiene::unchanged_fn(); |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +pub mod call_changed_function { |
| 40 | + pub fn changed() { |
| 41 | + cached_hygiene::changed_fn(); |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +pub fn main() { |
| 46 | + call_unchanged_function::unchanged(); |
| 47 | + call_changed_function::changed(); |
| 48 | +} |
0 commit comments