Skip to content

[ICE] with const_evaluatable_checked #7033

@leonardo-m

Description

@leonardo-m
#![feature(const_generics, const_evaluatable_checked, const_option)]
#![allow(incomplete_features, dead_code)]

struct Foo<T, const N: usize>
where [(); N.checked_next_power_of_two().unwrap()]: {
    arr: [T; N.checked_next_power_of_two().unwrap()],
    n: usize,
}

impl<T: Copy + Default, const N: usize> Foo<T, N>
where [(); N.checked_next_power_of_two().unwrap()]: {
    fn new() -> Self {
        Self {
            arr: [T::default(); N.checked_next_power_of_two().unwrap()],
            n: 0,
        }
    }
}

fn main() {}

Gives:

    Checking test1 v0.1.0 (...\test1)
error: internal compiler error: compiler\rustc_middle\src\ty\context.rs:553:13: node_type: no type for node `expr N.checked_next_power_of_two() (hir_id=HirId { owner: DefId(0:14 ~ test1[52e2]::{impl#0}::new), local_id: 13 })`

thread 'rustc' panicked at 'Box<Any>', /rustc/0b417ab5cdfdedffd74fb22cf22d27033c851304\library\std\src\panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt::{{closure}}
   6: rustc_middle::ty::context::tls::with_opt
   7: rustc_middle::util::bug::opt_span_bug_fmt
   8: rustc_middle::util::bug::bug_fmt
   9: rustc_middle::ty::context::TypeckResults::node_type::{{closure}}
  10: rustc_middle::ty::context::TypeckResults::expr_ty
  11: <clippy_lints::doc::FindPanicUnwrap as rustc_hir::intravisit::Visitor>::visit_expr
  12: rustc_hir::intravisit::walk_expr
  13: rustc_hir::intravisit::walk_expr
  14: <clippy_lints::doc::DocMarkdown as rustc_lint::passes::LateLintPass>::check_impl_item
  15: <rustc_lint::late::LateLintPassObjects as rustc_lint::passes::LateLintPass>::check_impl_item
  16: rustc_hir::intravisit::Visitor::visit_nested_impl_item
  17: rustc_hir::intravisit::walk_item
  18: rustc_hir::intravisit::Visitor::visit_nested_item
  19: rustc_hir::intravisit::walk_crate
  20: rustc_lint::late::late_lint_pass_crate
  21: rustc_lint::late::late_lint_crate
  22: rustc_session::utils::<impl rustc_session::session::Session>::time
  23: rustc_interface::passes::analysis::{{closure}}::{{closure}}
  24: rustc_interface::passes::analysis
  25: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  26: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  27: rustc_data_structures::stack::ensure_sufficient_stack
  28: rustc_query_system::query::plumbing::force_query_with_job
  29: rustc_query_system::query::plumbing::get_query_impl
  30: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  31: rustc_interface::passes::QueryContext::enter
  32: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  33: rustc_span::with_source_map
  34: rustc_interface::interface::create_compiler_and_run
  35: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.1.53 (0b417ab5 2021-04-03)

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `test1`

To learn more, run the command again with --verbose.
Command exited with non-zero status 101

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions