From c626fdef07d8d5a255ec16f2a1064ab691b12b9f Mon Sep 17 00:00:00 2001 From: Sergii K Date: Mon, 28 Jul 2025 17:07:56 +0300 Subject: [PATCH] feat: improve unused import warnings --- compiler/src/dmd/semantic3.d | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/compiler/src/dmd/semantic3.d b/compiler/src/dmd/semantic3.d index b3522fca445b..141cd7bfcae0 100644 --- a/compiler/src/dmd/semantic3.d +++ b/compiler/src/dmd/semantic3.d @@ -1839,16 +1839,10 @@ private void checkUnusedImports(Module mod) if (!imp.aliasdecls.length) return; // only check selective imports - bool used = false; foreach (ad; imp.aliasdecls) { - if (ad.wasRead) - { - used = true; - break; - } + if (!ad.wasRead) + global.errorSink.warning(ad.loc, "import `%s` is unused", ad.toChars()); } - if (!used) - global.errorSink.warning(imp.loc, "import `%s` is unused", imp.toChars()); }); }