Skip to content

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

Closed
@smoelius

Description

@smoelius

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions