Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: type parameter E/#2 (E/2) out of range when substituting #82952

Closed
redgoldlace opened this issue Mar 9, 2021 · 6 comments
Closed

ICE: type parameter E/#2 (E/2) out of range when substituting #82952

redgoldlace opened this issue Mar 9, 2021 · 6 comments
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@redgoldlace
Copy link

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: <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty
   9: rustc_middle::ty::fold::TypeFoldable::fold_with
  10: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  11: <<dyn rustc_typeck::astconv::AstConv>::create_substs_for_ast_path::SubstsForAstPathCtxt as rustc_typeck::astconv::CreateSubstsForGenericArgsCtxt>::inferred_kind
  12: <dyn rustc_typeck::astconv::AstConv>::create_substs_for_ast_path
  13: <dyn rustc_typeck::astconv::AstConv>::ast_path_substs_for_ty
  14: <dyn rustc_typeck::astconv::AstConv>::res_to_ty
  15: <dyn rustc_typeck::astconv::AstConv>::ast_ty_to_ty_inner
  16: <dyn rustc_typeck::astconv::AstConv>::ty_of_fn
  17: rustc_typeck::collect::fn_sig
  18: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::fn_sig>::compute
  19: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::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: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::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::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::collect_mod_item_types>::compute
  28: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::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::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  36: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  37: rustc_query_system::dep_graph::graph::DepGraph<K>::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::<impl rustc_interface::interface::Compiler>::enter
  42: rustc_span::with_source_map
  43: rustc_interface::interface::create_compiler_and_run

@redgoldlace redgoldlace added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 9, 2021
@SNCPlay42
Copy link
Contributor

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

@rustbot rustbot added A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 9, 2021
@matthiaskrgr
Copy link
Member

Probably a duplicate of #78671

@JohnTitor
Copy link
Member

JohnTitor commented Mar 9, 2021

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

@apiraino
Copy link
Contributor

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
Copy link
Contributor

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

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 10, 2021
fanninpm added a commit to fanninpm/glacier that referenced this issue Mar 12, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 12, 2021
@Alexendoo
Copy link
Member

Fixed by #83935

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants