Skip to content

ICE: compiler/rustc_middle/src/ty/subst.rs:529:17: type parameter T/#1 (T/1) out of range when substituting, substs=[Self] #78671

Closed
@chengniansun

Description

@chengniansun

Code

trait CollectionFamily {
    type Member<T>;
}
fn floatify() {
    Family as CollectionFamily
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (b20253260 2020-11-01)
binary: rustc
commit-hash: b2025326088b54fb3f083bebeba14e0a15bf00d3
commit-date: 2020-11-01
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Error output

warning: trait objects without an explicit `dyn` are deprecated
  --> mutant.rs:37:66
   |
37 | let mut res = < C :: Family as CollectionFamily > :: Member :: < CollectionFamily > :: empty ( ) ;
   |                                                                  ^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn CollectionFamily`
   |
   = note: `#[warn(bare_trait_objects)]` on by default

error[E0191]: the value of the associated type `Member` (from trait `CollectionFamily`) must be specified
  --> mutant.rs:37:66
   |
14 | type Member < T > : Collection < T , Family = Self > ;
   | ------------------------------------------------------ `Member` defined here
...
37 | let mut res = < C :: Family as CollectionFamily > :: Member :: < CollectionFamily > :: empty ( ) ;
   |                                                                  ^^^^^^^^^^^^^^^^ help: specify the associated type: `CollectionFamily<Member = Type>`

error[E0599]: no function or associated item named `empty` found for associated type `<<C as Collection<i32>>::Family as CollectionFamily>::Member<dyn CollectionFamily>` in the current scope
  --> mutant.rs:37:88
   |
13 | trait CollectionFamily {
   | ---------------------- doesn't satisfy `dyn CollectionFamily: Sized`
...
37 | let mut res = < C :: Family as CollectionFamily > :: Member :: < CollectionFamily > :: empty ( ) ;
   |                                                                                        ^^^^^ function or associated item not found in `<<C as Collection<i32>>::Family as CollectionFamily>::Member<dyn CollectionFamily>`
   |
   = note: the method `empty` exists but the following trait bounds were not satisfied:
           `dyn CollectionFamily: Sized`
           which is required by `<<C as Collection<i32>>::Family as CollectionFamily>::Member<dyn CollectionFamily>: Collection<dyn CollectionFamily>`

error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:529:17: type parameter `T/#1` (T/1) out of range when substituting, substs=[Self]

thread 'rustc' panicked at 'Box<Any>', /rustc/b2025326088b54fb3f083bebeba14e0a15bf00d3/compiler/rustc_errors/src/lib.rs:904: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.49.0-nightly (b20253260 2020-11-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [object_safety_violations] determine object safety of trait `CollectionFamily`
#1 [typeck] type-checking `floatify`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0191, E0599.
For more information about an error, try `rustc --explain E0191`.

Backtrace

thread 'rustc' panicked at 'Box<Any>', /rustc/b2025326088b54fb3f083bebeba14e0a15bf00d3/compiler/rustc_errors/src/lib.rs:904:9
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: <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty
  12: rustc_middle::ty::fold::TypeFoldable::fold_with
  13: rustc_middle::ty::fold::TypeFoldable::fold_with
  14: rustc_middle::ty::Predicate::subst_supertrait
  15: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
  16: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  17: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  18: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
  19: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  20: rustc_middle::arena::Arena::alloc_from_iter
  21: rustc_trait_selection::traits::object_safety::object_safety_violations
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_query_system::query::plumbing::get_query_impl
  25: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::is_object_safe
  26: rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations
  27: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_where_possible
  28: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
  29: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_method_argument_types
  30: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  31: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  32: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  33: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_coercable_to_type
  34: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_decl_local
  35: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  36: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  37: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  38: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  39: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  40: rustc_typeck::check::check::check_fn
  41: rustc_infer::infer::InferCtxtBuilder::enter
  42: rustc_typeck::check::typeck
  43: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  44: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  45: rustc_data_structures::stack::ensure_sufficient_stack
  46: rustc_query_system::query::plumbing::get_query_impl
  47: rustc_query_system::query::plumbing::ensure_query_impl
  48: rustc_typeck::check::typeck_item_bodies
  49: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  50: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  51: rustc_data_structures::stack::ensure_sufficient_stack
  52: rustc_query_system::query::plumbing::get_query_impl
  53: rustc_typeck::check_crate
  54: rustc_interface::passes::analysis
  55: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  56: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  57: rustc_data_structures::stack::ensure_sufficient_stack
  58: rustc_query_system::query::plumbing::get_query_impl
  59: rustc_interface::passes::QueryContext::enter

NOTE: The bug is found by our work-in-progress compiler testing tool Kira, and the test program is reduced/minimized by Perses

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions