diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 1a1bb37f70a..c3b13278c00 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -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) -> () { diff --git a/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs b/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs new file mode 100644 index 00000000000..338ac3d2505 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.rs @@ -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() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr b/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr new file mode 100644 index 00000000000..3af71d6ff78 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/attr-misuse.stderr @@ -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 +