Rust-GCC / Rust-GCC/gccrs

internal compiler error: in throw_exception, at rust/util/expected.h

Open
#4,476 1 comment 0 reactions 1 assignee View on GitHub

@hriztam is already working on this.

Since Mar 21, 2026.

bug
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() {
     Foo { #[cfg(feature = -1)] .. } = S {};
    
}

original:

#![feature(no_core)]
#![no_core]
// #81282: Attributes are not allowed on struct field rest patterns (the ..).

struct S {}

fn main() {
    if 0 {} else if 0 {#![attr]} Foo { #[cfg(feature = -1)] .. } = S {};
    //~^ ERROR expected identifier, found `..`
}

Version information:

1a9102843099b18f9dbb6b5e979436f6c4566f1c

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/1a9102843099b18f9dbb6b5e979436f6c4566f1c/gcc/rust/util/expected.h#L209-L221

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

crab1: internal compiler error: in throw_exception, at rust/util/expected.h:215
0x3097ef9 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0xc3aa61 fancy_abort(char const*, int, char const*)
	../../gcc/diagnostics/context.cc:1813
0xd66899 void tl::detail::throw_exception<tl::bad_expected_access<Rust::Parse::Error::StructExprField> >(tl::bad_expected_access<Rust::Parse::Error::StructExprField>&&)
	../../gcc/rust/util/expected.h:215
0xd66899 std::unique_ptr<Rust::AST::StructExprField, std::default_delete<Rust::AST::StructExprField> >& tl::expected<std::unique_ptr<Rust::AST::StructExprField, std::default_delete<Rust::AST::StructExprField> >, Rust::Parse::Error::StructExprField>::value<std::unique_ptr<Rust::AST::StructExprField, std::default_delete<Rust::AST::StructExprField> >, (void*)0>() &
	../../gcc/rust/util/expected.h:1989
0xd66899 Rust::Parser<Rust::Lexer>::parse_struct_expr_struct_partial(Rust::AST::PathInExpression, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gcc/rust/parse/rust-parse-impl-expr.hxx:4071
0xd68bd8 Rust::Parser<Rust::Lexer>::null_denotation_path(Rust::AST::PathInExpression, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >, Rust::ParseRestrictions)
	../../gcc/rust/parse/rust-parse-impl-expr.hxx:2004
0xd74730 Rust::Parser<Rust::Lexer>::parse_stmt_or_expr()
	../../gcc/rust/parse/rust-parse-impl.hxx:7157
0xd752ef Rust::Parser<Rust::Lexer>::parse_block_expr(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >, tl::optional<Rust::AST::LoopLabel>, unsigned long)
	../../gcc/rust/parse/rust-parse-impl-expr.hxx:55
0xd9ebf3 Rust::Parser<Rust::Lexer>::parse_function(Rust::AST::Visibility, std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >, bool)
	../../gcc/rust/parse/rust-parse-impl.hxx:1630
0xda759b Rust::Parser<Rust::Lexer>::parse_vis_item(std::vector<Rust::AST::Attribute, std::allocator<Rust::AST::Attribute> >)
	../../gcc/rust/parse/rust-parse-impl.hxx:509
0xda893a Rust::Parser<Rust::Lexer>::parse_item(bool)
	../../gcc/rust/parse/rust-parse-impl.hxx:402
0xda9e0c Rust::Parser<Rust::Lexer>::parse_items()
	../../gcc/rust/parse/rust-parse-impl.hxx:278
0xdaa047 Rust::Parser<Rust::Lexer>::parse_crate()
	../../gcc/rust/parse/rust-parse-impl.hxx:305
0xe73a74 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:603
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.SWIncjcagEds/rustc_testrunner_tmpdir_reporting.65cxxdtPUsCL/mvce.rs -o/tmp/icemaker_global_tempdir.SWIncjcagEds/rustc_testrunner_tmpdir_reporting.65cxxdtPUsCL/binaryname -frust-incomplete-and-experimental-compiler-do-not-use
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.