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 on nightly when using trait objects with lazy_static #68541

Closed
foxbenjaminfox opened this issue Jan 25, 2020 · 2 comments
Closed

ICE on nightly when using trait objects with lazy_static #68541

foxbenjaminfox opened this issue Jan 25, 2020 · 2 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@foxbenjaminfox
Copy link

When creating a lazy_static with a reference to a trait object, I get an internal compiler error (only on nightly).

Here's a minimal example: (playground link)

lazy_static::lazy_static! {
    static ref X: &dyn std::any::Any = ();
}

On stable and beta this gives a expected error message, but on nightly it causes an ICE.

Meta

Output from rustc --version --verbose:

rustc 1.42.0-nightly (c2d141df5 2020-01-24)
binary: rustc
commit-hash: c2d141df59703393c0c683abc259f9a8c3be041a
commit-date: 2020-01-24
host: x86_64-unknown-linux-gnu
release: 1.42.0-nightly
LLVM version: 9.0
Backtrace
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("src/main.rs"), BytePos(0)), end: (Macros("::lazy_static::__lazy_static_internal"), BytePos(6703667)) })', src/librustc_errors/lib.rs:197:29
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: rust_begin_unwind
             at src/libstd/panicking.rs:380
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  14: core::option::expect_none_failed
             at src/libcore/option.rs:1199
  15: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  16: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  17: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
  18: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
  19: rustc_errors::HandlerInner::emit_diagnostic
  20: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  21: rustc_resolve::lifetimes::LifetimeContext::resolve_elided_lifetimes
  22: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_lifetime
  23: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_ty
  24: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_impl_item
  25: rustc_hir::intravisit::walk_item
  26: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_item
  27: rustc_resolve::lifetimes::resolve_lifetimes
  28: rustc::dep_graph::graph::DepGraph::with_task_impl
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query
  30: rustc::ty::query::plumbing::force_from_dep_node
  31: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  32: rustc::dep_graph::graph::DepGraph::try_mark_previous_green
  33: rustc::dep_graph::graph::DepGraph::try_mark_green
  34: rustc::dep_graph::graph::DepGraph::try_mark_green_and_read
  35: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  36: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  37: rustc::hir::map::Map::visit_item_likes_in_module
  38: rustc_typeck::collect::collect_mod_item_types
  39: rustc::ty::query::__query_compute::collect_mod_item_types
  40: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  41: rustc::dep_graph::graph::DepGraph::with_task_impl
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  44: rustc_typeck::check_crate
  45: rustc_interface::passes::analysis
  46: rustc::ty::query::__query_compute::analysis
  47: rustc::dep_graph::graph::DepGraph::with_task_impl
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  49: rustc::ty::context::tls::enter_global
  50: rustc_interface::interface::run_compiler_in_existing_thread_pool
  51: scoped_tls::ScopedKey<T>::set
  52: syntax::with_globals
@jonas-schievink jonas-schievink 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. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Jan 25, 2020
@DutchGhost
Copy link
Contributor

Doesn't only happen for trait objects, but for all reference types without a lifetime declared (e.g &u8)

@estebank
Copy link
Contributor

estebank commented Jan 25, 2020

Will be fixed by #68530.

Edit: this will work again after tonight's nightly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants