Skip to content

ICE trying to use Err(1)? with let_else in a try block #100103

Closed

Description

Code

#![feature(try_blocks)]
#![feature(let_else)]

fn main() {
    let _: Result<i32, i32> = try {
        let Some(x) = Some(0) else {
            Err(1)?
        };

        x
    };
}

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (4493a0f47 2022-08-02)
binary: rustc
commit-hash: 4493a0f4724c0bae1436242d76cccc9c0a287b80
commit-date: 2022-08-02
host: x86_64-pc-windows-msvc
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued                                                                                               

error: internal compiler error: broken MIR in DefId(0:3 ~ tst[ba3f]::main) (_0 = _11): bad assignment (() = !): NoSolution
 --> src\main.rs:7:13
  |
7 |             Err(1)?
  |             ^^^^^^^
  |
  = note: delayed at compiler\rustc_borrowck\src\type_check\mod.rs:1273:21
Backtrace

warning: Error finalizing incremental compilation session directory `\\?\C:\Users\QWERTY\CLionProjects\tst\target\debug\incremental\tst-2tyoqd6xyashy\s-gc907kqbnn-3utrm0-working`: The 
system cannot find the file specified. (os error 2)

error: internal compiler error: no errors encountered even though `delay_span_bug` issued                                                                                               

error: internal compiler error: broken MIR in DefId(0:3 ~ tst[ba3f]::main) (_0 = _11): bad assignment (() = !): NoSolution
 --> src\main.rs:7:13
  |
7 |             Err(1)?
  |             ^^^^^^^
  |
  = note: delayed at compiler\rustc_borrowck\src\type_check\mod.rs:1273:21

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1426:13
stack backtrace:
   0:     0x7ffd5713a2df - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hfdc7a2cc264e6509
   1:     0x7ffd5717601a - core::fmt::write::h0f908d637b50c6af 
   2:     0x7ffd5712ceea - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h15a91224f38ef438
   3:     0x7ffd5713dceb - std::panicking::default_hook::hbf41b655c2698377
   4:     0x7ffd5713d911 - std::panicking::default_hook::hbf41b655c2698377
   5:     0x7ffd32a3bee1 - <rustc_session[376c17906c2155d1]::options::WasiExecModel as rustc_session[376c17906c2155d1]::config::dep_tracking::DepTrackingHash>::hash                    
   6:     0x7ffd5713e6cc - std::panicking::rust_panic_with_hook::h43e63fbaeccfd4a6
   7:     0x7ffd34caf313 - <rustc_errors[b9e08c6509a05373]::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter>::ui_testing
   8:     0x7ffd34caf0b9 - <rustc_errors[b9e08c6509a05373]::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter>::ui_testing
   9:     0x7ffd34ca49a9 - <rustc_errors[b9e08c6509a05373]::emitter::FileWithAnnotatedLines as core[36f99f4866a80ce5]::fmt::Debug>::fmt
  10:     0x7ffd34c99da9 - <rustc_feature[260e98188d46b7aa]::builtin_attrs::AttributeType as core[36f99f4866a80ce5]::fmt::Debug>::fmt
  11:     0x7ffd3129aabd - <rustc_errors[b9e08c6509a05373]::HandlerInner as core[36f99f4866a80ce5]::ops::drop::Drop>::drop
  12:     0x7ffd303d80d9 - <rustc_middle[c4caad5b04e39e5d]::ty::SymbolName as core[36f99f4866a80ce5]::fmt::Debug>::fmt
  13:     0x7ffd303db92f - <rustc_middle[c4caad5b04e39e5d]::ty::SymbolName as core[36f99f4866a80ce5]::fmt::Debug>::fmt
  14:     0x7ffd303c886d - <unknown>
  15:     0x7ffd303d65b7 - <unknown>
  16:     0x7ffd303ee4c7 - rustc_driver[5be5b24934faa65c]::args::arg_expand_all
  17:     0x7ffd303d7bd9 - <unknown>
  18:     0x7ffd303dd35d - <rustc_middle[c4caad5b04e39e5d]::ty::SymbolName as core[36f99f4866a80ce5]::fmt::Debug>::fmt
  19:     0x7ffd5714f82c - std::sys::windows::thread::Thread::new::hed1234cb21584066
  20:     0x7ffdc6277974 - BaseThreadInitThunk
  21:     0x7ffdc8c8a2f1 - RtlUserThreadStart                                                                                                                                           

note: 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.64.0-nightly (4493a0f47 2022-08-02) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `tst` (bin "tst") generated 1 warning                                                                                                                                          
error: could not compile `tst`; 1 warning emitted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

C-bugCategory: This is a bug.F-let_elseIssues related to let-else statements (RFC 3137)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.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions