]> git.lizzy.rs Git - rust.git/commit
factor variances into a proper query
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 24 Apr 2017 15:15:12 +0000 (11:15 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 3 May 2017 20:42:07 +0000 (16:42 -0400)
commit4824a199ca3c6c1c12c90f0146db540045220c9a
tree13fc7438a45773d7d0d3ea4f94d706be650b4f20
parent55412a201aa687e16cb76681d8dc7d595253800d
factor variances into a proper query

There are now two queries: crate and item. The crate one computes the
variance of all items in the crate; it is sort of an implementation
detail, and not meant to be used. The item one reads from the crate one,
synthesizing correct deps in lieu of the red-green algorithm.

At the same time, remove the `variance_computed` flag, which was a
horrible hack used to force invariance early on (e.g. when type-checking
constants). This is only needed because of trait applications, and
traits are always invariant anyway. Therefore, we now change to take
advantage of the query system:

- When asked to compute variances for a trait, just return a vector
  saying 'all invariant'.
- Remove the corresponding "inferreds" from traits, and tweak the
  constraint generation code to understand that traits are always
  inferred.
13 files changed:
src/librustc/dep_graph/dep_node.rs
src/librustc/ty/context.rs
src/librustc/ty/maps.rs
src/librustc/ty/mod.rs
src/librustc/ty/relate.rs
src/librustc_data_structures/transitive_relation.rs
src/librustc_typeck/lib.rs
src/librustc_typeck/variance/README.md
src/librustc_typeck/variance/constraints.rs
src/librustc_typeck/variance/mod.rs
src/librustc_typeck/variance/solve.rs
src/librustc_typeck/variance/terms.rs
src/test/compile-fail/dep-graph-variance-alias.rs [new file with mode: 0644]