mut struct member var(ref) bind to new obj still hint: does not live long enough
Open
Nobody has claimed this yet.
A-borrow-checker
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
#[derive(Debug)]
struct ImportantExcerpt<'a> {
part: &'a str,
}
fn main() {
let mut root = ImportantExcerpt {part: "abc"};
{
let novel = String::from("Call me Ishmael. Some years ago...");
let first_sentence = novel.split('.').next().expect("Could not find a '.'");
root = ImportantExcerpt {part: first_sentence};
root.part = "1234"; // bind to new static str
}
println!("{:?}", root); // error does not live long enough
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the standalone Rust reproducer in the issue and inspect the lifetime diagnostic around the assignment to root.part. Compare the reported error with the intended lifetime behavior; done requires establishing whether this is a compiler bug and, if so, adding an appropriate regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100