gccrs: Search lang_prelude when reaching module boundary during name resolution#4580
Merged
Merged
Conversation
powerboat9
approved these changes
Jun 6, 2026
powerboat9
left a comment
Collaborator
There was a problem hiding this comment.
I'm pretty sure there's some better way we should be doing this, but I'm not quite sure what, so LGTM
CohenArthur
reviewed
Jun 8, 2026
Comment on lines
+386
to
+389
| if ((current_node->is_root () | ||
| || (is_start (iterator, segments) | ||
| && current_node->rib.kind == Rib::Kind::Module)) | ||
| && !searched_prelude) |
Member
There was a problem hiding this comment.
I would suggest doing something like this which would be cleaner and easier to modify later:
Suggested change
| if ((current_node->is_root () | |
| || (is_start (iterator, segments) | |
| && current_node->rib.kind == Rib::Kind::Module)) | |
| && !searched_prelude) | |
| if (should_search_prelude()) |
Member
There was a problem hiding this comment.
You'll need to do something like should_search_prelude(current_node, searched_prelude) if we want to keep it as a simple static void function helper and not a full-on class function
Contributor
Author
There was a problem hiding this comment.
Oh there's some template jank involved around here, see whether my current abstraction works out :v
CohenArthur
reviewed
Jun 8, 2026
6128f0e to
f88754e
Compare
CohenArthur
approved these changes
Jun 10, 2026
CohenArthur
left a comment
Member
There was a problem hiding this comment.
Once the style comment is fixed I think this is good to go 👍 well done
…resolution gcc/rust/ChangeLog: * resolve/rust-name-resolution-context.h (NameResolutionContext): Add new function definition for `should_search_prelude`. * resolve/rust-name-resolution-context.hxx (NameResolutionContext::should_search_prelude): Add implementation. (NameResolutionContext::resolve_segments): Update the check to trigger lang_prelude search during name resolution in modules. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
f88754e to
0154f5c
Compare
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.
Name resolution does not resolve language preludes properly within a module. This PR fixes that.