2020-01-05 00:17:46 +00:00
|
|
|
error[E0308]: `match` arms have incompatible types
|
2022-04-01 17:13:25 +00:00
|
|
|
--> $DIR/old-lub-glb-hr-noteq2.rs:25:14
|
2019-02-20 17:52:23 +00:00
|
|
|
|
|
|
|
|
LL | let z = match 22 {
|
|
|
|
| _____________-
|
2020-06-08 23:12:01 +00:00
|
|
|
LL | | 0 => y,
|
|
|
|
| | - this is found to be of type `for<'a> fn(&'a u8, &'a u8) -> &'a u8`
|
|
|
|
LL | | _ => x,
|
move leak-check to during coherence, candidate eval
In particular, it no longer occurs during the subtyping check. This is
important for enabling lazy normalization, because the subtyping check
will be producing sub-obligations that could affect its results.
Consider an example like
for<'a> fn(<&'a as Mirror>::Item) =
fn(&'b u8)
where `<T as Mirror>::Item = T` for all `T`. We will wish to produce a
new subobligation like
<'!1 as Mirror>::Item = &'b u8
This will, after being solved, ultimately yield a constraint that `'!1
= 'b` which will fail. But with the leak-check being performed on
subtyping, there is no opportunity to normalize `<'!1 as
Mirror>::Item` (unless we invoke that normalization directly from
within subtyping, and I would prefer that subtyping and unification
are distinct operations rather than part of the trait solving stack).
The reason to keep the leak check during coherence and trait
evaluation is partly for backwards compatibility. The coherence change
permits impls for `fn(T)` and `fn(&T)` to co-exist, and the trait
evaluation change means that we can distinguish those two cases
without ambiguity errors. It also avoids recreating #57639, where we
were incorrectly choosing a where clause that would have failed the
leak check over the impl which succeeds.
The other reason to keep the leak check in those places is that I
think it is actually close to the model we want. To the point, I think
the trait solver ought to have the job of "breaking down"
higher-ranked region obligation like ``!1: '2` into into region
obligations that operate on things in the root universe, at which
point they should be handed off to polonius. The leak check isn't
*really* doing that -- these obligations are still handed to the
region solver to process -- but if/when we do adopt that model, the
decision to pass/fail would be happening in roughly this part of the
code.
This change had somewhat more side-effects than I anticipated. It
seems like there are cases where the leak-check was not being enforced
during method proving and trait selection. I haven't quite tracked
this down but I think it ought to be documented, so that we know what
precisely we are committing to.
One surprising test was `issue-30786.rs`. The behavior there seems a
bit "fishy" to me, but the problem is not related to the leak check
change as far as I can tell, but more to do with the closure signature
inference code and perhaps the associated type projection, which
together seem to be conspiring to produce an unexpected
signature. Nonetheless, it is an example of where changing the
leak-check can have some unexpected consequences: we're now failing to
resolve a method earlier than we were, which suggests we might change
some method resolutions that would have been ambiguous to be
successful.
TODO:
* figure out remainig test failures
* add new coherence tests for the patterns we ARE disallowing
2020-05-20 10:19:36 +00:00
|
|
|
| | ^ one type is more general than the other
|
2022-05-20 06:00:42 +00:00
|
|
|
LL | |
|
2019-02-20 17:52:23 +00:00
|
|
|
LL | | };
|
|
|
|
| |_____- `match` arms have incompatible types
|
|
|
|
|
|
2020-06-08 23:12:01 +00:00
|
|
|
= note: expected fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8`
|
|
|
|
found fn pointer `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
|
2019-02-20 17:52:23 +00:00
|
|
|
|
|
|
|
error: aborting due to previous error
|
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0308`.
|