libelektra icon indicating copy to clipboard operation
libelektra copied to clipboard

Rust bindings fail to build with stable (rustc 1.71.0)

Open skull-squadron opened this issue 2 years ago • 4 comments

Output
error[E0425]: cannot find value `KEY_CP_NAME` in crate `elektra_sys`
  --> elektra/src/key.rs:58:42
   |
58 |         const KEY_CP_NAME = elektra_sys::KEY_CP_NAME as elektra_sys::elektraCopyFlags;
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_CP_STRING` in crate `elektra_sys`
  --> elektra/src/key.rs:60:44
   |
60 |         const KEY_CP_STRING = elektra_sys::KEY_CP_STRING as elektra_sys::elektraCopyFlags;
   |                                            ^^^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_CP_VALUE` in crate `elektra_sys`
  --> elektra/src/key.rs:62:43
   |
62 |         const KEY_CP_VALUE = elektra_sys::KEY_CP_VALUE as elektra_sys::elektraCopyFlags;
   |                                           ^^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_CP_META` in crate `elektra_sys`
  --> elektra/src/key.rs:64:42
   |
64 |         const KEY_CP_META = elektra_sys::KEY_CP_META as elektra_sys::elektraCopyFlags;
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_NS_SPEC` in crate `elektra_sys`
  --> elektra/src/readable.rs:72:42
   |
72 |         self.namespace() == elektra_sys::KEY_NS_SPEC
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_NS_DIR` in crate `elektra_sys`
  --> elektra/src/readable.rs:77:42
   |
77 |         self.namespace() == elektra_sys::KEY_NS_DIR
   |                                          ^^^^^^^^^^ help: a constant with a similar name exists: `KEY_NS_FIRST`
   |
  ::: /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:21:1
   |
21 | pub const KEY_NS_FIRST: elektraNamespace = 2;
   | ---------------------------------------- similarly named constant `KEY_NS_FIRST` defined here

error[E0425]: cannot find value `KEY_NS_PROC` in crate `elektra_sys`
  --> elektra/src/readable.rs:82:42
   |
82 |         self.namespace() == elektra_sys::KEY_NS_PROC
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_NS_USER` in crate `elektra_sys`
  --> elektra/src/readable.rs:87:42
   |
87 |         self.namespace() == elektra_sys::KEY_NS_USER
   |                                          ^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KEY_NS_SYSTEM` in crate `elektra_sys`
  --> elektra/src/readable.rs:92:42
   |
92 |         self.namespace() == elektra_sys::KEY_NS_SYSTEM
   |                                          ^^^^^^^^^^^^^ help: a constant with a similar name exists: `KEY_NS_LAST`
   |
  ::: /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:22:1
   |
22 | pub const KEY_NS_LAST: elektraNamespace = 8;
   | --------------------------------------- similarly named constant `KEY_NS_LAST` defined here

error[E0425]: cannot find value `KEY_NS_CASCADING` in crate `elektra_sys`
  --> elektra/src/readable.rs:97:42
   |
97 |         self.namespace() == elektra_sys::KEY_NS_CASCADING
   |                                          ^^^^^^^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KDB_O_NONE` in crate `elektra_sys`
  --> elektra/src/keyset.rs:74:41
   |
74 |         const KDB_O_NONE = elektra_sys::KDB_O_NONE as elektra_sys::elektraLookupFlags;
   |                                         ^^^^^^^^^^ not found in `elektra_sys`

error[E0425]: cannot find value `KDB_O_POP` in crate `elektra_sys`
  --> elektra/src/keyset.rs:76:40
   |
76 |         const KDB_O_POP = elektra_sys::KDB_O_POP as elektra_sys::elektraLookupFlags;
   |                                        ^^^^^^^^^ not found in `elektra_sys`

error[E0308]: mismatched types
   --> elektra/src/key.rs:221:21
    |
218 |                 elektra_sys::keySetBinary(
    |                 ------------------------- arguments to this function are incorrect
...
221 |                     data.len(),
    |                     ^^^^^^^^^^ expected `u64`, found `usize`
    |
note: function defined here
   --> /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:211:12
    |
211 |     pub fn keySetBinary(
    |            ^^^^^^^^^^^^
help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
    |
221 |                     data.len().try_into().unwrap(),
    |                               ++++++++++++++++++++

error[E0308]: mismatched types
   --> elektra/src/key.rs:235:17
    |
232 |             elektra_sys::keyGetBinary(
    |             ------------------------- arguments to this function are incorrect
...
235 |                 vec.capacity(),
    |                 ^^^^^^^^^^^^^^ expected `u64`, found `usize`
    |
note: function defined here
   --> /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:204:12
    |
204 |     pub fn keyGetBinary(
    |            ^^^^^^^^^^^^
help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
    |
235 |                 vec.capacity().try_into().unwrap(),
    |                               ++++++++++++++++++++

error[E0308]: mismatched types
  --> elektra/src/readable.rs:43:18
   |
42 |     fn basename_size(&self) -> isize {
   |                                ----- expected `isize` because of return type
43 |         unsafe { elektra_sys::keyGetBaseNameSize(self.as_ref()) }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `i64`
   |
help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit
   |
43 |         unsafe { elektra_sys::keyGetBaseNameSize(self.as_ref()).try_into().unwrap() }
   |                                                                ++++++++++++++++++++

error[E0308]: mismatched types
   --> elektra/src/keyset.rs:177:50
    |
177 |         let ks_ptr = unsafe { elektra_sys::ksNew(capacity, elektra_sys::KS_END) };
    |                               ------------------ ^^^^^^^^ expected `u64`, found `usize`
    |                               |
    |                               arguments to this function are incorrect
    |
note: function defined here
   --> /tmp/libelektra/build/src/bindings/rust/target/release/build/elektra-sys-b82dff8e72fe2f0c/out/bindings.rs:226:12
    |
226 |     pub fn ksNew(alloc: size_t, ...) -> *mut KeySet;
    |            ^^^^^
help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
    |
177 |         let ks_ptr = unsafe { elektra_sys::ksNew(capacity.try_into().unwrap(), elektra_sys::KS_END) };
    |                                                          ++++++++++++++++++++

error[E0308]: mismatched types
   --> elektra/src/keyset.rs:194:18
    |
193 |     pub fn append(&mut self, to_append: &KeySet) -> isize {
    |                                                     ----- expected `isize` because of return type
194 |         unsafe { elektra_sys::ksAppend(self.as_ptr(), to_append.as_ref()) }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `i64`
    |
help: you can convert an `i64` to an `isize` and panic if the converted value doesn't fit
    |
194 |         unsafe { elektra_sys::ksAppend(self.as_ptr(), to_append.as_ref()).try_into().unwrap() }
    |                                                                          ++++++++++++++++++++

Some errors have detailed explanations: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `elektra` (lib) due to 17 previous errors
Note: /tmp/libelektra/build/src/bindings/jna/process/src/main/java/org/libelektra/process/PluginProcess.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
  1. The bindgen-generated bindings.rs in the electra-sys crate is indeed missing these symbols, and so the electra crate fails to build.
  2. Integer types need to be updated to use ssize_t/size_t defined by bindgen rather than rust types isize/usize, or it's always going to be fragile.

skull-squadron avatar Aug 02 '23 09:08 skull-squadron

@steakknife thx for reporting this problem!

Which bindgen version did you use? We recently upgraded in #4983.

We also published a very recent version (which is more or less identical to 0.11.0) but we called it "version 0.10.0". Is this the version you used?

markus2330 avatar Aug 03 '23 15:08 markus2330

Will be hopefully fixed after the release.

@atmaxinger did you try with rustc 1.71.0?

markus2330 avatar Aug 03 '23 15:08 markus2330

No, I really don't have any expertise with rust.

atmaxinger avatar Aug 03 '23 15:08 atmaxinger

I'll have to retry when I get a chance.

On Thu, Aug 3, 2023 at 10:46 AM Maximilian Irlinger < @.***> wrote:

No, I really don't have any expertise with rust.

— Reply to this email directly, view it on GitHub https://github.com/ElektraInitiative/libelektra/issues/4984#issuecomment-1664225821, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWYMBPPFSPRZDLSDL2OCTXTPBW7ANCNFSM6AAAAAA3A6SCSU . You are receiving this because you were mentioned.Message ID: @.***>

skull-squadron avatar Aug 04 '23 15:08 skull-squadron

I mark this stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping by writing a message here or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:

github-actions[bot] avatar Aug 04 '24 01:08 github-actions[bot]

I closed this now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. Thank you for your contributions :sparkling_heart:

github-actions[bot] avatar Aug 18 '24 01:08 github-actions[bot]