Skip to content

Commit 60ef5ee

Browse files
committed
run clippy in compile-pass tests if available
1 parent 472e392 commit 60ef5ee

6 files changed

Lines changed: 47 additions & 2 deletions

File tree

.github/workflows/rust.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ jobs:
114114
cd ./tests/smoke-test
115115
cargo +beta clippy
116116
117+
- name: Tests
118+
run: cargo test
119+
117120
embedded:
118121
name: Build (embedded)
119122
runs-on: ubuntu-latest

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ macro_rules! bitflags {
481481
non_upper_case_globals,
482482
clippy::assign_op_pattern,
483483
clippy::indexing_slicing,
484-
clippy::same_name_method
484+
clippy::same_name_method,
485+
clippy::iter_without_into_iter,
485486
)]
486487
const _: () = {
487488
// Declared in a "hidden" scope that can't be reached directly
@@ -553,7 +554,8 @@ macro_rules! bitflags {
553554
unused_mut,
554555
unused_imports,
555556
non_upper_case_globals,
556-
clippy::assign_op_pattern
557+
clippy::assign_op_pattern,
558+
clippy::iter_without_into_iter,
557559
)]
558560
const _: () = {
559561
__impl_public_bitflags! {

tests/compile-pass/item_positions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::let_unit_value)]
2+
13
#[macro_use]
24
extern crate bitflags;
35

tests/compile-pass/missing_docs.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*!
2+
Crate-level doc
3+
*/
4+
5+
#![deny(missing_docs)]
6+
7+
use bitflags::bitflags;
8+
9+
bitflags! {
10+
#[allow(missing_docs)]
11+
pub struct MyFlags: u32 {
12+
#[allow(missing_docs)]
13+
const A = 1;
14+
#[allow(missing_docs)]
15+
const B = 2;
16+
}
17+
}
18+
19+
fn main() {}

tests/compile-pass/pedantic.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![deny(clippy::pedantic)]
2+
3+
use bitflags::bitflags;
4+
5+
bitflags! {
6+
pub struct MyFlags: u32 {
7+
const A = 1;
8+
const B = 2;
9+
}
10+
}
11+
12+
fn main() {}

tests/compile.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ fn fail() {
1111

1212
#[test]
1313
fn pass() {
14+
// If `clippy` is available, then use it
15+
if std::process::Command::new("clippy-driver").arg("--version").output().is_ok() {
16+
println!("Using `clippy`");
17+
18+
std::env::set_var("RUSTC_WORKSPACE_WRAPPER", "clippy-driver");
19+
}
20+
1421
let t = trybuild::TestCases::new();
1522
t.pass("tests/compile-pass/**/*.rs");
1623
}

0 commit comments

Comments
 (0)