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

build: Update rustc to nightly-2024-07-21 #9319

Merged
merged 21 commits into from
Jul 23, 2024
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions crates/binding_macros/build.rs

This file was deleted.

4 changes: 2 additions & 2 deletions crates/dbg-swc/src/es/minifier/next/check_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl CheckSizeCommand {
println!(
"{}: {} bytes (swc) vs {} bytes (terser)",
file.path
.strip_prefix(&self.workspace.join("inputs"))
.strip_prefix(self.workspace.join("inputs"))
.unwrap()
.display(),
file.swc,
Expand All @@ -92,7 +92,7 @@ impl CheckSizeCommand {
format!(
"{}: Diff: {} bytes; {} bytes (swc) vs {} bytes (terser)",
f.path
.strip_prefix(&self.workspace.join("inputs"))
.strip_prefix(self.workspace.join("inputs"))
.unwrap()
.display(),
f.swc as i32 - f.terser as i32,
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/benches/minify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn files_group(c: &mut Criterion) {
group.sample_size(10);

let mut bench_file = |name: &str| {
group.bench_function(&format!("es/full/minify/libraries/{name}"), |b| {
group.bench_function(format!("es/full/minify/libraries/{name}"), |b| {
bench_minify(b, &format!("{}.js", name));
});
};
Expand Down
3 changes: 0 additions & 3 deletions crates/swc_bundler/src/bundler/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ mod computed_key;
mod merge;
mod plan;

#[derive(Debug, Default)]
struct State {}

impl<L, R> Bundler<'_, L, R>
where
L: Load,
Expand Down
31 changes: 1 addition & 30 deletions crates/swc_common/benches/serde.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg_attr(not(feature = "serde-impl"), allow(unused))]

use ast_node::ast_node;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -65,32 +63,5 @@ fn bench_serde(c: &mut Criterion) {
});
}

fn bench_ast_node(c: &mut Criterion) {
#[cfg(feature = "serde-impl")]
c.bench_function("serialization of ast node", |b| {
let src = AstNode::String(Str {
span: DUMMY_SP,
value: String::from("perf-diff"),
});

b.iter(|| black_box(serde_json::to_string(&src).unwrap()));
});
#[cfg(feature = "serde-impl")]
c.bench_function("deserialization of ast node", |b| {
let src = serde_json::to_string(&AstNode::String(Str {
span: DUMMY_SP,
value: String::from("perf-diff"),
}))
.unwrap();
println!("{}", src);

b.iter(|| {
let t: AstNode = serde_json::from_str(&src).unwrap();

black_box(t);
});
});
}

criterion_group!(benches, bench_ast_node, bench_serde);
criterion_group!(benches, bench_serde);
criterion_main!(benches);
11 changes: 1 addition & 10 deletions crates/swc_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use vergen::EmitBuilder;

// Validate conflict between host / plugin features
#[cfg(all(
feature = "plugin_transform",
feature = "ecma_plugin_transform",
any(
feature = "plugin_transform_host_native",
feature = "plugin_transform_host_js"
Expand All @@ -21,15 +21,6 @@ compile_error!(
run plugin, use 'plugin_transform_host_*' instead."
);

#[cfg(all(feature = "__plugin_transform", feature = "common_concurrent"))]
compile_error!("plugin transform cannot enable concurrent mode.");

#[cfg(all(feature = "transforms", feature = "transforms_concurrent"))]
compile_error!(
"'transforms' and 'transforms_concurrent' features are mutually exclusive. Please choose only \
one feature."
);

fn main() {
// Creates a static compile time constants for the version of swc_core.
let pkg_version = env::var("CARGO_PKG_VERSION").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub extern crate swc_ecma_quote_macros;
)]
pub mod plugin;

#[cfg(feature = "preset_env")]
#[cfg(feature = "ecma_preset_env")]
#[cfg_attr(docsrs, doc(cfg(feature = "preset_env")))]
pub mod preset_env {
pub use preset_env_base::*;
Expand Down
12 changes: 6 additions & 6 deletions crates/swc_core/tests/quote.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#[cfg(feature = "quote")]
#[cfg(feature = "ecma_quote")]
use swc_core::{ast::Ident, common::DUMMY_SP, quote, quote_expr, utils::private_ident};

#[cfg(feature = "quote")]
#[cfg(feature = "ecma_quote")]
#[test]
fn quote_expr_call_1() {
let _expr = quote_expr!("call(arg1, typeof arg2, arg3)");
}

#[cfg(feature = "quote")]
#[cfg(feature = "ecma_quote")]
#[test]
fn quote_expr_var_cloned() {
testing::run_test2(false, |_cm, _handler| {
Expand All @@ -20,7 +20,7 @@ fn quote_expr_var_cloned() {
.unwrap();
}

#[cfg(feature = "quote")]
#[cfg(feature = "ecma_quote")]
#[test]
fn quote_example() {
let _stmt = quote!(
Expand All @@ -29,7 +29,7 @@ fn quote_example() {
);
}

#[cfg(feature = "quote")]
#[cfg(feature = "ecma_quote")]
#[test]
fn quote_var_type_expr() {
let _stmt = quote!(
Expand All @@ -39,7 +39,7 @@ fn quote_var_type_expr() {
);
}

#[cfg(feature = "quote")]
#[cfg(feature = "ecma_quote")]
#[test]
fn quote_var_type_pat() {
let _stmt = quote!(
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_css_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2792,7 +2792,7 @@ fn serialize_dimension_unit(value: &str) -> Cow<'_, str> {
// Fast-path
let need_escape =
(value.len() >= 2 && value.as_bytes()[0] == b'e' && value.as_bytes()[1].is_ascii_digit())
|| value.contains(|c| c == char::REPLACEMENT_CHARACTER);
|| value.contains(char::REPLACEMENT_CHARACTER);

if !need_escape {
return Cow::Borrowed(value);
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_css_compat/src/compiler/custom_media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl CustomMediaHandler {
Some((query.modifier.clone(), query.media_type.clone()));
}

for condition in &query.condition {
if let Some(condition) = &query.condition {
match &**condition {
MediaConditionType::All(media_condition) => {
if new_media_condition.conditions.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_css_minifier/src/compressor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,5 @@ impl VisitMut for Compressor {
}

fn contains_only_ascii_characters(string: &str) -> bool {
string.chars().all(|c: char| c.is_ascii())
string.is_ascii()
}
2 changes: 1 addition & 1 deletion crates/swc_ecma_ast/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct Class {

pub ctxt: SyntaxContext,

#[cfg_attr(c, serde(default))]
#[cfg_attr(feature = "serde-impl", serde(default))]
pub decorators: Vec<Decorator>,

#[cfg_attr(feature = "serde-impl", serde(default))]
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3908,7 +3908,7 @@ fn get_template_element_from_raw(s: &str, ascii_only: bool) -> String {
}

fn get_ascii_only_ident(sym: &str, may_need_quote: bool, target: EsVersion) -> Cow<str> {
if sym.chars().all(|c| c.is_ascii()) {
if sym.is_ascii() {
return Cow::Borrowed(sym);
}

Expand Down
17 changes: 0 additions & 17 deletions crates/swc_ecma_codegen_macros/src/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ pub(crate) struct InjectSelf {
pub parser: Option<Ident>,
}

#[cfg(procmacro2_semver_exempt)]
fn get_joined_span(t: &dyn ToTokens) -> Span {
let tts: TokenStream = t.dump().into();
let (mut first, mut last) = (None, None);
for tt in tts {
match first {
None => first = Some(tt.span()),
_ => {}
}

last = Some(tt.span());
}
let cs = Span::call_site();
first.unwrap_or(cs).join(last.unwrap_or(cs)).unwrap_or(cs)
}

#[cfg(not(procmacro2_semver_exempt))]
fn get_joined_span(t: &dyn ToTokens) -> Span {
let tts: TokenStream = t.into_token_stream();
let mut first = None;
Expand Down
7 changes: 2 additions & 5 deletions crates/swc_ecma_lints/src/rules/duplicate_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,8 @@ fn emit_error(name: &str, span: Span, prev_span: Span) {
span,
&format!("the name `{}` is defined multiple times", name),
)
.span_label(
prev_span,
&format!("previous definition of `{}` here", name),
)
.span_label(span, &format!("`{}` redefined here", name))
.span_label(prev_span, format!("previous definition of `{}` here", name))
.span_label(span, format!("`{}` redefined here", name))
.emit();
});
}
2 changes: 1 addition & 1 deletion crates/swc_ecma_lints/src/rules/no_dupe_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn error(first: &BindingIdent, second: &BindingIdent) {
),
)
.span_label(first.span, "previous definition here".to_string())
.span_label(second.span, &"used as parameter more than once".to_string())
.span_label(second.span, "used as parameter more than once".to_string())
.emit();
});
}
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_minifier/benches/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn bench_files(c: &mut Criterion) {
let mut bench_file = |name: &str| {
let src = read_to_string(format!("benches/full/{}.js", name)).unwrap();

group.bench_function(&format!("es/minifier/libs/{}", name), |b| {
group.bench_function(format!("es/minifier/libs/{}", name), |b| {
b.iter(|| {
// We benchmark full time, including time for creating cm, handler
let allocator = Allocator::default();
Expand Down
7 changes: 2 additions & 5 deletions crates/swc_ecma_minifier/src/compress/pure/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ impl Pure<'_> {
if !self.options.props {
return None;
}
if let Some(obj) = obj {
match obj {
Expr::Array(..) | Expr::Await(..) | Expr::Yield(..) | Expr::Lit(..) => return None,
_ => {}
}
if let Some(Expr::Array(..) | Expr::Await(..) | Expr::Yield(..) | Expr::Lit(..)) = obj {
return None;
}

match &*c.expr {
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_minifier/src/pass/precompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::HEAVY_TASK_PARALLELS;
/// Optimizer invoked before invoking compressor.
///
/// - Remove parens.
///
/// TODO: remove completely after #8333
pub(crate) fn precompress_optimizer<'a>() -> impl 'a + VisitMut {
PrecompressOptimizer {}
Expand Down
10 changes: 5 additions & 5 deletions crates/swc_ecma_transforms_base/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ const LOG: bool = false && cfg!(debug_assertions);
/// 3. Defined `a` with syntax context of the block statement.
///
/// 4. Found usage of `a`, and determines that it's reference to `a` in the
/// block. So the reference to `a` will have same syntax context as `a` in the
/// block.
/// block. So the reference to `a` will have same syntax context as `a` in
/// the block.
///
/// 5. Found usage of `a` (last line), and determines that it's a
/// reference to top-level `a`, and change syntax context of `a` on last line to
/// top-level syntax context.
/// 5. Found usage of `a` (last line), and determines that it's a reference to
/// top-level `a`, and change syntax context of `a` on last line to top-level
/// syntax context.
///
///
/// # Parameters
Expand Down
6 changes: 6 additions & 0 deletions crates/swc_ecma_transforms_base/tests/par.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ impl Parallel for ExampleFold {

#[parallel]
impl Fold for ExampleFold {}

#[test]
fn test() {
let _ = ExampleFold;
let _ = ExampleVisitMut;
}
7 changes: 7 additions & 0 deletions crates/swc_ecma_transforms_base/tests/par_explode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ impl ParExplode for ExampleFold {

#[parallel(explode)]
impl Fold for ExampleFold {}

#[test]
fn test_1() {
let _ = ExampleFold;

let _ = ExampleVisitMut;
}
9 changes: 0 additions & 9 deletions crates/swc_ecma_transforms_module/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,6 @@ pub(super) fn use_strict() -> Stmt {
Lit::Str(quote_str!("use strict")).into_stmt()
}

/// Private `_exports` ident.
pub(super) struct Exports(#[allow(dead_code)] pub Ident);

impl Default for Exports {
fn default() -> Self {
Exports(private_ident!("_exports"))
}
}

pub(crate) fn object_define_enumerable(
target: ExprOrSpread,
prop_name: ExprOrSpread,
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_transforms_testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ fn exec_with_node_test_runner(src: &str) -> Result<(), ()> {
};

let output = base_cmd
.arg(&format!("{}", path.display()))
.arg(format!("{}", path.display()))
.arg("--color")
.current_dir(root)
.output()
Expand Down
5 changes: 3 additions & 2 deletions crates/swc_ecma_transforms_typescript/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ pub struct TsxConfig {

#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum TsImportExportAssignConfig {
/// - Rewrite `import foo = require("foo")` to `var foo = require("foo")`
/// - Rewrite `export =` to `module.exports = `
/// - Rewrite `import foo = require("foo")` to `var foo = require("foo")`
/// - Rewrite `export =` to `module.exports = `
///
/// Note: This option is deprecated as all CJS/AMD/UMD can handle it
/// themselves.
#[default]
Expand Down
5 changes: 3 additions & 2 deletions crates/swc_ecma_usage_analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ bench = false

[features]
# This enables global concurrent mode
concurrent = ["swc_common/concurrent", "indexmap/rayon"]
trace-ast = []
concurrent = ["swc_common/concurrent", "indexmap/rayon"]
trace-ast = []
tracing-spans = []

[dependencies]
indexmap = { workspace = true }
Expand Down
Loading
Loading