diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-10-03 17:08:42 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-10-04 08:06:54 +0000 |
| commit | 33bcea8f614f5019012f16b49dc3cd934326ca87 (patch) | |
| tree | b47a72a2d9195bc4d203a1f52c0638a6c15a7fce /compiler/rustc_trait_selection | |
| parent | d9f8b4b98503e3f88623eb59d4f20432161b840a (diff) | |
| download | rust-33bcea8f614f5019012f16b49dc3cd934326ca87.tar.gz rust-33bcea8f614f5019012f16b49dc3cd934326ca87.zip | |
Only allow ~const bounds for traits with #[const_trait]
Diffstat (limited to 'compiler/rustc_trait_selection')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/wf.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 9722b48a68a..ef7b27e408c 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -308,6 +308,10 @@ impl<'tcx> WfPredicates<'tcx> { let obligations = if trait_pred.constness == ty::BoundConstness::NotConst { self.nominal_obligations_without_const(trait_ref.def_id, trait_ref.substs) } else { + if !tcx.has_attr(trait_ref.def_id, rustc_span::sym::const_trait) { + tcx.sess + .span_err(self.span, "~const can only be applied to `#[const_trait]` traits"); + } self.nominal_obligations(trait_ref.def_id, trait_ref.substs) }; |
