I am counting the number of times a word appears in Macbeth:
use std::io::{BufRead, BufReader};
use std::fs::File;
use std::collections::HashMap;
fn main()
The error is both right and wrong here. l is blamed, because w lives only as long as l (and l.unwrap()) and l doesn't live long enough to put it in hashmap in a higher scope.
In practice, you just have to look at what other variables depend on the lifetime of a variable the compiler complains about.
But Rust is also working lately on improving error reporting, so I'd raise this case as potential bug.