From 10bc5acf0d6736bc0a99d55beae739878f94de16 Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 16 Mar 2025 22:27:09 -0400 Subject: Document `#![register_tool]` --- tests/ui/tool-attributes/crate-attr.rs | 5 +++++ tests/ui/tool-attributes/multiple-registered.rs | 7 +++++++ tests/ui/tool-attributes/nested-disallowed.rs | 4 ++++ tests/ui/tool-attributes/nested-disallowed.stderr | 8 ++++++++ 4 files changed, 24 insertions(+) create mode 100644 tests/ui/tool-attributes/crate-attr.rs create mode 100644 tests/ui/tool-attributes/multiple-registered.rs create mode 100644 tests/ui/tool-attributes/nested-disallowed.rs create mode 100644 tests/ui/tool-attributes/nested-disallowed.stderr (limited to 'tests') diff --git a/tests/ui/tool-attributes/crate-attr.rs b/tests/ui/tool-attributes/crate-attr.rs new file mode 100644 index 00000000000..c6d7974945f --- /dev/null +++ b/tests/ui/tool-attributes/crate-attr.rs @@ -0,0 +1,5 @@ +//@ check-pass +//@ compile-flags: -Z crate-attr=feature(register_tool) -Z crate-attr=register_tool(foo) + +#[allow(foo::bar)] +fn main() {} diff --git a/tests/ui/tool-attributes/multiple-registered.rs b/tests/ui/tool-attributes/multiple-registered.rs new file mode 100644 index 00000000000..4d54c2dcb08 --- /dev/null +++ b/tests/ui/tool-attributes/multiple-registered.rs @@ -0,0 +1,7 @@ +//@ check-pass + +#![feature(register_tool)] +#![register_tool(foo, bar, baz)] + +#[allow(foo::a, bar::b, baz::c)] +fn main() {} diff --git a/tests/ui/tool-attributes/nested-disallowed.rs b/tests/ui/tool-attributes/nested-disallowed.rs new file mode 100644 index 00000000000..8e780427761 --- /dev/null +++ b/tests/ui/tool-attributes/nested-disallowed.rs @@ -0,0 +1,4 @@ +#![feature(register_tool)] +#![register_tool(foo::bar)] //~ ERROR only accepts identifiers + +fn main() {} diff --git a/tests/ui/tool-attributes/nested-disallowed.stderr b/tests/ui/tool-attributes/nested-disallowed.stderr new file mode 100644 index 00000000000..1af73fc2f19 --- /dev/null +++ b/tests/ui/tool-attributes/nested-disallowed.stderr @@ -0,0 +1,8 @@ +error: `register_tool` only accepts identifiers + --> $DIR/nested-disallowed.rs:2:18 + | +LL | #![register_tool(foo::bar)] + | ^^^^^^^^ not an identifier + +error: aborting due to 1 previous error + -- cgit 1.4.1-3-g733a5