rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.64k stars 12.49k forks source link

ICE: `expected item, found (root_crate)` #128190

Open matthiaskrgr opened 1 month ago

matthiaskrgr commented 1 month ago

auto-reduced (treereduce-rust):

fn a(&self) {
    15
}

reuse a as b {  struct S; }

original:

#![rustc_dummy]
#![allow(as)]

fn a(&self) { 15 }

reuse a as b { #![feature(fn_delegation)] struct S; }

fn main(self) {
    const_fn();
    const_fn_extern();
}

Version information

rustc 1.82.0-nightly (54be9ad5e 2024-07-25)
binary: rustc
commit-hash: 54be9ad5eb47207d155904f6c912a9526133f75f
commit-date: 2024-07-25
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 18.1.7

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

Program output

``` error: `self` parameter is only allowed in associated functions --> /tmp/icemaker_global_tempdir.Xm44oviEaTg6/rustc_testrunner_tmpdir_reporting.4oFYSg3eBqPr/mvce.rs:1:6 | 1 | fn a(&self) { | ^^^^^ not semantically valid as function parameter | = note: associated functions are those in `impl` or `trait` definitions error[E0658]: functions delegation is not yet fully implemented --> /tmp/icemaker_global_tempdir.Xm44oviEaTg6/rustc_testrunner_tmpdir_reporting.4oFYSg3eBqPr/mvce.rs:5:1 | 5 | reuse a as b { struct S; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #118212 for more information = help: add `#![feature(fn_delegation)]` to the crate attributes to enable = note: this compiler was built on 2024-07-25; consider upgrading it if it is out of date error[E0601]: `main` function not found in crate `mvce` --> /tmp/icemaker_global_tempdir.Xm44oviEaTg6/rustc_testrunner_tmpdir_reporting.4oFYSg3eBqPr/mvce.rs:5:28 | 5 | reuse a as b { struct S; } | ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Xm44oviEaTg6/rustc_testrunner_tmpdir_reporting.4oFYSg3eBqPr/mvce.rs` error[E0308]: mismatched types --> /tmp/icemaker_global_tempdir.Xm44oviEaTg6/rustc_testrunner_tmpdir_reporting.4oFYSg3eBqPr/mvce.rs:2:5 | 1 | fn a(&self) { | - help: try adding a return type: `-> i32` 2 | 15 | ^^ expected `()`, found integer error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:694:18: expected item, found (root_crate) thread 'rustc' panicked at compiler/rustc_middle/src/hir/map/mod.rs:694:18: Box stack backtrace: 0: 0x7adb2a44a015 - std::backtrace_rs::backtrace::libunwind::trace::h40979b3cf07e4302 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x7adb2a44a015 - std::backtrace_rs::backtrace::trace_unsynchronized::hc25be74c83b982ea at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7adb2a44a015 - std::sys::backtrace::_print_fmt::he0e7b21c916cf37e at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/sys/backtrace.rs:68:9 3: 0x7adb2a44a015 - ::fmt::hdae9b4b38b07800f at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/sys/backtrace.rs:41:26 4: 0x7adb2a4999eb - core::fmt::rt::Argument::fmt::h23f55724cbf6fed3 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/core/src/fmt/rt.rs:173:76 5: 0x7adb2a4999eb - core::fmt::write::heb69bd2b65d4670c at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/core/src/fmt/mod.rs:1182:21 6: 0x7adb2a43e85f - std::io::Write::write_fmt::hb10e609dc145c64e at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/io/mod.rs:1827:15 7: 0x7adb2a44c801 - std::sys::backtrace::BacktraceLock::print::h151b0d7b810486c7 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/sys/backtrace.rs:44:9 8: 0x7adb2a44c801 - std::panicking::default_hook::{{closure}}::h6076738be33ec9e8 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/panicking.rs:269:22 9: 0x7adb2a44c4dc - std::panicking::default_hook::h304663758ec021ea at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/panicking.rs:296:9 10: 0x7adb268333da - std[f69981ba459e4be9]::panicking::update_hook::>::{closure#0} 11: 0x7adb2a44d1cf - as core::ops::function::Fn>::call::h3898ed4990ae07d7 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/alloc/src/boxed.rs:2163:9 12: 0x7adb2a44d1cf - std::panicking::rust_panic_with_hook::hb301fa95c486ca11 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/panicking.rs:808:13 13: 0x7adb2686d981 - std[f69981ba459e4be9]::panicking::begin_panic::::{closure#0} 14: 0x7adb26860936 - std[f69981ba459e4be9]::sys::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 15: 0x7adb268608e6 - std[f69981ba459e4be9]::panicking::begin_panic:: 16: 0x7adb26876fc1 - ::emit_producing_guarantee 17: 0x7adb26e21414 - rustc_middle[eb4fa39c1860cd4]::util::bug::opt_span_bug_fmt::::{closure#0} 18: 0x7adb26e0707a - rustc_middle[eb4fa39c1860cd4]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 19: 0x7adb26e06f1b - rustc_middle[eb4fa39c1860cd4]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 20: 0x7adb24c0ce30 - rustc_middle[eb4fa39c1860cd4]::util::bug::bug_fmt 21: 0x7adb2816e840 - ::expect_item 22: 0x7adb280fa8d7 - rustc_query_impl[abbe88964be750a7]::plumbing::__rust_begin_short_backtrace::> 23: 0x7adb280f9bc2 - rustc_query_system[274de9dac1528dd3]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[abbe88964be750a7]::plumbing::QueryCtxt, false> 24: 0x7adb280f98a3 - rustc_query_impl[abbe88964be750a7]::query_impl::associated_item::get_query_non_incr::__rust_end_short_backtrace 25: 0x7adb26a4e47d - rustc_middle[eb4fa39c1860cd4]::query::plumbing::query_get_at::>> 26: 0x7adb24759446 - ::lookup_probe 27: 0x7adb28847e69 - ::check_expr_with_expectation_and_args 28: 0x7adb288416f5 - ::check_block_with_expected 29: 0x7adb28847d5d - ::check_expr_with_expectation_and_args 30: 0x7adb28062dcf - rustc_hir_typeck[9ad8e17cc0d5c271]::check::check_fn 31: 0x7adb28059183 - rustc_hir_typeck[9ad8e17cc0d5c271]::typeck 32: 0x7adb28058b29 - rustc_query_impl[abbe88964be750a7]::plumbing::__rust_begin_short_backtrace::> 33: 0x7adb2806c2f3 - rustc_query_system[274de9dac1528dd3]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[abbe88964be750a7]::plumbing::QueryCtxt, false> 34: 0x7adb2806b4cd - rustc_query_impl[abbe88964be750a7]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace 35: 0x7adb2806b0c4 - ::par_body_owners::::{closure#0} 36: 0x7adb28068efc - rustc_hir_analysis[40d7e38617de2bd]::check_crate 37: 0x7adb28a2a815 - rustc_interface[73e2d76034883eaa]::passes::analysis 38: 0x7adb28a2a3db - rustc_query_impl[abbe88964be750a7]::plumbing::__rust_begin_short_backtrace::> 39: 0x7adb28c5f8a5 - rustc_query_system[274de9dac1528dd3]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[abbe88964be750a7]::plumbing::QueryCtxt, false> 40: 0x7adb28c5f60f - rustc_query_impl[abbe88964be750a7]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 41: 0x7adb28b5e185 - rustc_interface[73e2d76034883eaa]::interface::run_compiler::, rustc_driver_impl[a70ed56c5c805152]::run_compiler::{closure#0}>::{closure#1} 42: 0x7adb28b44689 - std[f69981ba459e4be9]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[a70ed56c5c805152]::run_compiler::{closure#0}>::{closure#1}, core[4b0752be9b74dadf]::result::Result<(), rustc_span[b68f95fc1bdef1eb]::ErrorGuaranteed>>::{closure#0}, core[4b0752be9b74dadf]::result::Result<(), rustc_span[b68f95fc1bdef1eb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4b0752be9b74dadf]::result::Result<(), rustc_span[b68f95fc1bdef1eb]::ErrorGuaranteed>> 43: 0x7adb28b4443a - <::spawn_unchecked_, rustc_driver_impl[a70ed56c5c805152]::run_compiler::{closure#0}>::{closure#1}, core[4b0752be9b74dadf]::result::Result<(), rustc_span[b68f95fc1bdef1eb]::ErrorGuaranteed>>::{closure#0}, core[4b0752be9b74dadf]::result::Result<(), rustc_span[b68f95fc1bdef1eb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[4b0752be9b74dadf]::result::Result<(), rustc_span[b68f95fc1bdef1eb]::ErrorGuaranteed>>::{closure#1} as core[4b0752be9b74dadf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 44: 0x7adb2a45711b - as core::ops::function::FnOnce>::call_once::h00bda9a3a6915a28 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/alloc/src/boxed.rs:2149:9 45: 0x7adb2a45711b - as core::ops::function::FnOnce>::call_once::h3ee855f42fb95cb5 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/alloc/src/boxed.rs:2149:9 46: 0x7adb2a45711b - std::sys::pal::unix::thread::Thread::new::thread_start::h31514268db3ccba4 at /rustc/54be9ad5eb47207d155904f6c912a9526133f75f/library/std/src/sys/pal/unix/thread.rs:108:17 47: 0x7adb2a1eaded - 48: 0x7adb2a26e0dc - 49: 0x0 - 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: please make sure that you have updated to the latest nightly note: rustc 1.82.0-nightly (54be9ad5e 2024-07-25) running on x86_64-unknown-linux-gnu query stack during panic: #0 [associated_item] computing associated item data for `a` #1 [typeck] type-checking `b` end of query stack error: aborting due to 5 previous errors Some errors have detailed explanations: E0308, E0601, E0658. For more information about an error, try `rustc --explain E0308`. ```

@rustbot label +F-fn_delegation

GrigorenkoPV commented 1 month ago

126699