Skip to content

Provide structured suggestion instead of label #52413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
estebank opened this issue Jul 16, 2018 · 2 comments
Closed

Provide structured suggestion instead of label #52413

estebank opened this issue Jul 16, 2018 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@estebank
Copy link
Contributor

estebank commented Jul 16, 2018

Given

trait Foo {
    fn dummy(&self) { }
}
struct A;
impl Foo for A {}
struct B<'a>(&'a (Foo+'a));
fn foo<'a>(a: &Foo) -> B<'a> {
    B(a)
}

The output is

error[E0621]: explicit lifetime required in the type of `a`
  --> $DIR/issue-14285.rs:22:5
   |
LL | fn foo<'a>(a: &Foo) -> B<'a> {
   |            - consider changing the type of `a` to `&'a (dyn Foo + 'a)`
LL |     B(a)    //~ ERROR 22:5: 22:9: explicit lifetime required in the type of `a` [E0621]
   |     ^^^^ lifetime `'a` required

The label suggesting changing the type of a should be a span_suggestion instead of a span_label.


Another case:

use std::any::Any;
fn foo<T: Any>(value: &T) -> Box<Any> {
    Box::new(value) as Box<Any>
}
error[E0621]: explicit lifetime required in the type of `value`
  --> $DIR/issue-16922.rs:14:5
   |
LL | fn foo<T: Any>(value: &T) -> Box<Any> {
   |                ----- consider changing the type of `value` to `&'static T`
LL |     Box::new(value) as Box<Any>
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-diagnostics Area: Messages for errors, warnings, and lints labels Jul 16, 2018
@PramodBisht
Copy link
Contributor

@estebank: I would like to take this on if nobody else is working on that.

@estebank
Copy link
Contributor Author

@PramodBisht go ahead and feel free to reach out for any help you might need!

PramodBisht added a commit to PramodBisht/rust that referenced this issue Aug 6, 2018
bors added a commit that referenced this issue Aug 7, 2018
Closes #52413: Provide structured suggestion instead of label

Provide structured suggestion instead of label
r? @estebank
@bors bors closed this as completed in 1940108 Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants