rust-lang / rust

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

ICE: compiler/rustc_typeck/src/collect/type_of.rs:371:21: compute_type_of_item: unexpected item type: Trait.... #83483

Closed chengniansun closed 1 year ago

chengniansun commented 3 years ago

Code

#![feature(rustc_attrs)]
#[rustc_symbol_name]
trait Foo {}

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

error: internal compiler error: compiler/rustc_typeck/src/collect/type_of.rs:371:21: compute_type_of_item: unexpected item type: Trait(No, Normal, Generics { params: [], where_clause: WhereClause { predicates: [], span: perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:10: 3:10 (#0) }, span: perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:10: 3:10 (#0) }, [], [])
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:1
  |
3 | trait Foo {}
  | ^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.53.0-nightly (07e0e2ec2 2021-03-24) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

query stack during panic:
#0 [type_of] computing type of `Foo`
#1 [symbol_name] computing the symbol for `Foo`
end of query stack
error: aborting due to previous error
Backtrace

``` error: internal compiler error: compiler/rustc_typeck/src/collect/type_of.rs:371:21: compute_type_of_item: unexpected item type: Trait(No, Normal, Generics { params: [], where_clause: WhereClause { predicates: [], span: perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:10: 3:10 (#0) }, span: perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:10: 3:10 (#0) }, [], []) --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:1 | 3 | trait Foo {} | ^^^^^^^^^^^^ thread 'rustc' panicked at 'Box', /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panic.rs:59:5 stack backtrace: 0: std::panicking::begin_panic 1: std::panic::panic_any 2: rustc_errors::HandlerInner::span_bug 3: rustc_errors::Handler::span_bug 4: rustc_middle::ty::context::tls::with_opt 5: rustc_middle::util::bug::opt_span_bug_fmt 6: rustc_middle::util::bug::span_bug_fmt 7: rustc_typeck::collect::type_of::type_of 8: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 9: rustc_data_structures::stack::ensure_sufficient_stack 10: rustc_query_system::query::plumbing::force_query_with_job 11: rustc_query_system::query::plumbing::get_query_impl 12: ::type_of 13: rustc_symbol_mangling::legacy::mangle 14: rustc_symbol_mangling::symbol_name_provider 15: rustc_query_impl:: for rustc_query_impl::queries::symbol_name>::compute 16: rustc_query_system::dep_graph::graph::DepGraph::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: ::symbol_name 21: rustc_symbol_mangling::test::SymbolNamesTest::process_attrs 22: rustc_hir::hir::Crate::visit_all_item_likes 23: rustc_middle::dep_graph::::with_deps 24: rustc_symbol_mangling::test::report_symbol_names 25: rustc_interface::passes::QueryContext::enter 26: rustc_interface::queries::Queries::ongoing_codegen 27: rustc_interface::queries::::enter 28: rustc_span::with_source_map 29: rustc_interface::interface::create_compiler_and_run 30: scoped_tls::ScopedKey::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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.53.0-nightly (07e0e2ec2 2021-03-24) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type staticlib query stack during panic: #0 [type_of] computing type of `Foo` #1 [symbol_name] computing the symbol for `Foo` end of query stack error: aborting due to previous error ```

chengniansun commented 3 years ago

A duplicate.

Code

#![feature(rustc_attrs)]
#[rustc_symbol_name]
trait PrinterSupport {}

Meta

rustc --version --verbose:

rustc 1.55.0-nightly (a435b49e8 2021-06-28)
binary: rustc
commit-hash: a435b49e86d16e98dcc6595dd471f95e823f41aa
commit-date: 2021-06-28
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1

Error output

error: internal compiler error: compiler/rustc_typeck/src/collect/type_of.rs:407:21: compute_type_of_item: unexpected item type: Trait(No, Normal, Generics { params: [], where_clause: WhereClause { predicates: [], span: mutant.rs:3:21: 3:21 (#0) }, span: mutant.rs:3:21: 3:21 (#0) }, [], [])
 --> mutant.rs:3:1
  |
3 | trait PrinterSupport {}
  | ^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/a435b49e86d16e98dcc6595dd471f95e823f41aa/compiler/rustc_errors/src/lib.rs:953:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.55.0-nightly (a435b49e8 2021-06-28) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

query stack during panic:
#0 [type_of] computing type of `PrinterSupport`
#1 [symbol_name] computing the symbol for `PrinterSupport`
end of query stack
error: aborting due to previous error
Backtrace

``` error: internal compiler error: compiler/rustc_typeck/src/collect/type_of.rs:407:21: compute_type_of_item: unexpected item type: Trait(No, Normal, Generics { params: [], where_clause: WhereClause { predicates: [], span: mutant.rs:3:21: 3:21 (#0) }, span: mutant.rs:3:21: 3:21 (#0) }, [], []) --> mutant.rs:3:1 | 3 | trait PrinterSupport {} | ^^^^^^^^^^^^^^^^^^^^^^^ thread 'rustc' panicked at 'Box', /rustc/a435b49e86d16e98dcc6595dd471f95e823f41aa/compiler/rustc_errors/src/lib.rs:953:9 stack backtrace: 0: std::panicking::begin_panic 1: std::panic::panic_any 2: rustc_errors::HandlerInner::span_bug 3: rustc_errors::Handler::span_bug 4: rustc_middle::ty::context::tls::with_opt 5: rustc_middle::util::bug::opt_span_bug_fmt 6: rustc_middle::util::bug::span_bug_fmt 7: rustc_typeck::collect::type_of::type_of 8: rustc_query_system::query::plumbing::get_query_impl 9: ::type_of 10: rustc_symbol_mangling::legacy::mangle 11: rustc_symbol_mangling::symbol_name_provider 12: rustc_query_system::query::plumbing::get_query_impl 13: ::symbol_name 14: rustc_symbol_mangling::test::SymbolNamesTest::process_attrs 15: rustc_hir::hir::Crate::visit_all_item_likes 16: rustc_middle::dep_graph::::with_deps 17: rustc_symbol_mangling::test::report_symbol_names 18: rustc_interface::passes::QueryContext::enter 19: rustc_interface::queries::Queries::ongoing_codegen 20: rustc_interface::queries::::enter 21: rustc_span::with_source_map 22: rustc_interface::interface::create_compiler_and_run 23: scoped_tls::ScopedKey::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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.55.0-nightly (a435b49e8 2021-06-28) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type staticlib query stack during panic: #0 [type_of] computing type of `PrinterSupport` #1 [symbol_name] computing the symbol for `PrinterSupport` end of query stack error: aborting due to previous error ```

workingjubilee commented 1 year ago

This requires blatant misuse of a rustc-internal attribute and thus will probably not be fixed.