Skip to content

ICE when lowering sym fn operand in global/inline asm macro that has a nested def id #137179

Closed
@compiler-errors

Description

@compiler-errors

Code

use std::arch::global_asm;

global_asm! {
    "{}",
    sym foo::<{
        || {};
        0
    }>,
}

fn foo<const N: usize>() {}

Meta

rustc --version --verbose:

idk whatever nightly is today (feb 17, 2024)

Error output

error: internal compiler error: `type_of` called on const argument's anon const before the const argument was lowered
 --> src/lib.rs:5:15
  |
5 |       sym foo::<{
  |  _______________^
6 | |         || {};
7 | |         0
8 | |     }>,
  | |_____^
  |
note: delayed at compiler/rustc_hir_analysis/src/collect/type_of.rs:168:14 - disabled backtrace
 --> src/lib.rs:5:15
  |
5 |       sym foo::<{
  |  _______________^
6 | |         || {};
7 | |         0
8 | |     }>,
  | |_____^

error: internal compiler error: Trying to feed an already recorded value for query type_of key=DefId(0:7 ~ playground[f84d]::{global_asm#0}::{constant#0}):
                                old value: EarlyBinder { value: {type error}, .. }
                                new value: EarlyBinder { value: usize, .. }
  |
  = note: delayed at compiler/rustc_middle/src/query/mod.rs:2514:1 - disabled backtrace

error: internal compiler error: mir_const_qualif: MIR had errors
 --> src/lib.rs:5:15
  |
5 |       sym foo::<{
  |  _______________^
6 | |         || {};
7 | |         0
8 | |     }>,
  | |_____^
  |
note: delayed at compiler/rustc_mir_transform/src/lib.rs:362:19 - disabled backtrace
 --> src/lib.rs:5:15
  |
5 |       sym foo::<{
  |  _______________^
6 | |         || {};
7 | |         0
8 | |     }>,
  | |_____^

error: internal compiler error: mir_const_qualif: MIR had errors
 --> src/lib.rs:5:5
  |
5 | /     sym foo::<{
6 | |         || {};
7 | |         0
8 | |     }>,
  | |______^
  |
note: delayed at compiler/rustc_mir_transform/src/lib.rs:362:19 - disabled backtrace
 --> src/lib.rs:5:5
  |
5 | /     sym foo::<{
6 | |         || {};
7 | |         0
8 | |     }>,
  | |______^

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/playground/rustc-ice-2025-02-17T16_30_28-21.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack
warning: `playground` (lib) generated 1 warning
error: could not compile `playground` (lib); 1 warning emitted

Metadata

Metadata

Labels

A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions