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

Type error causes cascading region error #30580

Closed
arielb1 opened this issue Dec 27, 2015 · 1 comment
Closed

Type error causes cascading region error #30580

arielb1 opened this issue Dec 27, 2015 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions

Comments

@arielb1
Copy link
Contributor

arielb1 commented Dec 27, 2015

I have encountered this problem several times while compiling versions of rustc with errors, but this is the first self-contained example I have found.

STR

pub struct Foo { a: u32 }
pub struct Pass<'a, 'tcx: 'a>(&'a mut &'a (), &'a &'tcx ());

impl<'a, 'tcx> Pass<'a, 'tcx>
{
    pub fn tcx(&self) -> &'a &'tcx () { self.1 }
    fn lol(&mut self, b: &Foo)
    {
        b.c;
        self.tcx();
    }
}

fn main() {}

Expected Result

A single error as the field c does not exist

Actual Result

<anon>:9:9: 9:12 error: attempted access of field `c` on type `&Foo`, but no field with that name was found
<anon>:9         b.c;
                 ^~~
<anon>:10:14: 10:19 error: cannot infer an appropriate lifetime for lifetime parameter `'tcx` due to conflicting requirements [E0495]
<anon>:10         self.tcx();
                       ^~~~~
<anon>:7:5: 11:6 help: consider using an explicit lifetime parameter as shown: fn lol(&mut self, b: &Foo)
<anon>: 7     fn lol(&mut self, b: &Foo)
<anon>: 8     {
<anon>: 9         b.c;
<anon>:10         self.tcx();
<anon>:11     }
error: aborting due to 2 previous errors

Note the fat cascading region error. This reproduces on 1.5/1.6 and current nightly.

@arielb1 arielb1 added A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions labels Dec 27, 2015
@arielb1
Copy link
Contributor Author

arielb1 commented Dec 27, 2015

cc @pnkfelix

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 9, 2016
reported during the lifetime of this inferencer. Fixes rust-lang#30580.
Manishearth added a commit to Manishearth/rust that referenced this issue Mar 12, 2016
Do not report errors from regionck if other errors were already reported

Do not report errors from regionck if other errors were already reported during the lifetime of this inferencer. Fixes rust-lang#30580.

r? @arielb1
Manishearth added a commit to Manishearth/rust that referenced this issue Mar 13, 2016
Do not report errors from regionck if other errors were already reported

Do not report errors from regionck if other errors were already reported during the lifetime of this inferencer. Fixes rust-lang#30580.

r? @arielb1
alexcrichton pushed a commit to alexcrichton/rust that referenced this issue Mar 16, 2016
reported during the lifetime of this inferencer. Fixes rust-lang#30580.
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 A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

1 participant