diff options
| author | bors <bors@rust-lang.org> | 2022-09-22 04:22:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-22 04:22:24 +0000 |
| commit | 7a8636c843bd24038fe1d1f69b4a8e4b0ea55d4e (patch) | |
| tree | 242508adbaeccdb47f57c20a90717945a433130a /compiler/rustc_borrowck/src | |
| parent | 626b02a8f97a9e35a647aa18fcdb67cbcb3b09c8 (diff) | |
| parent | 898c76cd8257ffd91e9de9714215ece477e1065b (diff) | |
| download | rust-7a8636c843bd24038fe1d1f69b4a8e4b0ea55d4e.tar.gz rust-7a8636c843bd24038fe1d1f69b4a8e4b0ea55d4e.zip | |
Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, r=oli-obk
Require `#[const_trait]` on `Trait` for `impl const Trait` r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_borrowck/src')
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index c51debdc863..d03f0369648 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -428,12 +428,18 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> { } if let ty::FnDef(def_id, substs) = *constant.literal.ty().kind() { + // 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; + self.cx.param_env = prev.without_const(); self.cx.normalize_and_prove_instantiated_predicates( def_id, instantiated_predicates, locations, ); + self.cx.param_env = prev; } } } |
