Skip to content

Borrow-check considers argument borrows to live too long #7729

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
bblum opened this issue Jul 11, 2013 · 1 comment
Closed

Borrow-check considers argument borrows to live too long #7729

bblum opened this issue Jul 11, 2013 · 1 comment
Labels
A-lifetimes Area: Lifetimes / regions

Comments

@bblum
Copy link
Contributor

bblum commented Jul 11, 2013

Example program:

use std::util;
fn main() {
    let mut x = ();
    util::ignore((&mut x, util::ignore(&mut x)));
}

The error is "can't borrow x as mutable more than once at a time", even though a trivial rewrite of the program would show that the first borrow doesn't live until the second function call is made.

In case this looks too contrived, the actual code I was writing when I ran into this was:

sched.enqueue_task(blk(~Task::new_root(&mut sched.stack_pool, ||{})));
@nikomatsakis
Copy link
Contributor

Dup of #6268 (while not exactly the same scenario, same fix would apply to both)

flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 21, 2021
Add `format_in_format_args` and `to_string_in_format_args` lints

Fixes rust-lang#7667 and rust-lang#7729

I put these in `perf` since that was one of `@jplatte's` suggestions, and `redundant_clone` (which I consider to be similar) lives there as well.

However, I am open to changing the category or anything else.

r? `@camsteffen`

changelog: Add `format_in_format_args` and `to_string_in_format_args` lints
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

2 participants