Skip to content

Commit 9d4bc35

Browse files
authored
Fix lint errors with newer Rust (#58)
Plus update to Rust 2024, and clean up crate configs. Fixes the CI failures seen in #57: ``` warning: a method with this name may be added to the standard library in the future --> shared/src/inventory_help.rs:119:10 | 119 | file.unlock()?; | ^^^^^^ | = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue #48919 <rust-lang/rust#48919> = help: call with fully qualified syntax `fs2::FileExt::unlock(...)` to keep using the current method = note: `#[warn(unstable_name_collisions)]` on by default ```
1 parent a41f31c commit 9d4bc35

File tree

11 files changed

+87
-77
lines changed

11 files changed

+87
-77
lines changed

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
[workspace]
2+
resolver = "3"
23
members = [
34
"jruby_executable",
45
"ruby_executable",
56
"shared",
67
]
78

9+
[workspace.package]
10+
edition = "2024"
11+
rust-version = "1.85"
12+
813
[workspace.dependencies]
914
java-properties = "2.0.0"
1015
glob = "0.3.1"

jruby_executable/Cargo.toml

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "jruby_executable"
3-
version = "0.1.0"
4-
edition = "2021"
3+
edition.workspace = true
4+
rust-version.workspace = true
55

66
[[bin]]
77
name = "jruby_build"
@@ -17,20 +17,20 @@ path = "src/bin/jruby_changelog.rs"
1717

1818
[dependencies]
1919
java-properties = { workspace = true }
20-
glob = { workspace = true}
21-
clap = { workspace = true}
22-
shared = { workspace = true}
23-
indoc = { workspace = true}
24-
lazy_static = { workspace = true}
25-
flate2 = { workspace = true}
26-
fs-err = { workspace = true}
27-
fun_run = { workspace = true}
28-
nom = { workspace = true}
29-
regex = { workspace = true}
30-
reqwest = { workspace = true}
31-
tar = { workspace = true}
32-
tempfile = { workspace = true}
33-
thiserror = { workspace = true}
20+
glob = { workspace = true }
21+
clap = { workspace = true }
22+
shared = { workspace = true }
23+
indoc = { workspace = true }
24+
lazy_static = { workspace = true }
25+
flate2 = { workspace = true }
26+
fs-err = { workspace = true }
27+
fun_run = { workspace = true }
28+
nom = { workspace = true }
29+
regex = { workspace = true }
30+
reqwest = { workspace = true }
31+
tar = { workspace = true }
32+
tempfile = { workspace = true }
33+
thiserror = { workspace = true }
3434
bullet_stream = { workspace = true }
3535
libherokubuildpack = { workspace = true }
3636
chrono = { workspace = true }

jruby_executable/src/bin/jruby_build.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bullet_stream::{style, Print};
1+
use bullet_stream::{Print, style};
22
use clap::Parser;
33
use fs_err::PathExt;
44
use gem_version::GemVersion;
@@ -7,9 +7,9 @@ use jruby_executable::jruby_build_properties;
77
use libherokubuildpack::inventory;
88
use libherokubuildpack::inventory::artifact::{Arch, Artifact};
99
use shared::{
10-
append_filename_with, artifact_is_different, artifact_same_url_different_checksum,
11-
atomic_inventory_update, download_tar, sha256_from_path, source_dir, tar_dir_to_file,
12-
untar_to_dir, ArtifactMetadata, BaseImage, TarDownloadPath,
10+
ArtifactMetadata, BaseImage, TarDownloadPath, append_filename_with, artifact_is_different,
11+
artifact_same_url_different_checksum, atomic_inventory_update, download_tar, sha256_from_path,
12+
source_dir, tar_dir_to_file, untar_to_dir,
1313
};
1414
use std::convert::From;
1515
use std::error::Error;
@@ -55,7 +55,9 @@ fn jruby_build(args: &Args) -> Result<(), Box<dyn Error>> {
5555
))
5656
.done();
5757
} else {
58-
let url = format!("https://repo1.maven.org/maven2/org/jruby/jruby-dist/{version}/jruby-dist-{version}-bin.tar.gz");
58+
let url = format!(
59+
"https://repo1.maven.org/maven2/org/jruby/jruby-dist/{version}/jruby-dist-{version}-bin.tar.gz"
60+
);
5961
let timer = log
6062
.bullet("Download JRuby")
6163
.sub_bullet(format!("To {}", download_path.as_ref().to_string_lossy()))

jruby_executable/src/bin/jruby_check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use bullet_stream::{style, Print};
1+
use bullet_stream::{Print, style};
22
use clap::Parser;
33
use fun_run::CommandWithName;
44
use indoc::formatdoc;
55
use jruby_executable::jruby_build_properties;
66
use libherokubuildpack::inventory::artifact::Arch;
7-
use shared::{source_dir, BaseImage};
7+
use shared::{BaseImage, source_dir};
88
use std::error::Error;
99
use std::io::Write;
1010
use std::{path::PathBuf, process::Command};

ruby_executable/Cargo.toml

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[package]
22
name = "ruby_executable"
3-
version = "0.1.0"
4-
edition = "2021"
3+
edition.workspace = true
4+
rust-version.workspace = true
55

66
[dependencies]
7-
clap = { workspace = true}
8-
shared = { workspace = true}
9-
indoc = { workspace = true}
10-
flate2 = { workspace = true}
11-
fs-err = { workspace = true}
12-
fun_run = { workspace = true}
13-
nom = { workspace = true}
14-
regex = { workspace = true}
15-
reqwest = { workspace = true}
16-
tar = { workspace = true}
17-
tempfile = { workspace = true}
18-
thiserror = { workspace = true}
7+
clap = { workspace = true }
8+
shared = { workspace = true }
9+
indoc = { workspace = true }
10+
flate2 = { workspace = true }
11+
fs-err = { workspace = true }
12+
fun_run = { workspace = true }
13+
nom = { workspace = true }
14+
regex = { workspace = true }
15+
reqwest = { workspace = true }
16+
tar = { workspace = true }
17+
tempfile = { workspace = true }
18+
thiserror = { workspace = true }
1919
bullet_stream = { workspace = true }
2020
libherokubuildpack = { workspace = true }
2121
chrono = { workspace = true }

ruby_executable/src/bin/ruby_build.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bullet_stream::{style, Print};
1+
use bullet_stream::{Print, style};
22
use clap::Parser;
33
use fs_err::PathExt;
44
use fun_run::CommandWithName;
@@ -9,9 +9,9 @@ use libherokubuildpack::inventory::{
99
artifact::{Arch, Artifact},
1010
};
1111
use shared::{
12-
append_filename_with, artifact_is_different, artifact_same_url_different_checksum,
13-
atomic_inventory_update, download_tar, output_tar_path, sha256_from_path, source_dir,
14-
validate_version_for_stack, ArtifactMetadata, BaseImage, RubyDownloadVersion, TarDownloadPath,
12+
ArtifactMetadata, BaseImage, RubyDownloadVersion, TarDownloadPath, append_filename_with,
13+
artifact_is_different, artifact_same_url_different_checksum, atomic_inventory_update,
14+
download_tar, output_tar_path, sha256_from_path, source_dir, validate_version_for_stack,
1515
};
1616
use std::{
1717
io::Write,

ruby_executable/src/bin/ruby_check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use bullet_stream::{style, Print};
1+
use bullet_stream::{Print, style};
22
use clap::Parser;
33
use fun_run::CommandWithName;
44
use indoc::formatdoc;
55
use libherokubuildpack::inventory::artifact::Arch;
6-
use shared::{output_tar_path, source_dir, BaseImage, RubyDownloadVersion};
6+
use shared::{BaseImage, RubyDownloadVersion, output_tar_path, source_dir};
77
use std::{error::Error, path::PathBuf, process::Command};
88

99
static INNER_OUTPUT: &str = "/tmp/output";

shared/Cargo.toml

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
[package]
22
name = "shared"
3-
version = "0.1.0"
4-
edition = "2021"
3+
edition.workspace = true
4+
rust-version.workspace = true
55

66
[[bin]]
77
name = "inventory_check"
88
path = "src/bin/inventory_check.rs"
99

1010
[dependencies]
11-
glob = { workspace = true}
12-
clap = { workspace = true}
13-
indoc = { workspace = true}
14-
flate2 = { workspace = true}
15-
fs-err = { workspace = true}
16-
fun_run = { workspace = true}
17-
nom = { workspace = true}
18-
regex = { workspace = true}
19-
reqwest = { workspace = true}
20-
tar = { workspace = true}
21-
tempfile = { workspace = true}
22-
thiserror = { workspace = true}
11+
glob = { workspace = true }
12+
clap = { workspace = true }
13+
indoc = { workspace = true }
14+
flate2 = { workspace = true }
15+
fs-err = { workspace = true }
16+
fun_run = { workspace = true }
17+
nom = { workspace = true }
18+
regex = { workspace = true }
19+
reqwest = { workspace = true }
20+
tar = { workspace = true }
21+
tempfile = { workspace = true }
22+
thiserror = { workspace = true }
2323
bullet_stream = { workspace = true }
2424
sha2 = { workspace = true }
2525
chrono = { workspace = true }
@@ -31,7 +31,6 @@ rayon = { workspace = true }
3131
hex = { workspace = true }
3232
gem_version = { workspace = true }
3333

34-
3534
[dev-dependencies]
3635
tiny_http = "0.12.0"
3736
indoc = "2.0.5"

shared/src/inventory_help.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::base_image::DistroVersion;
2-
use crate::{download_tar, Error, TarDownloadPath};
2+
use crate::{Error, TarDownloadPath, download_tar};
33
use chrono::{DateTime, Utc};
44
use fs2::FileExt;
55
use gem_version::GemVersion;
@@ -116,7 +116,7 @@ where
116116
file.read_to_string(&mut contents).map_err(Error::FsError)?;
117117
file.rewind()?;
118118
let result: Result<T, Box<dyn std::error::Error>> = f(&mut file, &contents);
119-
file.unlock()?;
119+
fs2::FileExt::unlock(&file)?;
120120
result
121121
}
122122

shared/src/lib.rs

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use bullet_stream::state::SubBullet;
21
use bullet_stream::Print;
2+
use bullet_stream::state::SubBullet;
33
use fs_err::{File, PathExt};
44
use fun_run::CommandWithName;
55
use libherokubuildpack::inventory::artifact::Arch;
@@ -14,8 +14,8 @@ mod inventory_help;
1414
pub use base_image::BaseImage;
1515
pub use download_ruby_version::RubyDownloadVersion;
1616
pub use inventory_help::{
17-
artifact_is_different, artifact_same_url_different_checksum, atomic_inventory_update,
18-
inventory_check, sha256_from_path, ArtifactMetadata,
17+
ArtifactMetadata, artifact_is_different, artifact_same_url_different_checksum,
18+
atomic_inventory_update, inventory_check, sha256_from_path,
1919
};
2020

2121
/// Appends the given string after the filename and before the `ends_with`
@@ -287,17 +287,21 @@ mod test {
287287

288288
#[test]
289289
fn test_validate_version_for_stack() {
290-
assert!(validate_version_for_stack(
291-
&RubyDownloadVersion::from_str("2.7.3").unwrap(),
292-
&BaseImage::new("heroku-22").unwrap()
293-
)
294-
.is_ok());
295-
296-
assert!(validate_version_for_stack(
297-
&RubyDownloadVersion::from_str("3.0.0").unwrap(),
298-
&BaseImage::new("heroku-22").unwrap()
299-
)
300-
.is_err());
290+
assert!(
291+
validate_version_for_stack(
292+
&RubyDownloadVersion::from_str("2.7.3").unwrap(),
293+
&BaseImage::new("heroku-22").unwrap()
294+
)
295+
.is_ok()
296+
);
297+
298+
assert!(
299+
validate_version_for_stack(
300+
&RubyDownloadVersion::from_str("3.0.0").unwrap(),
301+
&BaseImage::new("heroku-22").unwrap()
302+
)
303+
.is_err()
304+
);
301305
}
302306

303307
#[test]

0 commit comments

Comments
 (0)