Skip to content

Commit 399ab40

Browse files
committed
get rid of normalize_generic_arg... queries
1 parent 8250eef commit 399ab40

File tree

3 files changed

+9
-41
lines changed

3 files changed

+9
-41
lines changed

Diff for: compiler/rustc_middle/src/query/mod.rs

-21
Original file line numberDiff line numberDiff line change
@@ -1658,27 +1658,6 @@ rustc_queries! {
16581658
remap_env_constness
16591659
}
16601660

1661-
// FIXME: Implement `normalize_generic_arg_after_erasing_regions` and
1662-
// `normalize_mir_const_after_erasing_regions` in terms of
1663-
// `try_normalize_generic_arg_after_erasing_regions` and
1664-
// `try_normalize_mir_const_after_erasing_regions`, respectively.
1665-
1666-
/// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1667-
query normalize_generic_arg_after_erasing_regions(
1668-
goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
1669-
) -> GenericArg<'tcx> {
1670-
desc { "normalizing `{}`", goal.value }
1671-
remap_env_constness
1672-
}
1673-
1674-
/// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1675-
query normalize_mir_const_after_erasing_regions(
1676-
goal: ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
1677-
) -> mir::ConstantKind<'tcx> {
1678-
desc { "normalizing `{}`", goal.value }
1679-
remap_env_constness
1680-
}
1681-
16821661
/// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
16831662
query try_normalize_generic_arg_after_erasing_regions(
16841663
goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>

Diff for: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
176176
let arg = self.param_env.and(arg);
177177
debug!(?arg);
178178

179-
self.tcx.normalize_generic_arg_after_erasing_regions(arg)
179+
self.tcx.try_normalize_generic_arg_after_erasing_regions(arg).unwrap_or_else(|_| bug!(
180+
"Failed to normalize {:?}, maybe try to call `try_normalize_erasing_regions` instead",
181+
arg.value
182+
))
180183
}
181184
}
182185

@@ -197,7 +200,9 @@ impl TypeFolder<'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> {
197200
fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx> {
198201
// FIXME: This *probably* needs canonicalization too!
199202
let arg = self.param_env.and(c);
200-
self.tcx.normalize_mir_const_after_erasing_regions(arg)
203+
self.tcx
204+
.try_normalize_mir_const_after_erasing_regions(arg)
205+
.unwrap_or_else(|_| bug!("failed to normalize {:?}", c))
201206
}
202207
}
203208

Diff for: compiler/rustc_traits/src/normalize_erasing_regions.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,14 @@ use std::sync::atomic::Ordering;
88

99
crate fn provide(p: &mut Providers) {
1010
*p = Providers {
11-
normalize_generic_arg_after_erasing_regions: |tcx, goal| {
12-
debug!("normalize_generic_arg_after_erasing_regions(goal={:#?})", goal);
11+
try_normalize_generic_arg_after_erasing_regions: |tcx, goal| {
12+
debug!("try_normalize_generic_arg_after_erasing_regions(goal={:#?}", goal);
1313

1414
tcx.sess
1515
.perf_stats
1616
.normalize_generic_arg_after_erasing_regions
1717
.fetch_add(1, Ordering::Relaxed);
1818

19-
let (param_env, goal) = goal.into_parts();
20-
tcx.try_normalize_erasing_regions(param_env, goal).unwrap_or_else(|_| bug!(
21-
"Failed to normalize {:?}, maybe try to call `try_normalize_erasing_regions` instead",
22-
goal
23-
))
24-
},
25-
normalize_mir_const_after_erasing_regions: |tcx, goal| {
26-
let (param_env, goal) = goal.into_parts();
27-
tcx.try_normalize_erasing_regions(param_env, goal).unwrap_or_else(|_| bug!(
28-
"Failed to normalize {:?}, maybe try to call `try_normalize_erasing_regions` instead",
29-
goal
30-
))
31-
},
32-
try_normalize_generic_arg_after_erasing_regions: |tcx, goal| {
33-
debug!("try_normalize_generic_arg_after_erasing_regions(goal={:#?}", goal);
34-
3519
try_normalize_after_erasing_regions(tcx, goal)
3620
},
3721
try_normalize_mir_const_after_erasing_regions: |tcx, goal| {

0 commit comments

Comments
 (0)