Skip to content

ICE on nested items when asm! has errors #82869

Description

@jyn514
#![feature(asm)]

fn aarch64(a: f64, b: f64) {
    asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d1") {
        || {};
        b
    });
}
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/hir/map/mod.rs:300:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Details
stack backtrace:
   0: rust_begin_unwind
             at /rustc/45b3c28518e4c45dfd12bc2c4400c0d0e9639927/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/45b3c28518e4c45dfd12bc2c4400c0d0e9639927/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/45b3c28518e4c45dfd12bc2c4400c0d0e9639927/library/core/src/panicking.rs:50:5
   3: rustc_middle::hir::map::Map::body_owner
   4: rustc_middle::hir::map::Map::body_owner_def_id
   5: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
   6: rustc_typeck::check::typeck_item_bodies
   7: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   8: rustc_data_structures::stack::ensure_sufficient_stack
   9: rustc_query_system::query::plumbing::force_query_with_job
  10: rustc_query_system::query::plumbing::get_query_impl
  11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_typeck::check_crate
  14: rustc_interface::passes::analysis
  15: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  16: rustc_data_structures::stack::ensure_sufficient_stack
  17: rustc_query_system::query::plumbing::force_query_with_job
  18: rustc_query_system::query::plumbing::get_query_impl
  19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  20: rustc_interface::passes::QueryContext::enter
  21: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  22: rustc_span::with_source_map
  23: rustc_interface::interface::create_compiler_and_run
  24: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Originally posted by @jyn514 in #82838 (comment)

Activity

  1. added
    F-asm`#![feature(asm)]` (not `llvm_asm`)
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Mar 7, 2021
  2. Amanieu commented on Mar 8, 2021

    @Amanieu
    Member

    If an error occurs during asm lowering we still call lower_expr_mut for every operand (this is needed to avoid errors later on) but we simply emit a hir::ExprKind::Err for the whole asm! expression. This means that the hir::Expr generated by lower_expr_mut aren't actually reachable from the crate root.

    I'm not sure this is 100% correct...

  3. added a commit that references this issue on Mar 12, 2021
  4. added a commit that references this issue on Mar 16, 2021
    d0222f1
  5. added a commit that references this issue on Mar 16, 2021
    f24ce9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-asm`#![feature(asm)]` (not `llvm_asm`)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions