Skip to content

Commit

Permalink
run clippy in compile-pass tests if available
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Oct 9, 2023
1 parent 472e392 commit 60ef5ee
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ jobs:
cd ./tests/smoke-test
cargo +beta clippy
- name: Tests
run: cargo test

embedded:
name: Build (embedded)
runs-on: ubuntu-latest
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ macro_rules! bitflags {
non_upper_case_globals,
clippy::assign_op_pattern,
clippy::indexing_slicing,
clippy::same_name_method
clippy::same_name_method,
clippy::iter_without_into_iter,
)]
const _: () = {
// Declared in a "hidden" scope that can't be reached directly
Expand Down Expand Up @@ -553,7 +554,8 @@ macro_rules! bitflags {
unused_mut,
unused_imports,
non_upper_case_globals,
clippy::assign_op_pattern
clippy::assign_op_pattern,
clippy::iter_without_into_iter,
)]
const _: () = {
__impl_public_bitflags! {
Expand Down
2 changes: 2 additions & 0 deletions tests/compile-pass/item_positions.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::let_unit_value)]

#[macro_use]
extern crate bitflags;

Expand Down
19 changes: 19 additions & 0 deletions tests/compile-pass/missing_docs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*!
Crate-level doc
*/

#![deny(missing_docs)]

use bitflags::bitflags;

bitflags! {
#[allow(missing_docs)]
pub struct MyFlags: u32 {
#[allow(missing_docs)]
const A = 1;
#[allow(missing_docs)]
const B = 2;
}
}

fn main() {}
12 changes: 12 additions & 0 deletions tests/compile-pass/pedantic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![deny(clippy::pedantic)]

use bitflags::bitflags;

bitflags! {
pub struct MyFlags: u32 {
const A = 1;
const B = 2;
}
}

fn main() {}
7 changes: 7 additions & 0 deletions tests/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ fn fail() {

#[test]
fn pass() {
// If `clippy` is available, then use it
if std::process::Command::new("clippy-driver").arg("--version").output().is_ok() {
println!("Using `clippy`");

std::env::set_var("RUSTC_WORKSPACE_WRAPPER", "clippy-driver");
}

let t = trybuild::TestCases::new();
t.pass("tests/compile-pass/**/*.rs");
}

0 comments on commit 60ef5ee

Please sign in to comment.