Skip to content

Commit

Permalink
deny rw warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Jan 22, 2024
1 parent 5ab5508 commit ba2de1c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 5 additions & 1 deletion ci/scripts/check-dylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ source ci/scripts/common.sh
unset RUSTC_WRAPPER

echo "--- Run dylint check (dev, all features)"
cargo dylint --all -- --all-targets --all-features --locked
# Instead of `-D warnings`, we only deny warnings from our own lints. This is because...
# - Warnings from `check` or `clippy` are already checked in `check.sh`.
# - The toolchain used for linting could be slightly different from the one used to
# compile RisingWave. Warnings from `rustc` itself may produce false positives.
DYLINT_RUSTFLAGS="-D rw_warnings" cargo dylint --all -- --all-targets --all-features --locked
20 changes: 17 additions & 3 deletions lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,26 @@ pub fn register_lints(_sess: &rustc_session::Session, lint_store: &mut rustc_lin

// -- End lint registration --

// Register all lints in the `rw::all` group.
let all_lints = lint_store
// Register lints into groups.
// Note: use `rw_` instead of `rw::` to avoid "error[E0602]: unknown lint tool: `rw`".
register_group(lint_store, "rw_all", |_| true);
register_group(lint_store, "rw_warnings", |l| {
l.default_level >= rustc_lint::Level::Warn
});
}

fn register_group(
lint_store: &mut rustc_lint::LintStore,
name: &'static str,
filter_predicate: impl Fn(&rustc_lint::Lint) -> bool,
) {
let lints = lint_store
.get_lints()
.iter()
.filter(|l| l.name.starts_with("rw::"))
.filter(|l| filter_predicate(l))
.map(|l| rustc_lint::LintId::of(l))
.collect();
lint_store.register_group(true, "rw::all", None, all_lints);

lint_store.register_group(true, name, None, lints);
}

0 comments on commit ba2de1c

Please sign in to comment.