]> git.lizzy.rs Git - rust.git/commit
make generalization code create new variables in correct universe
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 1 Feb 2019 15:41:08 +0000 (10:41 -0500)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Fri, 15 Feb 2019 13:38:26 +0000 (14:38 +0100)
commit4db6a9b82fcf7039c49cff53a6301a9d27f1a4df
treed1de7079e933790d1cd52fc8eeaefad8fc0b9e72
parenta49c9fb8c37081dca139834d4f7d336b443e6d0b
make generalization code create new variables in correct universe

In our type inference system, when we "generalize" a type T to become
a suitable value for a type variable V, we sometimes wind up creating
new inference variables. So, for example, if we are making V be some
subtype of `&'X u32`, then we might instantiate V with `&'Y u32`.
This generalized type is then related `&'Y u32 <: &'X u32`, resulting
in a region constriant `'Y: 'X`. Previously, however, we were making
these fresh variables like `'Y` in the "current universe", but they
should be created in the universe of V. Moreover, we sometimes cheat
in an invariant context and avoid creating fresh variables if we know
the result must be equal -- we can only do that when the universes
work out.
src/librustc/infer/combine.rs
src/librustc/infer/mod.rs
src/librustc/infer/region_constraints/mod.rs
src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr
src/test/ui/associated-types/cache/project-fn-ret-invariant.rs
src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr
src/test/ui/issues/issue-57843.rs [new file with mode: 0644]
src/test/ui/issues/issue-57843.stderr [new file with mode: 0644]