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

Option unwrap called on None value when building to wasm32-unknown-unknown #94602

Closed
inferrinizzard opened this issue Mar 4, 2022 · 1 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.

Comments

@inferrinizzard
Copy link

inferrinizzard commented Mar 4, 2022

This error started occurring after I moved the canvas module that contains the Canvas struct from the crate root into a submodule directory. (updates to mod.rs declared the new submodule, lib.rs to update the module path)
ie:
Old:
image

New:
image

It only occurs on the wasm32-unknown-unknown build target, running cargo build for other build targets compiles correctly

Code

use wasm_bindgen::prelude::*;
mod render;
use render::canvas::Canvas;

pub static mut CANVAS: Option<Canvas> = None;

// This is like the `main` function, except for JavaScript.
#[wasm_bindgen(start)]
pub fn main_js() -> Result<(), JsValue> {
    let window = web_sys::window().unwrap();
    let document = window.document().unwrap();
    unsafe {
        CANVAS = Some(Canvas::new(&document));
    }
    Ok(())
}

Meta

rustc --version --verbose:

rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-pc-windows-msvc
release: 1.58.1
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b\compiler\rustc_hir\src\definitions.rs:452:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.58.1 (db9d1b20b 2022-01-20) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type cdylib --crate-type rlib

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

query stack during panic:
#0 [typeck_item_bodies] type-checking all item bodies
#1 [analysis] running analysis passes on this crate
end of query stack
Backtrace

stack backtrace:
   0:     0x7fffc20e9e1f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h157fa6bf1896703a
   1:     0x7fffc211561a - core::fmt::write::hd933995fa5a3c525
   2:     0x7fffc20db718 - <std::io::IoSlice as core::fmt::Debug>::fmt::hb22a6129461aed2d
   3:     0x7fffc20ed736 - std::panicking::take_hook::he9e5ebb516ae9e93
   4:     0x7fffc20ed115 - std::panicking::take_hook::he9e5ebb516ae9e93
   5:     0x7fff650cd99e - <rustc_lint[7617183523d96aea]::BuiltinCombinedPreExpansionLintPass as rustc_lint[7617183523d96aea]::passes::EarlyLintPass>::check_impl_item
   6:     0x7fffc20ee049 - std::panicking::rust_panic_with_hook::hdfb9f2b0857b79cb
   7:     0x7fffc20edabf - rust_begin_unwind
   8:     0x7fffc20ea747 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h157fa6bf1896703a
   9:     0x7fffc20eda49 - rust_begin_unwind
  10:     0x7fffc2149a40 - core::panicking::panic_fmt::h0e1c9b751cd7872a
  11:     0x7fffc214998c - core::panicking::panic::hc887acba2270eb88
  12:     0x7fff69522dfa - <rustc_middle[ff7e0ef075a5e190]::ty::context::TyCtxt>::def_path_hash_to_def_id  
  13:     0x7fff6961662e - <rustc_query_system[ea294a3d7add80ba]::dep_graph::dep_node::DepNode<rustc_middle[ff7e0ef075a5e190]::dep_graph::dep_node::DepKind> as rustc_middle[ff7e0ef075a5e190]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  14:     0x7fff6888d1be - rustc_query_impl[45896b7db3cc92f1]::query_callbacks::hir_owner
  15:     0x7fff69507af3 - <rustc_middle[ff7e0ef075a5e190]::ty::context::TyCtxt as rustc_query_system[ea294a3d7add80ba]::dep_graph::DepContext>::try_force_from_dep_node
  16:     0x7fff688c35ab - rustc_query_impl[45896b7db3cc92f1]::query_callbacks::diagnostic_hir_wf_check    
  17:     0x7fff688c3587 - rustc_query_impl[45896b7db3cc92f1]::query_callbacks::diagnostic_hir_wf_check    
  18:     0x7fff688c3587 - rustc_query_impl[45896b7db3cc92f1]::query_callbacks::diagnostic_hir_wf_check    
  19:     0x7fff6889b8bd - rustc_query_impl[45896b7db3cc92f1]::query_callbacks::diagnostic_hir_wf_check    
  20:     0x7fff685c7dec - <rustc_mir_dataflow[204209cfb57e373]::framework::engine::RustcMirAttrs>::output_path
  21:     0x7fff6875ade3 - <rustc_mir_dataflow[204209cfb57e373]::framework::engine::RustcMirAttrs>::output_path
  22:     0x7fff67b7d44e - <<rustc_typeck[1612bd5dabb432b3]::coherence::inherent_impls_overlap::InherentOverlapChecker as rustc_hir[eb0a003bff263e90]::itemlikevisit::ItemLikeVisitor>::visit_item::RegionId as core[a1a53ba5778ea5ee]::fmt::Debug>::fmt
  23:     0x7fff67aac2a3 - <rustc_typeck[1612bd5dabb432b3]::check::CheckItemTypesVisitor as rustc_hir[eb0a003bff263e90]::itemlikevisit::ItemLikeVisitor>::visit_item
  24:     0x7fff6882229b - <rustc_span[2d757f059925335b]::def_id::DefIndex as rustc_query_impl[45896b7db3cc92f1]::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  25:     0x7fff688ff62e - rustc_query_impl[45896b7db3cc92f1]::query_callbacks::diagnostic_hir_wf_check    
  26:     0x7fff687d59da - <rustc_query_impl[45896b7db3cc92f1]::queries::diagnostic_hir_wf_check as rustc_query_system[ea294a3d7add80ba]::query::config::QueryDescription<rustc_query_impl[45896b7db3cc92f1]::plumbing::QueryCtxt>>::describe
  27:     0x7fff686d59b9 - <rustc_mir_dataflow[204209cfb57e373]::framework::engine::RustcMirAttrs>::output_path
  28:     0x7fff687f71a5 - <rustc_query_impl[45896b7db3cc92f1]::Queries as rustc_middle[ff7e0ef075a5e190]::ty::query::QueryEngine>::try_mark_green
  29:     0x7fff67a8e65d - <rustc_typeck[1612bd5dabb432b3]::outlives::explicit::ExplicitPredicatesMap as core[a1a53ba5778ea5ee]::fmt::Debug>::fmt
  30:     0x7fff67a8dc7b - rustc_typeck[1612bd5dabb432b3]::check_crate
  31:     0x7fff65217ce9 - rustc_interface[d7ab38303f68c91e]::passes::analysis
  32:     0x7fff68821cdb - <rustc_span[2d757f059925335b]::def_id::DefIndex as rustc_query_impl[45896b7db3cc92f1]::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  33:     0x7fff688f6f1e - rustc_query_impl[45896b7db3cc92f1]::query_callbacks::diagnostic_hir_wf_check    
  34:     0x7fff687c5ab1 - <rustc_query_impl[45896b7db3cc92f1]::queries::diagnostic_hir_wf_check as rustc_query_system[ea294a3d7add80ba]::query::config::QueryDescription<rustc_query_impl[45896b7db3cc92f1]::plumbing::QueryCtxt>>::describe
  35:     0x7fff686bfbe1 - <rustc_mir_dataflow[204209cfb57e373]::framework::engine::RustcMirAttrs>::output_path
  36:     0x7fff687f60d2 - <rustc_query_impl[45896b7db3cc92f1]::Queries as rustc_middle[ff7e0ef075a5e190]::ty::query::QueryEngine>::try_mark_green
  37:     0x7fff6513d7ca - <rustc_driver[ac5015f618b0d469]::args::Error as core[a1a53ba5778ea5ee]::fmt::Debug>::fmt
  38:     0x7fff650f39ec - <rustc_middle[ff7e0ef075a5e190]::ty::SymbolName as core[a1a53ba5778ea5ee]::fmt::Display>::fmt
  39:     0x7fff650e51db - <chalk_engine[160540b4fe62f842]::TableIndex>::increment
  40:     0x7fff651113f1 - <rustc_middle[ff7e0ef075a5e190]::ty::SymbolName as core[a1a53ba5778ea5ee]::fmt::Display>::fmt
  41:     0x7fff650f0a03 - rustc_driver[ac5015f618b0d469]::pretty::print_after_hir_lowering
  42:     0x7fff65158748 - <rustc_driver[ac5015f618b0d469]::args::Error as core[a1a53ba5778ea5ee]::fmt::Debug>::fmt
  43:     0x7fffc20fc39c - std::sys::windows::thread::Thread::new::h5e9e6e3c717bd931
  44:     0x7ff80faa7034 - BaseThreadInitThunk
  45:     0x7ff8116e2651 - RtlUserThreadStart

@inferrinizzard inferrinizzard 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 Mar 4, 2022
@workingjubilee
Copy link
Member

workingjubilee commented Feb 26, 2023

Closing as a probable duplicate of #91696

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

No branches or pull requests

2 participants