rust/src/librustc_data_structures
bors d2e2ad559e Auto merge of #40570 - nikomatsakis:inference-subtype-through-obligation, r=arielb1
Handle subtyping in inference through obligations

We currently store subtyping relations in the `TypeVariables` structure as a kind of special case. This branch uses normal obligations to propagate subtyping, thus converting our inference variables into normal fallback. It also does a few other things:

- Removes the (unstable, outdated) support for custom type inference fallback.
    - It's not clear how we want this to work, but we know that we don't want it to work the way it currently does.
    - The existing support was also just getting in my way.
- Fixes #30225, which was caused by the trait caching code pretending type variables were normal unification variables, when indeed they were not (but now are).

There is one fishy part of these changes: when computing the LUB/GLB of a "bivariant" type parameter, I currently return the `a` value. Bivariant type parameters are only allowed in a very particular situation, where the type parameter is only used as an associated type output, like this:

```rust
pub struct Foo<A, B>
    where A: Fn() -> B
{
    data: A
}
```

In principle, if one had `T=Foo<A, &'a u32>` and `U=Foo<A, &'b u32>` and (e.g.) `A: for<'a> Fn() -> &'a u32`, then I think that computing the LUB of `T` and `U` might do the wrong thing. Probably the right behavior is just to create a fresh type variable. However, that particular example would not compile (because the where-clause is illegal; `'a` does not appear in any input type). I was not able to make an example that *would* compile and demonstrate this shortcoming, and handling the LUB/GLB was mildly inconvenient, so I left it as is. I am considering whether to revisit this or what.

I have started a crater run to test the impact of these changes.
2017-04-13 00:28:11 +00:00
..
control_flow_graph run rustfmt on control_flow_graph folder 2016-10-20 00:25:19 +05:30
graph Warn unused type aliases 2016-12-15 18:35:20 +09:00
obligation_forest add some comments and debug! calls to "obligation forest" 2017-04-11 20:32:48 -04:00
snapshot_map Replace FnvHasher use with FxHasher. 2016-11-08 15:14:59 +11:00
unify Don't clone in UnificationTable::probe(). 2016-11-18 14:26:22 +11:00
veccell apply rustfmt to librustc_data_structures, correcting rust-lang-nursery/rustfmt#836 2016-03-05 08:40:33 -05:00
accumulate_vec.rs Fix various useless derefs and slicings 2017-03-27 08:58:00 +02:00
array_vec.rs ICH: Hash everything that gets encoded into crate metadata. 2017-04-12 11:42:15 +02:00
base_n.rs Fix various useless derefs and slicings 2017-03-27 08:58:00 +02:00
bitslice.rs Move IdxSetBuf and BitSlice to rustc_data_structures 2016-10-10 20:26:26 -04:00
bitvec.rs SwitchInt over Switch 2017-02-10 19:42:41 +02:00
blake2b.rs ICH: Replace old, transitive metadata hashing with direct hashing approach. 2017-04-12 11:47:26 +02:00
Cargo.toml Remove internal liblog 2017-03-23 11:28:00 -07:00
flock.rs Allow rustc data structures compile to android 2017-02-10 16:34:10 -02:00
fmt_wrap.rs Replace all uses of SHA-256 with BLAKE2b. 2016-10-30 19:14:18 -04:00
fnv.rs Documentation of what does for each type 2016-09-11 17:00:09 +05:30
fx.rs Add FxHasher, a faster alternative to FnvHasher. 2016-11-08 15:14:00 +11:00
indexed_set.rs Fix various useless derefs and slicings 2017-03-27 08:58:00 +02:00
indexed_vec.rs Add resize() method to IndexVec. 2017-03-22 16:11:18 +01:00
ivar.rs apply rustfmt to librustc_data_structures, correcting rust-lang-nursery/rustfmt#836 2016-03-05 08:40:33 -05:00
lib.rs ICH: Replace old, transitive metadata hashing with direct hashing approach. 2017-04-12 11:47:26 +02:00
small_vec.rs Use SmallVec for TypeWalker's stack. 2016-11-22 10:02:04 +11:00
snapshot_vec.rs Plumb inference obligations through selection 2016-05-11 17:29:23 -07:00
stable_hasher.rs ICH: Replace old, transitive metadata hashing with direct hashing approach. 2017-04-12 11:47:26 +02:00
transitive_relation.rs ICH: Hash everything that gets encoded into crate metadata. 2017-04-12 11:42:15 +02:00
tuple_slice.rs Add additional test cases to test all arities of tuple; And remove type suffix - i32 on integers 2016-06-11 22:31:24 +05:30