Skip to content

Commit

Permalink
Merge pull request #380 from KodrAus/ci/compile-pass-clippy
Browse files Browse the repository at this point in the history
Allow some new pedantic clippy lints
  • Loading branch information
KodrAus committed Oct 15, 2023
2 parents 472e392 + 03d1427 commit dd91b82
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 11 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/rust.yml
Expand Up @@ -84,18 +84,19 @@ jobs:
cd ./tests/smoke-test
cargo +$msrv build
mips:
name: Tests / MIPS (Big Endian)
miri:
name: "Miri"
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab

- name: Install Cross
run: cargo install cross

- uses: actions/checkout@v3
- name: Install Miri
run: |
rustup toolchain install nightly --component miri
cargo +nightly miri setup
- name: Default features
run: cross test --target mips-unknown-linux-gnu
run: cargo +nightly miri test
- name: BE
run: cargo +nightly miri test --target s390x-unknown-linux-gnu

clippy:
name: Clippy
Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -46,11 +46,17 @@ use bitflags::bitflags;

// The `bitflags!` macro generates `struct`s that manage a set of flags.
bitflags! {
/// Represents a set of flags.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
struct Flags: u32 {
/// The value `A`, at bit position `0`.
const A = 0b00000001;
/// The value `B`, at bit position `1`.
const B = 0b00000010;
/// The value `C`, at bit position `2`.
const C = 0b00000100;

/// The combination of `A`, `B`, and `C`.
const ABC = Self::A.bits() | Self::B.bits() | Self::C.bits();
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
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
1 change: 1 addition & 0 deletions src/tests/iter.rs
Expand Up @@ -3,6 +3,7 @@ use super::*;
use crate::Flags;

#[test]
#[cfg(not(miri))] // Very slow in miri
fn roundtrip() {
for a in 0u8..=255 {
for b in 0u8..=255 {
Expand Down
1 change: 1 addition & 0 deletions src/tests/parser.rs
Expand Up @@ -6,6 +6,7 @@ use crate::{
};

#[test]
#[cfg(not(miri))] // Very slow in miri
fn roundtrip() {
let mut s = String::new();

Expand Down
2 changes: 2 additions & 0 deletions tests/compile-pass/item_positions.rs
@@ -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
@@ -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() {}
2 changes: 2 additions & 0 deletions tests/compile.rs
Expand Up @@ -2,13 +2,15 @@
// an impossible build between error messages emitted on various channels.
// Since https://github.com/dtolnay/trybuild/pull/170 we always need to have a
// `stderr` file for each test so we can't simply ignore the output on different channels.
#[cfg(not(miri))]
#[rustversion::attr(beta, test)]
#[allow(dead_code)]
fn fail() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/compile-fail/**/*.rs");
}

#[cfg(not(miri))]
#[test]
fn pass() {
let t = trybuild::TestCases::new();
Expand Down

0 comments on commit dd91b82

Please sign in to comment.