Skip to content

[ICE] With wrong rustc_layout_scalar_valid_range_start #82251

Closed
@leonardo-m

Description

#![feature(rustc_attrs)]
#[rustc_layout_scalar_valid_range_start(u32::MAX)]
struct Foo(u32);
fn main() {
    const N: usize = std::mem::size_of::<Foo>();
}

Gives:

thread 'rustc' panicked at 'attribute takes lit', compiler\rustc_middle\src\ty\context.rs:1082:38
stack backtrace:
   0: rust_begin_unwind
             at /rustc/152f6609246558be5e2582e67376194815e6ba0d\/library\std\src\panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/152f6609246558be5e2582e67376194815e6ba0d\/library\core\src\panicking.rs:92:14
   2: core::option::expect_failed
             at /rustc/152f6609246558be5e2582e67376194815e6ba0d\/library\core\src\option.rs:1292:5
   3: rustc_middle::ty::context::TyCtxt::layout_scalar_valid_range::{{closure}}
   4: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::layout_raw_uncached
   5: rustc_middle::ty::layout::layout_raw
   6: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::layout_raw>::compute
   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_middle::ty::layout::LayoutCx<rustc_middle::ty::query::TyCtxtAt> as rustc_target::abi::LayoutOf>::layout_of
  12: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
  13: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  14: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
  15: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_allocation_raw>::compute
  16: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  17: rustc_data_structures::stack::ensure_sufficient_stack
  18: rustc_query_system::query::plumbing::force_query_with_job
  19: rustc_query_system::query::plumbing::get_query_impl
  20: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  21: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_query_system::query::plumbing::force_query_with_job
  25: rustc_query_system::query::plumbing::get_query_impl
  26: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  27: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_query_system::query::plumbing::force_query_with_job
  31: rustc_query_system::query::plumbing::get_query_impl
  32: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  33: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_poly
  34: <rustc_lint::BuiltinCombinedLateLintPass as rustc_lint::passes::LateLintPass>::check_item
  35: rustc_hir::intravisit::Visitor::visit_nested_item
  36: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_stmt
  37: rustc_hir::intravisit::walk_expr
  38: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_expr
  39: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_nested_body
  40: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_fn
  41: rustc_hir::intravisit::walk_item
  42: rustc_hir::intravisit::Visitor::visit_nested_item
  43: rustc_hir::intravisit::walk_crate
  44: rustc_session::utils::<impl rustc_session::session::Session>::time
  45: std::panicking::try
  46: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  47: rustc_session::utils::<impl rustc_session::session::Session>::time
  48: rustc_interface::passes::analysis
  49: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  50: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  51: rustc_data_structures::stack::ensure_sufficient_stack
  52: rustc_query_system::query::plumbing::force_query_with_job
  53: rustc_query_system::query::plumbing::get_query_impl
  54: rustc_interface::passes::QueryContext::enter
  55: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  56: rustc_span::with_source_map
  57: scoped_tls::ScopedKey<T>::set
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.52.0-nightly (152f66092 2021-02-17) running on x86_64-pc-windows-gnu

query stack during panic:
#0 [layout_raw] computing layout of `Foo`
#1 [eval_to_allocation_raw] const-evaluating + checking `main::N`
#2 [eval_to_const_value_raw] simplifying constant for the type system `main::N`
#3 [eval_to_const_value_raw] simplifying constant for the type system `main::N`
#4 [analysis] running analysis passes on this crate
end of query stack

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    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