rust-lang / rust-lang/rust-bindgen

Test header_objc_template_h failing on HEAD on macOS 10.15

Open
#2,061 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

I cloned bindgen yesterday on my Mac, and cargo test is producing a test failure in header_objc_template_h where it's using id instead of u64, e.g.:

 pub trait IFoo<ObjectType>: Sized + std::ops::Deref {
-    unsafe fn get(&self) -> u64
+    unsafe fn get(&self) -> id

This looks similar to #1619 but the other way around?

I'm running on macOS 10.15.7 (not terribly up to date) with Rust/Cargo nightly (rustc 1.54.0-nightly (625d5a693 2021-06-01)) from rustup. I believe I have no libclang from anywhere other than Xcode. RUST_LOG=bindgen produces the following log info about clang versions:

[2021-06-03T15:12:09Z DEBUG bindgen] Generating bindings, libclang at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib
[2021-06-03T15:12:09Z DEBUG bindgen] Trying to find clang with flags: ["-x", "objective-c", "--target=x86_64-unknown-linux"]
[2021-06-03T15:12:13Z DEBUG bindgen] Found clang: Clang { path: "/usr/bin/clang", version: Some(CXVersion { Major: 11, Minor: 0, Subminor: 3 }), c_search_paths: Some(["/usr/local/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include"]), cpp_search_paths: Some(["/usr/local/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/include"]) }

Here's the full test diff:

---- header_objc_template_h stdout ----



diff expected generated
--- expected: "/Users/geofft/src/rust-bindgen/tests/expectations/tests/libclang-9/objc_template.rs"
+++ generated from: "/Users/geofft/src/rust-bindgen/tests/headers/objc_template.h"
 #![allow(
     dead_code,
     non_snake_case,
     non_camel_case_types,
     non_upper_case_globals
 )]
 #![cfg(target_os = "macos")]
 
 #[macro_use]
 extern crate objc;
 #[allow(non_camel_case_types)]
 pub type id = *mut objc::runtime::Object;
 #[repr(transparent)]
 #[derive(Clone)]
 pub struct Foo(pub id);
 impl std::ops::Deref for Foo {
     type Target = objc::runtime::Object;
     fn deref(&self) -> &Self::Target {
         unsafe { &*self.0 }
     }
 }
 unsafe impl objc::Message for Foo {}
 impl Foo {
     pub fn alloc() -> Self {
         Self(unsafe { msg_send!(objc::class!(Foo), alloc) })
     }
 }
 impl<ObjectType: 'static> IFoo<ObjectType> for Foo {}
 pub trait IFoo<ObjectType>: Sized + std::ops::Deref {
-    unsafe fn get(&self) -> u64
+    unsafe fn get(&self) -> id
     where
         <Self as std::ops::Deref>::Target: objc::Message + Sized,
     {
         msg_send!(*self, get)
     }
 }
 #[repr(transparent)]
 #[derive(Clone)]
 pub struct FooMultiGeneric(pub id);
 impl std::ops::Deref for FooMultiGeneric {
     type Target = objc::runtime::Object;
     fn deref(&self) -> &Self::Target {
         unsafe { &*self.0 }
     }
 }
 unsafe impl objc::Message for FooMultiGeneric {}
 impl FooMultiGeneric {
     pub fn alloc() -> Self {
         Self(unsafe { msg_send!(objc::class!(FooMultiGeneric), alloc) })
     }
 }
 impl<KeyType: 'static, ObjectType: 'static>
     IFooMultiGeneric<KeyType, ObjectType> for FooMultiGeneric
 {
 }
 pub trait IFooMultiGeneric<KeyType, ObjectType>:
     Sized + std::ops::Deref
 {
-    unsafe fn objectForKey_(&self, key: u64) -> u64
+    unsafe fn objectForKey_(&self, key: id) -> id
     where
         <Self as std::ops::Deref>::Target: objc::Message + Sized,
     {
         msg_send!(*self, objectForKey: key)
     }
 }

Let me know if you need any more details.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with cargo test and inspect the header_objc_template_h test, tests/headers/objc_template.h, and expectations/tests/libclang-9/objc_template.rs. Compare the generated Objective-C bindings and RUST_LOG=bindgen clang details; done means the expected and generated results agree for the supported setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.