rust/compiler
bors 1025db84a6 Auto merge of #85211 - Aaron1011:metadata-invalid-span, r=michaelwoerister
Preserve `SyntaxContext` for invalid/dummy spans in crate metadata

Fixes #85197

We already preserved the `SyntaxContext` for invalid/dummy spans in the
incremental cache, but we weren't doing the same for crate metadata.
If an invalid (lo/hi from different files) span is written to the
incremental cache, we will decode it with a 'dummy' location, but keep
the original `SyntaxContext`. Since the crate metadata encoder was only
checking for `DUMMY_SP` (dummy location + root `SyntaxContext`),
the metadata encoder would treat it as a normal span, encoding the
`SyntaxContext`. As a result, the final span encoded to the metadata
would change across sessions, even if the crate itself was unchanged.

This could lead to an 'unstable fingerprint' ICE under the following conditions:
1. We compile a crate with an invalid span using incremental compilation. The metadata encoder discards the `SyntaxContext` since the span is invalid, while the incremental cache encoder preserves the `SyntaxContext`
2. From another crate, we execute a foreign query, decoding the invalid span from the metadata as `DUMMY_SP` (e.g. with `SyntaxContext::root()`). This span gets hashed into the query fingerprint. So far, this has always happened through the `optimized_mir` query.
3. We recompile the first crate using our populated incremental cache, without changing anything. We load the (previously) invalid span from our incremental cache - it gets converted to a span with a dummy (but valid) location, along with the original `SyntaxContext`. This span gets written out to the crate metadata - since it now has a valid location, we preserve its `SyntaxContext`.
4. We recompile the second crate, again using a populated incremental cache. We now re-run the foreign query `optimized_mir` - the foreign crate hash is unchanged, but we end up decoding a different span (it now ha a non-root `SyntaxContext`). This results in the fingerprint changing, resulting in an ICE.

This PR updates our encoding of spans in the crate metadata to mirror
the encoding of spans into the incremental cache. We now always encode a
`SyntaxContext`, and encode location information for spans with a
non-dummy location.
2021-05-14 16:58:30 +00:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Add support for const operands and options to global_asm! 2021-05-13 22:31:57 +01:00
rustc_ast_lowering Clarify error message when both asm! and global_asm! are unsupported 2021-05-13 22:31:58 +01:00
rustc_ast_passes Implement RFC 2951: Native link modifiers 2021-05-05 16:04:25 -07:00
rustc_ast_pretty Add support for const operands and options to global_asm! 2021-05-13 22:31:57 +01:00
rustc_attr
rustc_builtin_macros Add support for const operands and options to global_asm! 2021-05-13 22:31:57 +01:00
rustc_codegen_cranelift Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa 2021-05-14 12:58:58 +00:00
rustc_codegen_llvm Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa 2021-05-14 12:58:58 +00:00
rustc_codegen_ssa Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa 2021-05-14 12:58:58 +00:00
rustc_data_structures Only compute Obligation cache_key once in register_obligation_at 2021-05-04 11:57:53 -07:00
rustc_driver Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot 2021-05-12 08:38:03 +00:00
rustc_error_codes Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis 2021-05-04 08:09:23 +00:00
rustc_errors Show macro name in 'this error originates in macro' message 2021-05-12 19:03:06 -04:00
rustc_expand Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_feature Auto merge of #85186 - nikomatsakis:issue-83538-polluted-cache, r=jackh726 2021-05-13 19:36:46 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Add support for const operands and options to global_asm! 2021-05-13 22:31:57 +01:00
rustc_hir_pretty Add support for const operands and options to global_asm! 2021-05-13 22:31:57 +01:00
rustc_incremental Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot 2021-05-12 08:38:03 +00:00
rustc_index Change bitwise operator to more easily keep data in vector registers 2021-05-04 11:55:18 -04:00
rustc_infer Don't suggest adding 'static lifetime to arguments 2021-05-12 21:43:09 -04:00
rustc_interface Auto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakis 2021-05-13 10:49:29 +00:00
rustc_lexer
rustc_lint Implement span quoting for proc-macros 2021-05-12 00:51:31 -04:00
rustc_lint_defs Add additional migrations to handle auto-traits and clone traits 2021-05-06 14:17:59 -04:00
rustc_llvm Auto merge of #85190 - mati865:update-cc, r=Mark-Simulacrum 2021-05-14 04:12:40 +00:00
rustc_macros
rustc_metadata Auto merge of #85211 - Aaron1011:metadata-invalid-span, r=michaelwoerister 2021-05-14 16:58:30 +00:00
rustc_middle Auto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakis 2021-05-13 10:49:29 +00:00
rustc_mir global_asm! consts do not depend on other items 2021-05-13 22:31:58 +01:00
rustc_mir_build Auto merge of #85233 - FabianWolff:issue-85227, r=petrochenkov 2021-05-14 06:53:45 +00:00
rustc_parse Rollup merge of #84793 - estebank:parse-struct-field-default, r=davidtwco 2021-05-12 17:19:25 +02:00
rustc_parse_format
rustc_passes Add support for const operands and options to global_asm! 2021-05-13 22:31:57 +01:00
rustc_plugin_impl
rustc_privacy fix few typos 2021-04-19 15:57:08 +03:00
rustc_query_impl Apply --cfg parallel_compiler when documenting 2021-05-01 00:25:11 -04:00
rustc_query_system Show nicer error when an 'unstable fingerprints' error occurs 2021-05-10 17:43:51 -04:00
rustc_resolve Add support for const operands and options to global_asm! 2021-05-13 22:31:57 +01:00
rustc_save_analysis Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
rustc_serialize
rustc_session Auto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakis 2021-05-13 10:49:29 +00:00
rustc_span Auto merge of #85186 - nikomatsakis:issue-83538-polluted-cache, r=jackh726 2021-05-13 19:36:46 +00:00
rustc_symbol_mangling
rustc_target Add initial asm!() support for PowerPC 2021-05-11 19:04:16 -05:00
rustc_trait_selection have on_completion record subcycles 2021-05-13 05:58:21 -04:00
rustc_traits
rustc_ty_utils Implement changes suggested by tmiasko and davidtwco 2021-05-10 17:47:50 +02:00
rustc_type_ir Make TypeFoldable::is_global() false when fresh tys/consts are present 2021-05-01 16:58:33 -04:00
rustc_typeck Auto merge of #84107 - Amanieu:global_asm2, r=nagisa 2021-05-13 22:17:43 +00:00