ICE `in visit, at rust/backend/rust-compile-expr.cc:131`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
auto-reduced (treereduce-rust):
//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
fn main() {
[(); return match () {
'a' => 0,
0 => 0,
}];
}
original:
fn main() {
//~| NOTE: the return is part of this body...
//~| NOTE: not the enclosing function body
//~| NOTE: not the enclosing function body
[(); return match 0 { 0 => 0 }];
//~^ ERROR: return statement outside of function body [E0572]
//~| NOTE: this expression has type `()`
[(); return match 0 { 0 => 0 }];
//~^ ERROR: return statement outside of function body [E0572]
//~| NOTE: the return is part of this body...
[(); return match () { 'a' => 0, 0 => 0 }];
//~^ ERROR: return statement outside of function body [E0572]
//~| NOTE: not the enclosing function body
//~| ERROR: mismatched types [E0308]
//~| NOTE: expected `()`, found `char`
//~| NOTE: this expression has type `()`
}
Version information:
5dc8c4d20d62462ebce137c6e5146235ab9e9e2e
Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5dc8c4d20d62462ebce137c6e5146235ab9e9e2e/gcc/rust/backend/rust-compile-expr.cc#L125-L137
Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use
Program output
/tmp/icemaker_global_tempdir.LQuuUEtPQzY7/rustc_testrunner_tmpdir_reporting.8MKsGnjLHmtW/mvce.rs:3:9: error: mismatched types, expected ‘()’ but got ‘char’ [E0308]
2 | [(); return match () {
| ~
3 | 'a' => 0,
| ^~~
/tmp/icemaker_global_tempdir.LQuuUEtPQzY7/rustc_testrunner_tmpdir_reporting.8MKsGnjLHmtW/mvce.rs:4:9: error: mismatched types, expected ‘()’ but got ‘<integer>’ [E0308]
2 | [(); return match () {
| ~
3 | 'a' => 0,
4 | 0 => 0,
| ^
/tmp/icemaker_global_tempdir.LQuuUEtPQzY7/rustc_testrunner_tmpdir_reporting.8MKsGnjLHmtW/mvce.rs:2:5: error: mismatched types, expected ‘usize’ but got ‘!’ [E0308]
2 | [(); return match () {
| ^ ~~~~~~
crab1: internal compiler error: in visit, at rust/backend/rust-compile-expr.cc:131
0x2fecaf8 internal_error(char const*, ...)
../../gcc/diagnostic-global-context.cc:517
0xc0e04d fancy_abort(char const*, int, char const*)
../../gcc/diagnostic.cc:1803
0x90a003 Rust::Compile::CompileExpr::visit(Rust::HIR::ReturnExpr&)
../../gcc/rust/backend/rust-compile-expr.cc:131
0x1162c76 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
../../gcc/rust/backend/rust-compile-expr.cc:48
0x118e8ef Rust::Compile::HIRCompileBase::compile_constant_item(unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
../../gcc/rust/backend/rust-compile-base.cc:869
0x118f044 Rust::Compile::HIRCompileBase::compile_constant_expr(Rust::Compile::Context*, unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
../../gcc/rust/backend/rust-compile-base.cc:573
0x118f044 Rust::Compile::HIRCompileBase::query_compile_const_expr(Rust::Compile::Context*, Rust::TyTy::BaseType*, Rust::HIR::Expr&)
../../gcc/rust/backend/rust-compile-base.cc:588
0x109f8c0 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::ArrayExpr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1111
0x109a4d4 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x10a9acc ???
../../gcc/rust/typecheck/rust-hir-type-check-stmt.h:33
0x10aa163 Rust::Resolver::TypeCheckStmt::Resolve(Rust::HIR::Stmt&)
../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:34
0x109bef1 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:609
0x109a4d4 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x10773f0 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::Function&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:642
0x106e185 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
../../gcc/rust/typecheck/rust-hir-type-check-item.cc:59
0x100adcb Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
../../gcc/rust/typecheck/rust-hir-type-check.cc:74
0xdb97f8 Rust::Session::compile_crate(char const*)
../../gcc/rust/rust-session-manager.cc:685
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reduced Rust reproducer and command in the issue, then inspect gcc/rust/backend/rust-compile-expr.cc around line 131 and the ReturnExpr visit shown in the backtrace. Compare the reported diagnostics with the internal compiler error; done means this input no longer aborts at that location and reports diagnostics normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100