Skip to content

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

@gaurikholkar-zz

Description

@gaurikholkar-zz

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

Activity

cengiz-io

cengiz-io commented on Jul 17, 2017

@cengiz-io
Contributor

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

nikomatsakis

nikomatsakis commented on Jul 17, 2017

@nikomatsakis
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

gaurikholkar-zz commented on Jul 17, 2017

@gaurikholkar-zz
Author

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

cengiz-io

cengiz-io commented on Aug 16, 2017

@cengiz-io
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

nikomatsakis commented on Aug 30, 2017

@nikomatsakis
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

cengiz-io commented on Sep 5, 2017

@cengiz-io
Contributor

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

cengiz-io

cengiz-io commented on Sep 12, 2017

@cengiz-io
Contributor

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

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 lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @cengiz-io@nikomatsakis@estebank@Mark-Simulacrum@gaurikholkar-zz

      Issue actions

        Improve case with one named, one anonymous lifetime parameter - SubSupConflict Errors · Issue #42701 · rust-lang/rust