Skip to content

Commit

Permalink
Auto merge of rust-lang#121387 - oli-obk:eager_const_failures_regress…
Browse files Browse the repository at this point in the history
…ion, r=<try>

Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from rust-lang#121087
  • Loading branch information
bors committed Feb 26, 2024
2 parents dc00e8c + c9f78da commit 1298e36
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/interpret/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'tcx> TyCtxt<'tcx> {
let args = GenericArgs::identity_for_item(self, def_id);
let instance = ty::Instance::new(def_id, args);
let cid = GlobalId { instance, promoted: None };
let param_env = self.param_env(def_id).with_reveal_all_normalized(self);
let param_env = self.param_env_reveal_all_normalized(def_id);
self.const_eval_global_id(param_env, cid, None)
}
/// Resolves and evaluates a constant.
Expand Down Expand Up @@ -188,7 +188,7 @@ impl<'tcx> TyCtxtEnsure<'tcx> {
let args = GenericArgs::identity_for_item(self.tcx, def_id);
let instance = ty::Instance::new(def_id, args);
let cid = GlobalId { instance, promoted: None };
let param_env = self.tcx.param_env(def_id).with_reveal_all_normalized(self.tcx);
let param_env = self.tcx.param_env_reveal_all_normalized(def_id);
// Const-eval shouldn't depend on lifetimes at all, so we can erase them, which should
// improve caching of queries.
let inputs = self.tcx.erase_regions(param_env.and(cid));
Expand Down

0 comments on commit 1298e36

Please sign in to comment.