Conversation
u7k4rs6
force-pushed
the
fix-4732-path-pattern-refutable
branch
from
August 24, 2026 08:30
6017e6c to
87b6e5a
Compare
u7k4rs6
force-pushed
the
fix-4732-path-pattern-refutable
branch
from
September 4, 2026 10:29
c65d6ec to
3ec7478
Compare
Contributor
Author
|
Reworked the hunk and replaced rust_unreachable since non-ADT paths are refutable constants. |
Collaborator
|
For could you stick more of the second line after the colon? |
u7k4rs6
force-pushed
the
fix-4732-path-pattern-refutable
branch
from
September 4, 2026 13:11
3ec7478 to
dfe4ea5
Compare
Contributor
Author
|
@powerboat9 Done with the re- wrapping |
u7k4rs6
force-pushed
the
fix-4732-path-pattern-refutable
branch
3 times, most recently
from
September 17, 2026 13:25
3aa30bc to
721545d
Compare
CohenArthur
reviewed
Sep 17, 2026
CohenArthur
left a comment
Member
There was a problem hiding this comment.
The code changes look good to me. I reached out privately for the commit message which I think needs to be changed.
u7k4rs6
force-pushed
the
fix-4732-path-pattern-refutable
branch
3 times, most recently
from
September 19, 2026 18:59
75d0a5c to
757dc19
Compare
Resolve path patterns through their node id instead of the last segment, handling variant, impl, and trait mappings before falling back to the scrutinee type. Closes Rust-GCC#4732. A single variant enum is now seen as irrefutable, so compilation reaches the backend and trips the older assertion from Rust-GCC#4553, which is why irrefutable-path.rs keeps its dg-ice. gcc/rust/ChangeLog: * hir/tree/rust-hir-pattern-abstract.cc (PathPattern::is_refutable): Resolve path patterns through the node to HIR mappings instead of calling rust_unreachable. gcc/testsuite/ChangeLog: * rust/compile/refutable-path.rs: Remove dg-ice. * rust/compile/irrefutable-path-single-variant.rs: New test. Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
u7k4rs6
force-pushed
the
fix-4732-path-pattern-refutable
branch
from
September 28, 2026 05:59
757dc19 to
5f4b7be
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4732
PathPattern::is_refutablelooked up the final path segment'sHirIdin the HIR item map. A path segment does not carry theHirIdof the referenced item, solookup_hir_itemalways failed and path patterns in let bindings and function parameters reachedrust_internal_error_at.The fix resolves the path using the path expression's
NodeId, then maps the resolved definition throughlookup_node_to_hirto find the HIR item. Both Values and Types namespaces are checked.Enum variants are stored separately from regular HIR items, so failed item lookup falls back to checking the scrutinee type. Non-enum ADTs are also handled to avoid another ICE for unit struct patterns.
This adds the first
rust/hir->rust/resolveinclude. No build changes are needed sincerust/resolveis already on the include path, and there is no include cycle.rust-hir-pattern-abstract.ccalready includesrust-hir-type-check.hand callsTypeCheckContext::get ()inis_refutable_with_lookup, so this file already depends on a later pass. I can move the lookup intoPatternCheckerif the direct dependency is considered undesirable, but that would require threading the context through theis_refutablevirtual interface since it recurses into nested patterns.refutable-path.rsnow checks the expected diagnostics instead of usingdg-ice, covering let bindings, function parameters, an associated constant, and a const generic.irrefutable-path-single-variant.rswas added to directly test single-variant enums and unit structs without hitting the existing backend ICE from #4553.irrefutable-path.rsis left unchanged and keeps itsdg-ice, but now reaches a different ICE. The single-variant enum parameter is correctly considered irrefutable, so compilation proceeds into the backend and hits the pre-existingfunction_set_parametersassertion from #4553, whichirrefutable-slice.rsalready XFAILs on.Validation on the rebased head: 11,598 expected passes, 86 expected failures, 10 unsupported, zero unexpected failures.