mirror of https://github.com/rust-lang/rust.git
Test for misusing attribute
This commit is contained in:
parent
a79e08ca2a
commit
88b29f5fb2
|
@ -1137,7 +1137,7 @@ rustc_queries! {
|
|||
}
|
||||
|
||||
query impl_constness(def_id: DefId) -> hir::Constness {
|
||||
desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
|
||||
desc { |tcx| "looking up whether `{}` is a const impl", tcx.def_path_str(def_id) }
|
||||
}
|
||||
|
||||
query check_item_well_formed(key: LocalDefId) -> () {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#![feature(const_trait_impl)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
#[default_method_body_is_const] //~ ERROR attribute should be applied
|
||||
trait A {
|
||||
#[default_method_body_is_const] //~ ERROR attribute should be applied
|
||||
fn no_body(self);
|
||||
|
||||
#[default_method_body_is_const]
|
||||
fn correct_use(&self) {}
|
||||
}
|
||||
|
||||
#[default_method_body_is_const] //~ ERROR attribute should be applied
|
||||
fn main() {}
|
|
@ -0,0 +1,32 @@
|
|||
error: attribute should be applied to a trait method with body
|
||||
--> $DIR/attr-misuse.rs:4:1
|
||||
|
|
||||
LL | #[default_method_body_is_const]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | / trait A {
|
||||
LL | | #[default_method_body_is_const]
|
||||
LL | | fn no_body(self);
|
||||
LL | |
|
||||
LL | | #[default_method_body_is_const]
|
||||
LL | | fn correct_use(&self) {}
|
||||
LL | | }
|
||||
| |_- not a trait method or missing a body
|
||||
|
||||
error: attribute should be applied to a trait method with body
|
||||
--> $DIR/attr-misuse.rs:13:1
|
||||
|
|
||||
LL | #[default_method_body_is_const]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | fn main() {}
|
||||
| ------------ not a trait method or missing a body
|
||||
|
||||
error: attribute should be applied to a trait method with body
|
||||
--> $DIR/attr-misuse.rs:6:5
|
||||
|
|
||||
LL | #[default_method_body_is_const]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | fn no_body(self);
|
||||
| ----------------- not a trait method or missing a body
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
Loading…
Reference in New Issue