diff options
author | Florian Klink <flokli@flokli.de> | 2023-02-03T11·38+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-03-11T14·26+0000 |
commit | c9c8b103701411eddcc00955d30eaa667091963f (patch) | |
tree | dbbea77caa282c46627d37b1d964aff6fc7f409c | |
parent | e4687765d79bc07c1252743fe655f0c054ef9ead (diff) |
feat(tvix/eval): don't warn twice about dead code r/5954
We currently send two warnings in case of detecting dead code - W008 inside compile_dead_code, and a more detailed warning in all places that invoke compile_dead_code: ``` warning[W007]: useless operation on boolean: this expression is always false --> /nix/store/qz3gjn95gazab4fkb7s8lm6hz17rdzzy-414z9nnj1wy66ymq6vgb693x9xjz6hf2-nixpkgs-src/pkgs/top-level/perl-packages.nix:12079:15 | 12079 | doCheck = false && !stdenv.isDarwin; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning[W008]: this code will never be executed --> /nix/store/qz3gjn95gazab4fkb7s8lm6hz17rdzzy-414z9nnj1wy66ymq6vgb693x9xjz6hf2-nixpkgs-src/pkgs/top-level/perl-packages.nix:12079:24 | 12079 | doCheck = false && !stdenv.isDarwin; | ^^^^^^^^^^^^^^^^ ``` The place invoking `compile_dead_code` has more context to why the code is unused, so it's error message is much more useful. Stop emitting the less informative warning inside compile_dead_code (W008), and update the comment that we expect the caller to emit a warning. I kept W008 itself still around, in case we end up having places this will get used again. Change-Id: I2c5d84fc0cb4035872cd4b71cc3e9e34e120eb37 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8024 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz>
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index a59f935b0494..69c232926b41 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -302,9 +302,11 @@ impl Compiler<'_> { /// Compiles an expression, but does not emit any code for it as /// it is considered dead. This will still catch errors and /// warnings in that expression. + /// + /// A warning about the that code being dead is assumed to already be + /// emitted by the caller of [compile_dead_code]. fn compile_dead_code(&mut self, slot: LocalIdx, node: ast::Expr) { self.dead_scope += 1; - self.emit_warning(&node, WarningKind::DeadCode); self.compile(slot, node); self.dead_scope -= 1; } |