Open jessa0 opened 2 years ago
Bisection points to #93095 for this, but it may be a different manifestation of the earlier issue the PR was supposed to fix ? In any case, cc PR author @Aaron1011 and reviewer @cjgillot.
Since this repro depends on serde_repr
, and in turn serde
, syn
, etc it would be good to have an MCVE so that we can turn it into a test ?
Since this repro depends on
serde_repr
, and in turnserde
,syn
, etc it would be good to have an MCVE so that we can turn it into a test ?
Here's a minimal proc-macro-derive:
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, Data, DataEnum, DeriveInput};
#[proc_macro_derive(Bar)]
pub fn derive_bar(input: TokenStream) -> TokenStream {
let DeriveInput { ident, data, .. } = parse_macro_input!(input as DeriveInput);
match data {
Data::Enum(DataEnum { variants, .. }) => {
let constants = variants.iter().map(|variant| {
quote! {
const #variant: () = ();
}
});
quote! {
impl #ident {
#(#constants)*
}
}
.into()
}
_ => panic!(),
}
}
And here's the code to compile incrementally (before):
#[derive(foo_macros::Bar)]
pub enum FooEnum { One }
and after:
#[derive(foo_macros::Bar)]
pub enum FooEnum { Zero, One }
I couldn't manage to reproduce it by just passing in idents to a regular proc-macro. I'm not sure how to best eliminate syn
as a dependency..
Note: this issue was fixed by #95656 which will be available in tomorrow's nightly.
I have a minimized test locally - unfortunately, ai don't think it can be made to work with the revision system. I work on converting to a run-make test that manually edits the file.
Recompiling this minimal example using
rustc 1.60.0 (7737e0b5c 2022-04-04)
orrustc 1.62.0-nightly (1f7fb6413 2022-04-10)
crashes withFound unstable fingerprints for def_ident_span(foo[c936]::{impl#0}::deserialize::{impl#0}::One): Some(src/lib.rs:5:5: 5:8 (#0))
:Code
Since this is an incremental compilation bug, there are "before" and "after" code snippets, where a
cargo build
happens on the "before" snippet and then on the "after" snippet.Before
Unexpanded:
Expanded (via
cargo-expand
):After
Unexpanded:
Expanded (via
cargo-expand
):Meta
rustc --version --verbose
:rustc +nightly --version --verbose
:Error output
Before
After
Backtrace
``` thread 'rustc' panicked at 'Found unstable fingerprints for def_ident_span(foo[368a]::{impl#0}::deserialize::{impl#0}::One): Some(src/lib.rs:5:5: 5:8 (#0))', compiler/rustc_query_system/src/query/plumbing.rs:657:9 stack backtrace: 0: 0x103527118 -::fmt::h10cf06316d33e2a9
1: 0x103573808 - core::fmt::write::h1faf18c959c3a8df
2: 0x103519104 - std::io::Write::write_fmt::h86ab231360bc97d2
3: 0x10352ae44 - std::panicking::default_hook::{{closure}}::h36e628ffaf3cd44f
4: 0x10352aabc - std::panicking::default_hook::h3ee1564a7544e58f
5: 0x10a9005c4 - rustc_driver[3e35567b0507961a]::DEFAULT_HOOK::{closure#0}::{closure#0}
6: 0x10352b634 - std::panicking::rust_panic_with_hook::h191339fbd2fe2360
7: 0x10352b388 - std::panicking::begin_panic_handler::{{closure}}::h91c230befd9929e3
8: 0x103527600 - std::sys_common::backtrace::__rust_end_short_backtrace::haaaeebb1d37476b3
9: 0x10352b0c4 - _rust_begin_unwind
10: 0x1035a17fc - core::panicking::panic_fmt::h4fe1013b011ef602
11: 0x10e814198 - rustc_query_system[91d58cadb6adb151]::query::plumbing::incremental_verify_ich_cold
12: 0x10d701584 - rustc_query_system[91d58cadb6adb151]::query::plumbing::incremental_verify_ich::>
13: 0x10d6d881c - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_load_from_disk_and_cache_in_memory::>
14: 0x10d696ae4 - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_execute_query::>>
15: 0x10d7252fc - rustc_query_system[91d58cadb6adb151]::query::plumbing::get_query::
16: 0x10e3d9f4c - ::ident
17: 0x10e3dab10 - ::find_by_name_and_namespace
18: 0x10cd2d354 - ::associated_value
19: 0x10cd95088 - ::impl_or_trait_item
20: 0x10cd90654 - ::assemble_inherent_impl_probe
21: 0x10cd90518 - ::assemble_inherent_impl_candidates_for_type
22: 0x10cd8fa48 - ::assemble_inherent_candidates
23: 0x10ce29aa0 - ::probe::, ::probe_op<::probe_for_name::{closure#0}, rustc_typeck[761806a90de36c46]::check::method::probe::Pick>::{closure#4}>
24: 0x10cd498f0 - ::probe_for_name
25: 0x10cd4bcb0 - ::resolve_fully_qualified_call
26: 0x10cd159e8 - ::resolve_ty_and_res_fully_qualified_call
27: 0x10cd4c484 - ::check_pat
28: 0x10cd3db80 - ::check_match
29: 0x10cd0aa50 - ::check_expr_with_expectation_and_args
30: 0x10cd1aefc - ::check_block_with_expected
31: 0x10cd0aa50 - ::check_expr_with_expectation_and_args
32: 0x10cd0b6d0 - ::check_return_expr
33: 0x10cefd5cc - rustc_typeck[761806a90de36c46]::check::check::check_fn
34: 0x10ce16c80 - ::enter::<&rustc_middle[48a4de8117124789]::ty::context::TypeckResults, ::enter::{closure#1}, &rustc_middle[48a4de8117124789]::ty::context::TypeckResults>::{closure#0}>
35: 0x10cdcd188 - rustc_typeck[761806a90de36c46]::check::typeck
36: 0x10d89e320 - >::with_task::
37: 0x10d9f18a0 - rustc_data_structures[6a7bec35f5e261c6]::stack::ensure_sufficient_stack::<(&rustc_middle[48a4de8117124789]::ty::context::TypeckResults, rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepNodeIndex), rustc_query_system[91d58cadb6adb151]::query::plumbing::execute_job::{closure#3}>
38: 0x10d6926bc - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_execute_query::>
39: 0x10d760968 - rustc_query_system[91d58cadb6adb151]::query::plumbing::get_query::
40: 0x10ce60c58 - ::par_body_owners::
41: 0x10cdd0cf4 - rustc_typeck[761806a90de36c46]::check::typeck_item_bodies
42: 0x10d8d0fec - >::with_task::
43: 0x10d9f6224 - rustc_data_structures[6a7bec35f5e261c6]::stack::ensure_sufficient_stack::<((), rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepNodeIndex), rustc_query_system[91d58cadb6adb151]::query::plumbing::execute_job::{closure#3}>
44: 0x10d6ca520 - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_execute_query::>
45: 0x10d734004 - rustc_query_system[91d58cadb6adb151]::query::plumbing::get_query::
46: 0x10cde1514 - ::time::<(), rustc_typeck[761806a90de36c46]::check_crate::{closure#7}>
47: 0x10cdc27e0 - rustc_typeck[761806a90de36c46]::check_crate
48: 0x10a9e6010 - rustc_interface[2280aded15839b11]::passes::analysis
49: 0x10d8c7df0 - >::with_task::>
50: 0x10d9e8a34 - rustc_data_structures[6a7bec35f5e261c6]::stack::ensure_sufficient_stack::<(core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>, rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepNodeIndex), rustc_query_system[91d58cadb6adb151]::query::plumbing::execute_job>::{closure#3}>
51: 0x10d6c1464 - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_execute_query::>>
52: 0x10d760dc4 - rustc_query_system[91d58cadb6adb151]::query::plumbing::get_query::
53: 0x10a8f3d38 - ::enter::>
54: 0x10a8a744c - rustc_interface[2280aded15839b11]::interface::create_compiler_and_run::, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>
55: 0x10a88ecb0 - std[8541ff70ccfedbb0]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>
56: 0x10a908648 - <::spawn_unchecked_, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#1} as core[e180da0f2c78f25f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
57: 0x103536b70 - std::sys::unix::thread::Thread::new::thread_start::h8ccdabc567c5eee0
58: 0x1b5a35240 - __pthread_deallocate
```