-
Notifications
You must be signed in to change notification settings - Fork 162
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
Fix name resolution for enums with generics #3307
Conversation
Not quite sure if it's appropriate to add a test case for this. It seems like we already have testcases involving enum+Generic, they just weren't run with NR2.0. See, for example issue-850.rs, issue-2105.rs, etc |
540afdc
to
08e4443
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! this looks great
if these tests are passing now with nr2.0, can we take them out of the exclude list for NR2? or are there other issues with them? if there are other issues with them I'd like to see a small testcase for this specifically for NR2.0 |
I did a run without excludes, and I didn't get any previous tests to start passing. I looked into why issue-850.rs fails, and it seems to be due to lang items paths not working under NR2.0. A lot of other tests involving enums+generics seem to be more complex, and I'm guessing, fail for other unrelated reasons. |
08e4443
to
59c2eae
Compare
I added a test for this: |
b090053
to
6c23091
Compare
Looks good -- should probably add the visitor to |
Are you referring to this? I can see how it would make sense to add this to DefaultResolver auto generic_vis = [this, &enum_item] () {
for (auto &g : enum_item.get_generic_params ())
{
g->accept_vis (*this);
}
};
ctx.scoped (Rib::Kind::Item, enum_item.get_node_id (), generic_vis); |
Yes, I think |
It didn't seem to from my look. I checked lines 101-110 of DefaultResover, and saw: 101 void
102 DefaultResolver::visit (AST::Enum &type)
103 {
104 // FIXME: Do we need to scope anything by default?
105
106 auto variant_fn = [this, &type] () { AST::DefaultASTVisitor::visit (type); };
107
108 ctx.scoped (Rib::Kind::Item /* FIXME: Correct? */, type.get_node_id (),
109 variant_fn, type.get_identifier ());
110 } |
Granted I am new to this part of the codebase, so it's possible I'm missing something. |
Ah, yeah, it delegates that out to |
6c23091
to
c8246d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename this file issue-3304.rs
instead, as 3307 is this PR and not the issue itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 I fixed this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries it's all good :D
#[lang = "sized"] | ||
trait Sized {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[lang = "sized"] | |
trait Sized {} | |
// { dg-additional-options "-frust-name-resolution-2.0" } | |
#[lang = "sized"] | |
trait Sized {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this patch. Wouldn't this cause issue-3304.rs to be run with NR2.0 twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it shouldn't matter -- that line should be alright either present or not present
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'm happy to keep it there since it clarifies that this is specifically a NR2.0 test
232f5f7
to
debe715
Compare
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc: Change the late name resolver to enter proper lexical scope during typechecking * resolve/rust-late-name-resolver-2.0.h: Add needed prototype to header * resolve/rust-toplevel-name-resolver-2.0.cc: Add generic parameters to enum's scoped RIB to allow for proper name resolution on types. gcc/testsuite/ChangeLog: * rust/compile/issue-3304.rs: Add small test for generics+enums combination for NR2.0 Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
debe715
to
7471e51
Compare
Fixes #3304
Here is a checklist to help you with your PR.
make check-rust
passes locallyclang-format
gcc/testsuite/rust/
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
*Please write a comment explaining your change. This is the message
that will be part of the merge commit.