Skip to content

Incorrect lifetime suggested in diagnostics help message #35619

Closed
@viraptor

Description

@viraptor

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.

Activity

changed the title [-]Rustc should never suggest obviously illegal solutions[/-] [+]Incorrect lifetime suggested in diagnostics help message[/+] on Aug 12, 2016
brson

brson commented on Aug 12, 2016

@brson
Contributor

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.

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
and removed
T-langRelevant to the language team
on Aug 12, 2016
nikomatsakis

nikomatsakis commented on Aug 18, 2016

@nikomatsakis
Contributor

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

nikomatsakis commented on Aug 18, 2016

@nikomatsakis
Contributor

triage: P-medium

arielb1

arielb1 commented on Aug 18, 2016

@arielb1
Contributor

@brson

I-wrong is only for wrong-codegen issues, which is not one of.

brson

brson commented on Aug 23, 2016

@brson
Contributor

@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

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@brson@nikomatsakis@viraptor@arielb1

        Issue actions

          Incorrect lifetime suggested in diagnostics help message · Issue #35619 · rust-lang/rust