Skip to content

Commit

Permalink
Adjust dylint_lib uses
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Aug 24, 2023
1 parent e940d62 commit 2cf4911
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 72 deletions.
5 changes: 1 addition & 4 deletions cargo-dylint/tests/dylint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ fn markdown_link_check() {
}

// smoelius: `supply_chain` is the only test that uses `supply_chain.json`. So there is no race.
#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[cfg_attr(dylint_lib = "overscoped_allow", allow(overscoped_allow))]
#[test]
fn supply_chain() {
Expand Down
2 changes: 1 addition & 1 deletion cargo-dylint/tests/package_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn check_dylint_dependencies(path: &Path) -> Result<()> {
Ok(())
}

#[cfg_attr(dylint_lib = "commented_code", allow(commented_code))]
#[cfg_attr(dylint_lib = "supplementary", allow(commented_code))]
#[test]
fn downgrade_upgrade_package() {
let tempdir = tempdir().unwrap();
Expand Down
5 changes: 1 addition & 4 deletions dylint-link/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,7 @@ mod test {
}

#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[test]
fn global_config() {
let cargo_home = tempdir().unwrap();
Expand Down
17 changes: 4 additions & 13 deletions dylint/src/driver_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn is_outdated(opts: &crate::Dylint, toolchain: &str, driver: &Path) -> Result<b
})
}

#[cfg_attr(dylint_lib = "commented_code", allow(commented_code))]
#[cfg_attr(dylint_lib = "supplementary", allow(commented_code))]
fn build(opts: &crate::Dylint, toolchain: &str, driver: &Path) -> Result<()> {
let tempdir = tempdir().with_context(|| "`tempdir` failed")?;
let package = tempdir.path();
Expand Down Expand Up @@ -174,10 +174,7 @@ fn build(opts: &crate::Dylint, toolchain: &str, driver: &Path) -> Result<()> {
.target_directory
.join("debug")
.join(format!("dylint_driver-{toolchain}{}", consts::EXE_SUFFIX));
#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
copy(&binary, driver).with_context(|| {
format!(
"Could not copy `{binary}` to `{}`",
Expand All @@ -189,10 +186,7 @@ fn build(opts: &crate::Dylint, toolchain: &str, driver: &Path) -> Result<()> {
}

// smoelius: `package` is a temporary directory. So there should be no race here.
#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
fn initialize(toolchain: &str, package: &Path) -> Result<()> {
let version_spec = format!("version = \"={}\"", env!("CARGO_PKG_VERSION"));

Expand Down Expand Up @@ -229,10 +223,7 @@ mod test {
use super::*;

// smoelius: `tempdir` is a temporary directory. So there should be no race here.
#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[test]
fn nightly() {
let tempdir = tempdir().unwrap();
Expand Down
12 changes: 3 additions & 9 deletions dylint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(deprecated)]
#![cfg_attr(dylint_lib = "crate_wide_allow", allow(crate_wide_allow))]
#![cfg_attr(dylint_lib = "general", allow(crate_wide_allow))]
#![deny(clippy::expect_used)]
#![deny(clippy::unwrap_used)]
#![deny(clippy::panic)]
Expand Down Expand Up @@ -577,10 +577,7 @@ mod test {
NameToolchainMap::new(&OPTS)
}

#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[test]
fn multiple_libraries_multiple_toolchains() {
let _lock = MUTEX.lock().unwrap();
Expand Down Expand Up @@ -626,10 +623,7 @@ mod test {
//
// https://bugzilla.redhat.com/show_bug.cgi?id=1722181
//
#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[test]
fn multiple_libraries_one_toolchain() {
let _lock = MUTEX.lock().unwrap();
Expand Down
5 changes: 1 addition & 4 deletions dylint/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,7 @@ fn git_dependency_root(config: &Config, dep: &Dependency) -> Result<PathBuf> {
}
}

#[cfg_attr(
dylint_lib = "non_local_effect_before_error_return",
allow(non_local_effect_before_error_return)
)]
#[cfg_attr(dylint_lib = "general", allow(non_local_effect_before_error_return))]
#[cfg_attr(dylint_lib = "overscoped_allow", allow(overscoped_allow))]
fn sample_package_id(dep: &Dependency, source: &mut dyn Source) -> Result<PackageId> {
let mut package_id: Option<PackageId> = None;
Expand Down
5 changes: 1 addition & 4 deletions dylint/src/package_options/revs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ impl<'revs> Iterator for RevIter<'revs> {
// smoelius: I think it is okay to ignore the `non_local_effect_before_error_return` warning
// here. If `self.commit` were not updated, the same commits would be traversed the next time
// `next` was called.
#[cfg_attr(
dylint_lib = "non_local_effect_before_error_return",
allow(non_local_effect_before_error_return)
)]
#[cfg_attr(dylint_lib = "general", allow(non_local_effect_before_error_return))]
#[cfg_attr(dylint_lib = "overscoped_allow", allow(overscoped_allow))]
fn next(&mut self) -> Option<Self::Item> {
(|| -> Result<Option<Rev>> {
Expand Down
5 changes: 1 addition & 4 deletions dylint/src/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#![allow(clippy::single_char_pattern)]
#![allow(clippy::too_many_lines)]
#![allow(clippy::uninlined_format_args)]
#![cfg_attr(dylint_lib = "general", allow(non_local_effect_before_error_return))]
#![cfg_attr(
dylint_lib = "inconsistent_qualification",
allow(inconsistent_qualification)
Expand All @@ -25,10 +26,6 @@
dylint_lib = "misleading_variable_name",
allow(misleading_variable_name)
)]
#![cfg_attr(
dylint_lib = "non_local_effect_before_error_return",
allow(non_local_effect_before_error_return)
)]
#![cfg_attr(dylint_lib = "overscoped_allow", allow(overscoped_allow))]

// smoelius: `DetailedTomlDependency::unused_keys` does not appear in the original.
Expand Down
10 changes: 2 additions & 8 deletions examples/restriction/overscoped_allow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,7 @@ mod test {

static MUTEX: Mutex<()> = Mutex::new(());

#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[test]
fn ui_general() {
let _lock = MUTEX.lock().unwrap();
Expand Down Expand Up @@ -514,10 +511,7 @@ mod test {
);
}

#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[test]
fn ui_test() {
let _lock = MUTEX.lock().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/restriction/overscoped_allow/ui_test/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(clippy::missing_const_for_fn, clippy::manual_assert)]
#![cfg_attr(dylint_lib = "crate_wide_allow", allow(crate_wide_allow))]
#![cfg_attr(dylint_lib = "general", allow(crate_wide_allow))]
#![warn(clippy::panic)]

fn main() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(rustc_private)]
#![allow(unused_imports)]
#![cfg_attr(dylint_lib = "crate_wide_allow", allow(crate_wide_allow))]
#![cfg_attr(dylint_lib = "general", allow(crate_wide_allow))]
#![cfg_attr(
dylint_lib = "inconsistent_qualification",
allow(inconsistent_qualification)
Expand Down
2 changes: 1 addition & 1 deletion examples/supplementary/redundant_reference/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ fn ui() {
);
}

#[cfg_attr(dylint_lib = "commented_code", allow(commented_code))]
#[cfg_attr(dylint_lib = "supplementary", allow(commented_code))]
#[test]
fn ui_no_lifetime_check() {
// smoelius: For some reason, the diagnostic messages are printed in a different order on Linux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![feature(let_chains)]
#![recursion_limit = "256"]
#![allow(clippy::items_after_test_module)]
#![cfg_attr(dylint_lib = "crate_wide_allow", allow(crate_wide_allow))]
#![cfg_attr(dylint_lib = "general", allow(crate_wide_allow))]
#![warn(unused_extern_crates)]

extern crate rustc_data_structures;
Expand Down Expand Up @@ -368,10 +368,7 @@ mod test {

static MUTEX: Mutex<()> = Mutex::new(());

#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[test]
fn general() {
let _lock = MUTEX.lock().unwrap();
Expand Down Expand Up @@ -404,10 +401,7 @@ mod test {
assert_eq!(combined_watchlist.len(), coverage_lines.len());
}

#[cfg_attr(
dylint_lib = "non_thread_safe_call_in_test",
allow(non_thread_safe_call_in_test)
)]
#[cfg_attr(dylint_lib = "general", allow(non_thread_safe_call_in_test))]
#[test]
fn check_inherents() {
let _lock = MUTEX.lock().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/testing/clippy/tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dylint_internal::{clone, env};
use std::{env::set_var, path::Path};
use tempfile::{tempdir, tempdir_in};

#[cfg_attr(dylint_lib = "commented_code", allow(commented_code))]
#[cfg_attr(dylint_lib = "supplementary", allow(commented_code))]
#[test]
fn ui() {
// smoelius: Try to order failures by how informative they are: failure to build the library,
Expand Down
10 changes: 2 additions & 8 deletions internal/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ impl Command {
self
}

#[cfg_attr(
dylint_lib = "non_local_effect_before_error_return",
allow(non_local_effect_before_error_return)
)]
#[cfg_attr(dylint_lib = "general", allow(non_local_effect_before_error_return))]
#[cfg_attr(dylint_lib = "overscoped_allow", allow(overscoped_allow))]
pub fn output(&mut self) -> Result<Output> {
log::debug!("{:?}", self.command.get_envs().collect::<Vec<_>>());
Expand All @@ -83,10 +80,7 @@ impl Command {

// smoelius: Why not get the status by calling `self.output()`? Because we don't want stdout and
// stderr to be captured.
#[cfg_attr(
dylint_lib = "non_local_effect_before_error_return",
allow(non_local_effect_before_error_return)
)]
#[cfg_attr(dylint_lib = "general", allow(non_local_effect_before_error_return))]
#[cfg_attr(dylint_lib = "overscoped_allow", allow(overscoped_allow))]
pub fn success(&mut self) -> Result<()> {
log::debug!("{:?}", self.command.get_envs().collect::<Vec<_>>());
Expand Down

0 comments on commit 2cf4911

Please sign in to comment.