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 expression doesn't evaluate to a struct #127332

Closed
matthiaskrgr opened this issue Jul 4, 2024 · 2 comments · Fixed by #127409
Closed

ICE: with expression doesn't evaluate to a struct #127332

matthiaskrgr opened this issue Jul 4, 2024 · 2 comments · Fixed by #127409
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

async fn fun() {
    enum Foo {
        A { x: u32 },
    }
    let orig = Foo::A { x: 5 };
    Foo::A { x: 6, ..orig };
}

original:

#![derive(Clone,Copy)]

static mut A: [u8; (N / 2) as Foo] = [1, 2, 3, 4, 5];

async fn fun() {
    enum Foo { A { x: u32 } }
    let orig = Foo::A { x: 5 };
    Foo::A { x: 6, ..orig };
    //~^ ERROR functional record update syntax requires a struct
}

fn deref(&self) -> &T {
        self.0.get()
    }

fn main() {
    let mut x: A;
    x.a = 1; //~ ERROR E0381
    drop(x.a);
}

Version information

rustc 1.81.0-nightly (9f877c9cd 2024-07-04)
binary: rustc
commit-hash: 9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0
commit-date: 2024-07-04
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

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

Program output

error[E0670]: `async fn` is not permitted in Rust 2015
 --> /tmp/icemaker_global_tempdir.kjjtaMiZob00/rustc_testrunner_tmpdir_reporting.bVfRd0uWVozS/mvce.rs:1:1
  |
1 | async fn fun() {
  | ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2021` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

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

error[E0436]: functional record update syntax requires a struct
 --> /tmp/icemaker_global_tempdir.kjjtaMiZob00/rustc_testrunner_tmpdir_reporting.bVfRd0uWVozS/mvce.rs:6:22
  |
6 |     Foo::A { x: 6, ..orig };
  |                      ^^^^

error: internal compiler error: compiler/rustc_hir_typeck/src/expr_use_visitor.rs:737:17: with expression doesn't evaluate to a struct
 --> /tmp/icemaker_global_tempdir.kjjtaMiZob00/rustc_testrunner_tmpdir_reporting.bVfRd0uWVozS/mvce.rs:6:22
  |
6 |     Foo::A { x: 6, ..orig };
  |                      ^^^^

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/expr_use_visitor.rs:737:17:
Box<dyn Any>
stack backtrace:
   0:     0x77db18b343f5 - std::backtrace_rs::backtrace::libunwind::trace::hf95b38e760987df5
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x77db18b343f5 - std::backtrace_rs::backtrace::trace_unsynchronized::h296dde3f482524c6
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x77db18b343f5 - std::sys::backtrace::_print_fmt::hf5b0a643237cf0f2
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/sys/backtrace.rs:68:5
   3:     0x77db18b343f5 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8847e6f470e9998e
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/sys/backtrace.rs:44:22
   4:     0x77db18b83afb - core::fmt::rt::Argument::fmt::h9bedf3d768907291
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/core/src/fmt/rt.rs:173:76
   5:     0x77db18b83afb - core::fmt::write::h7b9272420444247e
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/core/src/fmt/mod.rs:1174:21
   6:     0x77db18b28eef - std::io::Write::write_fmt::h395f8db856dd3d7c
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/io/mod.rs:1835:15
   7:     0x77db18b341ce - std::sys::backtrace::_print::hab4ed7f12c4f0e2c
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/sys/backtrace.rs:47:5
   8:     0x77db18b341ce - std::sys::backtrace::print::hb8a622806e3eee3f
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/sys/backtrace.rs:34:9
   9:     0x77db18b36b19 - std::panicking::default_hook::{{closure}}::h5e163cbe25e6a5c0
  10:     0x77db18b368bc - std::panicking::default_hook::h1226f6a3a5c247c9
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/panicking.rs:292:9
  11:     0x77db14fef4c9 - std[faa4223efe7856f]::panicking::update_hook::<alloc[1decfec8ca93d970]::boxed::Box<rustc_driver_impl[5a4a041a766a7e22]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x77db18b3743f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h76ce033080e2c059
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/alloc/src/boxed.rs:2078:9
  13:     0x77db18b3743f - std::panicking::rust_panic_with_hook::hac91cbe88bf9e4a2
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/panicking.rs:804:13
  14:     0x77db1502a621 - std[faa4223efe7856f]::panicking::begin_panic::<rustc_errors[b63c4c7c05b14eb6]::ExplicitBug>::{closure#0}
  15:     0x77db1501d426 - std[faa4223efe7856f]::sys::backtrace::__rust_end_short_backtrace::<std[faa4223efe7856f]::panicking::begin_panic<rustc_errors[b63c4c7c05b14eb6]::ExplicitBug>::{closure#0}, !>
  16:     0x77db15018756 - std[faa4223efe7856f]::panicking::begin_panic::<rustc_errors[b63c4c7c05b14eb6]::ExplicitBug>
  17:     0x77db150336a1 - <rustc_errors[b63c4c7c05b14eb6]::diagnostic::BugAbort as rustc_errors[b63c4c7c05b14eb6]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x77db151dc520 - <rustc_errors[b63c4c7c05b14eb6]::DiagCtxtHandle>::span_bug::<rustc_span[71907ca1d8b79b4c]::span_encoding::Span, alloc[1decfec8ca93d970]::string::String>
  19:     0x77db15251ff7 - rustc_middle[c92b5b18a583c5ff]::util::bug::opt_span_bug_fmt::<rustc_span[71907ca1d8b79b4c]::span_encoding::Span>::{closure#0}
  20:     0x77db15254e8a - rustc_middle[c92b5b18a583c5ff]::ty::context::tls::with_opt::<rustc_middle[c92b5b18a583c5ff]::util::bug::opt_span_bug_fmt<rustc_span[71907ca1d8b79b4c]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x77db1520561b - rustc_middle[c92b5b18a583c5ff]::ty::context::tls::with_context_opt::<rustc_middle[c92b5b18a583c5ff]::ty::context::tls::with_opt<rustc_middle[c92b5b18a583c5ff]::util::bug::opt_span_bug_fmt<rustc_span[71907ca1d8b79b4c]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x77db13d61eb7 - rustc_middle[c92b5b18a583c5ff]::util::bug::span_bug_fmt::<rustc_span[71907ca1d8b79b4c]::span_encoding::Span>
  23:     0x77db17095b55 - <rustc_hir_typeck[265ab5f968becff4]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[265ab5f968becff4]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[265ab5f968becff4]::upvar::InferBorrowKind>>::walk_expr
  24:     0x77db170930fc - <rustc_hir_typeck[265ab5f968becff4]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[265ab5f968becff4]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[265ab5f968becff4]::upvar::InferBorrowKind>>::consume_expr
  25:     0x77db17091a60 - <rustc_hir_typeck[265ab5f968becff4]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[265ab5f968becff4]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[265ab5f968becff4]::upvar::InferBorrowKind>>::walk_block
  26:     0x77db170930fc - <rustc_hir_typeck[265ab5f968becff4]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[265ab5f968becff4]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[265ab5f968becff4]::upvar::InferBorrowKind>>::consume_expr
  27:     0x77db170930fc - <rustc_hir_typeck[265ab5f968becff4]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[265ab5f968becff4]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[265ab5f968becff4]::upvar::InferBorrowKind>>::consume_expr
  28:     0x77db17091a8c - <rustc_hir_typeck[265ab5f968becff4]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[265ab5f968becff4]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[265ab5f968becff4]::upvar::InferBorrowKind>>::walk_block
  29:     0x77db170930fc - <rustc_hir_typeck[265ab5f968becff4]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[265ab5f968becff4]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[265ab5f968becff4]::upvar::InferBorrowKind>>::consume_expr
  30:     0x77db1708c602 - <rustc_hir_typeck[265ab5f968becff4]::fn_ctxt::FnCtxt>::analyze_closure
  31:     0x77db13d59318 - <rustc_hir_typeck[265ab5f968becff4]::upvar::InferBorrowKindVisitor as rustc_hir[bfa12b5b67296b67]::intravisit::Visitor>::visit_expr
  32:     0x77db1687cd3e - rustc_hir_typeck[265ab5f968becff4]::typeck
  33:     0x77db1687c43d - rustc_query_impl[97ead6281a4b469d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[97ead6281a4b469d]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>
  34:     0x77db16806439 - rustc_query_system[1b2f10e7360ef175]::query::plumbing::try_execute_query::<rustc_query_impl[97ead6281a4b469d]::DynamicConfig<rustc_query_system[1b2f10e7360ef175]::query::caches::VecCache<rustc_span[71907ca1d8b79b4c]::def_id::LocalDefId, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[97ead6281a4b469d]::plumbing::QueryCtxt, false>
  35:     0x77db1680560d - rustc_query_impl[97ead6281a4b469d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  36:     0x77db16e86973 - rustc_middle[c92b5b18a583c5ff]::query::plumbing::query_get_at::<rustc_query_system[1b2f10e7360ef175]::query::caches::VecCache<rustc_span[71907ca1d8b79b4c]::def_id::LocalDefId, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>>
  37:     0x77db17546aab - rustc_hir_analysis[7a13266d696f7129]::collect::type_of::type_of_opaque
  38:     0x77db175469e5 - rustc_query_impl[97ead6281a4b469d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[97ead6281a4b469d]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>
  39:     0x77db1670ef20 - rustc_query_system[1b2f10e7360ef175]::query::plumbing::try_execute_query::<rustc_query_impl[97ead6281a4b469d]::DynamicConfig<rustc_query_system[1b2f10e7360ef175]::query::caches::DefIdCache<rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[97ead6281a4b469d]::plumbing::QueryCtxt, false>
  40:     0x77db17786bf6 - rustc_query_impl[97ead6281a4b469d]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
  41:     0x77db16c9b45e - rustc_middle[c92b5b18a583c5ff]::query::plumbing::query_get_at::<rustc_query_system[1b2f10e7360ef175]::query::caches::DefIdCache<rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>>
  42:     0x77db13efa916 - rustc_hir_analysis[7a13266d696f7129]::collect::type_of::type_of
  43:     0x77db167101ea - rustc_query_impl[97ead6281a4b469d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[97ead6281a4b469d]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>
  44:     0x77db1670ef20 - rustc_query_system[1b2f10e7360ef175]::query::plumbing::try_execute_query::<rustc_query_impl[97ead6281a4b469d]::DynamicConfig<rustc_query_system[1b2f10e7360ef175]::query::caches::DefIdCache<rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[97ead6281a4b469d]::plumbing::QueryCtxt, false>
  45:     0x77db1670eae7 - rustc_query_impl[97ead6281a4b469d]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  46:     0x77db16c9b45e - rustc_middle[c92b5b18a583c5ff]::query::plumbing::query_get_at::<rustc_query_system[1b2f10e7360ef175]::query::caches::DefIdCache<rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 8usize]>>>
  47:     0x77db12bf8c01 - rustc_hir_analysis[7a13266d696f7129]::check::check::check_item_type
  48:     0x77db13f1bd0c - rustc_hir_analysis[7a13266d696f7129]::check::wfcheck::check_well_formed
  49:     0x77db16b2c969 - rustc_query_impl[97ead6281a4b469d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[97ead6281a4b469d]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 1usize]>>
  50:     0x77db16b2cbf5 - rustc_query_system[1b2f10e7360ef175]::query::plumbing::try_execute_query::<rustc_query_impl[97ead6281a4b469d]::DynamicConfig<rustc_query_system[1b2f10e7360ef175]::query::caches::VecCache<rustc_hir[bfa12b5b67296b67]::hir_id::OwnerId, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[97ead6281a4b469d]::plumbing::QueryCtxt, false>
  51:     0x77db16b2c946 - rustc_query_impl[97ead6281a4b469d]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  52:     0x77db16b2d609 - rustc_hir_analysis[7a13266d696f7129]::check::wfcheck::check_mod_type_wf
  53:     0x77db16b2d459 - rustc_query_impl[97ead6281a4b469d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[97ead6281a4b469d]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 1usize]>>
  54:     0x77db174f7df8 - rustc_query_system[1b2f10e7360ef175]::query::plumbing::try_execute_query::<rustc_query_impl[97ead6281a4b469d]::DynamicConfig<rustc_query_system[1b2f10e7360ef175]::query::caches::DefaultCache<rustc_span[71907ca1d8b79b4c]::def_id::LocalModDefId, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[97ead6281a4b469d]::plumbing::QueryCtxt, false>
  55:     0x77db174f7ba7 - rustc_query_impl[97ead6281a4b469d]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  56:     0x77db16802c85 - rustc_hir_analysis[7a13266d696f7129]::check_crate
  57:     0x77db16b1e8d5 - rustc_interface[23f572ce4202121c]::passes::analysis
  58:     0x77db16b1e49b - rustc_query_impl[97ead6281a4b469d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[97ead6281a4b469d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 1usize]>>
  59:     0x77db174bdfe5 - rustc_query_system[1b2f10e7360ef175]::query::plumbing::try_execute_query::<rustc_query_impl[97ead6281a4b469d]::DynamicConfig<rustc_query_system[1b2f10e7360ef175]::query::caches::SingleCache<rustc_middle[c92b5b18a583c5ff]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[97ead6281a4b469d]::plumbing::QueryCtxt, false>
  60:     0x77db174bdd4f - rustc_query_impl[97ead6281a4b469d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  61:     0x77db1740b145 - rustc_interface[23f572ce4202121c]::interface::run_compiler::<core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>, rustc_driver_impl[5a4a041a766a7e22]::run_compiler::{closure#0}>::{closure#1}
  62:     0x77db1738d689 - std[faa4223efe7856f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[23f572ce4202121c]::util::run_in_thread_with_globals<rustc_interface[23f572ce4202121c]::util::run_in_thread_pool_with_globals<rustc_interface[23f572ce4202121c]::interface::run_compiler<core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>, rustc_driver_impl[5a4a041a766a7e22]::run_compiler::{closure#0}>::{closure#1}, core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>>::{closure#0}, core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>>
  63:     0x77db1738d43a - <<std[faa4223efe7856f]::thread::Builder>::spawn_unchecked_<rustc_interface[23f572ce4202121c]::util::run_in_thread_with_globals<rustc_interface[23f572ce4202121c]::util::run_in_thread_pool_with_globals<rustc_interface[23f572ce4202121c]::interface::run_compiler<core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>, rustc_driver_impl[5a4a041a766a7e22]::run_compiler::{closure#0}>::{closure#1}, core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>>::{closure#0}, core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d2741c740a512875]::result::Result<(), rustc_span[71907ca1d8b79b4c]::ErrorGuaranteed>>::{closure#2} as core[d2741c740a512875]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  64:     0x77db18b4129b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3fdeba6b156389f8
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/alloc/src/boxed.rs:2064:9
  65:     0x77db18b4129b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hca998e1ecdf5345b
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/alloc/src/boxed.rs:2064:9
  66:     0x77db18b4129b - std::sys::pal::unix::thread::Thread::new::thread_start::hc562414405cef500
                               at /rustc/9f877c9cd2c3f8f2f64df1e0c1804ad0682416d0/library/std/src/sys/pal/unix/thread.rs:108:17
  67:     0x77db11aa6ded - <unknown>
  68:     0x77db11b2a0dc - <unknown>
  69:                0x0 - <unknown>

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.81.0-nightly (9f877c9cd 2024-07-04) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `fun`
#1 [type_of_opaque] computing type of opaque `fun::{opaque#0}`
end of query stack
error: aborting due to 4 previous errors

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Jul 4, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 4, 2024
@matthiaskrgr
Copy link
Member Author

#127202 cc @oli-obk

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jul 5, 2024
@gurry
Copy link
Contributor

gurry commented Jul 6, 2024

The ICE occurs because of this span_bug:

_ => {
// the base expression should always evaluate to a
// struct; however, when EUV is run during typeck, it
// may not. This will generate an error earlier in typeck,
// so we can just ignore it.
span_bug!(with_expr.span, "with expression doesn't evaluate to a struct");
}

As per the title of commit 814bfe9, which is part of PR #127202, this code should not be reachable any more, but looks like it still is. Perhaps we should change the span_bug to a span_delayed_bug.

@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 7, 2024
@bors bors closed this as completed in 1ee6345 Jul 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 7, 2024
Rollup merge of rust-lang#127409 - gurry:127332-ice-with-expr-not-struct, r=oli-obk

Emit a wrap expr span_bug only if context is not tainted

Fixes rust-lang#127332

The ICE occurs because of this `span_bug`: https://github.com/rust-lang/rust/blob/51917e2e69702e5752bce6a4f3bfd285d0f4ae39/compiler/rustc_hir_typeck/src/expr_use_visitor.rs#L732-L738
which is triggered by the fact that we're trying to use an `enum` in a `with` expression instead of a `struct`.

The issue originates in commit rust-lang@814bfe9   from PR rust-lang#127202. As per the title of that commit the ICEing code should not be reachable any more, but looks like it still is.

This PR changes the code so that the `span_bug` will be emitted only if the context is not tainted by a previous error.
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

4 participants