Skip to content

ICE. delegation: index out of bounds with syntax error #119921

Closed
@matthiaskrgr

Description

@matthiaskrgr

snippet:

trait Trait {
    fn static_method2(, ) -> i32 { x + y }
    fn baz<'a>(&self, x: &'a i32) -> &'a i32 { x }
}

struct F;

struct S(F);
impl Trait for S {
    reuse <S as Trait>::static_method2 { (self); // oopsie
    reuse Trait::baz { &self.0 }
}
}

Version information

rustc 1.77.0-nightly (89110dafe 2024-01-13)
binary: rustc
commit-hash: 89110dafe79621fa07d6cd7c8493dd1d0a83cfaf
commit-date: 2024-01-13
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected argument name, found `,`
 --> /tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs:3:23
  |
3 |     fn static_method2(, ) -> i32 { x + y }
  |                       ^ expected argument name

error[E0425]: cannot find value `x` in this scope
 --> /tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs:3:36
  |
3 |     fn static_method2(, ) -> i32 { x + y }
  |                                    ^ help: a unit struct with a similar name exists: `F`
...
7 | struct F;
  | --------- similarly named unit struct `F` defined here

error[E0425]: cannot find value `y` in this scope
 --> /tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs:3:40
  |
3 |     fn static_method2(, ) -> i32 { x + y }
  |                                        ^ help: a unit struct with a similar name exists: `F`
...
7 | struct F;
  | --------- similarly named unit struct `F` defined here

error[E0658]: functions delegation is not yet fully implemented
  --> /tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs:12:5
   |
12 |     reuse Trait::baz { &self.0 }
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
   = help: add `#![feature(fn_delegation)]` to the crate attributes to enable

error[E0658]: functions delegation is not yet fully implemented
  --> /tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs:11:5
   |
11 | /     reuse <S as Trait>::static_method2 { (self); // oppsie
12 | |     reuse Trait::baz { &self.0 }
13 | | }
   | |_^
   |
   = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
   = help: add `#![feature(fn_delegation)]` to the crate attributes to enable

warning: anonymous parameters are deprecated and will be removed in the next edition
 --> /tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs:3:22
  |
3 |     fn static_method2(, ) -> i32 { x + y }
  |                      ^ help: try naming the parameter or explicitly ignoring it: `_: (`
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
  = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
  = note: `#[warn(anonymous_parameters)]` on by default

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs:14:2
   |
14 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs`

thread 'rustc' panicked at compiler/rustc_middle/src/ty/generics.rs:233:25:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f2c60f9b7e6 - std::backtrace_rs::backtrace::libunwind::trace::h4f92a9ab1e969130
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f2c60f9b7e6 - std::backtrace_rs::backtrace::trace_unsynchronized::hff5adbaff3a8cfb8
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2c60f9b7e6 - std::sys_common::backtrace::_print_fmt::h9d3e0e63f6f89eaf
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f2c60f9b7e6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2d31e6c8aa8ef934
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f2c60fedec0 - core::fmt::rt::Argument::fmt::hd4eaf83b012a42ab
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/core/src/fmt/rt.rs:142:9
   5:     0x7f2c60fedec0 - core::fmt::write::hb507e806b3ae16c4
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f2c60f8f14f - std::io::Write::write_fmt::h203bf95b6a67c7a0
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/io/mod.rs:1810:15
   7:     0x7f2c60f9b5c4 - std::sys_common::backtrace::_print::h2f732cf10966ea1c
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f2c60f9b5c4 - std::sys_common::backtrace::print::hef45416e244164df
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f2c60f9e357 - std::panicking::default_hook::{{closure}}::h1a73802a0a993acf
  10:     0x7f2c60f9e0b9 - std::panicking::default_hook::h34548737700c4b4d
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/panicking.rs:292:9
  11:     0x7f2c5dd4e80c - std[d6f21989bfff4f42]::panicking::update_hook::<alloc[21b544e6cc75226b]::boxed::Box<rustc_driver_impl[bce72efeea91a1de]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f2c60f9eaa6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb0b823449909a650
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/alloc/src/boxed.rs:2030:9
  13:     0x7f2c60f9eaa6 - std::panicking::rust_panic_with_hook::h60e4310ab2a16e4e
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/panicking.rs:785:13
  14:     0x7f2c60f9e7f2 - std::panicking::begin_panic_handler::{{closure}}::h61737518028fa2b2
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/panicking.rs:659:13
  15:     0x7f2c60f9bce6 - std::sys_common::backtrace::__rust_end_short_backtrace::h7870f48bedce1dac
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f2c60f9e550 - rust_begin_unwind
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/panicking.rs:647:5
  17:     0x7f2c60fea5c5 - core::panicking::panic_fmt::h01c3f6a1955aca70
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/core/src/panicking.rs:72:14
  18:     0x7f2c60fea802 - core::panicking::panic_bounds_check::h25b685aaca1db28e
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/core/src/panicking.rs:208:5
  19:     0x7f2c6033b750 - <rustc_middle[63813a132a817cd4]::ty::generics::Generics>::type_param.cold.0
  20:     0x7f2c5f263655 - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_field
  21:     0x7f2c5fadc938 - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:     0x7f2c5fadc73f - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:     0x7f2c5f9f1065 - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_block_with_expected
  24:     0x7f2c5fadc049 - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x7f2c5fb69770 - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_argument_types
  26:     0x7f2c5fa0ff0a - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_call
  27:     0x7f2c5fadbc39 - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7f2c5f9f1065 - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_block_with_expected
  29:     0x7f2c5fadc049 - <rustc_hir_typeck[995280b49f849d23]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x7f2c5f655848 - rustc_hir_typeck[995280b49f849d23]::check::check_fn
  31:     0x7f2c5f2d3f02 - rustc_hir_typeck[995280b49f849d23]::typeck
  32:     0x7f2c5f2d3289 - rustc_query_impl[f8b584d7216df600]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f8b584d7216df600]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 8usize]>>
  33:     0x7f2c5f0bfdf9 - rustc_query_system[13649e0efc92577a]::query::plumbing::try_execute_query::<rustc_query_impl[f8b584d7216df600]::DynamicConfig<rustc_query_system[13649e0efc92577a]::query::caches::VecCache<rustc_span[6e44e330265df079]::def_id::LocalDefId, rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[f8b584d7216df600]::plumbing::QueryCtxt, false>
  34:     0x7f2c5f0bfa90 - rustc_query_impl[f8b584d7216df600]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f2c5f5e99cc - <rustc_middle[63813a132a817cd4]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[f88d56455d931b67]::check_crate::{closure#6}>::{closure#0}
  36:     0x7f2c5f5e82c4 - rustc_hir_analysis[f88d56455d931b67]::check_crate
  37:     0x7f2c5fa94419 - rustc_interface[37b6cebe1bce16]::passes::analysis
  38:     0x7f2c5fa9405f - rustc_query_impl[f8b584d7216df600]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f8b584d7216df600]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 1usize]>>
  39:     0x7f2c5ffcd040 - rustc_query_system[13649e0efc92577a]::query::plumbing::try_execute_query::<rustc_query_impl[f8b584d7216df600]::DynamicConfig<rustc_query_system[13649e0efc92577a]::query::caches::SingleCache<rustc_middle[63813a132a817cd4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f8b584d7216df600]::plumbing::QueryCtxt, false>
  40:     0x7f2c5ffcce47 - rustc_query_impl[f8b584d7216df600]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f2c5fd343ed - rustc_interface[37b6cebe1bce16]::interface::run_compiler::<core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>, rustc_driver_impl[bce72efeea91a1de]::run_compiler::{closure#0}>::{closure#0}
  42:     0x7f2c5fff3546 - std[d6f21989bfff4f42]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[37b6cebe1bce16]::util::run_in_thread_with_globals<rustc_interface[37b6cebe1bce16]::util::run_in_thread_pool_with_globals<rustc_interface[37b6cebe1bce16]::interface::run_compiler<core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>, rustc_driver_impl[bce72efeea91a1de]::run_compiler::{closure#0}>::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>
  43:     0x7f2c5fff3373 - <<std[d6f21989bfff4f42]::thread::Builder>::spawn_unchecked_<rustc_interface[37b6cebe1bce16]::util::run_in_thread_with_globals<rustc_interface[37b6cebe1bce16]::util::run_in_thread_pool_with_globals<rustc_interface[37b6cebe1bce16]::interface::run_compiler<core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>, rustc_driver_impl[bce72efeea91a1de]::run_compiler::{closure#0}>::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a757d3bbb7cc29b8]::result::Result<(), rustc_span[6e44e330265df079]::ErrorGuaranteed>>::{closure#1} as core[a757d3bbb7cc29b8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7f2c60fa89d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc62465ce3696edbb
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/alloc/src/boxed.rs:2016:9
  45:     0x7f2c60fa89d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2898b364df1453ed
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/alloc/src/boxed.rs:2016:9
  46:     0x7f2c60fa89d5 - std::sys::unix::thread::Thread::new::thread_start::hefe0ce868779f0f1
                               at /rustc/89110dafe79621fa07d6cd7c8493dd1d0a83cfaf/library/std/src/sys/unix/thread.rs:108:17
  47:     0x7f2c5ae6f9eb - <unknown>
  48:     0x7f2c5aef37cc - <unknown>
  49:                0x0 - <unknown>

error: 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.77.0-nightly (89110dafe 2024-01-13) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `<impl at /tmp/icemaker_global_tempdir.9KzAYMOKvvyy/rustc_testrunner_tmpdir_reporting.iFAbOoiLuUqy/mvce.rs:10:1: 10:17>::static_method2::baz`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted

Some errors have detailed explanations: E0425, E0601, E0658.
For more information about an error, try `rustc --explain E0425`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-fn_delegation`#![feature(fn_delegation)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions