Skip to content
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

Improve case with one named, one anonymous lifetime parameter - SubSupConflict Errors #42701

Closed
gaurikholkar-zz opened this issue Jun 16, 2017 · 7 comments · Fixed by #44167
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics

Comments

@gaurikholkar-zz
Copy link

gaurikholkar-zz commented Jun 16, 2017

Currently in #42669, we are handling only ConcreteFailure RegionResolution Errors. We need to detect and improve the error message for SubSupConflict Error as well.

struct Foo {
  field: i32
}
impl Foo{

  fn foo2<'a>(&self, x: &'a i32) -> &'a i32 {
    if true { &self.field } else { x }
  }
}

cc @nikomatsakis

@Mark-Simulacrum Mark-Simulacrum added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 23, 2017
@cengiz-io
Copy link
Contributor

I'd like to start working on this if noone else is assigned.

@nikomatsakis
Copy link
Contributor

@cengizio expressed some interest in taking a look at this. @cengizio, here are some rough instructions for what would have to be done. Currently, when reporting region errors, we check for the special case of a "named-anon conflict". If you look into this function, you'll see that it first tests for ConcreteFailure. The basic task here is to extend that also work for SubSupConflict. I think, in this case, that is probably as easy as extracting the sub and sup regions involved (as well as the "main span") and returning them, and then checking what impact that has on the tests involved and making sure everything still looks ok. It's a good opportunity though to read over the code and understand what it does.

@gaurikholkar-zz
Copy link
Author

gaurikholkar-zz commented Jul 17, 2017

You can read up my blogs here. I hope they will be of help :)

@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@cengiz-io
Copy link
Contributor

Ping: I was busy with other stuff since I've signed up to this. Now that they are over, I'm diving into it.

@nikomatsakis
Copy link
Contributor

I think this is a good test case:

struct Foo {
    field: i32,
}

fn foo2<'a>(a: &'a Foo, x: &i32) -> &'a i32 {
    if true {
        let p: &i32 = &a.field;
        &*p
    } else {
        &*x
    }
}

fn main() { }

@cengiz-io
Copy link
Contributor

Hello @gaurikholkar I was in LOA during last week, just returned. Will revise my PR tomorrow.

@cengiz-io
Copy link
Contributor

I've removed the redundant test case and updated the sample input with the provided one up in #42701 (comment)

@estebank estebank added E-needs-mentor WG-diagnostics Working group: Diagnostics labels Oct 13, 2017
bors added a commit that referenced this issue Nov 9, 2017
Improve SubSupConflict with a named and an anonymous lifetime parameter #42701

Hello!

This fixes #42701.

## UPDATE 01
Tests are producing different results between different env builds.
This inconsistency might take a long time to investigate and fix. So, be patient

## UPDATE 02
Changed an `FxHashMap` with a `BTreeMap`. Inconsistency seems to be resolved for now.
bors added a commit that referenced this issue Nov 12, 2017
Improve SubSupConflict with a named and an anonymous lifetime parameter #42701

Hello!

This fixes #42701.

## UPDATE 01
Tests are producing different results between different env builds.
This inconsistency might take a long time to investigate and fix. So, be patient

## UPDATE 02
Changed an `FxHashMap` with a `BTreeMap`. Inconsistency seems to be resolved for now.
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 C-enhancement Category: An issue proposing an enhancement or a PR with one. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants