File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
src/test/ui/rfc-2632-const-trait-impl Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ allow( incomplete_features) ]
2
+ #![ feature( allow_internal_unstable) ]
3
+ #![ feature( const_add) ]
4
+ #![ feature( const_trait_impl) ]
5
+ #![ feature( staged_api) ]
6
+
7
+ pub struct Int ( i32 ) ;
8
+
9
+ #[ rustc_const_unstable( feature = "const_add" , issue = "none" ) ]
10
+ impl const std:: ops:: Add for Int {
11
+ type Output = Self ;
12
+
13
+ fn add ( self , rhs : Self ) -> Self {
14
+ Int ( self . 0 + rhs. 0 )
15
+ }
16
+ }
17
+
18
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
19
+ #[ rustc_const_stable( feature = "rust1" , since = "1.0.0" ) ]
20
+ pub const fn foo ( ) -> Int {
21
+ Int ( 1i32 ) + Int ( 2i32 )
22
+ //~^ ERROR can only call other `const fn` within a `const fn`
23
+ }
24
+
25
+ // ok
26
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
27
+ #[ rustc_const_unstable( feature = "bar" , issue = "none" ) ]
28
+ pub const fn bar ( ) -> Int {
29
+ Int ( 1i32 ) + Int ( 2i32 )
30
+ }
31
+
32
+
33
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0723]: can only call other `const fn` within a `const fn`, but `const <Int as std::ops::Add>::add` is not stable as `const fn`
2
+ --> $DIR/stability.rs:21:5
3
+ |
4
+ LL | Int(1i32) + Int(2i32)
5
+ | ^^^^^^^^^^^^^^^^^^^^^
6
+ |
7
+ = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
8
+ = help: add `#![feature(const_fn)]` to the crate attributes to enable
9
+
10
+ error: aborting due to previous error
11
+
12
+ For more information about this error, try `rustc --explain E0723`.
You can’t perform that action at this time.
0 commit comments