Test for misusing attribute
This commit is contained in:
parent
a79e08ca2a
commit
88b29f5fb2
3 changed files with 47 additions and 1 deletions
|
@ -1137,7 +1137,7 @@ rustc_queries! {
|
||||||
}
|
}
|
||||||
|
|
||||||
query impl_constness(def_id: DefId) -> hir::Constness {
|
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) -> () {
|
query check_item_well_formed(key: LocalDefId) -> () {
|
||||||
|
|
14
src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs
Normal file
14
src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs
Normal file
|
@ -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() {}
|
32
src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr
Normal file
32
src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue