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

Internal compiler error after a trait/struct rename. #70037

Closed
JTKBowers opened this issue Mar 16, 2020 · 1 comment
Closed

Internal compiler error after a trait/struct rename. #70037

JTKBowers opened this issue Mar 16, 2020 · 1 comment

Comments

@JTKBowers
Copy link

Rustc segfaults after a trait/struct rename.

I tried this code:

Reproducing

This bug only seems to occur when changing from one version of code to another. Both code snippets compile successfully with a clean build.

  1. cargo new rustc-repr
  2. Add the following to main.rs:
trait F {
    fn id(&self) -> u32;
}

struct ImplF {
    id: u32
}

impl F for ImplF {
    fn id(&self) -> u32 {
        self.id
    }
}

fn main() {
    println!("Hello, world!");
}
  1. cargo run
  2. Change main.rs to contain:
struct F {
    id: u32
}

impl F {
    fn id(&self) -> u32 {
        self.id
    }
}

fn main() {
    println!("Hello, world!");
}
  1. cargo run

I expected to see this happen: Code compiling successfully

Instead, this happened: An internal compiler error occurs

Meta

rustc --version --verbose:

rustc 1.42.0 (b8cedc004 2020-03-09)
binary: rustc
commit-hash: b8cedc00407a4c56a3bda1ed605c6fc166655447
commit-date: 2020-03-09
host: x86_64-unknown-linux-gnu
release: 1.42.0
LLVM version: 9.0

Backtrace:

error: internal compiler error: src/librustc/dep_graph/graph.rs:687: DepNode Hir(rustc_repr[9782]::F[0]::id[0]) should have been pre-allocated but wasn't.

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:873:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:476
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::bug_fmt
  20: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  21: rustc::dep_graph::graph::DepGraph::try_mark_green
  22: rustc::dep_graph::graph::DepGraph::try_mark_green_and_read
  23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  24: <rustc_typeck::outlives::implicit_infer::InferVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
  25: rustc_hir::hir::Crate::visit_all_item_likes
  26: rustc_typeck::outlives::inferred_outlives_crate
  27: rustc::ty::query::__query_compute::inferred_outlives_crate
  28: rustc::dep_graph::graph::DepGraph::with_task_impl
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  30: rustc_typeck::outlives::inferred_outlives_of
  31: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::inferred_outlives_of>::compute
  32: rustc::dep_graph::graph::DepGraph::with_task_impl
  33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query
  34: rustc::ty::query::plumbing::force_from_dep_node
  35: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  36: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  37: rustc::dep_graph::graph::DepGraph::try_mark_green
  38: rustc::dep_graph::graph::DepGraph::try_mark_green_and_read
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  41: rustc::hir::map::Map::visit_item_likes_in_module
  42: rustc_typeck::collect::collect_mod_item_types
  43: rustc::ty::query::__query_compute::collect_mod_item_types
  44: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  45: rustc::dep_graph::graph::DepGraph::with_task_impl
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  48: rustc_typeck::check_crate
  49: rustc_interface::passes::analysis
  50: rustc::ty::query::__query_compute::analysis
  51: rustc::dep_graph::graph::DepGraph::with_task_impl
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  53: rustc::ty::context::tls::enter_global
  54: rustc_interface::interface::run_compiler_in_existing_thread_pool
  55: scoped_tls::ScopedKey<T>::set
  56: syntax::with_globals
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0 (b8cedc004 2020-03-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [type_of] processing `F::id`
#1 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
#2 [inferred_outlives_of] processing `F`
#3 [predicates_of] processing `F`
#4 [collect_mod_item_types] collecting item types in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `rustc-repr`.

To learn more, run the command again with --verbose.
@jonas-schievink
Copy link
Contributor

Duplicate of #62649

@jonas-schievink jonas-schievink marked this as a duplicate of #62649 Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants