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: upgrade rust to 1.81.0 nightly #8111

Merged
merged 2 commits into from
Oct 15, 2024
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets -- -D warnings
args: --workspace --all-targets --tests -- -D warnings

- name: Run rustfmt
uses: actions-rs/cargo@v1
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_binding_values/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ impl From<rspack_core::StatsChunkGroupAsset> for JsStatsChunkGroupAsset {
fn from(stats: rspack_core::StatsChunkGroupAsset) -> Self {
Self {
name: stats.name,
size: stats.size,
size: stats.size as f64,
}
}
}
Expand Down Expand Up @@ -1024,11 +1024,11 @@ impl From<rspack_core::StatsChunkGroup> for JsStatsChunkGroup {
name: stats.name,
chunks: stats.chunks,
assets: stats.assets.into_iter().map(Into::into).collect(),
assets_size: stats.assets_size,
assets_size: stats.assets_size as f64,
auxiliary_assets: stats
.auxiliary_assets
.map(|assets| assets.into_iter().map(Into::into).collect()),
auxiliary_assets_size: stats.auxiliary_assets_size,
auxiliary_assets_size: stats.auxiliary_assets_size.map(|inner| inner as f64),
children: stats.children.map(|i| i.into()),
child_assets: stats.child_assets.map(|i| i.into()),
is_over_size_limit: stats.is_over_size_limit,
Expand Down
1 change: 1 addition & 0 deletions crates/rspack_core/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl miette::Diagnostic for ModuleBuildError {
}

/// Represent any errors or warnings during module parse
///
/// This does NOT aligned with webpack as webpack does not have parse warning.
/// However, rspack may create warning during parsing stage, taking CSS as an example.
#[derive(Debug, Error)]
Expand Down
7 changes: 3 additions & 4 deletions crates/rspack_core/src/options/filename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ impl LocalFilenameFn for NoFilenameFn {

impl From<FilenameTemplate> for Filename {
fn from(value: FilenameTemplate) -> Self {
Self(match value.0 {
FilenameKind::Template(template) => FilenameKind::Template(template),
FilenameKind::Fn(no_fn) => match no_fn.0 {},
})
let FilenameKind::Template(template) = value.0;

Self(FilenameKind::Template(template))
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/stats/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,17 @@ pub struct StatsChunk<'a> {
#[derive(Debug)]
pub struct StatsChunkGroupAsset {
pub name: String,
pub size: f64,
pub size: usize,
jerrykingxyz marked this conversation as resolved.
Show resolved Hide resolved
}

#[derive(Debug)]
pub struct StatsChunkGroup {
pub name: String,
pub chunks: Vec<String>,
pub assets: Vec<StatsChunkGroupAsset>,
pub assets_size: f64,
pub assets_size: usize,
pub auxiliary_assets: Option<Vec<StatsChunkGroupAsset>>,
pub auxiliary_assets_size: Option<f64>,
pub auxiliary_assets_size: Option<usize>,
pub children: Option<StatsChunkGroupChildren>,
pub is_over_size_limit: Option<bool>,
pub child_assets: Option<StatschunkGroupChildAssets>,
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/stats/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use crate::{
ChunkGroupByUkey, ChunkGroupOrderKey, ChunkGroupUkey, Compilation, CompilerOptions, ModuleGraph,
};

pub fn get_asset_size(file: &str, compilation: &Compilation) -> f64 {
pub fn get_asset_size(file: &str, compilation: &Compilation) -> usize {
compilation
.assets()
.get(file)
.and_then(|asset| asset.get_source().map(|s| s.size() as f64))
.unwrap_or(-1f64)
.and_then(|asset| asset.get_source().map(|s| s.size()))
.unwrap_or(0)
}

pub fn sort_modules(modules: &mut [StatsModule]) {
Expand Down
35 changes: 17 additions & 18 deletions crates/rspack_regex/src/algo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,6 @@ impl Algo {
}
}

#[cfg(test)]
impl Algo {
fn end_with_pats(&self) -> std::collections::HashSet<&str> {
match self {
Algo::EndWith { pats } => pats.iter().map(|s| s.as_str()).collect(),
Algo::Regress(_) => panic!("expect EndWith"),
}
}

fn is_end_with(&self) -> bool {
matches!(self, Self::EndWith { .. })
}

fn is_regress(&self) -> bool {
matches!(self, Self::Regress(..))
}
}

fn is_ends_with_regex(hir: &Hir) -> bool {
if let HirKind::Concat(list) = hir.kind() {
list[0].kind() != &HirKind::Look(Look::Start)
Expand All @@ -143,6 +125,23 @@ fn is_ends_with_regex(hir: &Hir) -> bool {
mod test_algo {
use super::*;

impl Algo {
fn end_with_pats(&self) -> std::collections::HashSet<&str> {
match self {
Algo::EndWith { pats } => pats.iter().map(|s| s.as_str()).collect(),
Algo::Regress(_) => panic!("expect EndWith"),
}
}

fn is_end_with(&self) -> bool {
matches!(self, Self::EndWith { .. })
}

fn is_regress(&self) -> bool {
matches!(self, Self::Regress(..))
}
}

#[test]
fn should_use_end_with_algo_with_i_flag() {
assert!(Algo::new("\\.js$", "").unwrap().is_end_with());
Expand Down
6 changes: 2 additions & 4 deletions crates/rspack_util/src/infallible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ pub trait ResultInfallibleExt {
impl<T> ResultInfallibleExt for Result<T, Infallible> {
type Ok = T;
fn always_ok(self) -> T {
match self {
Ok(ok) => ok,
Err(infallible) => match infallible {},
}
let Ok(ok) = self;
ok
}
}
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
profile = "default"
# Use nightly for better access to the latest Rust features.
# This date is aligned to stable release dates.
channel = "nightly-2024-06-07" # v1.80.0
channel = "nightly-2024-09-05" # v1.81.0
Loading