-
Notifications
You must be signed in to change notification settings - Fork 175
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 fnptr not auto implement fn once #3492
base: master
Are you sure you want to change the base?
Conversation
9f2c10d
to
735c652
Compare
gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (FnPtr::setup_fn_once_output): Fix fnptr not auto implement fn once * typecheck/rust-tyty.h: Likewise. gcc/testsuite/ChangeLog: * rust/compile/format_args_basic_expansion.rs: add sized and fn_once * rust/compile/issue-2042.rs: add sized and fn_once * rust/compile/privacy6.rs: add sized and fn_once * rust/compile/rust_abi.rs: add sized and fn_once * rust/compile/torture/function_reference2.rs: add sized and fn_once * rust/compile/torture/function_reference3.rs: add sized and fn_once * rust/compile/torture/function_reference4.rs: add sized and fn_once * rust/compile/try-catch-unwind-new.rs: add sized and fn_once * rust/compile/try-catch-unwind-old.rs: add sized and fn_once
735c652
to
1eaee67
Compare
i somehow missed privacy6.rs ... will force push soo for merge if Philip doesn't have any change requests |
I may be wrong, but I think you're missing the "Signed-off-by" footer (unless you've filed copyright assignment, in that case please ignore my comment) :) |
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 think the code looks good, and it's not easy so well done. I'll let Philip take a look before merging as that is more his area of expertise. Thanks for working on this @badumbatish!!
auto fn_once_lookup = mappings.lookup_lang_item (LangItem::Kind::FN_ONCE); | ||
auto fn_once_output_lookup | ||
= mappings.lookup_lang_item (LangItem::Kind::FN_ONCE_OUTPUT); | ||
if (!fn_once_lookup) | ||
{ | ||
rust_fatal_error (UNKNOWN_LOCATION, | ||
"Missing required %<fn_once%> lang item"); | ||
return; | ||
} | ||
if (!fn_once_output_lookup) | ||
{ | ||
rust_fatal_error (UNKNOWN_LOCATION, | ||
"Missing required %<fn_once_ouput%> lang item"); | ||
return; | ||
} |
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.
there should be a mappings.get_lang_item(...)
API which already emits the rust_fatal_error
for you. we should probably rename it btw lol
DefId &trait_id = fn_once_lookup.value (); | ||
DefId &trait_item_id = fn_once_output_lookup.value (); |
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.
this would also allow you to avoid these lines, as get_lang_item
already returns a DefId
instead of an optional<Defid>
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'll probably fix the original code from Philip too
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 think this is part of the fix but there are some work to be done for bounds checking. Which i think the original issue is about. I think we do need this though.
@@ -2222,6 +2222,56 @@ FnPtr::clone () const | |||
get_combined_refs ()); | |||
} | |||
|
|||
void | |||
FnPtr::setup_fn_once_output () const |
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.
Yeah this is a dup of ClosureType::setup_fn_once_output its probably better to find a way to extract that out to be a shared helper
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, will do
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.
Would adding this to CallableTypeInterface
work?
im a bit rather new to this area...
this fixes #3354
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: