Skip to content

Lifetime error? #21764

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

Closed
GuillaumeGomez opened this issue Jan 30, 2015 · 2 comments
Closed

Lifetime error? #21764

GuillaumeGomez opened this issue Jan 30, 2015 · 2 comments
Labels
A-type-system Area: Type system

Comments

@GuillaumeGomez
Copy link
Member

Hi,

I have the following file. If the line 131 is set at line 152, so just above this line:

let mut s = rgsl::MultiFitFdfSolver::new(&T, n as u64, p as u64).unwrap();

I get the following error:

examples/multifit_solver/main.rs:152:47: 152:48 error: `T` does not live long enough
examples/multifit_solver/main.rs:152     let mut s = rgsl::MultiFitFdfSolver::new(&T, n as u64, p as u64).unwrap();
                                                                                   ^
examples/multifit_solver/main.rs:138:6: 191:2 note: reference must be valid for the block suffix following statement 10 at 138:5...
examples/multifit_solver/main.rs:138     };
examples/multifit_solver/main.rs:139 
examples/multifit_solver/main.rs:140     /* This is the data to be fitted */
examples/multifit_solver/main.rs:141     let mut iter = 0us;
examples/multifit_solver/main.rs:142 
examples/multifit_solver/main.rs:143     for i in range(0, n) {
                                     ...
examples/multifit_solver/main.rs:151:50: 191:2 note: ...but borrowed value is only valid for the block suffix following statement 13 at 151:49
examples/multifit_solver/main.rs:151     let T = rgsl::MultiFitFdfSolverType::lmsder();
examples/multifit_solver/main.rs:152     let mut s = rgsl::MultiFitFdfSolver::new(&T, n as u64, p as u64).unwrap();
examples/multifit_solver/main.rs:153     
examples/multifit_solver/main.rs:154     s.set(&mut f, &x.vector());
examples/multifit_solver/main.rs:155 
examples/multifit_solver/main.rs:156     print_state(iter as u64, &mut s);
                                     ...
error: aborting due to previous error

Is that normal? The variable does live long enough so I don't get why there is an error in here.

@kmcallister kmcallister added the A-type-system Area: Type system label Jan 30, 2015
@aidanhs
Copy link
Member

aidanhs commented Feb 11, 2015

@steveklabnik
Copy link
Member

Triage: the original file is gone. @GuillaumeGomez if you're still seeing this, can you give me a new reproduction? Closing till then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

4 participants