Allow ~const bounds on inherent impls

This commit is contained in:
Deadbeef 2021-09-03 10:37:57 +00:00
parent 146abdd119
commit f749e05f6b
No known key found for this signature in database
GPG Key ID: 027DF9338862ADDD
2 changed files with 24 additions and 1 deletions

View File

@ -1655,7 +1655,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
walk_list!(self, visit_ty, ty); walk_list!(self, visit_ty, ty);
} }
AssocItemKind::Fn(box FnKind(_, ref sig, ref generics, ref body)) AssocItemKind::Fn(box FnKind(_, ref sig, ref generics, ref body))
if self.in_const_trait_impl || ctxt == AssocCtxt::Trait => if self.in_const_trait_impl
|| ctxt == AssocCtxt::Trait
|| matches!(sig.header.constness, Const::Yes(_)) =>
{ {
self.visit_vis(&item.vis); self.visit_vis(&item.vis);
self.visit_ident(item.ident); self.visit_ident(item.ident);

View File

@ -0,0 +1,21 @@
// check-pass
#![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)]
struct S;
trait A {}
trait B {}
impl const A for S {}
impl const B for S {}
impl S {
const fn a<T: ~const A>() where T: ~const B {
}
}
const _: () = S::a::<S>();
fn main() {}