From fb3e4b349a7b9e7bceb1f222551483550ee42ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 9 Dec 2022 15:21:12 -0800 Subject: [PATCH] Account for macros in const generics --- compiler/rustc_lint/src/unused.rs | 1 + src/test/ui/lint/unused_braces_macro.rs | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 src/test/ui/lint/unused_braces_macro.rs diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index b5db94f8c06..4699f7487e6 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1138,6 +1138,7 @@ fn check_unused_delims_expr( && !cx.sess().source_map().is_multiline(value.span) && value.attrs.is_empty() && !value.span.from_expansion() + && !inner.span.from_expansion() { self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos) } diff --git a/src/test/ui/lint/unused_braces_macro.rs b/src/test/ui/lint/unused_braces_macro.rs new file mode 100644 index 00000000000..bfee95378bf --- /dev/null +++ b/src/test/ui/lint/unused_braces_macro.rs @@ -0,0 +1,6 @@ +// build-pass +pub fn foo () {} + +fn main() { + foo::<{cfg!(feature = "foo")}>(); +}