This should not fail to compile, the issue is that the borrowed closure in the function is not assigned to the value.
Instead, the compiler panics.
Meta
Backtrace
```
Sorry :^(
Internal Compiler Error: use of operand before definition
Occurred at '/Users/afedotov/projects/hash-org/hashc/compiler/hash-codegen/src/lower/operands.rs:489:17'
Backtrace for thread "main":
0: backtrace::backtrace::libunwind::trace
at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/libunwind.rs:93:5
backtrace::backtrace::trace_unsynchronized
at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:66:5
1: backtrace::backtrace::trace
at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:53:14
2: backtrace::capture::Backtrace::create
at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:176:9
3: backtrace::capture::Backtrace::new
at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:140:22
4: hash_utils::crash::crash_handler
at compiler/hash-utils/src/crash.rs:53:25
5: core::ops::function::Fn::call
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:79:5
6: as core::ops::function::Fn>::call
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/alloc/src/boxed.rs:2034:9
std::panicking::rust_panic_with_hook
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:783:13
7: std::panicking::begin_panic_handler::{{closure}}
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:649:13
8: std::sys_common::backtrace::__rust_end_short_backtrace
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/sys_common/backtrace.rs:171:18
9: rust_begin_unwind
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:645:5
10: core::panicking::panic_fmt
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/panicking.rs:72:14
11: hash_codegen::lower::operands::>::maybe_codegen_direct_operand_ref
at compiler/hash-codegen/src/lower/operands.rs:489:17
12: hash_codegen::lower::operands::>::codegen_consume_operand
at compiler/hash-codegen/src/lower/operands.rs:446:30
13: hash_codegen::lower::operands::>::codegen_operand
at compiler/hash-codegen/src/lower/operands.rs:425:42
14: hash_codegen::lower::terminator::>::codegen_call_terminator
at compiler/hash-codegen/src/lower/terminator.rs:152:28
15: hash_codegen::lower::terminator::>::codegen_terminator
at compiler/hash-codegen/src/lower/terminator.rs:90:17
16: hash_codegen::lower::block::>::codegen_block
at compiler/hash-codegen/src/lower/block.rs:65:33
17: hash_codegen::lower::codegen_ir_body
at compiler/hash-codegen/src/lower/mod.rs:198:9
18: hash_codegen_llvm::LLVMBackend::build_bodies
at compiler/hash-codegen-llvm/src/lib.rs:296:13
19: ::run::{{closure}}
at compiler/hash-codegen-llvm/src/lib.rs:339:37
20: hash_utils::profiling::HasMutMetrics::record::{{closure}}
at compiler/hash-utils/src/profiling.rs:111:16
21: hash_utils::profiling::timed
at compiler/hash-utils/src/profiling.rs:130:22
hash_utils::profiling::HasMutMetrics::record
at compiler/hash-utils/src/profiling.rs:110:21
22: ::run
at compiler/hash-codegen-llvm/src/lib.rs:339:9
23: >::run
at compiler/hash-backend/src/lib.rs:68:9
24: hash_driver::driver::Driver::run_stage::{{closure}}
at compiler/hash-driver/src/driver.rs:98:16
25: hash_utils::profiling::timed
at compiler/hash-utils/src/profiling.rs:130:22
hash_driver::driver::Driver::run_stage
at compiler/hash-driver/src/driver.rs:97:9
26: hash_driver::driver::Driver::run_pipeline
at compiler/hash-driver/src/driver.rs:159:26
27: hash_driver::driver::Driver::run
at compiler/hash-driver/src/driver.rs:248:22
28: hash_driver::driver::Driver::run_filename
at compiler/hash-driver/src/driver.rs:271:9
29: hash_driver::driver::Driver::run_on_entry_point
at compiler/hash-driver/src/driver.rs:277:32
30: hashc::main
at compiler/hash/./src/main.rs:35:5
31: core::ops::function::FnOnce::call_once
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:250:5
32: std::sys_common::backtrace::__rust_begin_short_backtrace
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/sys_common/backtrace.rs:155:18
33: std::rt::lang_start::{{closure}}
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/rt.rs:166:18
34: core::ops::function::impls:: for &F>::call_once
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:284:13
std::panicking::try::do_call
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:552:40
std::panicking::try
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:516:19
std::panic::catch_unwind
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panic.rs:146:14
std::rt::lang_start_internal::{{closure}}
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/rt.rs:148:48
std::panicking::try::do_call
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:552:40
std::panicking::try
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:516:19
std::panic::catch_unwind
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panic.rs:146:14
std::rt::lang_start_internal
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/rt.rs:148:20
35: std::rt::lang_start
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/rt.rs:165:17
36: _main
This is an compiler bug, please file a bug report at
https://github.com/hash-org/hashc/issues?labels=bug&template=bug_report
```
The following snippet:
This should not fail to compile, the issue is that the borrowed closure in the function is not assigned to the value.
Instead, the compiler panics.
Meta
Backtrace
``` Sorry :^( Internal Compiler Error: use of operand before definition Occurred at '/Users/afedotov/projects/hash-org/hashc/compiler/hash-codegen/src/lower/operands.rs:489:17' Backtrace for thread "main": 0: backtrace::backtrace::libunwind::trace at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/libunwind.rs:93:5 backtrace::backtrace::trace_unsynchronized at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:66:5 1: backtrace::backtrace::trace at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:53:14 2: backtrace::capture::Backtrace::create at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:176:9 3: backtrace::capture::Backtrace::new at /Users/afedotov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:140:22 4: hash_utils::crash::crash_handler at compiler/hash-utils/src/crash.rs:53:25 5: core::ops::function::Fn::call at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:79:5 6: as core::ops::function::Fn>::call
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/alloc/src/boxed.rs:2034:9
std::panicking::rust_panic_with_hook
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:783:13
7: std::panicking::begin_panic_handler::{{closure}}
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:649:13
8: std::sys_common::backtrace::__rust_end_short_backtrace
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/sys_common/backtrace.rs:171:18
9: rust_begin_unwind
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:645:5
10: core::panicking::panic_fmt
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/panicking.rs:72:14
11: hash_codegen::lower::operands::>::maybe_codegen_direct_operand_ref
at compiler/hash-codegen/src/lower/operands.rs:489:17
12: hash_codegen::lower::operands::>::codegen_consume_operand
at compiler/hash-codegen/src/lower/operands.rs:446:30
13: hash_codegen::lower::operands::>::codegen_operand
at compiler/hash-codegen/src/lower/operands.rs:425:42
14: hash_codegen::lower::terminator::>::codegen_call_terminator
at compiler/hash-codegen/src/lower/terminator.rs:152:28
15: hash_codegen::lower::terminator::>::codegen_terminator
at compiler/hash-codegen/src/lower/terminator.rs:90:17
16: hash_codegen::lower::block::>::codegen_block
at compiler/hash-codegen/src/lower/block.rs:65:33
17: hash_codegen::lower::codegen_ir_body
at compiler/hash-codegen/src/lower/mod.rs:198:9
18: hash_codegen_llvm::LLVMBackend::build_bodies
at compiler/hash-codegen-llvm/src/lib.rs:296:13
19: ::run::{{closure}}
at compiler/hash-codegen-llvm/src/lib.rs:339:37
20: hash_utils::profiling::HasMutMetrics::record::{{closure}}
at compiler/hash-utils/src/profiling.rs:111:16
21: hash_utils::profiling::timed
at compiler/hash-utils/src/profiling.rs:130:22
hash_utils::profiling::HasMutMetrics::record
at compiler/hash-utils/src/profiling.rs:110:21
22: ::run
at compiler/hash-codegen-llvm/src/lib.rs:339:9
23: >::run
at compiler/hash-backend/src/lib.rs:68:9
24: hash_driver::driver::Driver::run_stage::{{closure}}
at compiler/hash-driver/src/driver.rs:98:16
25: hash_utils::profiling::timed
at compiler/hash-utils/src/profiling.rs:130:22
hash_driver::driver::Driver::run_stage
at compiler/hash-driver/src/driver.rs:97:9
26: hash_driver::driver::Driver::run_pipeline
at compiler/hash-driver/src/driver.rs:159:26
27: hash_driver::driver::Driver::run
at compiler/hash-driver/src/driver.rs:248:22
28: hash_driver::driver::Driver::run_filename
at compiler/hash-driver/src/driver.rs:271:9
29: hash_driver::driver::Driver::run_on_entry_point
at compiler/hash-driver/src/driver.rs:277:32
30: hashc::main
at compiler/hash/./src/main.rs:35:5
31: core::ops::function::FnOnce::call_once
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:250:5
32: std::sys_common::backtrace::__rust_begin_short_backtrace
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/sys_common/backtrace.rs:155:18
33: std::rt::lang_start::{{closure}}
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/rt.rs:166:18
34: core::ops::function::impls:: for &F>::call_once
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:284:13
std::panicking::try::do_call
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:552:40
std::panicking::try
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:516:19
std::panic::catch_unwind
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panic.rs:146:14
std::rt::lang_start_internal::{{closure}}
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/rt.rs:148:48
std::panicking::try::do_call
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:552:40
std::panicking::try
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:516:19
std::panic::catch_unwind
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panic.rs:146:14
std::rt::lang_start_internal
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/rt.rs:148:20
35: std::rt::lang_start
at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/rt.rs:165:17
36: _main
This is an compiler bug, please file a bug report at
https://github.com/hash-org/hashc/issues?labels=bug&template=bug_report
```