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 with RPITIT and wrong number of type parameters #103824

Closed
jruderman opened this issue Nov 1, 2022 · 0 comments · Fixed by #103827
Closed

ICE with RPITIT and wrong number of type parameters #103824

jruderman opened this issue Nov 1, 2022 · 0 comments · Fixed by #103827
Assignees
Labels
C-bug Category: This is a bug. F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` 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.

Comments

@jruderman
Copy link
Contributor

Code

#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]

struct U;

trait Foo {
    fn bar(&self) -> impl Sized;
}

impl Foo for U {
    fn bar<T>(&self) {}
    //~^ ERROR method `bar` has 1 type parameter but its trait declaration has 0 type parameters
}

fn main() {
    U.bar();
}

Error output

error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters

error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:726:9: type parameter `T/#0` (T/0) out of range when substituting, substs=[]
Full output including backtrace

error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters
  --> rpj.rs:11:12
   |
7  |     fn bar(&self) -> impl Sized;
   |           - expected 0 type parameters
...
11 |     fn bar<T>(&self) {}
   |            ^ found 1 type parameter

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

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/77e57db384aca99444c3b5f6a9c86bc58a804d89/compiler/rustc_errors/src/lib.rs:1519:9
stack backtrace:
   0:        0x10b6ff7b2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he72a9ef32238839b
   1:        0x10b7575fa - core::fmt::write::h1aff7cb2c58c2dc4
   2:        0x10b6f188c - std::io::Write::write_fmt::ha243a154809d5cab
   3:        0x10b6ff57a - std::sys_common::backtrace::print::h5c145de23a7911ec
   4:        0x10b702976 - std::panicking::default_hook::{{closure}}::h4529c81e95495394
   5:        0x10b7026c7 - std::panicking::default_hook::h34ecf85663cebb19
   6:        0x11ae74b5d - rustc_driver[e2d9d853bbc8c7ad]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10b703171 - std::panicking::rust_panic_with_hook::h93ff9cb57bde6af7
   8:        0x11f551a97 - std[bb57373db5d340f5]::panicking::begin_panic::<rustc_errors[b6b6ada6006e0aff]::ExplicitBug>::{closure#0}
   9:        0x11f551469 - std[bb57373db5d340f5]::sys_common::backtrace::__rust_end_short_backtrace::<std[bb57373db5d340f5]::panicking::begin_panic<rustc_errors[b6b6ada6006e0aff]::ExplicitBug>::{closure#0}, !>
  10:        0x11fbf9599 - std[bb57373db5d340f5]::panicking::begin_panic::<rustc_errors[b6b6ada6006e0aff]::ExplicitBug>
  11:        0x11f551459 - std[bb57373db5d340f5]::panic::panic_any::<rustc_errors[b6b6ada6006e0aff]::ExplicitBug>
  12:        0x11f54f30c - <rustc_errors[b6b6ada6006e0aff]::HandlerInner>::bug::<&alloc[c4e361f59d12fa8]::string::String>
  13:        0x11f54ea97 - <rustc_errors[b6b6ada6006e0aff]::Handler>::bug::<&alloc[c4e361f59d12fa8]::string::String>
  14:        0x11f6a3b02 - rustc_middle[c99e28b2acd5d734]::ty::context::tls::with_context_opt::<rustc_middle[c99e28b2acd5d734]::ty::context::tls::with_opt<rustc_middle[c99e28b2acd5d734]::util::bug::opt_span_bug_fmt<rustc_span[206e1613de00d9a2]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  15:        0x11f6a7e01 - rustc_middle[c99e28b2acd5d734]::util::bug::opt_span_bug_fmt::<rustc_span[206e1613de00d9a2]::span_encoding::Span>
  16:        0x11fbfaf4e - rustc_middle[c99e28b2acd5d734]::util::bug::bug_fmt
  17:        0x11fbfad98 - <rustc_middle[c99e28b2acd5d734]::ty::subst::SubstFolder>::type_param_out_of_range
  18:        0x11f68d469 - <rustc_middle[c99e28b2acd5d734]::ty::subst::SubstFolder as rustc_middle[c99e28b2acd5d734]::ty::fold::TypeFolder>::fold_ty
  19:        0x11f68b767 - <&rustc_middle[c99e28b2acd5d734]::ty::list::List<rustc_middle[c99e28b2acd5d734]::ty::subst::GenericArg> as rustc_middle[c99e28b2acd5d734]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[c99e28b2acd5d734]::ty::subst::SubstFolder>
  20:        0x11f598e9c - <rustc_middle[c99e28b2acd5d734]::ty::PredicateKind as rustc_middle[c99e28b2acd5d734]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[c99e28b2acd5d734]::ty::subst::SubstFolder>
  21:        0x11f686539 - <rustc_middle[c99e28b2acd5d734]::ty::subst::SubstFolder as rustc_middle[c99e28b2acd5d734]::ty::fold::FallibleTypeFolder>::try_fold_binder::<rustc_middle[c99e28b2acd5d734]::ty::PredicateKind>
  22:        0x11f5b6c6b - <alloc[c4e361f59d12fa8]::vec::Vec<rustc_middle[c99e28b2acd5d734]::ty::Predicate> as alloc[c4e361f59d12fa8]::vec::spec_extend::SpecExtend<rustc_middle[c99e28b2acd5d734]::ty::Predicate, core[a5385033588888e7]::iter::adapters::map::Map<core[a5385033588888e7]::slice::iter::Iter<(rustc_middle[c99e28b2acd5d734]::ty::Predicate, rustc_span[206e1613de00d9a2]::span_encoding::Span)>, <rustc_middle[c99e28b2acd5d734]::ty::generics::GenericPredicates>::instantiate_into::{closure#0}>>>::spec_extend
  23:        0x11f62b97b - <rustc_middle[c99e28b2acd5d734]::ty::generics::GenericPredicates>::instantiate_into
  24:        0x11f622f67 - <rustc_middle[c99e28b2acd5d734]::ty::generics::GenericPredicates>::instantiate
  25:        0x11f2e149a - rustc_trait_selection[47d1ffb231ad99c9]::traits::project::project
  26:        0x11f2ddb85 - rustc_trait_selection[47d1ffb231ad99c9]::traits::project::opt_normalize_projection_type
  27:        0x11f2d84be - rustc_trait_selection[47d1ffb231ad99c9]::traits::project::normalize_projection_type
  28:        0x11f2d6cde - <rustc_trait_selection[47d1ffb231ad99c9]::traits::project::AssocTypeNormalizer as rustc_middle[c99e28b2acd5d734]::ty::fold::TypeFolder>::fold_ty
  29:        0x11d6f541f - <&rustc_middle[c99e28b2acd5d734]::ty::list::List<rustc_middle[c99e28b2acd5d734]::ty::Ty> as rustc_middle[c99e28b2acd5d734]::ty::fold::TypeFoldable>::try_fold_with::<rustc_trait_selection[47d1ffb231ad99c9]::traits::project::AssocTypeNormalizer>
  30:        0x11d78bb1a - <rustc_trait_selection[47d1ffb231ad99c9]::traits::project::AssocTypeNormalizer>::fold::<(rustc_middle[c99e28b2acd5d734]::ty::sty::FnSig, rustc_middle[c99e28b2acd5d734]::ty::InstantiatedPredicates)>
  31:        0x11d79993b - rustc_trait_selection[47d1ffb231ad99c9]::traits::project::normalize::<(rustc_middle[c99e28b2acd5d734]::ty::sty::FnSig, rustc_middle[c99e28b2acd5d734]::ty::InstantiatedPredicates)>
  32:        0x11d805071 - <rustc_infer[6f8f7550a4ea31d3]::infer::InferCtxt as rustc_trait_selection[47d1ffb231ad99c9]::infer::InferCtxtExt>::partially_normalize_associated_types_in::<(rustc_middle[c99e28b2acd5d734]::ty::sty::FnSig, rustc_middle[c99e28b2acd5d734]::ty::InstantiatedPredicates)>
  33:        0x11d7b0856 - <rustc_hir_typeck[a4375b6a24c3445d]::inherited::Inherited>::normalize_associated_types_in::<(rustc_middle[c99e28b2acd5d734]::ty::sty::FnSig, rustc_middle[c99e28b2acd5d734]::ty::InstantiatedPredicates)>
  34:        0x11d7d39c8 - <rustc_hir_typeck[a4375b6a24c3445d]::method::confirm::ConfirmContext>::confirm
  35:        0x11d6e2d26 - <rustc_hir_typeck[a4375b6a24c3445d]::fn_ctxt::FnCtxt>::lookup_method
  36:        0x11d6d0ec7 - <rustc_hir_typeck[a4375b6a24c3445d]::fn_ctxt::FnCtxt>::check_expr_kind
  37:        0x11d67a956 - <rustc_hir_typeck[a4375b6a24c3445d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  38:        0x11d690385 - <rustc_hir_typeck[a4375b6a24c3445d]::fn_ctxt::FnCtxt>::check_stmt
  39:        0x11d690acf - <rustc_hir_typeck[a4375b6a24c3445d]::fn_ctxt::FnCtxt>::check_block_with_expected
  40:        0x11d6d1718 - <rustc_hir_typeck[a4375b6a24c3445d]::fn_ctxt::FnCtxt>::check_expr_kind
  41:        0x11d67a956 - <rustc_hir_typeck[a4375b6a24c3445d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  42:        0x11d67b99a - <rustc_hir_typeck[a4375b6a24c3445d]::fn_ctxt::FnCtxt>::check_return_expr
  43:        0x11d7ecdbe - rustc_hir_typeck[a4375b6a24c3445d]::check::check_fn
  44:        0x11d7b400c - rustc_hir_typeck[a4375b6a24c3445d]::typeck
  45:        0x11e64a379 - rustc_query_system[e6dac468dcf8193f]::query::plumbing::try_execute_query::<rustc_query_impl[9d247feb43be9907]::plumbing::QueryCtxt, rustc_query_system[e6dac468dcf8193f]::query::caches::DefaultCache<rustc_span[206e1613de00d9a2]::def_id::LocalDefId, &rustc_middle[c99e28b2acd5d734]::ty::context::TypeckResults>>
  46:        0x11e74fb7c - rustc_query_system[e6dac468dcf8193f]::query::plumbing::get_query::<rustc_query_impl[9d247feb43be9907]::queries::typeck, rustc_query_impl[9d247feb43be9907]::plumbing::QueryCtxt>
  47:        0x11d7dbc5b - rustc_data_structures[37e5f7af2868d15d]::sync::par_for_each_in::<&[rustc_span[206e1613de00d9a2]::def_id::LocalDefId], <rustc_middle[c99e28b2acd5d734]::hir::map::Map>::par_body_owners<rustc_hir_typeck[a4375b6a24c3445d]::typeck_item_bodies::{closure#0}>::{closure#0}>
  48:        0x11d7b153d - rustc_hir_typeck[a4375b6a24c3445d]::typeck_item_bodies
  49:        0x11e6e3fd9 - rustc_query_system[e6dac468dcf8193f]::query::plumbing::try_execute_query::<rustc_query_impl[9d247feb43be9907]::plumbing::QueryCtxt, rustc_query_system[e6dac468dcf8193f]::query::caches::DefaultCache<(), ()>>
  50:        0x11e744569 - rustc_query_system[e6dac468dcf8193f]::query::plumbing::get_query::<rustc_query_impl[9d247feb43be9907]::queries::typeck_item_bodies, rustc_query_impl[9d247feb43be9907]::plumbing::QueryCtxt>
  51:        0x11d8d497e - <rustc_session[703568b9a0997f94]::session::Session>::time::<(), rustc_hir_analysis[1283c7899585cdba]::check_crate::{closure#7}>
  52:        0x11d883d7f - rustc_hir_analysis[1283c7899585cdba]::check_crate
  53:        0x11af4c2aa - rustc_interface[8f226da4d36d48ab]::passes::analysis
  54:        0x11e6d5d9c - rustc_query_system[e6dac468dcf8193f]::query::plumbing::try_execute_query::<rustc_query_impl[9d247feb43be9907]::plumbing::QueryCtxt, rustc_query_system[e6dac468dcf8193f]::query::caches::DefaultCache<(), core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>>>
  55:        0x11e74ff29 - rustc_query_system[e6dac468dcf8193f]::query::plumbing::get_query::<rustc_query_impl[9d247feb43be9907]::queries::analysis, rustc_query_impl[9d247feb43be9907]::plumbing::QueryCtxt>
  56:        0x11ae03cc6 - <rustc_interface[8f226da4d36d48ab]::passes::QueryContext>::enter::<rustc_driver[e2d9d853bbc8c7ad]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>>
  57:        0x11ae47d8d - rustc_span[206e1613de00d9a2]::with_source_map::<core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>, rustc_interface[8f226da4d36d48ab]::interface::run_compiler<core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>, rustc_driver[e2d9d853bbc8c7ad]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  58:        0x11ae3776c - <scoped_tls[d4eba0e9053bbc5a]::ScopedKey<rustc_span[206e1613de00d9a2]::SessionGlobals>>::set::<rustc_interface[8f226da4d36d48ab]::interface::run_compiler<core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>, rustc_driver[e2d9d853bbc8c7ad]::run_compiler::{closure#1}>::{closure#0}, core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>>
  59:        0x11ae0725a - std[bb57373db5d340f5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8f226da4d36d48ab]::util::run_in_thread_pool_with_globals<rustc_interface[8f226da4d36d48ab]::interface::run_compiler<core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>, rustc_driver[e2d9d853bbc8c7ad]::run_compiler::{closure#1}>::{closure#0}, core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>>
  60:        0x11aded29b - <<std[bb57373db5d340f5]::thread::Builder>::spawn_unchecked_<rustc_interface[8f226da4d36d48ab]::util::run_in_thread_pool_with_globals<rustc_interface[8f226da4d36d48ab]::interface::run_compiler<core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>, rustc_driver[e2d9d853bbc8c7ad]::run_compiler::{closure#1}>::{closure#0}, core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a5385033588888e7]::result::Result<(), rustc_errors[b6b6ada6006e0aff]::ErrorGuaranteed>>::{closure#1} as core[a5385033588888e7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  61:        0x10b70c227 - std::sys::unix::thread::Thread::new::thread_start::h1fb200cb108bd4fb
  62:     0x7ff814d514e1 - __pthread_start

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.67.0-nightly (77e57db38 2022-10-30) running on x86_64-apple-darwin

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

Regression

searched nightlies: from nightly-2022-10-16 to nightly-2022-10-31
regressed nightly: nightly-2022-10-17
searched commit range: b8c35ca...b8b5cae
regressed commit: 8be3ce9 (#102334)

Bisected with cargo-bisect-rustc v0.6.4 on x86_64-apple-darwin

Version

rustc 1.67.0-nightly (77e57db38 2022-10-30)
binary: rustc
commit-hash: 77e57db384aca99444c3b5f6a9c86bc58a804d89
commit-date: 2022-10-30
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

@rustbot label +F-return_position_impl_trait_in_trait

@jruderman jruderman 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 Nov 1, 2022
@rustbot rustbot added the F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` label Nov 1, 2022
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 8, 2022
…at, r=wesleywiser

Properly remap and check for substs compatibility in `confirm_impl_trait_in_trait_candidate`

Fixes rust-lang#103824
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 8, 2022
…at, r=wesleywiser

Properly remap and check for substs compatibility in `confirm_impl_trait_in_trait_candidate`

Fixes rust-lang#103824
@bors bors closed this as completed in 6c021cf Nov 9, 2022
@compiler-errors compiler-errors self-assigned this Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` 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.
Projects
None yet
3 participants