rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
95.04k stars 12.26k forks source link

ICE when get_adt_def called on a non-ADT DefId(33:288 ~ syntax[67bd]::ptr::SyntaxNodePtr) #92491

Open 0x7CFE opened 2 years ago

0x7CFE commented 2 years ago

Error happened while trying to build latest Rust Analyzer from the repo.

Code

commit b706ae22dc94231bdbb4bf91632e3ea45dfccce6 (HEAD -> master, origin/staging, origin/master, origin/HEAD)
Merge: bc81dca3d 65a1538dd
Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Date:   Sun Jan 2 03:48:38 2022 +0000

    Merge #11160

    11160: internal: Use basic `NonEmptyVec` in mbe::syntax_bridge r=Veykril a=Veykril

    There are some places in the ide crates where this can be used as well if memory serves right.
    bors r+

    Co-authored-by: Lukas Wirth <lukastw97@gmail.com>

Meta

rustc +nightly --version --verbose:

rustc 1.58.0-nightly (e90c5fbbc 2021-11-12)
binary: rustc
commit-hash: e90c5fbbc5df5c81267747daeb937d4e955ce6ad
commit-date: 2021-11-12
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0

Error output

korvin@epsilon:~/work/research/rust/rust-analyzer$ cargo +nightly xtask install
    Finished dev [unoptimized] target(s) in 0.12s
     Running `target/debug/xtask install`
$ cargo install --path crates/rust-analyzer --locked --force --features force-always-assert
  Installing rust-analyzer v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/rust-analyzer)
    Updating crates.io index
   Compiling parser v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/parser)
   Compiling stdx v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/stdx)
   Compiling tt v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/tt)
   Compiling test_utils v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/test_utils)
   Compiling flycheck v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/flycheck)
   Compiling syntax v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/syntax)
   Compiling cfg v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/cfg)
   Compiling proc_macro_api v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/proc_macro_api)
   Compiling mbe v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/mbe)
   Compiling base_db v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/base_db)
   Compiling project_model v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/project_model)
   Compiling hir_expand v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/hir_expand)
   Compiling proc_macro_srv v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/proc_macro_srv)
   Compiling hir_def v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/hir_def)
   Compiling hir_ty v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/hir_ty)
   Compiling hir v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/hir)
   Compiling ide_db v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/ide_db)
   Compiling ide_ssr v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/ide_ssr)
   Compiling ide_assists v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/ide_assists)
   Compiling ide_completion v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/ide_completion)
error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder.rs:898:18: get_adt_def called on a non-ADT DefId(33:288 ~ syntax[67bd]::ptr::SyntaxNodePtr)

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.58.0-nightly (e90c5fbbc 2021-11-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [adt_def] computing ADT definition for `syntax::ptr::SyntaxNodePtr`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `ide_assists`
warning: build failed, waiting for other jobs to finish...
Backtrace

``` korvin@epsilon:~/work/research/rust/rust-analyzer$ RUST_BACKTRACE=1 cargo +nightly xtask install Finished dev [unoptimized] target(s) in 0.05s Running `target/debug/xtask install` $ cargo install --path crates/rust-analyzer --locked --force --features force-always-assert Installing rust-analyzer v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/rust-analyzer) Updating crates.io index Compiling ide_assists v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/ide_assists) Compiling ide_diagnostics v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/ide_diagnostics) error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder.rs:898:18: get_adt_def called on a non-ADT DefId(33:288 ~ syntax[67bd]::ptr::SyntaxNodePtr) thread 'rustc' panicked at 'Box', compiler/rustc_errors/src/lib.rs:1169:9 stack backtrace: 0: std::panicking::begin_panic:: 1: std::panic::panic_any:: 2: ::bug 3: ::bug 4: rustc_middle::ty::context::tls::with_opt::::{closure#0}, ()> 5: rustc_middle::util::bug::opt_span_bug_fmt:: 6: rustc_middle::util::bug::bug_fmt 7: ::get_adt_def 8: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::adt_def 9: >::with_task:: 10: rustc_data_structures::stack::ensure_sufficient_stack::<(&rustc_middle::ty::adt::AdtDef, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job::{closure#3}> 11: rustc_query_system::query::plumbing::try_execute_query::> 12: rustc_query_system::query::plumbing::force_query:: 13: rustc_query_impl::query_callbacks::adt_def::force_from_dep_node 14: ::try_force_from_dep_node 15: >::try_mark_previous_green:: 16: >::try_mark_previous_green:: 17: >::try_mark_previous_green:: 18: >::try_mark_previous_green:: 19: >::try_mark_previous_green:: 20: rustc_query_system::query::plumbing::ensure_must_run:: 21: ::mir_borrowck 22: ::par_body_owners:: 23: ::time::<(), rustc_interface::passes::analysis::{closure#2}> 24: rustc_interface::passes::analysis 25: >::with_task::> 26: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job>::{closure#3}> 27: rustc_query_system::query::plumbing::try_execute_query::>> 28: rustc_query_system::query::plumbing::get_query:: 29: ::enter::> 30: ::enter::, rustc_errors::ErrorReported>> 31: rustc_span::with_source_map::, rustc_interface::interface::create_compiler_and_run, rustc_driver::run_compiler::{closure#1}>::{closure#1}> 32: rustc_interface::interface::create_compiler_and_run::, rustc_driver::run_compiler::{closure#1}> 33: >::set::, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>> note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. 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.58.0-nightly (e90c5fbbc 2021-11-12) running on x86_64-unknown-linux-gnu note: compiler flags: -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C incremental --crate-type lib note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [adt_def] computing ADT definition for `syntax::ptr::SyntaxNodePtr` #1 [analysis] running analysis passes on this crate end of query stack error: could not compile `ide_diagnostics` warning: build failed, waiting for other jobs to finish... thread 'rustc' panicked at 'Box', compiler/rustc_errors/src/lib.rs:1169:9 stack backtrace: 0: std::panicking::begin_panic:: 1: std::panic::panic_any:: 2: ::bug 3: ::bug 4: rustc_middle::ty::context::tls::with_opt::::{closure#0}, ()> 5: rustc_middle::util::bug::opt_span_bug_fmt:: 6: rustc_middle::util::bug::bug_fmt 7: ::get_adt_def 8: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::adt_def 9: >::with_task:: 10: rustc_data_structures::stack::ensure_sufficient_stack::<(&rustc_middle::ty::adt::AdtDef, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job::{closure#3}> 11: rustc_query_system::query::plumbing::try_execute_query::> 12: rustc_query_system::query::plumbing::force_query:: 13: rustc_query_impl::query_callbacks::adt_def::force_from_dep_node 14: ::try_force_from_dep_node 15: >::try_mark_previous_green:: 16: >::try_mark_previous_green:: 17: >::try_mark_previous_green:: 18: >::try_mark_previous_green:: 19: >::try_mark_previous_green:: 20: rustc_query_system::query::plumbing::ensure_must_run:: 21: ::mir_borrowck 22: ::par_body_owners:: 23: ::time::<(), rustc_interface::passes::analysis::{closure#2}> 24: rustc_interface::passes::analysis 25: >::with_task::> 26: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job>::{closure#3}> 27: rustc_query_system::query::plumbing::try_execute_query::>> 28: rustc_query_system::query::plumbing::get_query:: 29: ::enter::> 30: ::enter::, rustc_errors::ErrorReported>> 31: rustc_span::with_source_map::, rustc_interface::interface::create_compiler_and_run, rustc_driver::run_compiler::{closure#1}>::{closure#1}> 32: rustc_interface::interface::create_compiler_and_run::, rustc_driver::run_compiler::{closure#1}> 33: >::set::, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>> note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. 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.58.0-nightly (e90c5fbbc 2021-11-12) running on x86_64-unknown-linux-gnu note: compiler flags: -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C incremental --crate-type lib note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [adt_def] computing ADT definition for `syntax::ptr::SyntaxNodePtr` #1 [analysis] running analysis passes on this crate end of query stack error: failed to compile `rust-analyzer v0.0.0 (/home/korvin/work/research/rust/rust-analyzer/crates/rust-analyzer)`, intermediate artifacts can be found at `/home/korvin/work/research/rust/rust-analyzer/target` Caused by: build failed Error: install server Caused by: command `cargo install --path crates/rust-analyzer --locked --force --features force-always-assert` failed, exit status: 101 Stack backtrace: 0: anyhow::error:: for anyhow::Error>::from 1: as core::ops::try_trait::FromResidual>>::from_residual 2: xtask::install::install_server 3: xtask::install::::run 4: xtask::main 5: core::ops::function::FnOnce::call_once 6: std::sys_common::backtrace::__rust_begin_short_backtrace 7: std::rt::lang_start::{{closure}} 8: core::ops::function::impls:: for &F>::call_once at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/core/src/ops/function.rs:259:13 9: std::panicking::try::do_call at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/std/src/panicking.rs:406:40 10: std::panicking::try at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/std/src/panicking.rs:370:19 11: std::panic::catch_unwind at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/std/src/panic.rs:133:14 12: std::rt::lang_start_internal::{{closure}} at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/std/src/rt.rs:128:48 13: std::panicking::try::do_call at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/std/src/panicking.rs:406:40 14: std::panicking::try at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/std/src/panicking.rs:370:19 15: std::panic::catch_unwind at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/std/src/panic.rs:133:14 16: std::rt::lang_start_internal at /rustc/e90c5fbbc5df5c81267747daeb937d4e955ce6ad/library/std/src/rt.rs:128:20 17: std::rt::lang_start 18: main 19: __libc_start_main at /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16 20: _start ```

0x7CFE commented 2 years ago

Does not reproduce on the latest nightly.

rustc 1.59.0-nightly (c14569225 2022-01-01)
binary: rustc
commit-hash: c145692254e86974941f2c92c643a23df0f13e82
commit-date: 2022-01-01
host: x86_64-unknown-linux-gnu
release: 1.59.0-nightly
LLVM version: 13.0.0
jbolila commented 2 years ago

Same error happens with stable 1.57:

error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder.rs:900:18: get_adt_def called on a non-ADT DefId(33:288 ~ syntax[8264]::ptr::SyntaxNodePtr)

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1146:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.57.0 (f1edd0429 2021-11-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [adt_def] computing ADT definition for `syntax::ptr::SyntaxNodePtr`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `ide_diagnostics`