]> git.lizzy.rs Git - rust.git/commit
in region, treat current (and future) item-likes alike
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 21 Nov 2016 17:17:13 +0000 (12:17 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 1 Dec 2016 18:59:04 +0000 (13:59 -0500)
commitfa22fc387ad17510d5af9eb16db5e5e01bde38b4
tree16cb5ea18ed47a66a9d7fe31d49c9aaef26bb15d
parent908dba0c9477b7dd022a236cb1514ddfca9369f2
in region, treat current (and future) item-likes alike

The `visit_fn` code mutates its surrounding context.  Between *items*,
this was saved/restored, but between impl items it was not. This meant
that we wound up with `CallSiteScope` entries with two parents (or
more!).  As far as I can tell, this is harmless in actual type-checking,
since the regions you interact with are always from at most one of those
branches. But it can slow things down.

Before, the effect was limited, since it only applied to impl items
within an impl. After #37660, impl items are visisted all together at
the end, and hence this could create a very messed up
hierarchy. Isolating impl item properly solves both issues.

I cannot come up with a way to unit-test this; for posterity, however,
you can observe the messed up hierarchies with a test as simple as the
following, which would create a callsite scope with two parents both
before and after

```
struct Foo {
}

impl Foo {
    fn bar(&self) -> usize {
        22
    }

    fn baz(&self) -> usize {
        22
    }
}

fn main() { }
```

Fixes #37864.
src/librustc/middle/region.rs