diff options
| author | bors <bors@rust-lang.org> | 2020-11-29 11:37:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-29 11:37:44 +0000 |
| commit | 2e5723137b2b88368d018b262a0a823a1423131b (patch) | |
| tree | c42a79528d17f641eddb4047783149e945464134 | |
| parent | 760430e6fdd70cdb09b5b6d696905c0ee0ea27c8 (diff) | |
| parent | 6354e85e8ff51effe520d358b0810b69f7ecc7cf (diff) | |
| download | rust-2e5723137b2b88368d018b262a0a823a1423131b.tar.gz rust-2e5723137b2b88368d018b262a0a823a1423131b.zip | |
Auto merge of #77616 - jyn514:no-normalize, r=lcnr
Don't run `resolve_vars_if_possible` in `normalize_erasing_regions` Neither `@eddyb` nor I could figure out what this was for. I changed it to `assert_eq!(normalized_value, infcx.resolve_vars_if_possible(&normalized_value));` and it passed the UI test suite. <details><summary> Outdated, I figured out the issue - `needs_infer()` needs to come _after_ erasing the lifetimes </summary> Strangely, if I change it to `assert!(!normalized_value.needs_infer())` it panics almost immediately: ``` query stack during panic: #0 [normalize_generic_arg_after_erasing_regions] normalizing `<str::IsWhitespace as str::pattern::Pattern>::Searcher` #1 [needs_drop_raw] computing whether `str::iter::Split<str::IsWhitespace>` needs drop #2 [mir_built] building MIR for `str::<impl str>::split_whitespace` #3 [unsafety_check_result] unsafety-checking `str::<impl str>::split_whitespace` #4 [mir_const] processing MIR for `str::<impl str>::split_whitespace` #5 [mir_promoted] processing `str::<impl str>::split_whitespace` #6 [mir_borrowck] borrow-checking `str::<impl str>::split_whitespace` #7 [analysis] running analysis passes on this crate end of query stack ``` I'm not entirely sure what's going on - maybe the two disagree? </details> For context, this came up while reviewing https://github.com/rust-lang/rust/pull/77467/ (cc `@lcnr).` Possibly this needs a crater run? r? `@nikomatsakis` cc `@matthewjasper`
| -rw-r--r-- | compiler/rustc_traits/src/normalize_erasing_regions.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_traits/src/normalize_erasing_regions.rs b/compiler/rustc_traits/src/normalize_erasing_regions.rs index 750a0922be4..4841e4286a9 100644 --- a/compiler/rustc_traits/src/normalize_erasing_regions.rs +++ b/compiler/rustc_traits/src/normalize_erasing_regions.rs @@ -2,7 +2,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::traits::query::NoSolution; use rustc_middle::ty::query::Providers; use rustc_middle::ty::subst::GenericArg; -use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt}; +use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt, TypeFoldable}; use rustc_trait_selection::traits::query::normalize::AtExt; use rustc_trait_selection::traits::{Normalized, ObligationCause}; use std::sync::atomic::Ordering; @@ -31,8 +31,14 @@ fn normalize_generic_arg_after_erasing_regions<'tcx>( None, ); - let normalized_value = infcx.resolve_vars_if_possible(normalized_value); - infcx.tcx.erase_regions(normalized_value) + let resolved_value = infcx.resolve_vars_if_possible(normalized_value); + // It's unclear when `resolve_vars` would have an effect in a + // fresh `InferCtxt`. If this assert does trigger, it will give + // us a test case. + debug_assert_eq!(normalized_value, resolved_value); + let erased = infcx.tcx.erase_regions(resolved_value); + debug_assert!(!erased.needs_infer(), "{:?}", erased); + erased } Err(NoSolution) => bug!("could not fully normalize `{:?}`", value), } |
