File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( rustc_attrs, const_trait_impl) ]
2+
3+ const trait Trait {
4+ fn method ( ) { }
5+ }
6+
7+ #[ rustc_comptime]
8+ fn always_const < T : const Trait > ( ) {
9+ T :: method ( )
10+ }
11+
12+ #[ rustc_comptime]
13+ fn conditionally_const < T : [ const ] Trait >( ) {
14+ //~^ ERROR: `[const]` is not allowed here
15+ T :: method ( )
16+ //~^ ERROR: `T: const Trait` is not satisfied
17+ }
18+
19+ #[ rustc_comptime]
20+ fn non_const < T : Trait > ( ) {
21+ T :: method ( )
22+ //~^ ERROR: `T: const Trait` is not satisfied
23+ }
24+
25+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: `[const]` is not allowed here
2+ --> $DIR/trait_bounds.rs:13:27
3+ |
4+ LL | fn conditionally_const<T: [const] Trait>() {
5+ | ^^^^^^^
6+ |
7+ note: this function is not `const`, so it cannot have `[const]` trait bounds
8+ --> $DIR/trait_bounds.rs:13:4
9+ |
10+ LL | fn conditionally_const<T: [const] Trait>() {
11+ | ^^^^^^^^^^^^^^^^^^^
12+
13+ error[E0277]: the trait bound `T: const Trait` is not satisfied
14+ --> $DIR/trait_bounds.rs:15:5
15+ |
16+ LL | T::method()
17+ | ^
18+
19+ error[E0277]: the trait bound `T: const Trait` is not satisfied
20+ --> $DIR/trait_bounds.rs:21:5
21+ |
22+ LL | T::method()
23+ | ^
24+
25+ error: aborting due to 3 previous errors
26+
27+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments