diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2022-09-15 15:48:35 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2022-09-16 12:08:46 +0800 |
| commit | 08aeb1aa9b8baff7025fa4ae9958ce2ca0876c40 (patch) | |
| tree | c717af51c70051337deb8c6f6645554110c3b698 | |
| parent | 31f259ce5a400801daecd76760a7665aaf130643 (diff) | |
| download | rust-08aeb1aa9b8baff7025fa4ae9958ce2ca0876c40.tar.gz rust-08aeb1aa9b8baff7025fa4ae9958ce2ca0876c40.zip | |
unconditionally remap to nonconst in borrowck
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 79e7eb0f1cc..9aea99b6a12 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -424,31 +424,19 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { } if let ty::FnDef(def_id, substs) = *constant.literal.ty().kind() { - // N.B.: When instantiating a trait method as a function item, it does not actually matter - // whether the trait is `const` or not, or whether `where T: ~const Tr` needs to be satisfied - // as `const`. If we were to introduce instantiating trait methods as `const fn`s, we would - // check that after this, either via a bound `where F: ~const FnOnce` or when coercing to a - // `const fn` pointer. - // - // FIXME(fee1-dead) FIXME(const_trait_impl): update this doc when trait methods can satisfy - // `~const FnOnce` or can be coerced to `const fn` pointer. - let const_norm = self.tcx().def_kind(def_id) == hir::def::DefKind::AssocFn - && self.tcx().def_kind(ty::DefIdTree::parent(self.tcx(), def_id)) - == hir::def::DefKind::Trait; - + // const_trait_impl: use a non-const param env when checking that a FnDef type is well formed. + // this is because the well-formedness of the function does not need to be proved to have `const` + // impls for trait bounds. let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs); let prev = self.cx.param_env; - if const_norm { - self.cx.param_env = prev.without_const(); - } + self.cx.param_env = prev.without_const(); self.cx.normalize_and_prove_instantiated_predicates( def_id, instantiated_predicates, locations, ); - if const_norm { - self.cx.param_env = prev; - } + self.cx.param_env = prev; + } } } |
