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

Temporary value dropped while borrowed #13

Closed
cgroves3 opened this issue Nov 9, 2024 · 4 comments
Closed

Temporary value dropped while borrowed #13

cgroves3 opened this issue Nov 9, 2024 · 4 comments

Comments

@cgroves3
Copy link

cgroves3 commented Nov 9, 2024

I'm trying to use this library to develop Stereo Direct Spare Odometry. But I came across this error when building:

error[E0716]: temporary value dropped while borrowed
   --> /home/craig/.cargo/registry/src/index.crates.io-6f17d22bba15001f/factrs-0.1.0/src/variables/se2.rs:145:14
    |
130 |         let xy = if cfg!(feature = "fake_exp") {
    |             -- borrow later stored here
...
145 |             &(Vinv * self.xy)
    |              ^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
146 |         };
    |         - temporary value is freed at the end of this statement
    |
    = note: consider using a `let` binding to create a longer lived value

For more information about this error, try `rustc --explain E0716`.
@contagon
Copy link
Collaborator

contagon commented Nov 9, 2024

Hmm, I'm having trouble reproducing this. I tried initializing a fresh repository with cargo init and then cargo add factrs and it built fine. Any chance you could share a minimal example of this occurring? And what version of rust you are using?

@cgroves3
Copy link
Author

cgroves3 commented Nov 9, 2024

Good question. My rust version is 1.75.0. I think this goes away when I upgrade to the latest rust version.
Steps to reproduce:

  1. Checkout v0.1.0 of the library
  2. run rustup default 1.75.0 (Sets the rust version to 1.75.0)
  3. run cargo build

rustup default 1.82.0 to restore the version back to the latest.

@cgroves3
Copy link
Author

cgroves3 commented Nov 9, 2024

It might help consumers of this library to set the rust-version in the Cargo.toml.

That way users with older rust versions will just see an error stating a newer rust version is required.

That being said, thank you for all of the work you guys put into this library.

@contagon
Copy link
Collaborator

contagon commented Nov 9, 2024

Yup, that's definitely something that we should have and slipped between the cracks. I pin to 1.81 (num-dual recently had an update that pins to 1.81 so that's the lowest we can go) in #14 that should solve this. I'll submit a 0.2.0 release in a few days with the fix.

Let me know if you hit any other kinks or have any other questions - factrs is decently well used internally, but I'm sure there's some edge cases like this that we have missed.

If your implementation is open-source, we'd love to feature it as an example once it's finished too:)

@contagon contagon closed this as completed Nov 9, 2024
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

No branches or pull requests

2 participants