Skip to content

Commit

Permalink
Allow ~const bounds on inherent impls
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Sep 9, 2021
1 parent 146abdd commit f749e05
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
walk_list!(self, visit_ty, ty);
}
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_ident(item.ident);
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit f749e05

Please sign in to comment.