Skip to content

Commit

Permalink
build: upgrade to Rust 1.81 (#3972)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos committed Sep 18, 2024
1 parent 756dd38 commit 0a80daa
Show file tree
Hide file tree
Showing 23 changed files with 99 additions and 121 deletions.
27 changes: 18 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ empty_docs = "allow" # there are some false positives inside biome_
multiple_crate_versions = "allow"

# pedantic
assigning_clones = "warn"
checked_conversions = "warn"
cloned_instead_of_copied = "warn"
copy_iterator = "warn"
Expand All @@ -35,10 +36,12 @@ implicit_hasher = "warn"
index_refutable_slice = "warn"
inefficient_to_string = "warn"
invalid_upcast_comparisons = "warn"
iter_filter_is_ok = "warn"
iter_not_returning_iterator = "warn"
large_stack_arrays = "warn"
large_types_passed_by_value = "warn"
macro_use_imports = "warn"
manual_is_variant_and = "warn"
manual_ok_or = "warn"
manual_string_new = "warn"
map_flatten = "warn"
Expand All @@ -50,9 +53,12 @@ needless_bitwise_bool = "warn"
needless_continue = "warn"
needless_for_each = "warn"
no_effect_underscore_binding = "warn"
option_as_ref_cloned = "warn"
ref_binding_to_reference = "warn"
ref_option_ref = "warn"
single_char_pattern = "warn"
stable_sort_primitive = "warn"
str_split_at_newline = "warn"
unnecessary_box_returns = "warn"
unnecessary_join = "warn"
unnested_or_patterns = "warn"
Expand All @@ -61,15 +67,18 @@ verbose_bit_mask = "warn"
zero_sized_map_values = "warn"

# restriction
empty_drop = "warn"
float_cmp_const = "warn"
get_unwrap = "warn"
infinite_loop = "warn"
lossy_float_literal = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
rest_pat_in_fully_bound_structs = "warn"
verbose_file_reads = "warn"
cfg_not_test = "warn"
empty_drop = "warn"
empty_enum_variants_with_brackets = "warn"
float_cmp_const = "warn"
get_unwrap = "warn"
infinite_loop = "warn"
lossy_float_literal = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
rest_pat_in_fully_bound_structs = "warn"
string_lit_chars_any = "warn"
verbose_file_reads = "warn"
# https://github.com/rustwasm/wasm-bindgen/issues/3944
#mem_forget = "warn"

Expand Down
5 changes: 1 addition & 4 deletions crates/biome_analyze/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use std::path::Path;
type RuleQueryResult<R> = <<R as Rule>::Query as Queryable>::Output;
type RuleServiceBag<R> = <<R as Rule>::Query as Queryable>::Services;

pub struct RuleContext<'a, R>
where
R: ?Sized + Rule,
{
pub struct RuleContext<'a, R: Rule> {
query_result: &'a RuleQueryResult<R>,
root: &'a RuleRoot<R>,
bag: &'a ServiceBag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ ci ━━━━━━━━━━━━━━━━━━━━━━━━━
# Emitted Messages

```block
src/folder_3/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
src/folder_1/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i The file src/folder_3/package-lock.json is protected because is handled by another tool. Biome won't process it.
i The file src/folder_1/package-lock.json is protected because is handled by another tool. Biome won't process it.
Verbose advice
Expand All @@ -34,9 +34,9 @@ src/folder_3/package-lock.json project VERBOSE ━━━━━━━━━━
```

```block
src/folder_2/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
src/folder_5/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i The file src/folder_2/package-lock.json is protected because is handled by another tool. Biome won't process it.
i The file src/folder_5/package-lock.json is protected because is handled by another tool. Biome won't process it.
Verbose advice
Expand All @@ -46,9 +46,9 @@ src/folder_2/package-lock.json project VERBOSE ━━━━━━━━━━
```

```block
src/folder_4/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
src/folder_0/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i The file src/folder_4/package-lock.json is protected because is handled by another tool. Biome won't process it.
i The file src/folder_0/package-lock.json is protected because is handled by another tool. Biome won't process it.
Verbose advice
Expand All @@ -58,9 +58,9 @@ src/folder_4/package-lock.json project VERBOSE ━━━━━━━━━━
```

```block
src/folder_6/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
src/folder_3/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i The file src/folder_6/package-lock.json is protected because is handled by another tool. Biome won't process it.
i The file src/folder_3/package-lock.json is protected because is handled by another tool. Biome won't process it.
Verbose advice
Expand All @@ -70,9 +70,9 @@ src/folder_6/package-lock.json project VERBOSE ━━━━━━━━━━
```

```block
src/folder_7/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
src/folder_2/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i The file src/folder_7/package-lock.json is protected because is handled by another tool. Biome won't process it.
i The file src/folder_2/package-lock.json is protected because is handled by another tool. Biome won't process it.
Verbose advice
Expand All @@ -82,9 +82,9 @@ src/folder_7/package-lock.json project VERBOSE ━━━━━━━━━━
```

```block
src/folder_1/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
src/folder_4/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i The file src/folder_1/package-lock.json is protected because is handled by another tool. Biome won't process it.
i The file src/folder_4/package-lock.json is protected because is handled by another tool. Biome won't process it.
Verbose advice
Expand All @@ -94,9 +94,9 @@ src/folder_1/package-lock.json project VERBOSE ━━━━━━━━━━
```

```block
src/folder_5/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
src/folder_6/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i The file src/folder_5/package-lock.json is protected because is handled by another tool. Biome won't process it.
i The file src/folder_6/package-lock.json is protected because is handled by another tool. Biome won't process it.
Verbose advice
Expand All @@ -106,9 +106,9 @@ src/folder_5/package-lock.json project VERBOSE ━━━━━━━━━━
```

```block
src/folder_0/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
src/folder_7/package-lock.json project VERBOSE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
i The file src/folder_0/package-lock.json is protected because is handled by another tool. Biome won't process it.
i The file src/folder_7/package-lock.json is protected because is handled by another tool. Biome won't process it.
Verbose advice
Expand Down
8 changes: 1 addition & 7 deletions crates/biome_console/src/write/termcolor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ where
// Unicode is currently poorly supported on most Windows
// terminal clients, so we always strip emojis in Windows
if cfg!(windows) || !self.writer.supports_color() {
let is_ascii = grapheme_is_ascii(grapheme);
let is_ascii = grapheme.is_ascii();

if !is_ascii {
let replacement = unicode_to_ascii(grapheme.chars().nth(0).unwrap());
Expand Down Expand Up @@ -201,12 +201,6 @@ fn grapheme_is_whitespace(grapheme: &str) -> bool {
grapheme.chars().all(|c| c.is_whitespace())
}

/// Determines if a grapheme contains code points which are out of the ASCII
/// range and thus cannot be printed where unicode is not supported.
fn grapheme_is_ascii(grapheme: &str) -> bool {
grapheme.chars().all(|c| c.is_ascii())
}

/// Replace emoji characters with similar but more widely supported ASCII
/// characters
fn unicode_to_ascii(c: char) -> char {
Expand Down
6 changes: 6 additions & 0 deletions crates/biome_fs/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,27 +241,32 @@ struct AliasPath {
}

impl AliasPath {
#[allow(dead_code)]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
prefix: vec![],
}
}

#[allow(dead_code)]
pub fn add_prefix(&mut self, prefix: impl Into<PathBuf>) {
self.prefix.push(prefix.into());
}
}

#[allow(dead_code)]
pub struct Aliases {
aliases: Vec<AliasPath>,
}

impl Aliases {
#[allow(dead_code)]
pub fn new() -> Self {
Self { aliases: vec![] }
}

#[allow(dead_code)]
pub fn with_alias<'a>(
mut self,
name: impl Into<String>,
Expand All @@ -275,6 +280,7 @@ impl Aliases {
self
}

#[allow(dead_code)]
pub fn get_paths_by_name(&self, name: &str) -> Option<&[PathBuf]> {
self.aliases
.iter()
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_grit_patterns/src/grit_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl Iterator for AncestorIterator {
type Item = GritNode;

fn next(&mut self) -> Option<Self::Item> {
let node = self.node.as_ref().cloned()?;
let node = self.node.clone()?;
self.node = node.parent();
Some(node)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_grit_patterns/src/grit_target_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl<'a> Iterator for AncestorIterator<'a> {
type Item = GritTargetNode<'a>;

fn next(&mut self) -> Option<Self::Item> {
let node = self.node.as_ref().cloned()?;
let node = self.node.clone()?;
self.node = node.parent();
Some(node)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ impl Visitor for CognitiveComplexityVisitor {
impl CognitiveComplexityVisitor {
fn on_enter(&mut self, node: &JsSyntaxNode) {
let parent = self.stack.last();
if parent
.map(|parent| parent.score == MAX_SCORE)
.unwrap_or_default()
{
if parent.is_some_and(|parent| parent.score == MAX_SCORE) {
return; // No need for further processing if we're already at the max.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,20 +386,17 @@ fn has_curly_braces(node: &AnyJsxCurlyQuery) -> bool {
}

fn contains_string_literal(node: &JsxExpressionAttributeValue) -> bool {
node.expression()
.map(|expr| {
matches!(
expr,
AnyJsExpression::AnyJsLiteralExpression(
AnyJsLiteralExpression::JsStringLiteralExpression(_)
)
node.expression().is_ok_and(|expr| {
matches!(
expr,
AnyJsExpression::AnyJsLiteralExpression(
AnyJsLiteralExpression::JsStringLiteralExpression(_)
)
})
.unwrap_or_default()
)
})
}

fn contains_jsx_tag(node: &JsxExpressionAttributeValue) -> bool {
node.expression()
.map(|expr| matches!(expr, AnyJsExpression::JsxTagExpression(_)))
.unwrap_or_default()
.is_ok_and(|expr| matches!(expr, AnyJsExpression::JsxTagExpression(_)))
}
12 changes: 4 additions & 8 deletions crates/biome_js_analyze/src/services/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,28 @@ impl ManifestServices {
self.manifest
.as_ref()
.as_ref()
.map(|pkg| pkg.dependencies.contains(specifier))
.unwrap_or_default()
.is_some_and(|pkg| pkg.dependencies.contains(specifier))
}

pub(crate) fn is_dev_dependency(&self, specifier: &str) -> bool {
self.manifest
.as_ref()
.as_ref()
.map(|pkg| pkg.dev_dependencies.contains(specifier))
.unwrap_or_default()
.is_some_and(|pkg| pkg.dev_dependencies.contains(specifier))
}

pub(crate) fn is_peer_dependency(&self, specifier: &str) -> bool {
self.manifest
.as_ref()
.as_ref()
.map(|pkg| pkg.peer_dependencies.contains(specifier))
.unwrap_or_default()
.is_some_and(|pkg| pkg.peer_dependencies.contains(specifier))
}

pub(crate) fn is_optional_dependency(&self, specifier: &str) -> bool {
self.manifest
.as_ref()
.as_ref()
.map(|pkg| pkg.optional_dependencies.contains(specifier))
.unwrap_or_default()
.is_some_and(|pkg| pkg.optional_dependencies.contains(specifier))
}
}

Expand Down
22 changes: 9 additions & 13 deletions crates/biome_js_analyze/src/suppression_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,14 @@ impl SuppressionAction for JsSuppressionAction {
// There are some tokens that might contains newlines in their tokens, only
// few nodes matches this criteria. If the token is inside one of those nodes,
// then we check its content.
let nodes_that_might_contain_newlines = current_token
.parent()
.map(|node| {
matches!(
node.kind(),
JsSyntaxKind::JSX_TEXT
| JsSyntaxKind::JS_STRING_LITERAL
| JsSyntaxKind::TEMPLATE_CHUNK
)
})
.unwrap_or_default();
let nodes_that_might_contain_newlines = current_token.parent().is_some_and(|node| {
matches!(
node.kind(),
JsSyntaxKind::JSX_TEXT
| JsSyntaxKind::JS_STRING_LITERAL
| JsSyntaxKind::TEMPLATE_CHUNK
)
});
if current_token
.trailing_trivia()
.pieces()
Expand Down Expand Up @@ -154,8 +151,7 @@ impl SuppressionAction for JsSuppressionAction {
// quick check is the element is inside a list
if current_jsx_element
.parent()
.map(|p| JsxChildList::can_cast(p.kind()))
.unwrap_or_default()
.is_some_and(|p| JsxChildList::can_cast(p.kind()))
{
let jsx_comment = jsx_expression_child(
token(T!['{']).with_trailing_trivia([(
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_js_parser/src/syntax/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,7 @@ pub(super) fn parse_unary_expr(p: &mut JsParser, context: ExpressionContext) ->
let mut rewriter = DeleteExpressionRewriter::default();
rewrite_events(&mut rewriter, checkpoint, p);

rewriter.result.take().map(|res| {
rewriter.result.take().inspect(|_| {
if StrictMode.is_supported(p) {
if let Some(range) = rewriter.exited_ident_expr {
kind = JS_BOGUS_EXPRESSION;
Expand All @@ -2180,8 +2180,6 @@ pub(super) fn parse_unary_expr(p: &mut JsParser, context: ExpressionContext) ->
range,
));
}

res
})
} else {
parse_unary_expr(p, context).ok()
Expand Down
4 changes: 0 additions & 4 deletions crates/biome_js_parser/src/syntax/typescript/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ impl TypeContext {
pub const TYPE_OR_INTERFACE_DECLARATION: Self =
Self(make_bitflags!(ContextFlag::{TypeOrInterfaceDeclaration}));

pub const fn empty() -> Self {
Self(BitFlags::EMPTY)
}

pub fn contains(&self, other: impl Into<TypeContext>) -> bool {
self.0.contains(other.into().0)
}
Expand Down
Loading

0 comments on commit 0a80daa

Please sign in to comment.