Skip to content

Commit 832353b

Browse files
authored
Chore: Rust 1.83.0 & Lint Fix (#302)
1 parent 42c8597 commit 832353b

36 files changed

+284
-388
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
cache: yarn
2828
- uses: dtolnay/rust-toolchain@master
2929
with:
30-
toolchain: 1.82.0
30+
toolchain: 1.83.0
3131
components: rustfmt
3232
- run: yarn --frozen-lockfile
3333
- run: yarn lint
@@ -69,7 +69,7 @@ jobs:
6969
node-version: ${{ matrix.node }}
7070
- uses: dtolnay/rust-toolchain@master
7171
with:
72-
toolchain: 1.82.0
72+
toolchain: 1.83.0
7373
- uses: Swatinem/rust-cache@v2
7474
with:
7575
shared-key: ${{ matrix.os }}
@@ -100,7 +100,7 @@ jobs:
100100
node-version: ${{ matrix.node }}
101101
- uses: dtolnay/rust-toolchain@master
102102
with:
103-
toolchain: 1.82.0
103+
toolchain: 1.83.0
104104
- uses: Swatinem/rust-cache@v2
105105
with:
106106
shared-key: ${{ matrix.os }}

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Install Rust
4444
uses: dtolnay/rust-toolchain@master
4545
with:
46-
toolchain: 1.82.0
46+
toolchain: 1.83.0
4747
target: ${{ matrix.target }}
4848
- uses: bahmutov/[email protected]
4949
- uses: Swatinem/rust-cache@v2
@@ -89,7 +89,7 @@ jobs:
8989
- name: Install Rust
9090
uses: actions-rs/toolchain@v1
9191
with:
92-
toolchain: 1.82.0
92+
toolchain: 1.83.0
9393
profile: minimal
9494
override: true
9595
- uses: bahmutov/[email protected]
@@ -141,7 +141,7 @@ jobs:
141141
- name: Install Rust
142142
uses: dtolnay/rust-toolchain@master
143143
with:
144-
toolchain: 1.82.0
144+
toolchain: 1.83.0
145145
target: ${{ matrix.target }}
146146
- name: Install cross compile toolchains
147147
run: |

.github/workflows/repl.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
node-version: 20
3737
- uses: dtolnay/rust-toolchain@master
3838
with:
39-
toolchain: 1.82.0
39+
toolchain: 1.83.0
4040
targets: wasm32-unknown-unknown
4141
- name: Install wasm-opt
4242
run: |

crates/atlaspack/src/atlaspack.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ mod tests {
185185
rpc(),
186186
)?;
187187

188-
let assets = vec!["foo", "bar", "baz"];
188+
let assets = ["foo", "bar", "baz"];
189189

190190
atlaspack.commit_assets(
191191
&assets

crates/atlaspack/src/project_root.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -118,54 +118,48 @@ mod tests {
118118
#[test]
119119
fn returns_none_when_there_is_no_common_path() {
120120
assert_eq!(
121-
common_path(&vec![PathBuf::from("dist"), PathBuf::from("src")]),
121+
common_path(&[PathBuf::from("dist"), PathBuf::from("src")]),
122122
None,
123123
);
124124

125125
assert_eq!(
126-
common_path(&vec![
127-
PathBuf::from("dist"),
128-
PathBuf::from("packages").join("foo"),
129-
]),
126+
common_path(&[PathBuf::from("dist"), PathBuf::from("packages").join("foo")]),
130127
None,
131128
);
132129
}
133130

134131
#[test]
135132
fn returns_the_common_prefix() {
136-
assert_eq!(
137-
common_path(&vec![PathBuf::from("/")]),
138-
Some(PathBuf::from("/"))
139-
);
133+
assert_eq!(common_path(&[PathBuf::from("/")]), Some(PathBuf::from("/")));
140134

141135
assert_eq!(
142-
common_path(&vec![PathBuf::from("src")]),
136+
common_path(&[PathBuf::from("src")]),
143137
Some(PathBuf::from("src"))
144138
);
145139

146140
assert_eq!(
147-
common_path(&vec![
141+
common_path(&[
148142
PathBuf::from("packages/foo"),
149143
PathBuf::from("packages/bar"),
150-
PathBuf::from("packages/baz"),
144+
PathBuf::from("packages/baz")
151145
]),
152146
Some(PathBuf::from("packages"))
153147
);
154148

155149
assert_eq!(
156-
common_path(&vec![
150+
common_path(&[
157151
PathBuf::from("packages/foo"),
158152
PathBuf::from("packages/foo/a.js"),
159-
PathBuf::from("packages/foo/bar/b.js"),
153+
PathBuf::from("packages/foo/bar/b.js")
160154
]),
161155
Some(PathBuf::from("packages").join("foo"))
162156
);
163157

164158
assert_eq!(
165-
common_path(&vec![
159+
common_path(&[
166160
PathBuf::from("packages/foo/a.js"),
167161
PathBuf::from("packages/bar/b.js"),
168-
PathBuf::from("packages/baz/c.js"),
162+
PathBuf::from("packages/baz/c.js")
169163
]),
170164
Some(PathBuf::from("packages"))
171165
);
@@ -312,7 +306,7 @@ mod tests {
312306

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

317311
assert_eq!(
318312
infer_project_root(fs, entries).map_err(|e| e.to_string()),

crates/atlaspack/src/requests/asset_graph_request.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ mod tests {
568568
asset_graph_request_result
569569
.graph
570570
.assets
571-
.get(0)
571+
.first()
572572
.unwrap()
573573
.asset
574574
.file_path,
@@ -578,7 +578,7 @@ mod tests {
578578
asset_graph_request_result
579579
.graph
580580
.assets
581-
.get(0)
581+
.first()
582582
.unwrap()
583583
.asset
584584
.code,
@@ -589,7 +589,7 @@ mod tests {
589589
"#
590590
)
591591
.trim_start()
592-
.trim_end_matches(|p| p == ' ')
592+
.trim_end_matches(' ')
593593
.to_string()
594594
))
595595
);
@@ -672,7 +672,7 @@ mod tests {
672672
asset_graph_request_result
673673
.graph
674674
.assets
675-
.get(0)
675+
.first()
676676
.unwrap()
677677
.asset
678678
.file_path,

crates/atlaspack/src/requests/target_request.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -874,10 +874,9 @@ mod tests {
874874
}}
875875
}}
876876
"#,
877-
module_format.map_or_else(
878-
|| String::default(),
879-
|module_format| format!(r#""type": "{module_format}","#)
880-
),
877+
module_format.map_or_else(String::default, |module_format| format!(
878+
r#""type": "{module_format}","#
879+
)),
881880
),
882881
None,
883882
None,
@@ -1734,10 +1733,9 @@ mod tests {
17341733
}}
17351734
}}
17361735
"#,
1737-
module_format.map_or_else(
1738-
|| String::default(),
1739-
|module_format| format!(r#""type": "{module_format}","#)
1740-
),
1736+
module_format.map_or_else(String::default, |module_format| format!(
1737+
r#""type": "{module_format}","#
1738+
)),
17411739
),
17421740
None,
17431741
None,

crates/atlaspack_config/src/atlaspack_rc_config_loader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ mod tests {
496496

497497
let err = AtlaspackRcConfigLoader::new(fs, package_manager)
498498
.load(
499-
&&project_root,
499+
&project_root,
500500
LoadConfigOptions {
501501
additional_reporters: Vec::new(),
502502
config: Some("@scope/config"),

crates/atlaspack_config/src/map/matcher.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ mod tests {
4242
for path in paths("a.ts") {
4343
let is_match = named_pattern_matcher(&path);
4444

45-
assert_eq!(is_match("*.t", ""), false);
46-
assert_eq!(is_match("*.tsx", ""), false);
47-
assert_eq!(is_match("types:*.{ts,tsx}", ""), false);
48-
assert_eq!(is_match("url:*", ""), false);
45+
assert!(!is_match("*.t", ""));
46+
assert!(!is_match("*.tsx", ""));
47+
assert!(!is_match("types:*.{ts,tsx}", ""));
48+
assert!(!is_match("url:*", ""));
4949
}
5050
}
5151

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

57-
assert_eq!(is_match("types:*.{ts,tsx}", "type"), false);
58-
assert_eq!(is_match("types:*.{ts,tsx}", "typesa"), false);
57+
assert!(!is_match("types:*.{ts,tsx}", "type"));
58+
assert!(!is_match("types:*.{ts,tsx}", "typesa"));
5959
}
6060
}
6161

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

67-
assert_eq!(is_match("*.{ts,tsx}", ""), true);
68-
assert_eq!(is_match("*.ts", ""), true);
69-
assert_eq!(is_match("*", ""), true);
67+
assert!(is_match("*.{ts,tsx}", ""));
68+
assert!(is_match("*.ts", ""));
69+
assert!(is_match("*", ""));
7070
}
7171
}
7272

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

78-
assert_eq!(is_match("types:*.{ts,tsx}", "types"), true);
79-
assert_eq!(is_match("types:*.ts", "types"), true);
80-
assert_eq!(is_match("types:*", "types"), true);
78+
assert!(is_match("types:*.{ts,tsx}", "types"));
79+
assert!(is_match("types:*.ts", "types"));
80+
assert!(is_match("types:*", "types"));
8181
}
8282
}
8383
}
@@ -90,10 +90,10 @@ mod tests {
9090
for path in paths("a.ts") {
9191
let is_match = pattern_matcher(&path);
9292

93-
assert_eq!(is_match("*.t"), false);
94-
assert_eq!(is_match("*.tsx"), false);
95-
assert_eq!(is_match("types:*.{ts,tsx}"), false);
96-
assert_eq!(is_match("url:*"), false);
93+
assert!(!is_match("*.t"));
94+
assert!(!is_match("*.tsx"));
95+
assert!(!is_match("types:*.{ts,tsx}"));
96+
assert!(!is_match("url:*"));
9797
}
9898
}
9999

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

105-
assert_eq!(is_match("*.{ts,tsx}"), true);
106-
assert_eq!(is_match("*.ts"), true);
107-
assert_eq!(is_match("*"), true);
105+
assert!(is_match("*.{ts,tsx}"));
106+
assert!(is_match("*.ts"));
107+
assert!(is_match("*"));
108108
}
109109
}
110110
}

crates/atlaspack_config/src/map/named_pipelines_map.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,15 @@ mod tests {
342342
String::from("data-url:*") => pipelines("1")
343343
});
344344

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

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

352-
assert_eq!(empty_map.contains_named_pipeline("data-url"), false);
353-
assert_eq!(empty_map.contains_named_pipeline("types"), false);
352+
assert!(!empty_map.contains_named_pipeline("data-url"));
353+
assert!(!empty_map.contains_named_pipeline("types"));
354354
}
355355

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

364-
assert_eq!(map.contains_named_pipeline("*"), false);
365-
assert_eq!(map.contains_named_pipeline("data-url"), false);
366-
assert_eq!(map.contains_named_pipeline("types"), false);
367-
assert_eq!(map.contains_named_pipeline("urls"), false);
364+
assert!(!map.contains_named_pipeline("*"));
365+
assert!(!map.contains_named_pipeline("data-url"));
366+
assert!(!map.contains_named_pipeline("types"));
367+
assert!(!map.contains_named_pipeline("urls"));
368368
}
369369
}
370370

crates/atlaspack_core/src/asset_graph.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -686,12 +686,12 @@ mod tests {
686686

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

692692
for value in entry {
693693
assert_eq!(
694-
get_dependency(&value),
694+
get_dependency(value),
695695
Some(json!(format!("dependency-{}", specifier)))
696696
);
697697

@@ -707,7 +707,7 @@ mod tests {
707707
}
708708

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

712712
value
713713
.get("value")
@@ -719,7 +719,7 @@ mod tests {
719719
}
720720

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

724724
value
725725
.get("value")

crates/atlaspack_core/src/project_path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod tests {
3131
let project_path = Path::new("test").join("a.js");
3232

3333
assert_eq!(
34-
to_project_path(&project_root, &project_root.join(project_path.clone())),
34+
to_project_path(project_root, &project_root.join(project_path.clone())),
3535
project_path
3636
);
3737
}

crates/atlaspack_package_manager/src/node_package_manager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct NodePackageManager<'a> {
1010
resolver: atlaspack_resolver::Resolver<'a>,
1111
}
1212

13-
impl<'a> NodePackageManager<'a> {
13+
impl NodePackageManager<'_> {
1414
pub fn new(project_root: PathBuf, fs: FileSystemRef) -> Self {
1515
Self {
1616
resolver: atlaspack_resolver::Resolver::node(
@@ -21,7 +21,7 @@ impl<'a> NodePackageManager<'a> {
2121
}
2222
}
2323

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

0 commit comments

Comments
 (0)