Skip to content

Commit

Permalink
Rename flexpect::expect to flexpect::flexpect (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
hkratz authored Sep 27, 2024
1 parent 0691d0a commit 240f7cf
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
toolchain: ${{ matrix.toolchain }}
components: clippy
# Run two tests to ensure that the output is consistent
- name: clippy on just the library should have no warnings
run: cargo clippy --all-features --lib
env:
RUSTFLAGS: "-D warnings"
- name: Run cargo check simple comparison
run: ./tests/compare-output.sh "check --all-features --test simple" "tests/check-expect-supported-simple.out"
- name: Run cargo check submod comparison
Expand All @@ -47,6 +51,7 @@ jobs:
RUSTFLAGS: "-D warnings"
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
# clippy+rustversion only works with clippy >= 1.64.0
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ use proc_macro::TokenStream;

#[rustversion::any(before(1.43.0))]
#[proc_macro_attribute]
pub fn expect(_attr: TokenStream, item: TokenStream) -> TokenStream {
pub fn flexpect(_attr: TokenStream, item: TokenStream) -> TokenStream {
// using #[allow(...)] does not work before 1.43.0 due to a bug
item
}

#[rustversion::all(since(1.43.0), before(1.81))]
#[proc_macro_attribute]
pub fn expect(attr: TokenStream, item: TokenStream) -> TokenStream {
pub fn flexpect(attr: TokenStream, item: TokenStream) -> TokenStream {
replace_attr_with(attr, item, "allow")
}

#[rustversion::since(1.81)]
#[proc_macro_attribute]
pub fn expect(attr: TokenStream, item: TokenStream) -> TokenStream {
pub fn flexpect(attr: TokenStream, item: TokenStream) -> TokenStream {
replace_attr_with(attr, item, "expect")
}

Expand Down
6 changes: 3 additions & 3 deletions tests/check-expect-supported-simple.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
warning: this lint expectation is unfulfilled
--> tests/simple.rs:14:20
--> tests/simple.rs:14:22
|
14 | #[flexpect::expect(unused_variables)]
| ^^^^^^^^^^^^^^^^
14 | #[flexpect::flexpect(unused_variables)]
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
6 changes: 3 additions & 3 deletions tests/check-expect-supported-submod.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
warning: this lint expectation is unfulfilled
--> tests/submod.rs:16:20
--> tests/submod.rs:16:22
|
16 | #[flexpect::expect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^
16 | #[flexpect::flexpect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
12 changes: 6 additions & 6 deletions tests/clippy-expect-supported-simple.out
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
warning: this lint expectation is unfulfilled
--> tests/simple.rs:14:20
--> tests/simple.rs:14:22
|
14 | #[flexpect::expect(unused_variables)]
| ^^^^^^^^^^^^^^^^
14 | #[flexpect::flexpect(unused_variables)]
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: this lint expectation is unfulfilled
--> tests/simple.rs:17:20
--> tests/simple.rs:17:22
|
17 | #[flexpect::expect(clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^^^^^^
17 | #[flexpect::flexpect(clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^^^^^^
12 changes: 6 additions & 6 deletions tests/clippy-expect-supported-submod.out
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
warning: this lint expectation is unfulfilled
--> tests/submod.rs:16:20
--> tests/submod.rs:16:22
|
16 | #[flexpect::expect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^
16 | #[flexpect::flexpect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: this lint expectation is unfulfilled
--> tests/submod.rs:16:38
--> tests/submod.rs:16:40
|
16 | #[flexpect::expect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^^^^^^
16 | #[flexpect::flexpect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^^^^^^
8 changes: 4 additions & 4 deletions tests/simple.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#[test]
#[flexpect::expect(unused_variables)]
#[flexpect::flexpect(unused_variables)]
fn compiler_warning_correctly_flexpected() {
let x = 1;
}

#[flexpect::expect(clippy::clone_on_copy)]
#[flexpect::flexpect(clippy::clone_on_copy)]
#[test]
fn clippy_warning_correctly_flexpected() {
let _ = 32.clone();
}

#[test]
#[flexpect::expect(unused_variables)]
#[flexpect::flexpect(unused_variables)]
fn compiler_warning_incorrectly_flexpected() {}

#[flexpect::expect(clippy::clone_on_copy)]
#[flexpect::flexpect(clippy::clone_on_copy)]
#[test]
fn clippy_warning_incorrectly_flexpected() {}
4 changes: 2 additions & 2 deletions tests/submod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(feature = "submodtests")]

#[flexpect::expect(unused_variables, clippy::clone_on_copy)]
#[flexpect::flexpect(unused_variables, clippy::clone_on_copy)]
mod submod_correct {
#[test]
fn compiler_warning_correctly_flexpected() {
Expand All @@ -13,7 +13,7 @@ mod submod_correct {
}
}

#[flexpect::expect(unused_variables, clippy::clone_on_copy)]
#[flexpect::flexpect(unused_variables, clippy::clone_on_copy)]
mod submod_incorrect {
#[test]
fn compiler_warning_incorrectly_flexpected() {}
Expand Down

0 comments on commit 240f7cf

Please sign in to comment.