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 when calling method on generic impl constrained by unmet trait alias #108132

Closed
eggyal opened this issue Feb 16, 2023 · 1 comment · Fixed by #108136
Closed

ICE when calling method on generic impl constrained by unmet trait alias #108132

eggyal opened this issue Feb 16, 2023 · 1 comment · Fixed by #108136
Assignees
Labels
C-bug Category: This is a bug. F-trait_alias `#![feature(trait_alias)]` 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

@eggyal
Copy link
Contributor

eggyal commented Feb 16, 2023

Similar to #108072, but when the method cannot be found.

Code

#![feature(trait_alias)]

trait IteratorAlias = Iterator;

struct Foo<I>(I);

impl<I: IteratorAlias> Foo<I> {
    fn f() {}
}

fn main() {
    Foo::<()>::f()
}

Playground

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (2d14db321 2023-02-15)
binary: rustc
commit-hash: 2d14db321b043ffc579a7461464c88d7e3f54f83
commit-date: 2023-02-15
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Error output

thread 'rustc' panicked at 'internal error: entered unreachable code: encountered `Item(Item { ident: IteratorAlias#0, owner_id: DefId(0:3 ~ playground[d092]::IteratorAlias), kind: TraitAlias(Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: src/main.rs:3:31: 3:31 (#0), span: src/main.rs:3:20: 3:20 (#0) }, [Trait(PolyTraitRef { bound_generic_params: [], trait_ref: TraitRef { path: Path { span: src/main.rs:3:23: 3:31 (#0), res: Def(Trait, DefId(2:7197 ~ core[f0a8]::iter::traits::iterator::Iterator)), segments: [PathSegment { ident: Iterator#0, hir_id: HirId(DefId(0:3 ~ playground[d092]::IteratorAlias).1), res: Def(Trait, DefId(2:7197 ~ core[f0a8]::iter::traits::iterator::Iterator)), args: None, infer_args: false }] }, hir_ref_id: HirId(DefId(0:3 ~ playground[d092]::IteratorAlias).2) }, span: src/main.rs:3:23: 3:31 (#0) }, None)]), span: src/main.rs:3:1: 3:32 (#0), vis_span: src/main.rs:3:1: 3:1 (#0) })`', compiler/rustc_hir_typeck/src/method/suggest.rs:729:35
Backtrace

   0:     0x7f7b110769ea - std::backtrace_rs::backtrace::libunwind::trace::h3a20221a56d872e6
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7b110769ea - std::backtrace_rs::backtrace::trace_unsynchronized::h23863182fd4b4481
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7b110769ea - std::sys_common::backtrace::_print_fmt::hde799c83b2fa8ddb
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7b110769ea - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb1ed906e28a16738
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7b110d6afe - core::fmt::write::hee7bc8dd2696f088
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f7b11067005 - std::io::Write::write_fmt::h031e716f6e3d1f66
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/io/mod.rs:1684:15
   6:     0x7f7b110767b5 - std::sys_common::backtrace::_print::h8cea91a8dc3abdb3
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7b110767b5 - std::sys_common::backtrace::print::hcd9f90783d8afb1f
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7b1107954f - std::panicking::default_hook::{{closure}}::hdf7c561ea2419acd
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/panicking.rs:267:22
   9:     0x7f7b1107928b - std::panicking::default_hook::h9669759e65745add
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/panicking.rs:286:9
  10:     0x7f7b143c4c44 - <rustc_driver_impl[cf5be2d75a70ff02]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[f0a84df7292b9247]::ops::function::FnOnce<(&core[f0a84df7292b9247]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f7b11079d8a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h71e54ddf4b01f8ef
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/alloc/src/boxed.rs:2002:9
  12:     0x7f7b11079d8a - std::panicking::rust_panic_with_hook::h96419a4a3670d907
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/panicking.rs:692:13
  13:     0x7f7b11079b09 - std::panicking::begin_panic_handler::{{closure}}::h17c261a3ff4b53aa
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/panicking.rs:579:13
  14:     0x7f7b11076e8c - std::sys_common::backtrace::__rust_end_short_backtrace::h6f10911888b9e113
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f7b11079812 - rust_begin_unwind
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/panicking.rs:575:5
  16:     0x7f7b110d34a3 - core::panicking::panic_fmt::hdb483708f9fb42ab
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/core/src/panicking.rs:64:14
  17:     0x7f7b1456dda0 - <rustc_hir_typeck[d1f10db731357cb4]::fn_ctxt::FnCtxt>::report_no_match_method_error
  18:     0x7f7b1457dd88 - <rustc_hir_typeck[d1f10db731357cb4]::fn_ctxt::FnCtxt>::report_method_error
  19:     0x7f7b1248c30a - <rustc_hir_typeck[d1f10db731357cb4]::fn_ctxt::FnCtxt>::check_expr_path
  20:     0x7f7b126636c5 - <rustc_hir_typeck[d1f10db731357cb4]::fn_ctxt::FnCtxt>::check_call
  21:     0x7f7b1243af78 - <rustc_hir_typeck[d1f10db731357cb4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:     0x7f7b1247c1fd - <rustc_hir_typeck[d1f10db731357cb4]::fn_ctxt::FnCtxt>::check_block_with_expected
  23:     0x7f7b1243b600 - <rustc_hir_typeck[d1f10db731357cb4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:     0x7f7b12f0322b - <rustc_hir_typeck[d1f10db731357cb4]::fn_ctxt::FnCtxt>::check_return_expr
  25:     0x7f7b12efabb5 - rustc_hir_typeck[d1f10db731357cb4]::check::check_fn
  26:     0x7f7b12edf0ce - rustc_hir_typeck[d1f10db731357cb4]::typeck
  27:     0x7f7b12522a83 - rustc_query_system[9c20c97984254eda]::query::plumbing::try_execute_query::<rustc_query_impl[e25e6056fa54423]::queries::typeck, rustc_query_impl[e25e6056fa54423]::plumbing::QueryCtxt>
  28:     0x7f7b13b02dfb - rustc_data_structures[4cb054fd51de001a]::sync::par_for_each_in::<&[rustc_span[ff2b83d94cd5766c]::def_id::LocalDefId], <rustc_middle[bd03a598433729a4]::hir::map::Map>::par_body_owners<rustc_hir_typeck[d1f10db731357cb4]::typeck_item_bodies::{closure#0}>::{closure#0}>
  29:     0x7f7b13b02bf1 - rustc_hir_typeck[d1f10db731357cb4]::typeck_item_bodies
  30:     0x7f7b1396b423 - rustc_query_system[9c20c97984254eda]::query::plumbing::try_execute_query::<rustc_query_impl[e25e6056fa54423]::queries::typeck_item_bodies, rustc_query_impl[e25e6056fa54423]::plumbing::QueryCtxt>
  31:     0x7f7b13d4f42b - <rustc_query_impl[e25e6056fa54423]::Queries as rustc_middle[bd03a598433729a4]::ty::query::QueryEngine>::typeck_item_bodies
  32:     0x7f7b138061fe - <rustc_session[130bf05e2988f5fc]::session::Session>::time::<(), rustc_hir_analysis[7e2943bc0d9db6d0]::check_crate::{closure#7}>
  33:     0x7f7b13803420 - rustc_hir_analysis[7e2943bc0d9db6d0]::check_crate
  34:     0x7f7b137f69d4 - rustc_interface[e19372daae8a4d61]::passes::analysis
  35:     0x7f7b13b56a02 - rustc_query_system[9c20c97984254eda]::query::plumbing::try_execute_query::<rustc_query_impl[e25e6056fa54423]::queries::analysis, rustc_query_impl[e25e6056fa54423]::plumbing::QueryCtxt>
  36:     0x7f7b13d4750a - <rustc_query_impl[e25e6056fa54423]::Queries as rustc_middle[bd03a598433729a4]::ty::query::QueryEngine>::analysis
  37:     0x7f7b13a58e79 - <rustc_middle[bd03a598433729a4]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[cf5be2d75a70ff02]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>>
  38:     0x7f7b135d2a19 - <rustc_interface[e19372daae8a4d61]::interface::Compiler>::enter::<rustc_driver_impl[cf5be2d75a70ff02]::run_compiler::{closure#1}::{closure#2}, core[f0a84df7292b9247]::result::Result<core[f0a84df7292b9247]::option::Option<rustc_interface[e19372daae8a4d61]::queries::Linker>, rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>>
  39:     0x7f7b135d0b04 - rustc_span[ff2b83d94cd5766c]::with_source_map::<core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>, rustc_interface[e19372daae8a4d61]::interface::run_compiler<core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>, rustc_driver_impl[cf5be2d75a70ff02]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  40:     0x7f7b135d0614 - <scoped_tls[94748c71a964531c]::ScopedKey<rustc_span[ff2b83d94cd5766c]::SessionGlobals>>::set::<rustc_interface[e19372daae8a4d61]::interface::run_compiler<core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>, rustc_driver_impl[cf5be2d75a70ff02]::run_compiler::{closure#1}>::{closure#0}, core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>>
  41:     0x7f7b135cfd12 - std[f1e96740c585910a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e19372daae8a4d61]::util::run_in_thread_pool_with_globals<rustc_interface[e19372daae8a4d61]::interface::run_compiler<core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>, rustc_driver_impl[cf5be2d75a70ff02]::run_compiler::{closure#1}>::{closure#0}, core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>>
  42:     0x7f7b135cfabc - <<std[f1e96740c585910a]::thread::Builder>::spawn_unchecked_<rustc_interface[e19372daae8a4d61]::util::run_in_thread_pool_with_globals<rustc_interface[e19372daae8a4d61]::interface::run_compiler<core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>, rustc_driver_impl[cf5be2d75a70ff02]::run_compiler::{closure#1}>::{closure#0}, core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f0a84df7292b9247]::result::Result<(), rustc_errors[580ee8295c6eeddb]::ErrorGuaranteed>>::{closure#1} as core[f0a84df7292b9247]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f7b11083d23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6f3268749d03f717
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/alloc/src/boxed.rs:1988:9
  44:     0x7f7b11083d23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he030b34c5a5b9772
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/alloc/src/boxed.rs:1988:9
  45:     0x7f7b11083d23 - std::sys::unix::thread::Thread::new::thread_start::h3f952212e35a76cc
                               at /rustc/2d14db321b043ffc579a7461464c88d7e3f54f83/library/std/src/sys/unix/thread.rs:108:17
  46:     0x7f7b10f46609 - start_thread
  47:     0x7f7b10e69133 - clone
  48:                0x0 - <unknown>

@rustbot label +F-trait_alias

@eggyal eggyal 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 Feb 16, 2023
@rustbot rustbot added the F-trait_alias `#![feature(trait_alias)]` label Feb 16, 2023
@eggyal
Copy link
Contributor Author

eggyal commented Feb 16, 2023

searched nightlies: from nightly-2023-01-01 to nightly-2023-02-16
regressed nightly: nightly-2023-01-15
searched commit range: 0b90256...afaf3e0
regressed commit: 4b51adf

bisected with cargo-bisect-rustc v0.6.5

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --regress ice --start 2023-01-01 --preserve --without-cargo 

Of that rollup, #106788 looks most likely responsible to me. cc @estebank

I think the ICE arises from https://github.com/rust-lang/rust/pull/106788/files#diff-fa9d26c02df9437e1b198df6ffd387a476adbb27a18b0a65dbed20c1fc8bd6d1R154-R165, where the DefId of trait aliases get stored in the impl_def_id of an ImplDerivedObligationCause (again cc @compiler-errors), which is a state that is later unexpected in report_no_match_method_error.

@rustbot claim

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-trait_alias `#![feature(trait_alias)]` 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
Development

Successfully merging a pull request may close this issue.

2 participants