Skip to content

Commit

Permalink
chore: use rust nightly-2023-10-24 (#722)
Browse files Browse the repository at this point in the history
* chore: use rust nightly-2023-10-24

* chore: update rust version in ci

* chore: use as_ref instead of clone
  • Loading branch information
sorrycc authored Nov 27, 2023
1 parent 0f0a595 commit 1cd1e92
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 31 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
if: ${{ !startsWith(github.event.head_commit.message, 'release:') && !startsWith(github.event.head_commit.message, 'ci:') && !startsWith(github.event.head_commit.message, 'docs:') }}
strategy:
matrix:
rust: [nightly-2022-09-23]
rust: [nightly-2023-10-24]
node_version: [lts/*]
steps:
- uses: actions/checkout@v2
Expand All @@ -46,7 +46,7 @@ jobs:
cache-on-failure: true

- name: test
if: ${{ matrix.rust == 'stable' || matrix.rust == 'beta' || matrix.rust == 'nightly-2022-09-23' }}
if: ${{ matrix.rust == 'stable' || matrix.rust == 'beta' || matrix.rust == 'nightly-2023-10-24' }}
run: >
cargo test -v
Expand All @@ -59,7 +59,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-09-23
toolchain: nightly-2023-10-24
override: true
components: clippy
- uses: actions-rs/cargo@v1
Expand All @@ -73,7 +73,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-09-23
toolchain: nightly-2023-10-24
override: true
components: rustfmt
- name: Run rustfmt check
Expand Down
4 changes: 2 additions & 2 deletions crates/mako/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ mod tests {
let result = parse_path("foo?bar=1&hoo=2").unwrap();
assert_eq!(result.path, "foo");
assert_eq!(
result.query.get(0).unwrap(),
result.query.first().unwrap(),
&("bar".to_string(), "1".to_string())
);
assert_eq!(
Expand All @@ -457,7 +457,7 @@ mod tests {
let result = parse_path("foo?bar").unwrap();
assert_eq!(result.path, "foo");
assert_eq!(
result.query.get(0).unwrap(),
result.query.first().unwrap(),
&("bar".to_string(), "".to_string())
);
assert!(result.has_query("bar"));
Expand Down
7 changes: 1 addition & 6 deletions crates/mako/src/chunk_pot/str_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,13 @@ fn to_module_line(
};
// let source_map_file = format!("{}.map", file_content_hash(module_id_str));

let content = vec![
let content = [
content,
format!(
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,{}",
base64_encode(source_map)
)
.into(),
// format!(
// "//# sourceMappingURL={}{}",
// context.config.public_path, source_map_file
// )
// .into(),
]
.join("");

Expand Down
2 changes: 0 additions & 2 deletions crates/mako/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(box_patterns)]
#![feature(hasher_prefixfree_extras)]
#![feature(is_some_with)]
#![feature(box_syntax)]

mod analyze_deps;
mod ast;
Expand Down
2 changes: 0 additions & 2 deletions crates/mako/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![feature(box_patterns)]
#![feature(is_some_with)]
#![feature(box_syntax)]

use std::sync::Arc;

Expand Down
2 changes: 1 addition & 1 deletion crates/mako/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Ord for ModuleId {

impl PartialOrd for ModuleId {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.id.partial_cmp(&other.id)
Some(self.cmp(other))
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/mako/src/plugins/farm_tree_shake/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ impl AllExports {
match self {
AllExports::Precise(ids) => ids
.iter()
.filter(|&id| id != "default")
.cloned()
.filter(|id| id != "default")
.collect::<Vec<_>>(),

AllExports::Ambiguous(ids) => ids
.iter()
.filter(|&id| id != "default")
.cloned()
.filter(|id| id != "default")
.collect::<Vec<_>>(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/mako/src/plugins/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl Visit for DepCollectVisitor {
}

pub fn resolve_web_worker(new_expr: &NewExpr, unresolved_mark: Mark) -> Option<&Str> {
if !new_expr.args.is_some_and(|args| !args.is_empty()) || !new_expr.callee.is_ident() {
if !new_expr.args.as_ref().is_some_and(|args| !args.is_empty()) || !new_expr.callee.is_ident() {
return None;
}

Expand All @@ -181,7 +181,7 @@ pub fn resolve_web_worker(new_expr: &NewExpr, unresolved_mark: Mark) -> Option<&

// new Worker(new URL(''), base);
if let Expr::New(new_expr) = &*args[0].expr {
if !new_expr.args.is_some_and(|args| !args.is_empty())
if !new_expr.args.as_ref().is_some_and(|args| !args.is_empty())
|| !new_expr.callee.is_ident()
{
return None;
Expand Down
4 changes: 3 additions & 1 deletion crates/mako/src/plugins/minifish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl VisitMut for MyInjector<'_> {
}
}

#[derive(Eq, Clone)]
#[derive(Clone)]
pub struct Inject {
pub from: String,
pub name: String,
Expand All @@ -262,6 +262,8 @@ pub struct Inject {
pub exclude: Option<Regex>,
}

impl Eq for Inject {}

impl PartialEq for Inject {
fn eq(&self, other: &Self) -> bool {
self.name == other.name
Expand Down
2 changes: 1 addition & 1 deletion crates/mako/src/plugins/node_polyfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn get_polyfill_modules() -> Vec<String> {
}

fn get_empty_modules() -> Vec<String> {
vec![
[
"child_process",
"cluster",
"dgram",
Expand Down
4 changes: 2 additions & 2 deletions crates/mako/src/transformers/transform_dep_replacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl DepReplacer<'_> {
}

pub fn resolve_web_worker_mut(new_expr: &mut NewExpr, unresolved_mark: Mark) -> Option<&mut Str> {
if !new_expr.args.is_some_and(|args| !args.is_empty()) || !new_expr.callee.is_ident() {
if !new_expr.args.as_ref().is_some_and(|args| !args.is_empty()) || !new_expr.callee.is_ident() {
return None;
}

Expand All @@ -165,7 +165,7 @@ pub fn resolve_web_worker_mut(new_expr: &mut NewExpr, unresolved_mark: Mark) ->

// new Worker(new URL(''), base);
if let Expr::New(new_expr) = &mut *args[0].expr {
if !new_expr.args.is_some_and(|args| !args.is_empty())
if !new_expr.args.as_ref().is_some_and(|args| !args.is_empty())
|| !new_expr.callee.is_ident()
{
return None;
Expand Down
14 changes: 10 additions & 4 deletions crates/mako/src/transformers/transform_env_replacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use mako_core::swc_ecma_ast::{
MemberProp, MetaPropExpr, MetaPropKind, Module, ModuleItem, Null, Number, ObjectLit, Prop,
PropName, PropOrSpread, Stmt, Str,
};
use mako_core::swc_ecma_utils::{collect_decls, quote_expr, quote_ident, ExprExt};
use mako_core::swc_ecma_utils::{collect_decls, quote_ident, ExprExt};
use mako_core::swc_ecma_visit::{VisitMut, VisitMutWith};

use crate::ast::build_js_ast;
Expand Down Expand Up @@ -120,7 +120,10 @@ impl VisitMut for EnvReplacer {
*expr = env;
} else {
// replace with `undefined` if env not found
*expr = *quote_expr!(DUMMY_SP, undefined);
*expr = *Box::new(Expr::Ident(Ident::new(
js_word!("undefined"),
DUMMY_SP,
)));
}
}
}
Expand All @@ -131,7 +134,10 @@ impl VisitMut for EnvReplacer {
*expr = env;
} else {
// replace with `undefined` if env not found
*expr = *quote_expr!(DUMMY_SP, undefined);
*expr = *Box::new(Expr::Ident(Ident::new(
js_word!("undefined"),
DUMMY_SP,
)));
}
}
_ => {}
Expand Down Expand Up @@ -190,7 +196,7 @@ fn get_env_expr(v: Value, context: &Arc<Context>) -> Result<Expr> {
Value::String(v) => {
// the string content is treat as expression, so it has to be parsed
let ast = build_js_ast("_define_.js", &v, context).unwrap();
let module = ast.ast.body.get(0).unwrap();
let module = ast.ast.body.first().unwrap();

match module {
ModuleItem::Stmt(Stmt::Expr(stmt_expr)) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/mako/src/transformers/transform_mako_require.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl VisitMut for MakoRequire {
..
}),
Callee::Expr(box Expr::Ident(ident)),
) = (&call_expr.args.get(0), &mut call_expr.callee)
) = (&call_expr.args.first(), &mut call_expr.callee)
{
let src = value.to_string();

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
profile = "default"
channel = "nightly-2022-09-23"
channel = "nightly-2023-10-24"

0 comments on commit 1cd1e92

Please sign in to comment.