-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
~const
bounds on non-const functions
- Loading branch information
Showing
4 changed files
with
43 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/test/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// check-pass | ||
#![feature(const_trait_impl)] | ||
#![feature(generic_arg_infer)] | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Foo<const N: usize>; | ||
|
||
impl<const N: usize> Foo<N> { | ||
fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> { | ||
Foo | ||
} | ||
} | ||
|
||
#[const_trait] | ||
trait Add42 { | ||
fn add(a: usize) -> usize; | ||
} | ||
|
||
impl const Add42 for () { | ||
fn add(a: usize) -> usize { | ||
a + 42 | ||
} | ||
} | ||
|
||
fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { | ||
Foo | ||
} | ||
|
||
fn main() { | ||
let foo = Foo::<0>; | ||
let foo = bar::<(), _>(foo); | ||
let _foo = bar::<(), _>(foo); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters