]> git.lizzy.rs Git - rust.git/commit
Auto merge of #37920 - nikomatsakis:compile-time-regression-37864, r=mw
authorbors <bors@rust-lang.org>
Sun, 4 Dec 2016 06:38:38 +0000 (06:38 +0000)
committerbors <bors@rust-lang.org>
Sun, 4 Dec 2016 06:38:38 +0000 (06:38 +0000)
commitd14d74d5f7d39d1e2583bca231c26bbc0d4ee9a0
tree9da857b85ddcf585c9d0fdd089f214ee7c69d9c0
parent125474de07f5391f017b3470ac96a770e52ad60c
parentf8097066f8d40ef2716b6d679324ef894038b261
Auto merge of #37920 - nikomatsakis:compile-time-regression-37864, r=mw

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.

r? @michaelwoerister

cc @pnkfelix -- can you think of a way to make a regr test?