Skip to content

gccrs: avoid MarkLive ICE on unresolved paths - #4776

Open
w3lld1 wants to merge 1 commit into
Rust-GCC:masterfrom
w3lld1:fix/4670-unresolved-marklive-path
Open

gccrs: avoid MarkLive ICE on unresolved paths#4776
w3lld1 wants to merge 1 commit into
Rust-GCC:masterfrom
w3lld1:fix/4670-unresolved-marklive-path

Conversation

@w3lld1

@w3lld1 w3lld1 commented Aug 12, 2026

Copy link
Copy Markdown

Fixes #4670

Name resolution already diagnoses the unknown enum variant in the match guard, but the lowered unresolved path still reached MarkLive, where a successful definition lookup was asserted. This change treats a missing definition as an already-diagnosed path and stops processing that expression instead of triggering an ICE.

I added a compile regression test for the reduced reproducer and its expected E0433 diagnostic.

Validation:

  • Focused build of rust/rust-lint-marklive.o
  • clang-format 16 dry-run on both changed C++ files
  • contrib/gcc-changelog/git_check_commit.py origin/master..HEAD
  • git diff --check origin/master...HEAD

The complete make check-rust suite is deferred to CI; the local compiler build exceeded the bounded run time after the changed translation unit compiled successfully.

Checklist:

  • DCO sign-off included
  • Read contributing guidelines
  • make check-rust passes locally (deferred to CI)
  • Ran clang-format
  • Added a relevant test case to gcc/testsuite/rust/

@P-E-P

P-E-P commented Aug 12, 2026

Copy link
Copy Markdown
Member

The CI does not pass, you'll have to fix whatever is required to make it green. Even though the CI is green about the commit format I believe your lines are too long, you need to wrap your text at col 50 for the title and 72 for the text.

I've seen that most of your recent contributions are AI generated, make sure you have taken a look at GCC's ai policy https://gcc.gnu.org/ai-policy.html

Name resolution reports an error for unresolved paths, but MarkLive
still visits their lowered HIR nodes. Treat a missing definition as an
already-diagnosed path and stop processing it instead of asserting.

Fixes Rust-GCC#4670

gcc/rust/ChangeLog:

	* checks/lints/rust-lint-marklive.cc (MarkLive::visit): Return on an
	unresolved path.
	(MarkLive::find_value_definition): Return whether lookup succeeded.
	* checks/lints/rust-lint-marklive.h
	(MarkLive::find_value_definition): Change return type.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4670.rs: New test.

Signed-off-by: w3lld1 <faststepbyme@gmail.com>
@w3lld1
w3lld1 force-pushed the fix/4670-unresolved-marklive-path branch from 528613e to bd2bcc4 Compare August 12, 2026 16:09
@Polygonalr

Copy link
Copy Markdown
Contributor

void mark_hir_id (HirId);
bool visit_path_segment (HIR::PathExprSegment);
void find_value_definition (NodeId ast_node_id, NodeId &ref_node_id);
bool find_value_definition (NodeId ast_node_id, NodeId &ref_node_id);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this can just return the optional<NodeId> instead of a boolean and updating the given reference

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 find_value_definition, at rust/checks/lints/rust-lint-marklive.cc match guard with unknown enum variant

4 participants