Skip to content

ICE: malformed repr(align(N)) #136717

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(fn_align)]
#![crate_type = "lib"]

trait MyTrait {
    #[repr(align)]
    fn myfun();
}

original:

#![feature(fn_align)]
#![crate_type = "lib"]

#[repr(align(16))] //~ ERROR `repr(align)` attributes on functions are unstable
fn requires_alignment() {}

trait MyTrait {
    #[repr(align)] //~ ERROR `repr(align)` attributes on functions are unstable
    fn myfun();
}

Version information

rustc 1.86.0-nightly (a9e7b3048 2025-02-07)
binary: rustc
commit-hash: a9e7b30487235621751cc628f170c0f15fb215c4
commit-date: 2025-02-07
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: trait `MyTrait` is never used
 --> /tmp/icemaker_global_tempdir.IlcHV1xQddA5/rustc_testrunner_tmpdir_reporting.EEJEkZMcNCvA/mvce.rs:4:7
  |
4 | trait MyTrait {
  |       ^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: malformed repr(align(N))
 --> /tmp/icemaker_global_tempdir.IlcHV1xQddA5/rustc_testrunner_tmpdir_reporting.EEJEkZMcNCvA/mvce.rs:5:12
  |
5 |     #[repr(align)]
  |            ^^^^^
  |
note: delayed at compiler/rustc_passes/src/check_attr.rs:2069:28
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <rustc_passes::check_attr::CheckAttrVisitor>::check_attributes
         5: <rustc_passes::check_attr::CheckAttrVisitor as rustc_hir::intravisit::Visitor>::visit_trait_item
         6: rustc_passes::check_attr::check_mod_attrs
         7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
         8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         9: rustc_query_impl::query_impl::check_mod_attrs::get_query_non_incr::__rust_end_short_backtrace
        10: <rustc_middle::hir::map::Map>::par_for_each_module::<rustc_interface::passes::run_required_analyses::{closure#0}::{closure#0}::{closure#1}::{closure#0}>::{closure#0}
        11: rustc_interface::passes::run_required_analyses
        12: rustc_interface::passes::analysis
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        15: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        16: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
        17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        18: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        19: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        20: std::sys::pal::unix::thread::Thread::new::thread_start
        21: <unknown>
        22: <unknown>
 --> /tmp/icemaker_global_tempdir.IlcHV1xQddA5/rustc_testrunner_tmpdir_reporting.EEJEkZMcNCvA/mvce.rs:5:12
  |
5 |     #[repr(align)]
  |            ^^^^^

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: rustc 1.86.0-nightly (a9e7b3048 2025-02-07) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@rustbot label +F-fn_align

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-fn_align`#![feature(fn_align)]`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