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

Chore: Rust 1.83.0 & Lint Fix #302

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 4 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: yarn
- uses: dtolnay/rust-toolchain@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.82.0
components: rustfmt
components: rustfmt, clippy
- run: yarn --frozen-lockfile
- run: yarn lint

Expand Down Expand Up @@ -67,9 +66,7 @@ jobs:
with:
cache: yarn
node-version: ${{ matrix.node }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.82.0
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.os }}
Expand Down Expand Up @@ -98,9 +95,7 @@ jobs:
with:
cache: yarn
node-version: ${{ matrix.node }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.82.0
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.os }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.82.0
target: ${{ matrix.target }}
- uses: bahmutov/[email protected]
- uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -139,9 +138,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.82.0
target: ${{ matrix.target }}
- name: Install cross compile toolchains
run: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/repl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ jobs:
with:
cache: yarn
node-version: 20
- uses: dtolnay/rust-toolchain@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.82.0
targets: wasm32-unknown-unknown
target: wasm32-unknown-unknown
- name: Install wasm-opt
run: |
curl -L -O https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-linux.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion crates/atlaspack/src/atlaspack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ mod tests {
rpc(),
)?;

let assets = vec!["foo", "bar", "baz"];
let assets = ["foo", "bar", "baz"];

atlaspack.commit_assets(
&assets
Expand Down
28 changes: 11 additions & 17 deletions crates/atlaspack/src/project_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,54 +118,48 @@ mod tests {
#[test]
fn returns_none_when_there_is_no_common_path() {
assert_eq!(
common_path(&vec![PathBuf::from("dist"), PathBuf::from("src")]),
common_path(&[PathBuf::from("dist"), PathBuf::from("src")]),
None,
);

assert_eq!(
common_path(&vec![
PathBuf::from("dist"),
PathBuf::from("packages").join("foo"),
]),
common_path(&[PathBuf::from("dist"), PathBuf::from("packages").join("foo")]),
None,
);
}

#[test]
fn returns_the_common_prefix() {
assert_eq!(
common_path(&vec![PathBuf::from("/")]),
Some(PathBuf::from("/"))
);
assert_eq!(common_path(&[PathBuf::from("/")]), Some(PathBuf::from("/")));

assert_eq!(
common_path(&vec![PathBuf::from("src")]),
common_path(&[PathBuf::from("src")]),
Some(PathBuf::from("src"))
);

assert_eq!(
common_path(&vec![
common_path(&[
PathBuf::from("packages/foo"),
PathBuf::from("packages/bar"),
PathBuf::from("packages/baz"),
PathBuf::from("packages/baz")
]),
Some(PathBuf::from("packages"))
);

assert_eq!(
common_path(&vec![
common_path(&[
PathBuf::from("packages/foo"),
PathBuf::from("packages/foo/a.js"),
PathBuf::from("packages/foo/bar/b.js"),
PathBuf::from("packages/foo/bar/b.js")
]),
Some(PathBuf::from("packages").join("foo"))
);

assert_eq!(
common_path(&vec![
common_path(&[
PathBuf::from("packages/foo/a.js"),
PathBuf::from("packages/bar/b.js"),
PathBuf::from("packages/baz/c.js"),
PathBuf::from("packages/baz/c.js")
]),
Some(PathBuf::from("packages"))
);
Expand Down Expand Up @@ -312,7 +306,7 @@ mod tests {

fs.set_current_working_directory(&cwd());
fs.create_directory(&vcs)
.expect(format!("Expected {} directory to be created", vcs.display()).as_str());
.unwrap_or_else(|_| panic!("Expected {} directory to be created", vcs.display()));

assert_eq!(
infer_project_root(fs, entries).map_err(|e| e.to_string()),
Expand Down
8 changes: 4 additions & 4 deletions crates/atlaspack/src/requests/asset_graph_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ mod tests {
asset_graph_request_result
.graph
.assets
.get(0)
.first()
.unwrap()
.asset
.file_path,
Expand All @@ -578,7 +578,7 @@ mod tests {
asset_graph_request_result
.graph
.assets
.get(0)
.first()
.unwrap()
.asset
.code,
Expand All @@ -589,7 +589,7 @@ mod tests {
"#
)
.trim_start()
.trim_end_matches(|p| p == ' ')
.trim_end_matches(' ')
.to_string()
))
);
Expand Down Expand Up @@ -672,7 +672,7 @@ mod tests {
asset_graph_request_result
.graph
.assets
.get(0)
.first()
.unwrap()
.asset
.file_path,
Expand Down
14 changes: 6 additions & 8 deletions crates/atlaspack/src/requests/target_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,9 @@ mod tests {
}}
}}
"#,
module_format.map_or_else(
|| String::default(),
|module_format| format!(r#""type": "{module_format}","#)
),
module_format.map_or_else(String::default, |module_format| format!(
r#""type": "{module_format}","#
)),
),
None,
None,
Expand Down Expand Up @@ -1734,10 +1733,9 @@ mod tests {
}}
}}
"#,
module_format.map_or_else(
|| String::default(),
|module_format| format!(r#""type": "{module_format}","#)
),
module_format.map_or_else(String::default, |module_format| format!(
r#""type": "{module_format}","#
)),
),
None,
None,
Expand Down
2 changes: 1 addition & 1 deletion crates/atlaspack_config/src/atlaspack_rc_config_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ mod tests {

let err = AtlaspackRcConfigLoader::new(fs, package_manager)
.load(
&&project_root,
&project_root,
LoadConfigOptions {
additional_reporters: Vec::new(),
config: Some("@scope/config"),
Expand Down
38 changes: 19 additions & 19 deletions crates/atlaspack_config/src/map/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ mod tests {
for path in paths("a.ts") {
let is_match = named_pattern_matcher(&path);

assert_eq!(is_match("*.t", ""), false);
assert_eq!(is_match("*.tsx", ""), false);
assert_eq!(is_match("types:*.{ts,tsx}", ""), false);
assert_eq!(is_match("url:*", ""), false);
assert!(!is_match("*.t", ""));
assert!(!is_match("*.tsx", ""));
assert!(!is_match("types:*.{ts,tsx}", ""));
assert!(!is_match("url:*", ""));
}
}

Expand All @@ -54,8 +54,8 @@ mod tests {
for path in paths("a.ts") {
let is_match = named_pattern_matcher(&path);

assert_eq!(is_match("types:*.{ts,tsx}", "type"), false);
assert_eq!(is_match("types:*.{ts,tsx}", "typesa"), false);
assert!(!is_match("types:*.{ts,tsx}", "type"));
assert!(!is_match("types:*.{ts,tsx}", "typesa"));
}
}

Expand All @@ -64,9 +64,9 @@ mod tests {
for path in paths("a.ts") {
let is_match = named_pattern_matcher(&path);

assert_eq!(is_match("*.{ts,tsx}", ""), true);
assert_eq!(is_match("*.ts", ""), true);
assert_eq!(is_match("*", ""), true);
assert!(is_match("*.{ts,tsx}", ""));
assert!(is_match("*.ts", ""));
assert!(is_match("*", ""));
}
}

Expand All @@ -75,9 +75,9 @@ mod tests {
for path in paths("a.ts") {
let is_match = named_pattern_matcher(&path);

assert_eq!(is_match("types:*.{ts,tsx}", "types"), true);
assert_eq!(is_match("types:*.ts", "types"), true);
assert_eq!(is_match("types:*", "types"), true);
assert!(is_match("types:*.{ts,tsx}", "types"));
assert!(is_match("types:*.ts", "types"));
assert!(is_match("types:*", "types"));
}
}
}
Expand All @@ -90,10 +90,10 @@ mod tests {
for path in paths("a.ts") {
let is_match = pattern_matcher(&path);

assert_eq!(is_match("*.t"), false);
assert_eq!(is_match("*.tsx"), false);
assert_eq!(is_match("types:*.{ts,tsx}"), false);
assert_eq!(is_match("url:*"), false);
assert!(!is_match("*.t"));
assert!(!is_match("*.tsx"));
assert!(!is_match("types:*.{ts,tsx}"));
assert!(!is_match("url:*"));
}
}

Expand All @@ -102,9 +102,9 @@ mod tests {
for path in paths("a.ts") {
let is_match = pattern_matcher(&path);

assert_eq!(is_match("*.{ts,tsx}"), true);
assert_eq!(is_match("*.ts"), true);
assert_eq!(is_match("*"), true);
assert!(is_match("*.{ts,tsx}"));
assert!(is_match("*.ts"));
assert!(is_match("*"));
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions crates/atlaspack_config/src/map/named_pipelines_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,15 @@ mod tests {
String::from("data-url:*") => pipelines("1")
});

assert_eq!(map.contains_named_pipeline("data-url"), true);
assert!(map.contains_named_pipeline("data-url"));
}

#[test]
fn returns_false_for_empty_map() {
let empty_map = NamedPipelinesMap::default();

assert_eq!(empty_map.contains_named_pipeline("data-url"), false);
assert_eq!(empty_map.contains_named_pipeline("types"), false);
assert!(!empty_map.contains_named_pipeline("data-url"));
assert!(!empty_map.contains_named_pipeline("types"));
}

#[test]
Expand All @@ -361,10 +361,10 @@ mod tests {
String::from("url:*") => pipelines("3")
});

assert_eq!(map.contains_named_pipeline("*"), false);
assert_eq!(map.contains_named_pipeline("data-url"), false);
assert_eq!(map.contains_named_pipeline("types"), false);
assert_eq!(map.contains_named_pipeline("urls"), false);
assert!(!map.contains_named_pipeline("*"));
assert!(!map.contains_named_pipeline("data-url"));
assert!(!map.contains_named_pipeline("types"));
assert!(!map.contains_named_pipeline("urls"));
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/atlaspack_core/src/asset_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,12 +686,12 @@ mod tests {

let mut specifier = first_entry.len() - 2;
for node in nodes[1..].iter() {
let entry = serde_json::from_str::<Value>(&node)?;
let entry = serde_json::from_str::<Value>(node)?;
let entry = entry.as_array().unwrap();

for value in entry {
assert_eq!(
get_dependency(&value),
get_dependency(value),
Some(json!(format!("dependency-{}", specifier)))
);

Expand All @@ -707,7 +707,7 @@ mod tests {
}

fn get_dependency(value: &Value) -> Option<Value> {
assert_eq!(get_type(&value), json!("dependency"));
assert_eq!(get_type(value), json!("dependency"));

value
.get("value")
Expand All @@ -719,7 +719,7 @@ mod tests {
}

fn get_asset(value: &Value) -> Option<Value> {
assert_eq!(get_type(&value), json!("asset"));
assert_eq!(get_type(value), json!("asset"));

value
.get("value")
Expand Down
2 changes: 1 addition & 1 deletion crates/atlaspack_core/src/project_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod tests {
let project_path = Path::new("test").join("a.js");

assert_eq!(
to_project_path(&project_root, &project_root.join(project_path.clone())),
to_project_path(project_root, &project_root.join(project_path.clone())),
project_path
);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/atlaspack_package_manager/src/node_package_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct NodePackageManager<'a> {
resolver: atlaspack_resolver::Resolver<'a>,
}

impl<'a> NodePackageManager<'a> {
impl NodePackageManager<'_> {
pub fn new(project_root: PathBuf, fs: FileSystemRef) -> Self {
Self {
resolver: atlaspack_resolver::Resolver::node(
Expand All @@ -21,7 +21,7 @@ impl<'a> NodePackageManager<'a> {
}
}

impl<'a> PackageManager for NodePackageManager<'a> {
impl PackageManager for NodePackageManager<'_> {
fn resolve(&self, specifier: &str, from: &std::path::Path) -> anyhow::Result<crate::Resolution> {
let res = self.resolver.resolve(specifier, from, SpecifierType::Cjs);

Expand Down
Loading
Loading