|
1 | 1 | use std::assert_matches::assert_matches; |
2 | 2 |
|
3 | | -use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable, extension}; |
| 3 | +use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
4 | 4 |
|
5 | 5 | use super::Const; |
6 | 6 | use crate::mir; |
7 | 7 | use crate::ty::abstract_const::CastKind; |
8 | | -use crate::ty::visit::TypeVisitableExt as _; |
9 | 8 | use crate::ty::{self, Ty, TyCtxt}; |
10 | 9 |
|
11 | | -#[extension(pub(crate) trait UnevaluatedConstEvalExt<'tcx>)] |
12 | | -impl<'tcx> ty::UnevaluatedConst<'tcx> { |
13 | | - /// FIXME(RalfJung): I cannot explain what this does or why it makes sense, but not doing this |
14 | | - /// hurts performance. |
15 | | - #[inline] |
16 | | - fn prepare_for_eval( |
17 | | - self, |
18 | | - tcx: TyCtxt<'tcx>, |
19 | | - param_env: ty::ParamEnv<'tcx>, |
20 | | - ) -> (ty::ParamEnv<'tcx>, Self) { |
21 | | - // HACK(eddyb) this erases lifetimes even though `const_eval_resolve` |
22 | | - // also does later, but we want to do it before checking for |
23 | | - // inference variables. |
24 | | - // Note that we erase regions *before* calling `with_reveal_all_normalized`, |
25 | | - // so that we don't try to invoke this query with |
26 | | - // any region variables. |
27 | | - |
28 | | - // HACK(eddyb) when the query key would contain inference variables, |
29 | | - // attempt using identity args and `ParamEnv` instead, that will succeed |
30 | | - // when the expression doesn't depend on any parameters. |
31 | | - // FIXME(eddyb, skinny121) pass `InferCtxt` into here when it's available, so that |
32 | | - // we can call `infcx.const_eval_resolve` which handles inference variables. |
33 | | - if (param_env, self).has_non_region_infer() { |
34 | | - (tcx.param_env(self.def), ty::UnevaluatedConst { |
35 | | - def: self.def, |
36 | | - args: ty::GenericArgs::identity_for_item(tcx, self.def), |
37 | | - }) |
38 | | - } else { |
39 | | - (tcx.erase_regions(param_env).with_reveal_all_normalized(tcx), tcx.erase_regions(self)) |
40 | | - } |
41 | | - } |
42 | | -} |
43 | | - |
44 | 10 | #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] |
45 | 11 | #[derive(HashStable, TyEncodable, TyDecodable, TypeVisitable, TypeFoldable)] |
46 | 12 | pub enum ExprKind { |
|
0 commit comments