Skip to content

Commit a4b0d24

Browse files
committed
Remove canonicalize_hr_query_hack
1 parent 9a8ca69 commit a4b0d24

File tree

3 files changed

+3
-61
lines changed

3 files changed

+3
-61
lines changed

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

-52
Original file line numberDiff line numberDiff line change
@@ -107,38 +107,6 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
107107
&mut query_state,
108108
)
109109
}
110-
111-
/// A hacky variant of `canonicalize_query` that does not
112-
/// canonicalize `'static`. Unfortunately, the existing leak
113-
/// check treats `'static` differently in some cases (see also
114-
/// #33684), so if we are performing an operation that may need to
115-
/// prove "leak-check" related things, we leave `'static`
116-
/// alone.
117-
///
118-
/// `'static` is also special cased when winnowing candidates when
119-
/// selecting implementation candidates, so we also have to leave `'static`
120-
/// alone for queries that do selection.
121-
//
122-
// FIXME(#48536): once the above issues are resolved, we can remove this
123-
// and just use `canonicalize_query`.
124-
pub fn canonicalize_hr_query_hack<V>(
125-
&self,
126-
value: &V,
127-
query_state: &mut OriginalQueryValues<'tcx>,
128-
) -> Canonicalized<'tcx, V>
129-
where
130-
V: TypeFoldable<'tcx>,
131-
{
132-
self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
133-
134-
Canonicalizer::canonicalize(
135-
value,
136-
Some(self),
137-
self.tcx,
138-
&CanonicalizeFreeRegionsOtherThanStatic,
139-
query_state,
140-
)
141-
}
142110
}
143111

144112
/// Controls how we canonicalize "free regions" that are not inference
@@ -254,26 +222,6 @@ impl CanonicalizeRegionMode for CanonicalizeAllFreeRegions {
254222
}
255223
}
256224

257-
struct CanonicalizeFreeRegionsOtherThanStatic;
258-
259-
impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
260-
fn canonicalize_free_region(
261-
&self,
262-
canonicalizer: &mut Canonicalizer<'_, 'tcx>,
263-
r: ty::Region<'tcx>,
264-
) -> ty::Region<'tcx> {
265-
if let ty::ReStatic = r {
266-
r
267-
} else {
268-
canonicalizer.canonical_var_for_region_in_root_universe(r)
269-
}
270-
}
271-
272-
fn any(&self) -> bool {
273-
true
274-
}
275-
}
276-
277225
struct Canonicalizer<'cx, 'tcx> {
278226
infcx: Option<&'cx InferCtxt<'cx, 'tcx>>,
279227
tcx: TyCtxt<'tcx>,

compiler/rustc_trait_selection/src/traits/query/normalize.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
163163
let mut orig_values = OriginalQueryValues::default();
164164
// HACK(matthewjasper) `'static` is special-cased in selection,
165165
// so we cannot canonicalize it.
166-
let c_data = self
167-
.infcx
168-
.canonicalize_hr_query_hack(&self.param_env.and(*data), &mut orig_values);
166+
let c_data =
167+
self.infcx.canonicalize_query(&self.param_env.and(*data), &mut orig_values);
169168
debug!("QueryNormalizer: c_data = {:#?}", c_data);
170169
debug!("QueryNormalizer: orig_values = {:#?}", orig_values);
171170
match tcx.normalize_projection_ty(c_data) {

compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,8 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx {
7676
return Ok(result);
7777
}
7878

79-
// FIXME(#33684) -- We need to use
80-
// `canonicalize_hr_query_hack` here because of things
81-
// like the subtype query, which go awry around
82-
// `'static` otherwise.
8379
let mut canonical_var_values = OriginalQueryValues::default();
84-
let canonical_self =
85-
infcx.canonicalize_hr_query_hack(&query_key, &mut canonical_var_values);
80+
let canonical_self = infcx.canonicalize_query(&query_key, &mut canonical_var_values);
8681
let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?;
8782

8883
let param_env = query_key.param_env;

0 commit comments

Comments
 (0)