Open
Description
From one of our tests:
fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() }
produces the following error:
error[E0106]: missing lifetime specifier
--> src/lib.rs:1:62
|
1 | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() }
| ------------------------------------ ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but the signature does not say which one of `iter`'s 2 lifetimes it is borrowed from
help: consider introducing a named lifetime parameter
|
1 | fn parse_type<'a>(iter: Box<dyn Iterator<Item=&'a str>+'static>) -> &'a str { iter.next() }
| ++++ ++ ++
error[E0308]: mismatched types
--> src/lib.rs:1:69
|
1 | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() }
| ---- ^^^^^^^^^^^ expected `&str`, found enum `Option`
| |
| expected `&'static str` because of return type
|
= note: expected reference `&'static str`
found enum `Option<&str>`
Note how in the mismatched types error we’re seing two spans disagreeing with each other on what the lifetime of &str
ought to be. This can come across as pretty weird.