Skip to content

Commit

Permalink
chore: clippy::type_complexity (rolldown#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon authored Mar 8, 2024
1 parent b522b91 commit 9dff0db
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
39 changes: 18 additions & 21 deletions crates/rolldown/src/ast_scanner/side_effect_detector.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
use once_cell::sync::Lazy;
use oxc::ast::ast::{IdentifierReference, MemberExpression};
use rolldown_common::AstScope;
use rustc_hash::FxHashSet;

// Probably we should generate this using macros.
static SIDE_EFFECT_FREE_MEMBER_EXPR_2: once_cell::sync::Lazy<
FxHashSet<(&'static str, &'static str)>,
> = once_cell::sync::Lazy::new(|| {
[
("Object", "create"),
("Object", "defineProperty"),
("Object", "getOwnPropertyDescriptor"),
("Object", "getPrototypeOf"),
("Object", "getOwnPropertyNames"),
]
.into_iter()
.collect()
});

// hyf0: clippy::type_complexity: This is only a temporary solution.
#[allow(clippy::type_complexity)]
static SIDE_EFFECT_FREE_MEMBER_EXPR_3: once_cell::sync::Lazy<
FxHashSet<(&'static str, &'static str, &'static str)>,
> = once_cell::sync::Lazy::new(|| {
[("Object", "prototype", "hasOwnProperty"), ("Object", "prototype", "constructor")]
static SIDE_EFFECT_FREE_MEMBER_EXPR_2: Lazy<FxHashSet<(&'static str, &'static str)>> =
Lazy::new(|| {
[
("Object", "create"),
("Object", "defineProperty"),
("Object", "getOwnPropertyDescriptor"),
("Object", "getPrototypeOf"),
("Object", "getOwnPropertyNames"),
]
.into_iter()
.collect()
});
});

static SIDE_EFFECT_FREE_MEMBER_EXPR_3: Lazy<FxHashSet<(&'static str, &'static str, &'static str)>> =
Lazy::new(|| {
[("Object", "prototype", "hasOwnProperty"), ("Object", "prototype", "constructor")]
.into_iter()
.collect()
});

pub struct SideEffectDetector<'a> {
pub scope: &'a AstScope,
Expand Down
2 changes: 1 addition & 1 deletion crates/rolldown/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Chunk {
}
}

#[allow(clippy::unnecessary_wraps, clippy::cast_possible_truncation, clippy::type_complexity)]
#[allow(clippy::unnecessary_wraps, clippy::cast_possible_truncation)]
pub fn render(
&self,
input_options: &InputOptions,
Expand Down
7 changes: 4 additions & 3 deletions crates/rolldown_error/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use ariadne::{sources, Config, Label, Report, ReportBuilder, ReportKind};

use crate::error::Severity;

#[allow(clippy::type_complexity)]
type Labels = Vec<Label<(String, Range<usize>)>>;

#[derive(Debug, Default)]
pub struct DiagnosticBuilder {
pub code: Option<&'static str>,
pub summary: Option<String>,
pub files: Option<Vec<(String, String)>>,
pub labels: Option<Vec<Label<(String, Range<usize>)>>>,
pub labels: Option<Labels>,
pub severity: Option<Severity>,
}

Expand All @@ -31,7 +32,7 @@ pub struct Diagnostic {
pub(crate) code: &'static str,
pub(crate) summary: String,
pub(crate) files: Vec<(String, String)>,
pub(crate) labels: Vec<Label<(String, Range<usize>)>>,
pub(crate) labels: Labels,
pub(crate) severity: Severity,
}

Expand Down
6 changes: 2 additions & 4 deletions crates/rolldown_fs/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,14 @@ impl FileSystem for MemoryFileSystem {
self
.fs
.remove_dir(&path.to_string_lossy())
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
Ok(())
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
}

fn create_dir_all(&self, path: &Path) -> io::Result<()> {
self
.fs
.create_dir(&path.to_string_lossy())
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
Ok(())
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
}

fn write(&self, path: &Path, content: &[u8]) -> io::Result<()> {
Expand Down

0 comments on commit 9dff0db

Please sign in to comment.