]> git.lizzy.rs Git - rust.git/commit
warn if leak-check relies on LBRs that will change
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 21 Apr 2016 09:15:53 +0000 (05:15 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 31 May 2016 23:41:25 +0000 (19:41 -0400)
commit52b2db1cca591a14b9790ce3d11fba39696ae4a7
treed204e1c7999e6c179507086778bf8f4147499400
parent08034eb1a58518f7fc684ad325d32195d48a9fe3
warn if leak-check relies on LBRs that will change

When we do a "HR subtype" check, we replace all late-bound regions (LBR)
in the subtype with fresh variables, and skolemize the late-bound
regions in the supertype. If those skolemized regions from the supertype
wind up being super-regions (directly or indirectly) of either

- another skolemized region; or,
- some region that pre-exists the HR subtype check
  - e.g., a region variable that is not one of those created
    to represent bound regions in the subtype

then the subtype check fails.

What will change when we fix #32330 is that some of the LBR in the
subtype may become early-bound. In that case, they would no longer be in
the "permitted set" of variables that can be related to a skolemized
type.

So the foundation for this warning is to collect variables that we found
to be related to a skolemized type. For each of them, we have a
`BoundRegion` which carries a `Issue32330` flag. We check whether any of
those flags indicate that this variable was created from a lifetime
that will change from late- to early-bound. If so, we issue a warning
indicating that the results of compilation may change.

This is imperfect, since there are other kinds of code that will not
compile once #32330 is fixed. However, it fixes the errors observed in
practice on crater runs.
src/librustc/infer/error_reporting.rs
src/librustc/infer/higher_ranked/mod.rs
src/test/compile-fail/associated-types/cache/project-fn-ret-contravariant.rs [new file with mode: 0644]
src/test/compile-fail/associated-types/cache/project-fn-ret-invariant.rs [new file with mode: 0644]
src/test/compile-fail/associated-types/cache/wasm-issue-32330.rs [new file with mode: 0644]