Closed
Description
While writing some doctests for a custom allocator this popped up. Easy fix for the doc test, just add # fn main() {}
after the static.
fn main() {
#[global_allocator]
static A: usize = 0;
}
Compiling playground v0.0.1 (/playground)
error[E0432]: unresolved import `super::A`
--> src/main.rs:3:5
|
3 | static A: usize = 0;
| ^^^^^^^^^^^^^^^^^^^^ no `A` in the root
thread 'rustc' panicked at 'assertion failed: prev.is_none()', src/librustc/middle/region.rs:442:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:70
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:58
at src/libstd/panicking.rs:200
3: std::panicking::default_hook
at src/libstd/panicking.rs:215
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:482
6: std::panicking::begin_panic
7: <rustc::middle::region::RegionResolutionVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_stmt
8: <rustc::middle::region::RegionResolutionVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_block
9: rustc::middle::region::resolve_expr
10: <rustc::middle::region::RegionResolutionVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
11: rustc::middle::region::region_scope_tree
12: rustc::ty::query::__query_compute::region_scope_tree
13: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::region_scope_tree<'tcx>>::compute
14: rustc::dep_graph::graph::DepGraph::with_task_impl
15: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
16: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_item
17: rustc::ty::context::GlobalCtxt::enter_local
18: rustc_typeck::check::wfcheck::check_item_well_formed
19: rustc::ty::query::__query_compute::check_item_well_formed
20: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::check_item_well_formed<'tcx>>::compute
21: rustc::dep_graph::graph::DepGraph::with_task_impl
22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
24: rustc::hir::Crate::visit_all_item_likes
25: rustc::util::common::time
26: rustc_typeck::check_crate
27: <std::thread::local::LocalKey<T>>::with
28: rustc::ty::context::TyCtxt::create_and_enter
29: rustc_driver::driver::compile_input
30: rustc_driver::run_compiler_with_pool
31: <scoped_tls::ScopedKey<T>>::set
32: rustc_driver::run_compiler
33: <scoped_tls::ScopedKey<T>>::set
query stack during panic:
#0 [region_scope_tree] processing `main`
#1 [check_item_well_formed] processing `main`
end of query stack
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.
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/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.34.0-nightly (852701ad6 2019-02-01) running on x86_64-unknown-linux-gnu
note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `playground`.
To learn more, run the command again with --verbose.