Skip to content

Commit a97e105

Browse files
authored
chore: upgrade rust to 1.81.0 nightly (#8111)
* chore: upgrade rust to 1.81.0 nightly * fix: update asset size to usize
1 parent 24e806d commit a97e105

File tree

9 files changed

+34
-37
lines changed

9 files changed

+34
-37
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ jobs:
267267
uses: actions-rs/cargo@v1
268268
with:
269269
command: clippy
270-
args: --workspace --all-targets -- -D warnings
270+
args: --workspace --all-targets --tests -- -D warnings
271271

272272
- name: Run rustfmt
273273
uses: actions-rs/cargo@v1

crates/rspack_binding_values/src/stats.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ impl From<rspack_core::StatsChunkGroupAsset> for JsStatsChunkGroupAsset {
991991
fn from(stats: rspack_core::StatsChunkGroupAsset) -> Self {
992992
Self {
993993
name: stats.name,
994-
size: stats.size,
994+
size: stats.size as f64,
995995
}
996996
}
997997
}
@@ -1024,11 +1024,11 @@ impl From<rspack_core::StatsChunkGroup> for JsStatsChunkGroup {
10241024
name: stats.name,
10251025
chunks: stats.chunks,
10261026
assets: stats.assets.into_iter().map(Into::into).collect(),
1027-
assets_size: stats.assets_size,
1027+
assets_size: stats.assets_size as f64,
10281028
auxiliary_assets: stats
10291029
.auxiliary_assets
10301030
.map(|assets| assets.into_iter().map(Into::into).collect()),
1031-
auxiliary_assets_size: stats.auxiliary_assets_size,
1031+
auxiliary_assets_size: stats.auxiliary_assets_size.map(|inner| inner as f64),
10321032
children: stats.children.map(|i| i.into()),
10331033
child_assets: stats.child_assets.map(|i| i.into()),
10341034
is_over_size_limit: stats.is_over_size_limit,

crates/rspack_core/src/diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ impl miette::Diagnostic for ModuleBuildError {
7878
}
7979

8080
/// Represent any errors or warnings during module parse
81+
///
8182
/// This does NOT aligned with webpack as webpack does not have parse warning.
8283
/// However, rspack may create warning during parsing stage, taking CSS as an example.
8384
#[derive(Debug, Error)]

crates/rspack_core/src/options/filename.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ impl LocalFilenameFn for NoFilenameFn {
117117

118118
impl From<FilenameTemplate> for Filename {
119119
fn from(value: FilenameTemplate) -> Self {
120-
Self(match value.0 {
121-
FilenameKind::Template(template) => FilenameKind::Template(template),
122-
FilenameKind::Fn(no_fn) => match no_fn.0 {},
123-
})
120+
let FilenameKind::Template(template) = value.0;
121+
122+
Self(FilenameKind::Template(template))
124123
}
125124
}
126125

crates/rspack_core/src/stats/struct.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,17 @@ pub struct StatsChunk<'a> {
220220
#[derive(Debug)]
221221
pub struct StatsChunkGroupAsset {
222222
pub name: String,
223-
pub size: f64,
223+
pub size: usize,
224224
}
225225

226226
#[derive(Debug)]
227227
pub struct StatsChunkGroup {
228228
pub name: String,
229229
pub chunks: Vec<String>,
230230
pub assets: Vec<StatsChunkGroupAsset>,
231-
pub assets_size: f64,
231+
pub assets_size: usize,
232232
pub auxiliary_assets: Option<Vec<StatsChunkGroupAsset>>,
233-
pub auxiliary_assets_size: Option<f64>,
233+
pub auxiliary_assets_size: Option<usize>,
234234
pub children: Option<StatsChunkGroupChildren>,
235235
pub is_over_size_limit: Option<bool>,
236236
pub child_assets: Option<StatschunkGroupChildAssets>,

crates/rspack_core/src/stats/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use crate::{
1111
ChunkGroupByUkey, ChunkGroupOrderKey, ChunkGroupUkey, Compilation, CompilerOptions, ModuleGraph,
1212
};
1313

14-
pub fn get_asset_size(file: &str, compilation: &Compilation) -> f64 {
14+
pub fn get_asset_size(file: &str, compilation: &Compilation) -> usize {
1515
compilation
1616
.assets()
1717
.get(file)
18-
.and_then(|asset| asset.get_source().map(|s| s.size() as f64))
19-
.unwrap_or(-1f64)
18+
.and_then(|asset| asset.get_source().map(|s| s.size()))
19+
.unwrap_or(0)
2020
}
2121

2222
pub fn sort_modules(modules: &mut [StatsModule]) {

crates/rspack_regex/src/algo.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,6 @@ impl Algo {
112112
}
113113
}
114114

115-
#[cfg(test)]
116-
impl Algo {
117-
fn end_with_pats(&self) -> std::collections::HashSet<&str> {
118-
match self {
119-
Algo::EndWith { pats } => pats.iter().map(|s| s.as_str()).collect(),
120-
Algo::Regress(_) => panic!("expect EndWith"),
121-
}
122-
}
123-
124-
fn is_end_with(&self) -> bool {
125-
matches!(self, Self::EndWith { .. })
126-
}
127-
128-
fn is_regress(&self) -> bool {
129-
matches!(self, Self::Regress(..))
130-
}
131-
}
132-
133115
fn is_ends_with_regex(hir: &Hir) -> bool {
134116
if let HirKind::Concat(list) = hir.kind() {
135117
list[0].kind() != &HirKind::Look(Look::Start)
@@ -143,6 +125,23 @@ fn is_ends_with_regex(hir: &Hir) -> bool {
143125
mod test_algo {
144126
use super::*;
145127

128+
impl Algo {
129+
fn end_with_pats(&self) -> std::collections::HashSet<&str> {
130+
match self {
131+
Algo::EndWith { pats } => pats.iter().map(|s| s.as_str()).collect(),
132+
Algo::Regress(_) => panic!("expect EndWith"),
133+
}
134+
}
135+
136+
fn is_end_with(&self) -> bool {
137+
matches!(self, Self::EndWith { .. })
138+
}
139+
140+
fn is_regress(&self) -> bool {
141+
matches!(self, Self::Regress(..))
142+
}
143+
}
144+
146145
#[test]
147146
fn should_use_end_with_algo_with_i_flag() {
148147
assert!(Algo::new("\\.js$", "").unwrap().is_end_with());

crates/rspack_util/src/infallible.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ pub trait ResultInfallibleExt {
88
impl<T> ResultInfallibleExt for Result<T, Infallible> {
99
type Ok = T;
1010
fn always_ok(self) -> T {
11-
match self {
12-
Ok(ok) => ok,
13-
Err(infallible) => match infallible {},
14-
}
11+
let Ok(ok) = self;
12+
ok
1513
}
1614
}

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
profile = "default"
33
# Use nightly for better access to the latest Rust features.
44
# This date is aligned to stable release dates.
5-
channel = "nightly-2024-06-07" # v1.80.0
5+
channel = "nightly-2024-09-05" # v1.81.0

0 commit comments

Comments
 (0)