Skip to content

parse: Fix ICE when using 'dyn' without trait bound#4421

Merged
P-E-P merged 1 commit intoRust-GCC:masterfrom
Islam-Imad:bugfix/issue-3905-dyn-type-error
Feb 4, 2026
Merged

parse: Fix ICE when using 'dyn' without trait bound#4421
P-E-P merged 1 commit intoRust-GCC:masterfrom
Islam-Imad:bugfix/issue-3905-dyn-type-error

Conversation

@Islam-Imad
Copy link
Contributor

@Islam-Imad Islam-Imad commented Feb 3, 2026

Fixes #3905

The parser was accepting dyn as a standalone type in contexts like:
static STATIC_1: dyn = 1;

also preferred to refactor some if-else stms into switch/case

@Islam-Imad
Copy link
Contributor Author

I am not CI friendly btw :)

@Islam-Imad Islam-Imad force-pushed the bugfix/issue-3905-dyn-type-error branch from a0bea3e to 42623ef Compare February 3, 2026 17:53
@Islam-Imad
Copy link
Contributor Author

@P-E-P any feedback ?

The parser was accepting 'dyn' as a standalone type in contexts like:
  static STATIC_1: dyn = 1;

This invalid syntax should be rejected at parse time.

Fixes Rust-GCC#3905

gcc/rust/ChangeLog:

	* lex/rust-lex.cc (is_whitespace): refactor if-else to switch
	* lex/rust-token.h: refactor if-else to switch
	* parse/rust-parse-impl.hxx: return nullptr when type is in invalid state

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3904.rs: refactor the testcase to match the new thrown error

Signed-off-by: Islam-Imad <islamimad404@gmail.com>
@Islam-Imad Islam-Imad force-pushed the bugfix/issue-3905-dyn-type-error branch from 42623ef to 0063e02 Compare February 4, 2026 12:21
Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@P-E-P P-E-P added this pull request to the merge queue Feb 4, 2026
Merged via the queue into Rust-GCC:master with commit 3ecd7b9 Feb 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE in resolve_path, at rust/resolve/rust-forever-stack.hxx:651

2 participants