Closed
Description
I got the following suggestion for correcting error:
help: consider using an explicit lifetime parameter as shown: fn string_by_path<'a, 'b>(doc: &'a Json, path: &'b [&'b str])
-> Result<String, Box<Error+ 'c>>
--> src/main.rs:16:1
|
16 | fn string_by_path<'a,'b,'c>(doc: &'a Json, path: &'b [&'b str]) -> Result<String, Box<Error + 'c>> {
| ^
But (irrelevant if this is going towards better solution or not) the suggestion is clearly illegal, because it's missing 'c
which exists in the return type.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]Rustc should never suggest obviously illegal solutions[/-][+]Incorrect lifetime suggested in diagnostics help message[/+]brson commentedon Aug 12, 2016
I agree that incorrect help suggestions are terrible and we should try much harder not to make them. I changed the title to be more about this specific message though since ISTM that "never suggest obviously illegal solutions" is quite a tall order. Let's solve this one!
cc @jonathandturner bogus help is super counterproductive.
nikomatsakis commentedon Aug 18, 2016
So this particular problem appears to be that we are failing to check trait object bounds, which didn't exist at the time this code was implemented. But there are also deeper problems with this check -- for example, it doesn't consider the possibility
'a: 'b
-style where-clauses. There are probably a number of fixes that could be done here.nikomatsakis commentedon Aug 18, 2016
triage: P-medium
arielb1 commentedon Aug 18, 2016
@brson
I-wrong
is only for wrong-codegen issues, which is not one of.brson commentedon Aug 23, 2016
@arielb1 I don't know how you came to this conclusion, but codegen is only one of Rust's many functions, and many of them can be "wrong". Which I-tag do you think applies here?
4 remaining items