Problem with program compilation

Hi Guys,
I am new to rust programming, trying to build the program for TM4C129x microcotroller with cortex M4 core from here: https://github.com/m-labs/ionpak/tree/master/firmware . I installed Cargo and rust-std components for the ARM Cortex-M targets. After entering "cargo +nightly build" output looks like this:

Compiling semver-parser v0.7.0
   Compiling proc-macro2 v0.4.27
   Compiling winapi-build v0.1.1
   Compiling unicode-xid v0.1.0
   Compiling winapi v0.2.8
   Compiling rand_core v0.4.0
   Compiling cortex-m-rt v0.6.7
   Compiling cortex-m v0.5.8
   Compiling byteorder v1.3.1
   Compiling build_const v0.2.1
   Compiling vcell v0.1.0
   Compiling r0 v0.2.2
   Compiling tm4c129x v0.8.0
   Compiling aligned v0.2.0
   Compiling managed v0.5.1
   Compiling bitflags v1.0.4
   Compiling libm v0.1.2
   Compiling semver v0.9.0
   Compiling rand_core v0.3.1
   Compiling volatile-register v0.2.0
   Compiling kernel32-sys v0.2.2
   Compiling rand v0.5.6
   Compiling crc v1.8.1
   Compiling rustc_version v0.2.3
   Compiling bare-metal v0.2.4
   Compiling smoltcp v0.4.0 (https://github.com/m-labs/smoltcp?rev=cd893e6#cd893e6a)
   Compiling quote v0.6.11
   Compiling syn v0.15.26
error[E0713]: borrow may still be in use when destructor runs
  --> C:\Users\xxx\.cargo\git\checkouts\smoltcp-ebf9e93b1271bd34\cd893e6\src\socket\ref_.rs:61:9
   |
39 | impl<'a, T: Session + 'a> Ref<'a, T> {
   |      -- lifetime `'a` defined here
...
61 |         ref_.socket
   |         ^^^^^^^^^^^ returning this value requires that `*ref_.socket` is borrowed for `'a`
62 |     }
   |     - here, drop of `ref_` needs exclusive access to `*ref_.socket`, because the type `ref_::Ref<'_, T>` implements the `Drop` trait

For more information about this error, try `rustc --explain E0713`.

Do You have idea what am i doing wrong?

The code you're trying to compile is 3 years old, and the version of smoltcp it is depending on had code that was erroneously accepted by the compiler but now is not. You will need to update the versions of dependencies to compile this code.

You can start out by running cargo update, which will update the library versions in the Cargo.lock file to compatible newer versions. If that doesn't suffice, you will need to change the Cargo.toml file's dependency versions to newer major (potentially incompatible) versions, and make any changes to the source code that are needed to work wirth those new library versions.

1 Like

It looks like the manifest for ionpak-firmware pins smoltcp to an old Git commit:

[dependencies.smoltcp]
git = "https://github.com/m-labs/smoltcp"
rev = "cd893e6"

(The commit in question.) So the only way to get around this is by forking ionpak-firmware, unfortunately.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.