diff options
| author | bors <bors@rust-lang.org> | 2022-05-12 00:08:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-12 00:08:08 +0000 |
| commit | 0cd939e36c0696aad44a213566c9b152f0437020 (patch) | |
| tree | 2499fbc88c8efc1693dc46f1f9946a5921fec865 /library/alloc/src | |
| parent | cb9cb4d4e10366ea2ce13813fff26b90ab3fec1d (diff) | |
| parent | 493af0b54f97840d3123a4020d178effdf841379 (diff) | |
| download | rust-0cd939e36c0696aad44a213566c9b152f0437020.tar.gz rust-0cd939e36c0696aad44a213566c9b152f0437020.zip | |
Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkov
Implement a lint to warn about unused macro rules
This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros.
```rust
macro_rules! unused_empty {
(hello) => { println!("Hello, world!") };
() => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used
}
fn main() {
unused_empty!(hello);
}
```
Builds upon #96149 and #96156.
Fixes #73576
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/macros.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/library/alloc/src/macros.rs b/library/alloc/src/macros.rs index 22c19243e7f..093b02113c3 100644 --- a/library/alloc/src/macros.rs +++ b/library/alloc/src/macros.rs @@ -56,6 +56,7 @@ macro_rules! vec { // `slice::into_vec` function which is only available with cfg(test) // NB see the slice::hack module in slice.rs for more information #[cfg(all(not(no_global_oom_handling), test))] +#[cfg_attr(not(bootstrap), allow(unused_macro_rules))] macro_rules! vec { () => ( $crate::vec::Vec::new() |
