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: type parameter `E/#2` (E/2) out of range when substituting #82952

Closed redgoldlace closed 3 years ago

redgoldlace commented 3 years ago

Code

trait ExampleTrait<I> {}
type BlahResult<I, E = impl ExampleTrait<I>> = Result<I, E>;

fn example<'a, T>() -> BlahResult<()> {}

Meta

rustc --version --verbose:

rustc 1.50.0 (cb75ad5db 2021-02-10)
binary: rustc
commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b
commit-date: 2021-02-10
host: x86_64-pc-windows-gnu
release: 1.50.0

I also had the same error on nightly, with the following version details:

rustc 1.52.0-nightly (45b3c2851 2021-03-04)
binary: rustc
commit-hash: 45b3c28518e4c45dfd12bc2c4400c0d0e9639927
commit-date: 2021-03-04
host: x86_64-pc-windows-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

Error output

error: internal compiler error: compiler\rustc_middle\src\ty\subst.rs:529:17: type parameter `E/#1` (E/1) out of range when substituting, substs=[()]
 --> src\lib.rs:4:24
  |
4 | fn example<'a, T>() -> BlahResult<()> {}
  |                        ^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b\compiler\rustc_errors\src\lib.rs:904:9

query stack during panic:
#0 [fn_sig] computing function signature of `example`
#1 [collect_mod_item_types] collecting item types in top-level module
end of query stack
Backtrace

``` 0: std::panicking::begin_panic 1: rustc_errors::HandlerInner::span_bug 2: rustc_errors::Handler::span_bug 3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}} 4: rustc_middle::ty::context::tls::with_opt::{{closure}} 5: rustc_middle::ty::context::tls::with_opt 6: rustc_middle::util::bug::opt_span_bug_fmt 7: rustc_middle::util::bug::span_bug_fmt 8: ::fold_ty 9: rustc_middle::ty::fold::TypeFoldable::fold_with 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: ::res_to_ty 15: ::ast_ty_to_ty_inner 16: ::ty_of_fn 17: rustc_typeck::collect::fn_sig 18: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::fn_sig>::compute 19: rustc_middle::dep_graph::::with_deps 20: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 21: rustc_data_structures::stack::ensure_sufficient_stack 22: rustc_query_system::query::plumbing::get_query_impl 23: rustc_query_system::query::plumbing::ensure_query_impl 24: ::visit_item 25: rustc_middle::hir::map::Map::visit_item_likes_in_module 26: rustc_typeck::collect::collect_mod_item_types 27: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::collect_mod_item_types>::compute 28: rustc_middle::dep_graph::::with_deps 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::get_query_impl 32: rustc_query_system::query::plumbing::ensure_query_impl 33: rustc_typeck::check_crate 34: rustc_interface::passes::analysis 35: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::analysis>::compute 36: rustc_middle::dep_graph::::with_deps 37: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 38: rustc_data_structures::stack::ensure_sufficient_stack 39: rustc_query_system::query::plumbing::get_query_impl 40: rustc_interface::passes::QueryContext::enter 41: rustc_interface::queries::::enter 42: rustc_span::with_source_map 43: rustc_interface::interface::create_compiler_and_run ```

SNCPlay42 commented 3 years ago

Output on 1.36:

error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
 --> <source>:2:24
  |
2 | type BlahResult<I, E = impl ExampleTrait<I>> = Result<I, E>;
  |                        ^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

@rustbot label regression-from-stable-to-stable A-impl-trait

matthiaskrgr commented 3 years ago

Probably a duplicate of https://github.com/rust-lang/rust/issues/78671

JohnTitor commented 3 years ago

@matthiaskrgr #78671 isn't ICE anymore but this one still is on nightly.

apiraino commented 3 years ago

bisection fails to identify a specific nightly because we dont have them anymore in the CI

********************************************************************************
Regression in nightly-2019-06-07
********************************************************************************
found 7 bors merge commits in the specified range
  commit[0] 2019-06-05UTC: Auto merge of #61548 - Centril:rollup-5t6cvbk, r=Centril
  commit[1] 2019-06-06UTC: Auto merge of #59331 - varkor:TypeVariableOrigin-refactor, r=eddyb
  commit[2] 2019-06-06UTC: Auto merge of #57428 - alexreg:associated_type_bounds, r=nikomatsakis,Centril
  commit[3] 2019-06-06UTC: Auto merge of #61373 - tmandry:emit-storagedead-along-unwind, r=eddyb
  commit[4] 2019-06-06UTC: Auto merge of #61494 - Mark-Simulacrum:move-to-cfg-bootstrap, r=alexcrichton
  commit[5] 2019-06-06UTC: Auto merge of #61583 - Centril:rollup-ug2cbfd, r=Centril
  commit[6] 2019-06-06UTC: Auto merge of #61601 - Centril:rollup-uegbsns, r=Centril
ERROR: no commits between 7cdaffd7962c4aae0cadd82baa241901b03f9458 and 5eeb567a27eba18420a620ca7d0c007e29d8bc0c within last 167 days
apiraino commented 3 years ago

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@rustbot label -I-prioritize +P-medium

Alexendoo commented 3 years ago

Fixed by #83935