rust-lang / rust

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

ICE: compiler/rustc_middle/src/ty/subst.rs:538:17: type parameter `T/#0` (T/0) out of range when substituting, substs=[] #86237

Closed Cancelll closed 3 years ago

Cancelll commented 3 years ago

Code

#![feature(const_generics)]
struct Foo<T = [u8; std]> {}
impl Foo {}

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (0a8629bff 2021-06-11)
binary: rustc
commit-hash: 0a8629bff642c3c3b84bb644c0099194f063b627
commit-date: 2021-06-11
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Error output

error[E0423]: expected value, found crate `std`
 --> mutant.rs:2:21
  |
2 | struct Foo<T = [u8; std]> {}
  |                     ^^^ not a value

warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
 --> mutant.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:538:17: type parameter `T/#0` (T/0) out of range when substituting, substs=[]
 --> mutant.rs:3:6
  |
3 | impl Foo {}
  |      ^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/0a8629bff642c3c3b84bb644c0099194f063b627/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.54.0-nightly (0a8629bff 2021-06-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3 -Z new-llvm-pass-manager=yes -Z unsound-mir-opts=yes -Z polonius=yes -Z polymorphize=yes -C debuginfo=2 -C opt-level=3 --crate-type staticlib

query stack during panic:
#0 [type_of] computing type of `<impl at mutant.rs:3:1: 3:12>`
#1 [collect_mod_item_types] collecting item types in top-level module
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0423`.
Backtrace

``` error[E0423]: expected value, found crate `std` --> mutant.rs:2:21 | 2 | struct Foo {} | ^^^ not a value warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes --> mutant.rs:1:12 | 1 | #![feature(const_generics)] | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 for more information error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:538:17: type parameter `T/#0` (T/0) out of range when substituting, substs=[] --> mutant.rs:3:6 | 3 | impl Foo {} | ^^^ thread 'rustc' panicked at 'Box', /rustc/0a8629bff642c3c3b84bb644c0099194f063b627/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: ::fold_ty 8: rustc_middle::ty::fold::TypeFoldable::fold_with 9: ::fold_const 10: rustc_middle::ty::structural_impls::::super_fold_with 11: <::create_substs_for_ast_path::SubstsForAstPathCtxt as rustc_typeck::astconv::CreateSubstsForGenericArgsCtxt>::inferred_kind 12: ::create_substs_for_ast_path 13: ::ast_path_substs_for_ty 14: ::ast_path_to_ty 15: ::ast_ty_to_ty_inner 16: rustc_typeck::collect::type_of::type_of 17: rustc_query_system::query::plumbing::get_query_impl 18: ::type_of 19: rustc_typeck::collect::convert_item 20: ::visit_item 21: rustc_middle::hir::map::Map::visit_item_likes_in_module 22: rustc_typeck::collect::collect_mod_item_types 23: rustc_query_system::query::plumbing::get_query_impl 24: ::collect_mod_item_types 25: rustc_session::session::Session::track_errors 26: rustc_typeck::check_crate 27: rustc_interface::passes::analysis 28: rustc_query_system::query::plumbing::get_query_impl 29: ::analysis 30: rustc_interface::queries::::enter 31: rustc_span::with_source_map 32: rustc_interface::interface::create_compiler_and_run 33: 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.54.0-nightly (0a8629bff 2021-06-11) running on x86_64-unknown-linux-gnu note: compiler flags: -Z mir-opt-level=3 -Z new-llvm-pass-manager=yes -Z unsound-mir-opts=yes -Z polonius=yes -Z polymorphize=yes -C debuginfo=2 -C opt-level=3 --crate-type staticlib query stack during panic: #0 [type_of] computing type of `` #1 [collect_mod_item_types] collecting item types in top-level module #2 [analysis] running analysis passes on this crate end of query stack error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0423`. ```

Cancelll commented 3 years ago

Possibly related to #83938

BoxyUwU commented 3 years ago

I think this is the same ICE as that issue yeah

oli-obk commented 3 years ago

closing as duplicate of #83938