Issue #919: rustc’s dead-code warnings reach the user in Rust’s words; Nikaia has to give them itself

Open and answer this issue on GitHub.

ready · opened 2026-10-28 · updated 2026-10-28 · 0 comments

Seen in the probe of #918, on develop at 642b0d9.

Probe

enum Bad { Neg, Big }
impl Error for Bad { fn message(ref self) -> String { return "bad" } }

fn risky(n: i64) -> i64 throws {
    if n < 0 { throw Bad::Neg }
    return n
}

fn main() throws {
    let v = risky(-1) catch { 0 }
    println(f"{v}")
}

nikaia run shows rustc’s warning, with Rust’s vocabulary:

warning: Variant `Big` is never constructed.
  --> f2.nika:1:1
   = note: `Bad` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis.

Why it matters

To build

  1. Inventory, with a probe each: which rustc warnings a program can bring out today (a variant never constructed, a function never called, a field never read, a local never read, mut never needed, unreachable code, an unused use, …). Write the list into this issue as a comment, with which of them Nikaia already says itself.
  2. Nikaia’s own warning for each, in the checker, on the .nika span, in Nikaia’s words with a way out (C.2): a code per class from a block the supervisor reserves, the specification text and Part III’s code table written with it (a short ADR if a class needs a decision, e.g. what counts as used for a pub item or across a package).
  3. rustc’s lint for that class switched off in the emitted program once Nikaia gives it, so the user is told once, in Nikaia’s words; a class not yet owned stays visible until it is.
  4. Tests in Nikaia (tests/compiler/tests/, .stderr): each class warned once, in Nikaia’s words, with no rustc text.

Back to Open Issues