From 2b1356d371b52d68243ddebbfcf3f65047c2fd76 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 7 Jul 2026 23:25:49 +0200 Subject: Be more specific on unused objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was downright lazy from my end to not inspect the line of the object that was being unused. Fix this by trying to fetch the bundle's node. This right now applies to variable definitions. Objects like macro arguments are pending to be done. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 9 +++++++-- tests/expected/unused_definition.txt | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 6ad2294..bc74d9e 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -1230,15 +1230,20 @@ impl<'a> Assembler<'a> { global: true, }); } else { + let (line, global) = match &bundle.node { + Some(n) => (n.value.line, false), + None => (0, true), + }; + // Otherwise, we cannot exactly pin down whether this is // harmless or not. Hence, just issue a warning and let // the programmer decide on this. self.warnings.push(Error { - line: 0, + line, message: format!("{} '{full_name}' is unused", bundle.object_type), source, expanded_from: self.macro_context.clone(), - global: true, + global, }); } continue; diff --git a/tests/expected/unused_definition.txt b/tests/expected/unused_definition.txt index 8e851b0..3d76553 100644 --- a/tests/expected/unused_definition.txt +++ b/tests/expected/unused_definition.txt @@ -1 +1 @@ -error: variable 'Var' is unused (def.s) +error: variable 'Var' is unused (def.s: line 2) -- cgit v1.2.3