File tree 3 files changed +47
-1
lines changed
compiler/rustc_middle/src/query
src/test/ui/rfc-2632-const-trait-impl
3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -1137,7 +1137,7 @@ rustc_queries! {
1137
1137
}
1138
1138
1139
1139
query impl_constness( def_id: DefId ) -> hir:: Constness {
1140
- desc { |tcx| "looking up whether `{}` is a default impl" , tcx. def_path_str( def_id) }
1140
+ desc { |tcx| "looking up whether `{}` is a const impl" , tcx. def_path_str( def_id) }
1141
1141
}
1142
1142
1143
1143
query check_item_well_formed( key: LocalDefId ) -> ( ) {
Original file line number Diff line number Diff line change
1
+ #![ feature( const_trait_impl) ]
2
+ #![ allow( incomplete_features) ]
3
+
4
+ #[ default_method_body_is_const] //~ ERROR attribute should be applied
5
+ trait A {
6
+ #[ default_method_body_is_const] //~ ERROR attribute should be applied
7
+ fn no_body ( self ) ;
8
+
9
+ #[ default_method_body_is_const]
10
+ fn correct_use ( & self ) { }
11
+ }
12
+
13
+ #[ default_method_body_is_const] //~ ERROR attribute should be applied
14
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: attribute should be applied to a trait method with body
2
+ --> $DIR/attr-misuse.rs:4:1
3
+ |
4
+ LL | #[default_method_body_is_const]
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6
+ LL | / trait A {
7
+ LL | | #[default_method_body_is_const]
8
+ LL | | fn no_body(self);
9
+ LL | |
10
+ LL | | #[default_method_body_is_const]
11
+ LL | | fn correct_use(&self) {}
12
+ LL | | }
13
+ | |_- not a trait method or missing a body
14
+
15
+ error: attribute should be applied to a trait method with body
16
+ --> $DIR/attr-misuse.rs:13:1
17
+ |
18
+ LL | #[default_method_body_is_const]
19
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20
+ LL | fn main() {}
21
+ | ------------ not a trait method or missing a body
22
+
23
+ error: attribute should be applied to a trait method with body
24
+ --> $DIR/attr-misuse.rs:6:5
25
+ |
26
+ LL | #[default_method_body_is_const]
27
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28
+ LL | fn no_body(self);
29
+ | ----------------- not a trait method or missing a body
30
+
31
+ error: aborting due to 3 previous errors
32
+
You can’t perform that action at this time.
0 commit comments