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

Use edition 2024 #1448

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backends/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "necessist-backends"
version = "1.0.4"
edition = "2021"
edition = "2024"

description = "necessist-backends"

Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "necessist-core"
version = "1.0.4"
edition = "2021"
edition = "2024"

description = "necessist-core"

Expand Down
53 changes: 42 additions & 11 deletions core/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ pub fn necessist<Identifier: Applicable + Display + IntoEnumIterator + ToImpleme
}

#[allow(clippy::type_complexity)]
#[cfg_attr(dylint_lib = "supplementary", allow(commented_code))]
fn prepare<Identifier: Applicable + Display + IntoEnumIterator + ToImplementation>(
context: &LightContext,
framework: framework::Auto<Identifier>,
Expand Down Expand Up @@ -228,17 +229,47 @@ fn prepare<Identifier: Applicable + Display + IntoEnumIterator + ToImplementatio
return Ok(None);
}

(context.println)({
let n_source_files = source_file_span_test_map.keys().len();
&format!(
"{} candidates in {} test{} in {} source file{}",
n_spans,
n_tests,
if n_tests == 1 { "" } else { "s" },
n_source_files,
if n_source_files == 1 { "" } else { "s" }
)
});
// smoelius: Curious. The code used to look like:
// ```
// (context.println)({
// let n_source_files = source_file_span_test_map.keys().len();
// &format!(
// ...
// )
// });
// ```
// But with Rust Edition 2024, that would cause the compiler to say:
// ```
// error[E0716]: temporary value dropped while borrowed
// --> core/src/core.rs:233:10
// |
// 233 | &format!(
// | _________-^
// | |__________|
// 234 | || "{} candidates in {} test{} in {} source file{}",
// 235 | || n_spans,
// 236 | || n_tests,
// ... ||
// 239 | || if n_source_files == 1 { "" } else { "s" }
// 240 | || )
// | || ^
// | || |
// | ||_________temporary value is freed at the end of this statement
// | |_________creates a temporary value which is freed while still in use
// | borrow later used here
// |
// = note: consider using a `let` binding to create a longer lived value
// = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
// ```
let n_source_files = source_file_span_test_map.keys().len();
(context.println)(&format!(
"{} candidates in {} test{} in {} source file{}",
n_spans,
n_tests,
if n_tests == 1 { "" } else { "s" },
n_source_files,
if n_source_files == 1 { "" } else { "s" }
));

Ok(Some((backend, n_spans, source_file_span_test_map)))
}
Expand Down
2 changes: 1 addition & 1 deletion fixtures/basic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "basic"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion fixtures/block_ending_in_expression/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "block_ending_in_expression"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion fixtures/cfg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cfg"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[features]
Expand Down
2 changes: 1 addition & 1 deletion fixtures/dry_run_failure/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dry_run_failure"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion fixtures/invalid_pattern/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "invalid_pattern"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion fixtures/invalid_utf8/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "invalid_utf8"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion fixtures/local_function/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "local_function"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion fixtures/parsing_failure/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "parsing_failure"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion fixtures/unknown_keys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "unknown_keys"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion fixtures/valid_pattern/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "valid_pattern"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[workspace]
2 changes: 1 addition & 1 deletion necessist/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "necessist"
version = "1.0.4"
edition = "2021"
edition = "2024"

description = "necessist"

Expand Down
4 changes: 3 additions & 1 deletion necessist/tests/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ fn initialize() {
if cfg!(not(target_os = "linux")) && var("CI").is_ok() {
exit(0);
}
remove_var("CARGO_TERM_COLOR");
unsafe {
remove_var("CARGO_TERM_COLOR");
}
set_current_dir("..").unwrap();
}

Expand Down
4 changes: 3 additions & 1 deletion necessist/tests/third_party_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ struct Task {
}

pub fn all_tests_in(path: impl AsRef<Path>) {
set_var("CARGO_TERM_COLOR", "never");
unsafe {
set_var("CARGO_TERM_COLOR", "never");
}

let mut tests = read_tests_in(path, true);
let n_tests = tests.values().map(Vec::len).sum();
Expand Down
4 changes: 3 additions & 1 deletion necessist/tests/trycmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const TIMEOUT: &str = "5";

#[ctor::ctor]
fn initialize() {
remove_var("CARGO_TERM_COLOR");
unsafe {
remove_var("CARGO_TERM_COLOR");
}
}

#[test]
Expand Down
Loading