feat(tvix/eval): don't warn twice about dead code
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>
This commit is contained in:
parent
e4687765d7
commit
c9c8b10370
1 changed files with 3 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue