diff options
| author | bors <bors@rust-lang.org> | 2022-09-08 19:01:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-08 19:01:39 +0000 |
| commit | 1120c5e01df508de64fe6642f22fadeb574afd6d (patch) | |
| tree | 78f3a29b504586b16e14494ce72239c39b69a4fe | |
| parent | 87788097b776f8e3662f76627944230684b671bd (diff) | |
| parent | 76b494a9dd7ba5a151882afc7c85a75c5aeb94db (diff) | |
| download | rust-1120c5e01df508de64fe6642f22fadeb574afd6d.tar.gz rust-1120c5e01df508de64fe6642f22fadeb574afd6d.zip | |
Auto merge of #101437 - compiler-errors:erase-normalize-ordering, r=tmandry
Normalize before erasing late-bound regions in `equal_up_to_regions` Normalize erasing regions **first**, before passing the type through a `BottomUpFolder` which erases late-bound regions too. The root cause of this issue is due to 96d4137deed6c52c6db2dd19568c37d1c160f1e7, which removes a `normalize_erasing_regions` that happens before this call to `equal_up_to_regions`. While reverting that commit might be a fix, I think it was suspicious to be erasing late-bound regions first _then_ normalizing types in the first place in `equal_up_to_regions`. ----- I am tempted to ask the reviewer to review and `r+` this without a UI test, since the existing issues that I think this fixes are all incredibly difficult to minimize (anything hyper/warp related, given the nature of those libraries :sweat:) or impossible to reproduce locally (the miri test), namely: * This recently reported issue with tokio + warp: #101430 * This issue from `@RalfJung` about Miri being broken: #101344 * This additional issue reported in a comment by `@tmandry` (issue with fuchsia + hyper): https://github.com/rust-lang/rust/issues/101344#issuecomment-1235974564 I have locally verified that the repro in #101430 is fixed with this PR, but after a couple of hours of attempting to minimize this error and either failing to actually repro the ICE, or being overwhelmed with the number of traits and functions I need to inline into a UI test, I have basically given up. Thoughts are appreciated on how best to handle this. r? `@oli-obk` who is at the intersection of MIR and types-related stuff who may be able to give advice :sweat_smile:
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 783ab350faa..8576e0f0f7c 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -90,20 +90,21 @@ pub fn equal_up_to_regions<'tcx>( // Normalize lifetimes away on both sides, then compare. let normalize = |ty: Ty<'tcx>| { - let ty = ty.fold_with(&mut BottomUpFolder { - tcx, - // FIXME: We erase all late-bound lifetimes, but this is not fully correct. - // If you have a type like `<for<'a> fn(&'a u32) as SomeTrait>::Assoc`, - // this is not necessarily equivalent to `<fn(&'static u32) as SomeTrait>::Assoc`, - // since one may have an `impl SomeTrait for fn(&32)` and - // `impl SomeTrait for fn(&'static u32)` at the same time which - // specify distinct values for Assoc. (See also #56105) - lt_op: |_| tcx.lifetimes.re_erased, - // Leave consts and types unchanged. - ct_op: |ct| ct, - ty_op: |ty| ty, - }); - tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty) + tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty).fold_with( + &mut BottomUpFolder { + tcx, + // FIXME: We erase all late-bound lifetimes, but this is not fully correct. + // If you have a type like `<for<'a> fn(&'a u32) as SomeTrait>::Assoc`, + // this is not necessarily equivalent to `<fn(&'static u32) as SomeTrait>::Assoc`, + // since one may have an `impl SomeTrait for fn(&32)` and + // `impl SomeTrait for fn(&'static u32)` at the same time which + // specify distinct values for Assoc. (See also #56105) + lt_op: |_| tcx.lifetimes.re_erased, + // Leave consts and types unchanged. + ct_op: |ct| ct, + ty_op: |ty| ty, + }, + ) }; tcx.infer_ctxt().enter(|infcx| infcx.can_eq(param_env, normalize(src), normalize(dest)).is_ok()) } |
