Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: -Zast-json ./src/test/ui/issues/issue-43023.rs #78510

Closed
matthiaskrgr opened this issue Oct 29, 2020 · 0 comments · Fixed by #78526
Closed

ICE: -Zast-json ./src/test/ui/issues/issue-43023.rs #78510

matthiaskrgr opened this issue Oct 29, 2020 · 0 comments · Fixed by #78526
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

code from ./src/test/ui/issues/issue-43023.rs

struct S;

impl S {
    #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
    fn f() {
        file!();
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (31ee872db 2020-10-28)
binary: rustc
commit-hash: 31ee872db5aae4750e3da1ca4ed1523c4356947f
commit-date: 2020-10-28
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Error output

rustc ./src/test/ui/issues/issue-43023.rs -Zast-json

error[E0774]: `derive` may only be applied to structs, enums and unions
 --> ./src/test/ui/issues/issue-43023.rs:4:5
  |
4 |     #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
  |     ^^^^^^^^^^^^^^^^

{"module":{"inner":{"lo":0,"hi":161},"unsafety":"No","items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":3,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":4,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":5,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":6,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":7,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":8,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":9,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":10,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":11,"span":{"lo":0,"hi":9},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"S","span":{"lo":7,"hi":8}},"kind":{"variant":"Struct","fields":[{"variant":"Unit","fields":[12]},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":8,"hi":8}},"span":{"lo":8,"hi":8}}]},"tokens":null},{"attrs":[],"id":13,"span":{"lo":11,"hi":146},"vis":{"kind":"Inherited","span":{"lo":11,"hi":11},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Impl","fields":["No","Positive","Final","No",{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":17,"hi":17}},"span":{"lo":15,"hi":15}},null,{"id":14,"kind":{"variant":"Path","fields":[null,{"span":{"lo":16,"hi":17},"segments":[{"ident":{"name":"S","span":{"lo":16,"hi":17}},"id":15,"args":null}],"tokens":null}]},"span":{"lo":16,"hi":17},"tokens":null},[{"attrs":[],"id":18,"span":{"lo":113,"hi":144},"vis":{"kind":"Inherited","span":{"lo":113,"hi":113},"tokens":null},"ident":{"name":"f","span":{"lo":116,"hi":117}},"kind":{"variant":"Fn","fields":["Final",{"header":{"unsafety":"No","asyncness":"No","constness":"No","ext":"None"},"decl":{"inputs":[],"output":{"variant":"Default","fields":[{"lo":120,"hi":120}]}},"span":{"lo":113,"hi":119}},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":119,"hi":119}},"span":{"lo":117,"hi":117}},{"stmts":[{"id":21,"kind":{"variant":"Semi","fields":[{"id":20,"kind":{"variant":"Lit","fields":[{"token":{"kind":"Str","symbol":"./src/test/ui/issues/issue-43023.rs","suffix":null},"kind":{"variant":"Str","fields":["thread 'rustc' panicked at 'Attempted to encode LazyTokenStream', /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/compiler/rustc_ast/src/tokenstream.rs:178:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0-nightly (31ee872db 2020-10-28) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z ast-json

query stack during panic:
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0774`.
./src/test/ui/issues/issue-43023.rs","Cooked"]},"span":{"lo":130,"hi":138}}]},"span":{"lo":130,"hi":138},"attrs":{"0":null},"tokens":null}]},"span":{"lo":130,"hi":138},"tokens":null}],"id":19,"rules":"Default","span":{"lo":120,"hi":144},"tokens":null}]},"tokens":%      
Backtrace

error[E0774]: `derive` may only be applied to structs, enums and unions
 --> ./src/test/ui/issues/issue-43023.rs:4:5
  |
4 |     #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
  |     ^^^^^^^^^^^^^^^^

{"module":{"inner":{"lo":0,"hi":160},"unsafety":"No","items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":3,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":4,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":5,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":6,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":7,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":8,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":9,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":10,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":11,"span":{"lo":0,"hi":9},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"S","span":{"lo":7,"hi":8}},"kind":{"variant":"Struct","fields":[{"variant":"Unit","fields":[12]},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":8,"hi":8}},"span":{"lo":8,"hi":8}}]},"tokens":null},{"attrs":[],"id":13,"span":{"lo":11,"hi":146},"vis":{"kind":"Inherited","span":{"lo":11,"hi":11},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Impl","fields":["No","Positive","Final","No",{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":17,"hi":17}},"span":{"lo":15,"hi":15}},null,{"id":14,"kind":{"variant":"Path","fields":[null,{"span":{"lo":16,"hi":17},"segments":[{"ident":{"name":"S","span":{"lo":16,"hi":17}},"id":15,"args":null}],"tokens":null}]},"span":{"lo":16,"hi":17},"tokens":null},[{"attrs":[],"id":18,"span":{"lo":113,"hi":144},"vis":{"kind":"Inherited","span":{"lo":113,"hi":113},"tokens":null},"ident":{"name":"f","span":{"lo":116,"hi":117}},"kind":{"variant":"Fn","fields":["Final",{"header":{"unsafety":"No","asyncness":"No","constness":"No","ext":"None"},"decl":{"inputs":[],"output":{"variant":"Default","fields":[{"lo":120,"hi":120}]}},"span":{"lo":113,"hi":119}},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":119,"hi":119}},"span":{"lo":117,"hi":117}},{"stmts":[{"id":21,"kind":{"variant":"Semi","fields":[{"id":20,"kind":{"variant":"Lit","fields":[{"token":{"kind":"Str","symbol":"./src/test/ui/issues/issue-43023.rs","suffix":null},"kind":{"variant":"Str","fields":["thread 'rustc' panicked at 'Attempted to encode LazyTokenStream', /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/compiler/rustc_ast/src/tokenstream.rs:178:9
stack backtrace:
   0:     0x7f5637585e10 - std::backtrace_rs::backtrace::libunwind::trace::h448c56741b6011d3
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5
   1:     0x7f5637585e10 - std::backtrace_rs::backtrace::trace_unsynchronized::h881b9d30a8a89a0c
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5637585e10 - std::sys_common::backtrace::_print_fmt::h720a2f61f75b9f58
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f5637585e10 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8d62bbfda6d5c836
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f56375f5d4c - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f5637577a72 - std::io::Write::write_fmt::h16a9fe7680ac245c
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/io/mod.rs:1518:15
   6:     0x7f563758adc5 - std::sys_common::backtrace::_print::h9ba51a6db618de7d
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f563758adc5 - std::sys_common::backtrace::print::h5f20e41c85e91716
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f563758adc5 - std::panicking::default_hook::{{closure}}::h8d48653392f3b04c
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/panicking.rs:208:50
   9:     0x7f563758aa68 - std::panicking::default_hook::hb3948d1f74b6ff4c
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/panicking.rs:227:9
  10:     0x7f5637e53b18 - rustc_driver::report_ice::h1ddbc5609a6e1f37
  11:     0x7f563758b6c6 - std::panicking::rust_panic_with_hook::h55d23fef0ad751bc
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/panicking.rs:597:17
  12:     0x7f5638076e24 - std::panicking::begin_panic::{{closure}}::h0de480f775c645f4
  13:     0x7f5638075f0c - std::sys_common::backtrace::__rust_end_short_backtrace::h647b7d938df017c5
  14:     0x7f5638076ddc - std::panicking::begin_panic::h60af106a34b67eb0
  15:     0x7f56380cf739 - <rustc_ast::tokenstream::LazyTokenStreamInner as rustc_serialize::serialize::Encodable<S>>::encode::h9eeb0ce5189b377a
  16:     0x7f5637f93ebe - <rustc_serialize::json::Encoder as rustc_serialize::serialize::Encoder>::emit_struct::h02e25c19ac282a81
  17:     0x7f5637fa5228 - <rustc_serialize::json::Encoder as rustc_serialize::serialize::Encoder>::emit_seq::h28ebadddb8886382
  18:     0x7f5637fb1dcb - <rustc_serialize::json::Encoder as rustc_serialize::serialize::Encoder>::emit_enum::hc857b016c0483460
  19:     0x7f5637f9cfbc - <rustc_serialize::json::Encoder as rustc_serialize::serialize::Encoder>::emit_struct::hb3bd300b7c1e88fd
  20:     0x7f5637fa7d28 - <rustc_serialize::json::Encoder as rustc_serialize::serialize::Encoder>::emit_seq::hfc2e303ab61bf8d1
  21:     0x7f5637fa332f - <rustc_serialize::json::Encoder as rustc_serialize::serialize::Encoder>::emit_struct::hffd2a3f8ace01639
  22:     0x7f5637f93fb5 - <rustc_serialize::json::Encoder as rustc_serialize::serialize::Encoder>::emit_struct::h077d9f5797530b4f
  23:     0x7f5637f9251b - <rustc_serialize::json::AsJson<T> as core::fmt::Display>::fmt::h515c54af385b66e6
  24:     0x7f56375f5d4c - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/core/src/fmt/mod.rs:1078:17
  25:     0x7f563757408b - std::io::Write::write_fmt::h247111350ae51583
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/io/mod.rs:1518:15
  26:     0x7f563757408b - <&std::io::stdio::Stdout as std::io::Write>::write_fmt::h20b1f5dfc7b242f7
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/io/stdio.rs:655:9
  27:     0x7f56375761b0 - <std::io::stdio::Stdout as std::io::Write>::write_fmt::h77aa710668163fdb
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/io/stdio.rs:629:9
  28:     0x7f56375761b0 - std::io::stdio::print_to::{{closure}}::h56ba84a248f3da52
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/io/stdio.rs:1018:28
  29:     0x7f56375761b0 - core::option::Option<T>::unwrap_or_else::hb1cf6ea0a03b0b88
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/core/src/option.rs:427:21
  30:     0x7f56375761b0 - std::io::stdio::print_to::hd44bd7beb95e6ca6
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/io/stdio.rs:999:18
  31:     0x7f56375761b0 - std::io::stdio::_print::h1862611cc749282f
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/io/stdio.rs:1033:5
  32:     0x7f563809b888 - rustc_interface::passes::configure_and_expand_inner::h88c1cfdc3da51317
  33:     0x7f563805b045 - rustc_interface::passes::configure_and_expand::{{closure}}::hc6faa1f206fffcb7
  34:     0x7f563804808f - rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new::hbbbef01caab98031
  35:     0x7f56380990a6 - rustc_interface::passes::configure_and_expand::h7478162212729b91
  36:     0x7f56380bdf7b - rustc_interface::queries::Queries::expansion::h644d08ebc965a5a0
  37:     0x7f5637e7050f - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h25b522245624a405
  38:     0x7f5637e3408f - rustc_span::with_source_map::h7455fffe3cd153a4
  39:     0x7f5637e6bb51 - scoped_tls::ScopedKey<T>::set::h8ae8151712a551fd
  40:     0x7f5637e76285 - std::sys_common::backtrace::__rust_begin_short_backtrace::h26de371bc27662fc
  41:     0x7f5637dddca8 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h80d1a8eb7971174b
  42:     0x7f563759a6ca - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9e7afb7a0a438236
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/alloc/src/boxed.rs:1312:9
  43:     0x7f563759a6ca - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70c646c4271337a1
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/alloc/src/boxed.rs:1312:9
  44:     0x7f563759a6ca - std::sys::unix::thread::Thread::new::thread_start::h35d2b8d36f210d02
                               at /rustc/31ee872db5aae4750e3da1ca4ed1523c4356947f/library/std/src/sys/unix/thread.rs:89:17
  45:     0x7f56374993e9 - start_thread
  46:     0x7f56373b6293 - __GI___clone
  47:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0-nightly (31ee872db 2020-10-28) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z ast-json

query stack during panic:
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0774`.
./src/test/ui/issues/issue-43023.rs","Cooked"]},"span":{"lo":130,"hi":138}}]},"span":{"lo":130,"hi":138},"attrs":{"0":null},"tokens":null}]},"span":{"lo":130,"hi":138},"tokens":null}],"id":19,"rules":"Default","span":{"lo":120,"hi":144},"tokens":null}]},"tokens":%  

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 29, 2020
@Aaron1011 Aaron1011 self-assigned this Oct 29, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 31, 2020
Strip tokens from trait and impl items before printing AST JSON

Fixes rust-lang#78510
m-ou-se added a commit to m-ou-se/rust that referenced this issue Oct 31, 2020
Strip tokens from trait and impl items before printing AST JSON

Fixes rust-lang#78510
m-ou-se added a commit to m-ou-se/rust that referenced this issue Oct 31, 2020
Strip tokens from trait and impl items before printing AST JSON

Fixes rust-lang#78510
@bors bors closed this as completed in 4ba57aa Oct 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants