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

[Panic]: no type for local variable #337

Open
matthiaskrgr opened this issue Dec 18, 2023 · 0 comments
Open

[Panic]: no type for local variable #337

matthiaskrgr opened this issue Dec 18, 2023 · 0 comments
Labels
C-bug Category: Something isn't working I-panic Issue: Some part of the linter panicked unexpectedly S-needs-triage Status: This issue needs triage

Comments

@matthiaskrgr
Copy link

matthiaskrgr commented Dec 18, 2023

Summary

No response

Reproducer

// Regression test for issue #114529
// Tests that we do not ICE during const eval for a
// break-with-value in contexts where it is illegal

#[allow(while_true)]
fn main() {
    [(); {
        while true {
            break 0x1223_3445_5667_7889; //~ ERROR `break` with value from a `while` loop
        };
        51
    }];

    [(); {
        while let Some(v) = Some(100000) {
            break v; //~ ERROR `break` with value from a `while` loop
        };
        51
    }];

    while true {
        break (|| { //~ ERROR `break` with value from a `while` loop
            let local = 14u32;
        });
    }
}

Version

No response

Logs and Backtrace

MARKER_ERROR_TRACE=1 MARKER_LOG=info RUST_BACKTRACE=1    LD_LIBRARY_PATH='/home/matthias/o/target/debug/deps:/home/matthias/.rustup/toolchains/nightly-2023-11-16-x86_64-unknown-linux-gnu/lib:/home/matthias/.rustup/toolchains/nightly-2023-11-16-x86_64-unknown-linux-gnu/lib:/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib'  RUSTC_WORKSPACE_WRAPPER=/home/matthias/.rustup/toolchains/nightly-2023-11-16-x86_64-unknown-linux-gnu/bin/marker_rustc_driver MARKER_LINT_CRATES=marker_lints:/home/matthias/o/target/marker/lints/libmarker_lints.so   RUSTUP_TOOLCHAIN=nightly-2023-11-16    /home/matthias/.rustup/toolchains/nightly-2023-11-16-x86_64-unknown-linux-gnu/bin/marker_rustc_driver /home/matthias/vcs/github/rust_misc_stuff/tests/ui/icemaker_omni/46E771E2C2F84ECA18BCB111A61D20AEB342C64C0652B9A74BA200AA73B19895.rs
error[E0571]: `break` with value from a `while` loop
 --> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/icemaker_omni/46E771E2C2F84ECA18BCB111A61D20AEB342C64C0652B9A74BA200AA73B19895.rs:9:13
  |
8 |         while true {
  |         ---------- you can't `break` with a value in a `while` loop
9 |             break 0x1223_3445_5667_7889; //~ ERROR `break` with value from a `while` loop
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block
  |
help: use `break` on its own without a value inside this `while` loop
  |
9 |             break; //~ ERROR `break` with value from a `while` loop
  |             ~~~~~

error[E0571]: `break` with value from a `while` loop
  --> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/icemaker_omni/46E771E2C2F84ECA18BCB111A61D20AEB342C64C0652B9A74BA200AA73B19895.rs:16:13
   |
15 |         while let Some(v) = Some(100000) {
   |         -------------------------------- you can't `break` with a value in a `while` loop
16 |             break v; //~ ERROR `break` with value from a `while` loop
   |             ^^^^^^^ can only break with a value inside `loop` or breakable block
   |
help: use `break` on its own without a value inside this `while` loop
   |
16 |             break; //~ ERROR `break` with value from a `while` loop
   |             ~~~~~

error[E0571]: `break` with value from a `while` loop
  --> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/icemaker_omni/46E771E2C2F84ECA18BCB111A61D20AEB342C64C0652B9A74BA200AA73B19895.rs:22:9
   |
21 |       while true {
   |       ---------- you can't `break` with a value in a `while` loop
22 | /         break (|| { //~ ERROR `break` with value from a `while` loop
23 | |             let local = 14u32;
24 | |         });
   | |__________^ can only break with a value inside `loop` or breakable block
   |
help: use `break` on its own without a value inside this `while` loop
   |
22 |         break;
   |         ~~~~~

error: internal compiler error: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:134:13: no type for local variable HirId(DefId(0:3 ~ 46E771E2C2F84ECA18BCB111A61D20AEB342C64C0652B9A74BA200AA73B19895[3fa9]::main).61) (local `let local = 14u32;`)
  --> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/icemaker_omni/46E771E2C2F84ECA18BCB111A61D20AEB342C64C0652B9A74BA200AA73B19895.rs:23:13
   |
23 |             let local = 14u32;
   |             ^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/compiler/rustc_errors/src/lib.rs:999:33:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::HandlerInner>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   2: <rustc_errors::Handler>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: <rustc_hir_typeck::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_local
   8: <rustc_hir_typeck::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
   9: <rustc_hir_typeck::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  10: <rustc_hir_typeck::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  11: <rustc_hir_typeck::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  12: <rustc_hir_typeck::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  13: <rustc_hir_typeck::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  14: <rustc_hir_typeck::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::resolve_type_vars_in_body
  16: rustc_hir_typeck::typeck
      [... omitted 1 frame ...]
  17: rustc_hir_analysis::check_crate
  18: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  19: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: we would appreciate a bug report: https://github.com/rust-marker/marker/issues/new?template=panic.yml

note: please attach the file at `/tmp/marker/rustc-ice-2023-12-18T00_02_43-1892158.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
note: marker_rustc_driver 0.4.3

note: Achievement Unlocked: [Free Ice Cream]

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0571`.
@matthiaskrgr matthiaskrgr added C-bug Category: Something isn't working I-panic Issue: Some part of the linter panicked unexpectedly S-needs-triage Status: This issue needs triage labels Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Something isn't working I-panic Issue: Some part of the linter panicked unexpectedly S-needs-triage Status: This issue needs triage
Projects
None yet
Development

No branches or pull requests

1 participant