Skip to content

nr2.0: Adjust alternate identifier handling #3821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

powerboat9
Copy link
Collaborator

No description provided.

gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc
	(visit_identifier_as_pattern): Make sure to map identifiers
	inside or-bindings to prior identifiers.

Signed-off-by: Owen Avery <[email protected]>
Comment on lines +239 to +241
auto res = ctx.values.get (ident);
rust_assert (res.has_value () && !res->is_ambiguous ());
ctx.map_usage (Usage (node_id), Definition (res->get_node_id ()));
Copy link
Member

Choose a reason for hiding this comment

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

don't we need to sometimes insert a shadowable name when resolving identifier patterns? e.g.

struct Foo(i32);

match foo {
    Foo(a) => { use(a) },
}

or am I misunderstanding?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let Foo(a | a) = x;
        ^   ^
        |   |_ 'a' is or-bound, map to last definition
        |_ 'a' is not or-bound, insert definition (see 'else' block)

Copy link
Member

Choose a reason for hiding this comment

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

thank youuuu perfect haha

@CohenArthur CohenArthur added this pull request to the merge queue Jun 13, 2025
Merged via the queue into Rust-GCC:master with commit 97ca260 Jun 13, 2025
12 checks passed
@powerboat9 powerboat9 deleted the fix-or branch June 13, 2025 14:24
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.

2 participants