LivacoNew / CrabFetch

Extremely fast, featureful and customizable command-line fetcher.
Apache License 2.0
21 stars 4 forks source link

Compiling error introduced in d5b2aaf #28

Closed CarterLi closed 3 months ago

CarterLi commented 3 months ago
error[E0308]: mismatched types
  --> src/util.rs:61:46
   |
61 |         let str: &str = match CStr::from_ptr(ptr).to_str() {
   |                               -------------- ^^^ expected `*const u8`, found `*const i8`
   |                               |
   |                               arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: associated function defined here
  --> /builddir/build/BUILD/rustc-1.80.0-src/library/core/src/ffi/c_str.rs:284:25

error[E0308]: mismatched types
   --> src/syscalls.rs:108:42
    |
108 |             sysname: util::cstr_from_ptr(utsname.sysname.as_ptr()).expect("Unable to convert CStr to Rust String"),
    |                      ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |                      |
    |                      arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`
note: function defined here
   --> src/util.rs:55:8
    |
55  | pub fn cstr_from_ptr(ptr: *const i8) -> Result<String, String> {
    |        ^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
   --> src/syscalls.rs:109:43
    |
109 |             nodename: util::cstr_from_ptr(utsname.nodename.as_ptr()).expect("Unable to convert CStr to Rust String"),
    |                       ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |                       |
    |                       arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`
note: function defined here
   --> src/util.rs:55:8
    |
55  | pub fn cstr_from_ptr(ptr: *const i8) -> Result<String, String> {
    |        ^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
   --> src/syscalls.rs:110:42
    |
110 |             release: util::cstr_from_ptr(utsname.release.as_ptr()).expect("Unable to convert CStr to Rust String"),
    |                      ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |                      |
    |                      arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`
note: function defined here
   --> src/util.rs:55:8
    |
55  | pub fn cstr_from_ptr(ptr: *const i8) -> Result<String, String> {
    |        ^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
   --> src/syscalls.rs:111:42
    |
111 |             version: util::cstr_from_ptr(utsname.version.as_ptr()).expect("Unable to convert CStr to Rust String"),
    |                      ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |                      |
    |                      arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`
note: function defined here
   --> src/util.rs:55:8
    |
55  | pub fn cstr_from_ptr(ptr: *const i8) -> Result<String, String> {
    |        ^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
   --> src/syscalls.rs:112:42
    |
112 |             machine: util::cstr_from_ptr(utsname.machine.as_ptr()).expect("Unable to convert CStr to Rust String"),
    |                      ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |                      |
    |                      arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`
note: function defined here
   --> src/util.rs:55:8
    |
55  | pub fn cstr_from_ptr(ptr: *const i8) -> Result<String, String> {
    |        ^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
   --> src/syscalls.rs:127:39
    |
127 |             name: util::cstr_from_ptr(passwd.pw_name).expect("Unable to convert CStr to Rust String"),
    |                   ------------------- ^^^^^^^^^^^^^^ expected `*const i8`, found `*mut u8`
    |                   |
    |                   arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*mut u8`
note: function defined here
   --> src/util.rs:55:8
    |
55  | pub fn cstr_from_ptr(ptr: *const i8) -> Result<String, String> {
    |        ^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
   --> src/syscalls.rs:130:38
    |
130 |             dir: util::cstr_from_ptr(passwd.pw_dir).expect("Unable to convert CStr to Rust String"),
    |                  ------------------- ^^^^^^^^^^^^^ expected `*const i8`, found `*mut u8`
    |                  |
    |                  arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*mut u8`
note: function defined here
   --> src/util.rs:55:8
    |
55  | pub fn cstr_from_ptr(ptr: *const i8) -> Result<String, String> {
    |        ^^^^^^^^^^^^^ --------------

error[E0308]: mismatched types
   --> src/syscalls.rs:131:40
    |
131 |             shell: util::cstr_from_ptr(passwd.pw_shell).expect("Unable to convert CStr to Rust String"),
    |                    ------------------- ^^^^^^^^^^^^^^^ expected `*const i8`, found `*mut u8`
    |                    |
    |                    arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*mut u8`
note: function defined here
   --> src/util.rs:55:8
    |
55  | pub fn cstr_from_ptr(ptr: *const i8) -> Result<String, String> {
    |        ^^^^^^^^^^^^^ --------------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `crabfetch` (bin "crabfetch") due to 9 previous errors
LivacoNew commented 3 months ago

What platform are you compiling on/for? Can I also get cargo --version

LivacoNew commented 3 months ago

Nvm, just ran into this on my phone while testing something for Android. I don't know much about pointer-land but I'm guessing this just different systems using different pointer types (aka signed/unsigned). Imagine that Rust probably has a built-in way to deal with this I just didn't know about .-.

LivacoNew commented 3 months ago

yep