about summary refs log tree commit diff
path: root/tests/coverage/attr/trait-impl-inherit.rs
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2024-12-19 06:43:09 -0800
committerZalathar <Zalathar@users.noreply.github.com>2024-12-24 00:09:38 +1100
commit0efa90f2464cad23abd371676b592d672d039057 (patch)
tree3d8d30506d9b16dadba3005ce8c92fbc3f9d61fe /tests/coverage/attr/trait-impl-inherit.rs
parent85c39893a761fe4c050523278da4e7e45ab42b6e (diff)
downloadrust-0efa90f2464cad23abd371676b592d672d039057.tar.gz
rust-0efa90f2464cad23abd371676b592d672d039057.zip
Add a test for coverage attr on trait function
Diffstat (limited to 'tests/coverage/attr/trait-impl-inherit.rs')
-rw-r--r--tests/coverage/attr/trait-impl-inherit.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/coverage/attr/trait-impl-inherit.rs b/tests/coverage/attr/trait-impl-inherit.rs
new file mode 100644
index 00000000000..951fecce90a
--- /dev/null
+++ b/tests/coverage/attr/trait-impl-inherit.rs
@@ -0,0 +1,25 @@
+#![feature(coverage_attribute)]
+// Checks that `#[coverage(..)]` in a trait method is not inherited in an
+// implementation.
+//@ edition: 2021
+//@ reference: attributes.coverage.trait-impl-inherit
+
+trait T {
+    #[coverage(off)]
+    fn f(&self) {
+        println!("default");
+    }
+}
+
+struct S;
+
+impl T for S {
+    fn f(&self) {
+        println!("impl S");
+    }
+}
+
+#[coverage(off)]
+fn main() {
+    S.f();
+}