Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow-unwrap-in-tests = true no longer works for plain #[test] #10264

Closed
smoelius opened this issue Jan 31, 2023 · 0 comments · Fixed by #10391
Closed

allow-unwrap-in-tests = true no longer works for plain #[test] #10264

smoelius opened this issue Jan 31, 2023 · 0 comments · Fixed by #10391
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@smoelius
Copy link
Contributor

Summary

Since #9686, allow-unwrap-in-tests = true seems to no longer work for plain #[test]. Was this intentional? (cc: @kraktus)

Reproducer

From within the Clippy repo, store the following a file called a.sh:

#! /bin/bash

rm -rf /tmp/a
cargo new /tmp/a
echo 'allow-unwrap-in-tests = true' >/tmp/a/clippy.toml
cat <<EOF >/tmp/a/src/main.rs
#![deny(clippy::unwrap_used)]
fn main() {}
#[test]
fn test() { let _ = Some(0).unwrap(); }
EOF
cargo build && cargo run --bin cargo-clippy -- cargo-clippy --manifest-path=/tmp/a/Cargo.toml --all-targets

Run the following commands:

git checkout 6551754
./a.sh # error: used `unwrap()` on `an Option` value

git checkout 6551754~1
./a.sh # no error (as expected)

Version

rustc 1.66.0-nightly (4b8f43199 2022-10-19)
binary: rustc
commit-hash: 4b8f4319954ff2642690b9e5cbe4af352d095bf6
commit-date: 2022-10-19
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Additional Labels

No response

@smoelius smoelius added the C-bug Category: Clippy is not doing the correct thing label Jan 31, 2023
bors added a commit that referenced this issue Feb 23, 2023
Fix test function checker in `unwrap_used`, `expect_used`

After #9686 , `unwrap` and `expect` in integration tests and raw test functions won't be allowed.

fixes #10011
fixes #10238
fixes #10264

---

changelog: Fix: [`expect_used`], [`unwrap_used`], [`dbg_macro`], [`print_stdout`], [`print_stderr`]: No longer lint in test functions, if the related configuration is set
[#10391](#10391)
<!-- changelog_checked -->
@bors bors closed this as completed in b528cc9 Feb 24, 2023
smoelius added a commit to smoelius/necessist that referenced this issue Feb 27, 2023
rust-lang/rust-clippy#10264 was fixed by
rust-lang/rust-clippy#10391.

Use nightly Clippy to get the fix.
smoelius added a commit to smoelius/necessist that referenced this issue Feb 27, 2023
rust-lang/rust-clippy#10264 was fixed by
rust-lang/rust-clippy#10391.

Use nightly Clippy to get the fix.
smoelius added a commit to smoelius/necessist that referenced this issue Feb 27, 2023
rust-lang/rust-clippy#10264 was fixed by
rust-lang/rust-clippy#10391.

Use nightly Clippy to get the fix.
smoelius added a commit to smoelius/necessist that referenced this issue Feb 27, 2023
rust-lang/rust-clippy#10264 was fixed by
rust-lang/rust-clippy#10391.

Use nightly Clippy to get the fix.
smoelius added a commit to trailofbits/necessist that referenced this issue Feb 27, 2023
rust-lang/rust-clippy#10264 was fixed by
rust-lang/rust-clippy#10391.

Use nightly Clippy to get the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant