]> git.lizzy.rs Git - rust.git/commit
Auto merge of #22512 - nikomatsakis:issue-20300-where-clause-not-bounds, r=nikomatsakis
authorbors <bors@rust-lang.org>
Wed, 25 Feb 2015 04:28:23 +0000 (04:28 +0000)
committerbors <bors@rust-lang.org>
Wed, 25 Feb 2015 04:28:23 +0000 (04:28 +0000)
commit880fb89bde126aa43fc348d0b93839d3d18a1f51
tree8bd3d758b1ae6a1f780142109a0e92c55c31e4d6
parentad04cce61c366968098e2adc8594e21e91c578e0
parent1ef3598ed9da3222467d373bc02973e8ecffbaad
Auto merge of #22512 - nikomatsakis:issue-20300-where-clause-not-bounds, r=nikomatsakis

This is a fix for #20300 though as a side-sweep it fixes a number of stack overflows because it integrates cycle detection into the conversion process. I didn't go through and retest everything.

The tricky part here is that in some cases we have to go find the information we need from the AST -- we can't use the converted form of the where-clauses because we often have to handle something like `T::Item` *while converting the where-clauses themselves*. Since this is also not a fixed-point process we can't just try and keep trying to find the best order. So instead I modified the `AstConv` interface to allow you to request the bounds for a type parameter; we'll then do a secondary scan of the where-clauses to figure out what we need. This may create a cycle in some cases, but we have code to catch that.

Another approach that is NOT taken by this PR would be to "convert" `T::Item` into a form that does not specify what trait it's using. This then kind of defers the problem of picking the trait till later. That might be a good idea, but it would make normalization and everything else much harder, so I'm holding off on that (and hoping to find a better way for handling things like `i32::T`).

This PR also removes "most of" the `bounds` struct from `TypeParameterDef`. Still a little ways to go before `ParamBounds` can be removed entirely -- it's used for supertraits, for example (though those really ought to be converted, I think, to a call to `get_type_parameter_bounds` on `Self` from within the trait definition).

cc @jroesch

Fixes #20300