This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +89
-0
lines changed
src/test/ui/rfc-2632-const-trait-impl Expand file tree Collapse file tree 4 files changed +89
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( const_trait_impl) ]
2
+ #![ allow( incomplete_features) ]
3
+
4
+ #![ feature( staged_api) ]
5
+ #![ stable( feature = "rust1" , since = "1.0.0" ) ]
6
+
7
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
8
+ pub trait MyTrait {
9
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
10
+ fn func ( ) ;
11
+ }
12
+
13
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
14
+ pub struct Unstable ;
15
+
16
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
17
+ #[ rustc_const_unstable( feature = "staged" , issue = "none" ) ]
18
+ impl const MyTrait for Unstable {
19
+ fn func ( ) {
20
+
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ // revisions: stock staged
2
+ #![ cfg_attr( staged, feature( staged) ) ]
3
+
4
+ #![ feature( const_trait_impl) ]
5
+ #![ allow( incomplete_features) ]
6
+
7
+ #![ feature( staged_api) ]
8
+ #![ stable( feature = "rust1" , since = "1.0.0" ) ]
9
+
10
+ // aux-build: staged-api.rs
11
+ extern crate staged_api;
12
+
13
+ use staged_api:: * ;
14
+
15
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
16
+ pub struct Stable ;
17
+
18
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
19
+ #[ cfg_attr( staged, rustc_const_stable( feature = "rust1" , since = "1.0.0" ) ) ]
20
+ // ^ should trigger error with or without the attribute
21
+ impl const MyTrait for Stable {
22
+ fn func ( ) { //~ ERROR trait methods cannot be stable const fn
23
+
24
+ }
25
+ }
26
+
27
+ fn non_const_context ( ) {
28
+ Unstable :: func ( ) ;
29
+ Stable :: func ( ) ;
30
+ }
31
+
32
+ #[ unstable( feature = "none" , issue = "none" ) ]
33
+ const fn const_context ( ) {
34
+ Unstable :: func ( ) ;
35
+ //[stock]~^ ERROR `<staged_api::Unstable as staged_api::MyTrait>::func` is not yet stable as a const fn
36
+ Stable :: func ( ) ;
37
+ }
38
+
39
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: trait methods cannot be stable const fn
2
+ --> $DIR/staged-api.rs:22:5
3
+ |
4
+ LL | / fn func() {
5
+ LL | |
6
+ LL | | }
7
+ | |_____^
8
+
9
+ error: aborting due to previous error
10
+
Original file line number Diff line number Diff line change
1
+ error: trait methods cannot be stable const fn
2
+ --> $DIR/staged-api.rs:22:5
3
+ |
4
+ LL | / fn func() {
5
+ LL | |
6
+ LL | | }
7
+ | |_____^
8
+
9
+ error: `<staged_api::Unstable as staged_api::MyTrait>::func` is not yet stable as a const fn
10
+ --> $DIR/staged-api.rs:34:5
11
+ |
12
+ LL | Unstable::func();
13
+ | ^^^^^^^^^^^^^^^^
14
+ |
15
+ = help: add `#![feature(staged)]` to the crate attributes to enable
16
+
17
+ error: aborting due to 2 previous errors
18
+
You can’t perform that action at this time.
0 commit comments