Skip to content
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 macos expectations #2176

Merged
merged 1 commit into from
Mar 15, 2022
Merged

Conversation

simlay
Copy link
Contributor

@simlay simlay commented Mar 8, 2022

Closes #1954

* Updated tests/expectations/Cargo.toml to use 2018 rust.
* Added Debug and Copy to objective-c structs.
* Fixed lifetimes in objective-c trait templates.
* Fixed imports for objective-c expectations tests.
@simlay simlay force-pushed the fix-macos-expectations branch from bb7fd33 to fcb3cc3 Compare March 8, 2022 02:47
@simlay simlay marked this pull request as ready for review March 8, 2022 02:47
@simlay
Copy link
Contributor Author

simlay commented Mar 11, 2022

@emilio or @kulp, up for a review?

Copy link
Member

@kulp kulp left a comment

Choose a reason for hiding this comment

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

I left a few comments, but I am far from knowledgeable on the Objective-C code in here (also @emilio will have to merge anyway).

You might want to untag the innocent user whose name is an anagram of mine :)

@@ -154,6 +159,9 @@

## Security


[(#2176)]: https://github.com/rust-lang/rust-bindgen/pull/2176

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I mostly just was putting the "links" section at the end of that unreleased release section.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, right. Rendered, the markdown would not show anything under Security. My mistake.

@@ -1,4 +1,4 @@
// bindgen-flags: --objc-extern-crate -- -x objective-c
Copy link
Member

Choose a reason for hiding this comment

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

Is --objc-extern-crate still needed under any circumstances ? Since it no longer appears in any expectations, should we be thinking about removing the option, or else about re-adding expectations for it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm up to remove it. I'd only argue that it should be an outside PR/issue to this. The main reason I removed it from all the tests expectations is because all of those expectations are modules and modules can't have #[macro_use] extern crate objc as that goes in a top level src/lib.rs/src/main.rs of a rust crate for rust 2015 edition crate.

Copy link
Member

Choose a reason for hiding this comment

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

Though I have not tried to understand the flag itself, I agree that removing it would be out of scope for this PR. As long as we do not forget about the flag's presence, it seems fine not to deal further with it here.

@@ -4381,7 +4381,7 @@ pub mod utils {
}
} else {
quote! {
use objc;
use objc::{self, msg_send, sel, sel_impl, class};
Copy link
Member

Choose a reason for hiding this comment

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

Are we worried about namespace pollution in the generated code with generic names like class and self ? This may be of no importance – I honestly do not have a good handle on the implications of bringing in these names unqualified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will admit that I don't know if self is needed here. It was there before so I left it in now that you question it, it may not be needed. The (unfortunate) generic class however is needed for the non-objc_extern_crate scenario.

Before rust edition 2018 (if I recall the history), things like:

#[macro_use] extern crate objc;

were required for all external crates and imported all macros from that crate via the #[macro_use] annotation. With rust 2018, one doesn't need extern crate foo for crate foo on src/lib.rs or src/main.rs but as a result one cannot just blanket import all the macros (this is probably for the best).

One unfortunate part of this is that macros use macros but the macros don't import the macros from the crates they use that I know of and not from the crates they live in (for the objc crate anyway).

Anyway, I bring this up because I find the #[macro_use] annotation nice but only because it works now. If I'm being honest this crate should probably deprecate it but argue that it's outside the scope of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that deprecation is out of scope for this PR. I am pretty weak on the edition differences and macro scoping rules, but after your explanation I think the namespace collision problem is not worse than it was. Thanks.

@simlay
Copy link
Contributor Author

simlay commented Mar 12, 2022

You might want to untag the innocent user whose name is an anagram of mine :)

haha. My bad!

Copy link
Member

@kulp kulp left a comment

Choose a reason for hiding this comment

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

I confirm that the tests below pass on my M1 Macbook with macOS 12.2.1 and rustc 1.59.0, whereas the tests/expectations directory fails on master, as expected.

for d in . tests/expectations tests/quickchecking bindgen-integration
do
    (cd $d && cargo test)
done

Looks good to me. Thanks!

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, and thanks so much @kulp for the review!

@emilio emilio merged commit 6a169f2 into rust-lang:master Mar 15, 2022
tshepang added a commit to tshepang/rust-bindgen that referenced this pull request May 25, 2023
tshepang added a commit to tshepang/rust-bindgen that referenced this pull request Jun 1, 2023
pvdrz pushed a commit that referenced this pull request Jun 2, 2023
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.

objc_interface_type.h generates non-compiling code.
3 participants