Skip to content

Commit f749e05

Browse files
committed
Allow ~const bounds on inherent impls
1 parent 146abdd commit f749e05

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
16551655
walk_list!(self, visit_ty, ty);
16561656
}
16571657
AssocItemKind::Fn(box FnKind(_, ref sig, ref generics, ref body))
1658-
if self.in_const_trait_impl || ctxt == AssocCtxt::Trait =>
1658+
if self.in_const_trait_impl
1659+
|| ctxt == AssocCtxt::Trait
1660+
|| matches!(sig.header.constness, Const::Yes(_)) =>
16591661
{
16601662
self.visit_vis(&item.vis);
16611663
self.visit_ident(item.ident);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// check-pass
2+
#![feature(const_trait_impl)]
3+
#![feature(const_fn_trait_bound)]
4+
5+
struct S;
6+
7+
trait A {}
8+
trait B {}
9+
10+
impl const A for S {}
11+
impl const B for S {}
12+
13+
impl S {
14+
const fn a<T: ~const A>() where T: ~const B {
15+
16+
}
17+
}
18+
19+
const _: () = S::a::<S>();
20+
21+
fn main() {}

0 commit comments

Comments
 (0)