Skip to content

Commit

Permalink
[meta] update MSRV to Rust 1.81, switch lints from allow to expect
Browse files Browse the repository at this point in the history
This caught a few outdated lints and a few that should have been `cfg(test)`.
  • Loading branch information
sunshowers committed Nov 29, 2024
1 parent 425aefd commit 0b61823
Show file tree
Hide file tree
Showing 30 changed files with 62 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ jobs:
# macos-14 for M1 runners
- macos-14
- windows-latest
# 1.75 is the MSRV
rust-version: ["1.75", stable]
# 1.81 is the MSRV
rust-version: ["1.81", stable]
fail-fast: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ members = [
]

[workspace.package]
rust-version = "1.75"
rust-version = "1.81"
edition = "2021"
license = "MIT OR Apache-2.0"

Expand Down
1 change: 0 additions & 1 deletion cargo-nextest/src/cargo_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ impl<'a> CargoCli<'a> {
}
}

#[allow(dead_code)]
pub(crate) fn add_arg(&mut self, arg: &'a str) -> &mut Self {
self.args.push(Cow::Borrowed(arg));
self
Expand Down
4 changes: 2 additions & 2 deletions cargo-nextest/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ struct TestBuildFilter {
}

impl TestBuildFilter {
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn compute_test_list<'g>(
&self,
ctx: &TestExecuteContext<'_>,
Expand Down Expand Up @@ -2000,7 +2000,7 @@ enum SetupSource {
}

impl SelfCommand {
#[allow(unused_variables)]
#[cfg_attr(not(feature = "self-update"), expect(unused_variables))]
fn exec(self, output: OutputOpts) -> Result<i32> {
let output = output.init();

Expand Down
2 changes: 1 addition & 1 deletion cargo-nextest/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl ExpectedError {
}
}

#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) fn experimental_feature_error(name: &'static str, var_name: &'static str) -> Self {
Self::ExperimentalFeatureNotEnabled { name, var_name }
}
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/tests/integration/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl CargoNextestCli {
}
}

#[allow(dead_code)]
#[expect(dead_code)]
pub fn arg(&mut self, arg: impl Into<String>) -> &mut Self {
self.args.push(arg.into());
self
Expand All @@ -64,7 +64,7 @@ impl CargoNextestCli {
self
}

#[allow(dead_code)]
#[expect(dead_code)]
pub fn envs(
&mut self,
envs: impl IntoIterator<Item = (impl Into<OsString>, impl Into<OsString>)>,
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/tests/integration/temp_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,13 @@ impl TempProject {
})
}

#[allow(dead_code)]
#[expect(dead_code)]
pub fn persist(&mut self) {
if let Some(dir) = self.temp_dir.take() {
_ = dir.into_path();
}
}

#[allow(dead_code)]
pub fn temp_root(&self) -> &Utf8Path {
&self.temp_root
}
Expand Down Expand Up @@ -168,7 +167,7 @@ pub(crate) use windows::*;

#[derive(Clone, Copy, Debug, PartialEq)]
#[must_use]
#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) enum UdsStatus {
Created,
NotCreated,
Expand Down
3 changes: 2 additions & 1 deletion nextest-filtering/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub enum SetDef<S = SourceSpan> {
}

impl SetDef {
#[cfg(test)]
fn drop_source_span(self) -> SetDef<()> {
match self {
Self::Package(matcher, _) => SetDef::Package(matcher, ()),
Expand Down Expand Up @@ -154,7 +155,7 @@ impl ParsedExpr {
ParsedExpr::Set(SetDef::None)
}

#[allow(unused)]
#[cfg(test)]
fn drop_source_span(self) -> ParsedExpr<()> {
match self {
Self::Not(op, expr) => ParsedExpr::Not(op, Box::new(expr.drop_source_span())),
Expand Down
4 changes: 0 additions & 4 deletions nextest-filtering/src/proptest_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) The nextest Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

// https://github.com/proptest-rs/proptest/pull/363, can be removed once that is in a released
// version of proptest.
#![allow(clippy::arc_with_non_send_sync)]

use crate::{
parsing::{
AndOperator, DifferenceOperator, GenericGlob, NotOperator, OrOperator, ParsedExpr, SetDef,
Expand Down
3 changes: 0 additions & 3 deletions nextest-filtering/tests/match.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) The nextest Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

// test_case causes clippy warnings with Rust 1.71.
#![allow(clippy::items_after_test_module)]

use guppy::{
graph::{cargo::BuildPlatform, PackageGraph},
PackageId,
Expand Down
11 changes: 8 additions & 3 deletions nextest-runner/src/cargo_config/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ impl EnvironmentMap {
let mut map = BTreeMap::<imp::EnvKey, CargoEnvironmentVariable>::new();

for (source, name, value) in env_configs {
#[allow(clippy::useless_conversion)]
match map.entry(OsString::from(name.clone()).into()) {
match map.entry(imp::EnvKey::from(name.clone())) {
Entry::Occupied(mut entry) => {
// Ignore the value lower in precedence, but do look at force and relative if
// they haven't been set already.
Expand Down Expand Up @@ -79,7 +78,7 @@ impl EnvironmentMap {
}

pub(crate) fn apply_env(&self, command: &mut Command) {
#[allow(clippy::useless_conversion)]
#[cfg_attr(not(windows), expect(clippy::useless_conversion))]
let existing_keys: BTreeSet<imp::EnvKey> =
std::env::vars_os().map(|(k, _v)| k.into()).collect();

Expand Down Expand Up @@ -250,6 +249,12 @@ mod imp {
}
}

impl From<String> for EnvKey {
fn from(k: String) -> Self {
OsString::from(k).into()
}
}

impl From<EnvKey> for OsString {
fn from(k: EnvKey) -> Self {
k.os_string
Expand Down
10 changes: 5 additions & 5 deletions nextest-runner/src/config/config_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl NextestConfig {
Ok((config.into_config_impl(), compiled))
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn deserialize_individual_config(
graph: &PackageGraph,
workspace_root: &Utf8Path,
Expand Down Expand Up @@ -814,7 +814,7 @@ impl<'cfg> EvaluatableProfile<'cfg> {
})
}

#[allow(dead_code)]
#[cfg(test)]
pub(super) fn custom_profile(&self) -> Option<&'cfg CustomProfileImpl> {
self.custom_profile
}
Expand Down Expand Up @@ -899,10 +899,10 @@ struct NextestConfigDeserialize {

// These are parsed as part of NextestConfigVersionOnly. They're re-parsed here to avoid
// printing an "unknown key" message.
#[allow(unused)]
#[expect(unused)]
#[serde(default)]
nextest_version: Option<NextestVersionDeserialize>,
#[allow(unused)]
#[expect(unused)]
#[serde(default)]
experimental: BTreeSet<String>,

Expand Down Expand Up @@ -1067,8 +1067,8 @@ pub(super) struct CustomProfileImpl {
archive: Option<ArchiveConfig>,
}

#[allow(dead_code)]
impl CustomProfileImpl {
#[cfg(test)]
pub(super) fn test_threads(&self) -> Option<TestThreads> {
self.test_threads
}
Expand Down
6 changes: 3 additions & 3 deletions nextest-runner/src/config/overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl TestSettings {
}
}

#[allow(dead_code)]
#[expect(dead_code)]
impl<Source: Copy> TestSettings<Source> {
pub(super) fn new<'p>(profile: &'p EvaluatableProfile<'_>, query: &TestQuery<'_>) -> Self
where
Expand Down Expand Up @@ -932,7 +932,7 @@ mod tests {
assert_eq!(overrides.success_output(), TestOutputDisplay::Never);
assert_eq!(overrides.failure_output(), TestOutputDisplay::Final);
// For clarity.
#[allow(clippy::bool_assert_comparison)]
#[expect(clippy::bool_assert_comparison)]
{
assert_eq!(overrides.junit_store_success_output(), false);
assert_eq!(overrides.junit_store_failure_output(), false);
Expand Down Expand Up @@ -978,7 +978,7 @@ mod tests {
);
assert_eq!(overrides.failure_output(), TestOutputDisplay::Final);
// For clarity.
#[allow(clippy::bool_assert_comparison)]
#[expect(clippy::bool_assert_comparison)]
{
assert_eq!(overrides.junit_store_success_output(), true);
assert_eq!(overrides.junit_store_failure_output(), false);
Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/double_spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl DoubleSpawnInfo {
#[derive(Debug)]
pub struct DoubleSpawnContext {
// Only used for the Drop impl.
#[allow(dead_code)]
#[expect(dead_code)]
inner: imp::DoubleSpawnContext,
}

Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ extern "C" {
}

#[inline]
#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) fn statically_unreachable() -> ! {
unsafe {
__nextest_external_symbol_that_does_not_exist();
Expand Down
4 changes: 2 additions & 2 deletions nextest-runner/src/indenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::write_str::WriteStr;
use std::io;

/// The set of supported formats for indentation
#[allow(missing_debug_implementations)]
#[expect(missing_debug_implementations)]
pub enum Format<'a> {
/// Insert uniform indentation before every line
///
Expand Down Expand Up @@ -55,7 +55,7 @@ pub enum Format<'a> {
/// lets it intercept each piece of output as its being written to the output buffer. It then
/// splits on newlines giving slices into the original string. Finally we alternate writing these
/// lines and the specified indentation to the output buffer.
#[allow(missing_debug_implementations)]
#[expect(missing_debug_implementations)]
pub struct Indented<'a, D: ?Sized> {
inner: &'a mut D,
needs_indent: bool,
Expand Down
3 changes: 0 additions & 3 deletions nextest-runner/src/list/output_format.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) The nextest Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

// clippy complains about the Arbitrary impl for OutputFormat
#![allow(clippy::unit_arg)]

use crate::{errors::WriteTestListError, write_str::WriteStr};
use owo_colors::Style;
use serde::Serialize;
Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/list/test_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub struct TestList<'g> {

impl<'g> TestList<'g> {
/// Creates a new test list by running the given command and applying the specified filter.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub fn new<I>(
ctx: &TestExecuteContext<'_>,
test_artifacts: I,
Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/reporter/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use quick_junit::{
use std::{borrow::Cow, collections::HashMap, fs::File};

#[derive(Clone, Debug)]
#[allow(dead_code)]
#[expect(dead_code)]
pub(crate) struct EventAggregator<'cfg> {
store_dir: Utf8PathBuf,
// TODO: log information in a JSONable report (converting that to XML later) instead of directly
Expand Down
4 changes: 2 additions & 2 deletions nextest-runner/src/reporter/displayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ fn write_summary_str(run_stats: &RunStats, styles: &Styles, out: &mut String) {

#[derive(Debug)]
enum FinalOutput {
Skipped(#[allow(dead_code)] MismatchReason),
Skipped(#[expect(dead_code)] MismatchReason),
Executed {
run_statuses: ExecutionStatuses,
display_output: bool,
Expand Down Expand Up @@ -1068,7 +1068,7 @@ impl<'a> TestReporterImpl<'a> {
Ok(())
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn write_setup_script_status_line(
&self,
script_id: &ScriptId,
Expand Down
4 changes: 2 additions & 2 deletions nextest-runner/src/reuse_build/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl ArchiveFormat {
/// Archives test binaries along with metadata to the given file.
///
/// The output file is a Zstandard-compressed tarball (`.tar.zst`).
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
pub fn archive_to_file<'a, F>(
profile: EvaluatableProfile<'a>,
binary_list: &'a BinaryList,
Expand Down Expand Up @@ -195,7 +195,7 @@ struct Archiver<'a, W: Write> {
}

impl<'a, W: Write> Archiver<'a, W> {
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
fn new(
config: &'a ArchiveConfig,
binary_list: &'a BinaryList,
Expand Down
Loading

0 comments on commit 0b61823

Please sign in to comment.