1
Fork 0

Rollup merge of #99704 - fee1-dead-contrib:add_self_tilde_const_trait, r=oli-obk

Add `Self: ~const Trait` to traits with `#[const_trait]`

r? `@oli-obk`
This commit is contained in:
Yuki Okushi 2022-07-27 19:05:33 +09:00 committed by GitHub
commit 28b44ff5d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 199 additions and 209 deletions

View file

@ -829,6 +829,14 @@ impl<'tcx> TraitPredicate<'tcx> {
pub fn is_const_if_const(self) -> bool {
self.constness == BoundConstness::ConstIfConst
}
pub fn is_constness_satisfied_by(self, constness: hir::Constness) -> bool {
match (self.constness, constness) {
(BoundConstness::NotConst, _)
| (BoundConstness::ConstIfConst, hir::Constness::Const) => true,
(BoundConstness::ConstIfConst, hir::Constness::NotConst) => false,
}
}
}
impl<'tcx> PolyTraitPredicate<'tcx> {

View file

@ -2556,7 +2556,7 @@ define_print_and_forward_display! {
ty::TraitPredicate<'tcx> {
p!(print(self.trait_ref.self_ty()), ": ");
if let ty::BoundConstness::ConstIfConst = self.constness {
if let ty::BoundConstness::ConstIfConst = self.constness && cx.tcx().features().const_trait_impl {
p!("~const ");
}
p!(print(self.trait_ref.print_only_trait_path()))