rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.41k stars 12.73k forks source link

ICE: thread 'rustc' panicked at 'attribute takes lit', compiler/rustc_middle/src/ty/context.rs:1095:38 #83180

Closed chengniansun closed 3 years ago

chengniansun commented 3 years ago

Code

#[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)]
struct NonZero(T);
fn not_field() -> impl {
    NonZero(false)
}

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (107896c32 2021-03-15)
binary: rustc
commit-hash: 107896c32d5dda4db508968ff34997a39d286966
commit-date: 2021-03-15
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

Error output

error: at least one trait must be specified
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:19
  |
3 | fn not_field() -> impl {
  |                   ^^^^

error[E0412]: cannot find type `T` in this scope
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:2:16
  |
2 | struct NonZero(T);
  |               -^ not found in this scope
  |               |
  |               help: you might be missing a type parameter: `<T>`

error[E0658]: the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable niche optimizations in libcore and will never be stable
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | / #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)]
2 | | struct NonZero(T);
3 | | fn not_field() -> impl {
4 | |     NonZero(false)
5 | | }
  | |_^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error: expected exactly one integer literal argument
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'attribute takes lit', compiler/rustc_middle/src/ty/context.rs:1095:38
note: run with `RUST_BACKTRACE=1` environment variable to display a 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 (107896c32 2021-03-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [unsafety_check_result] unsafety-checking `not_field`
#1 [mir_const] processing MIR for `not_field`
end of query stack
error: aborting due to 5 previous errors

Some errors have detailed explanations: E0412, E0601, E0658.
For more information about an error, try `rustc --explain E0412`.
Backtrace

``` error: at least one trait must be specified --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:19 | 3 | fn not_field() -> impl { | ^^^^ error[E0412]: cannot find type `T` in this scope --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:2:16 | 2 | struct NonZero(T); | -^ not found in this scope | | | help: you might be missing a type parameter: `` error[E0658]: the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable niche optimizations in libcore and will never be stable --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1 | 1 | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant` --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1 | 1 | / #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] 2 | | struct NonZero(T); 3 | | fn not_field() -> impl { 4 | | NonZero(false) 5 | | } | |_^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs` error: expected exactly one integer literal argument --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1 | 1 | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ thread 'rustc' panicked at 'attribute takes lit', compiler/rustc_middle/src/ty/context.rs:1095:38 stack backtrace: 0: rust_begin_unwind at /rustc/107896c32d5dda4db508968ff34997a39d286966/library/std/src/panicking.rs:493:5 1: core::panicking::panic_fmt at /rustc/107896c32d5dda4db508968ff34997a39d286966/library/core/src/panicking.rs:92:14 2: core::option::expect_failed at /rustc/107896c32d5dda4db508968ff34997a39d286966/library/core/src/option.rs:1321:5 3: rustc_middle::ty::context::TyCtxt::layout_scalar_valid_range::{{closure}} 4: rustc_middle::ty::context::TyCtxt::layout_scalar_valid_range 5: ::visit_rvalue 6: rustc_mir::transform::check_unsafety::unsafety_check_result 7: core::ops::function::FnOnce::call_once 8: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 9: rustc_query_system::query::plumbing::force_query_with_job 10: rustc_query_system::query::plumbing::get_query_impl 11: ::unsafety_check_result 12: rustc_mir::transform::mir_const 13: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 14: rustc_query_system::query::plumbing::force_query_with_job 15: rustc_query_system::query::plumbing::get_query_impl 16: ::mir_const 17: rustc_mir::transform::mir_promoted 18: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 19: rustc_query_system::query::plumbing::force_query_with_job 20: rustc_query_system::query::plumbing::get_query_impl 21: ::mir_promoted 22: rustc_mir::borrow_check::mir_borrowck 23: core::ops::function::FnOnce::call_once 24: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 25: rustc_query_system::query::plumbing::force_query_with_job 26: rustc_query_system::query::plumbing::get_query_impl 27: ::mir_borrowck 28: rustc_typeck::collect::type_of::type_of 29: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 30: rustc_data_structures::stack::ensure_sufficient_stack 31: rustc_query_system::query::plumbing::force_query_with_job 32: rustc_query_system::query::plumbing::get_query_impl 33: ::type_of 34: rustc_typeck::check::check::check_opaque 35: rustc_typeck::check::check::check_item_type 36: rustc_middle::hir::map::Map::visit_item_likes_in_module 37: rustc_typeck::check::check::check_mod_item_types 38: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 39: rustc_query_system::query::plumbing::force_query_with_job 40: rustc_query_system::query::plumbing::get_query_impl 41: ::check_mod_item_types 42: rustc_session::utils::::time 43: rustc_typeck::check_crate 44: rustc_interface::passes::analysis 45: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 46: rustc_data_structures::stack::ensure_sufficient_stack 47: rustc_query_system::query::plumbing::force_query_with_job 48: rustc_query_system::query::plumbing::get_query_impl 49: ::analysis 50: rustc_interface::passes::QueryContext::enter 51: rustc_interface::queries::::enter 52: rustc_span::with_source_map 53: scoped_tls::ScopedKey::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 (107896c32 2021-03-15) running on x86_64-unknown-linux-gnu query stack during panic: #0 [unsafety_check_result] unsafety-checking `not_field` #1 [mir_const] processing MIR for `not_field` #2 [mir_promoted] processing `not_field` #3 [mir_borrowck] borrow-checking `not_field` #4 [type_of] computing type of `not_field::{opaque#0}` #5 [check_mod_item_types] checking item types in top-level module #6 [analysis] running analysis passes on this crate end of query stack error: aborting due to 5 previous errors Some errors have detailed explanations: E0412, E0601, E0658. For more information about an error, try `rustc --explain E0412`. ```

jonas-schievink commented 3 years ago

should be fixed by https://github.com/rust-lang/rust/pull/83054