Skip to content

Commit

Permalink
build: upgrade toolchain to Rust 1.85.0 (#5225)
Browse files Browse the repository at this point in the history
  • Loading branch information
siketyan authored Mar 1, 2025
1 parent 8d9d282 commit c60ef4a
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 76 deletions.
6 changes: 3 additions & 3 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ where
}

fn range_match(filter: Option<TextRange>, range: TextRange) -> bool {
filter.map_or(true, |filter| filter.intersect(range).is_some())
filter.is_none_or(|filter| filter.intersect(range).is_some())
}

/// Signature for a suppression comment parser function
Expand Down Expand Up @@ -894,7 +894,7 @@ impl<'analysis> AnalysisFilter<'analysis> {
/// Return `true` if the group `G` matches this filter
pub fn match_group<G: RuleGroup>(&self) -> bool {
self.match_category::<G::Category>()
&& self.enabled_rules.map_or(true, |enabled_rules| {
&& self.enabled_rules.is_none_or(|enabled_rules| {
enabled_rules.iter().any(|filter| filter.match_group::<G>())
})
&& !self
Expand All @@ -906,7 +906,7 @@ impl<'analysis> AnalysisFilter<'analysis> {
/// Return `true` if the rule `R` matches this filter
pub fn match_rule<R: Rule>(&self) -> bool {
self.match_category::<<R::Group as RuleGroup>::Category>()
&& self.enabled_rules.map_or(true, |enabled_rules| {
&& self.enabled_rules.is_none_or(|enabled_rules| {
enabled_rules.iter().any(|filter| filter.match_rule::<R>())
})
&& !self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub(super) fn node_to_args_pairs(
let name = name
.strip_prefix(lang.metavariable_prefix())
.filter(|stripped| {
expected_params.as_ref().map_or(true, |expected| {
expected_params.as_ref().is_none_or(|expected| {
expected.iter().any(|exp| exp == &name || exp == stripped)
})
})
Expand Down
14 changes: 6 additions & 8 deletions crates/biome_js_analyze/src/lint/a11y/use_alt_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fn has_valid_alt_text(element: &AnyJsxElement) -> bool {

attribute
.as_static_value()
.map_or(true, |value| !value.is_null_or_undefined())
.is_none_or(|value| !value.is_null_or_undefined())
})
}

Expand All @@ -191,7 +191,7 @@ fn has_valid_label(element: &AnyJsxElement, name_to_lookup: &str) -> bool {
if attribute.initializer().is_none() {
return false;
}
attribute.as_static_value().map_or(true, |value| {
attribute.as_static_value().is_none_or(|value| {
!value.is_null_or_undefined() && value.is_not_string_constant("")
})
})
Expand All @@ -201,11 +201,9 @@ fn is_aria_hidden(element: &AnyJsxElement) -> bool {
element
.find_attribute_by_name("aria-hidden")
.is_some_and(|attribute| {
attribute
.as_static_value()
.map_or(true, |value| match value {
StaticValue::Boolean(token) => token.text_trimmed() == "true",
_ => false,
})
attribute.as_static_value().is_none_or(|value| match value {
StaticValue::Boolean(token) => token.text_trimmed() == "true",
_ => false,
})
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fn has_valid_anchor_content(node: &AnyJsxElement) -> bool {
}
attribute
.as_static_value()
.map_or(true, |attribute| !attribute.is_falsy())
.is_none_or(|attribute| !attribute.is_falsy())
})
|| node.has_spread_prop()
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn has_valid_heading_content(node: &AnyJsxElement) -> bool {
}
attribute
.as_static_value()
.map_or(true, |attribute| !attribute.is_falsy())
.is_none_or(|attribute| !attribute.is_falsy())
})
|| node.has_spread_prop()
}
2 changes: 1 addition & 1 deletion crates/biome_js_analyze/src/lint/a11y/use_html_lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Rule for UseHtmlLang {
if let Some(lang_attribute) = element.find_attribute_by_name("lang") {
if !lang_attribute
.as_static_value()
.map_or(true, |attribute| attribute.is_not_string_constant(""))
.is_none_or(|attribute| attribute.is_not_string_constant(""))
&& !element.has_trailing_spread_prop(&lang_attribute)
{
return Some(element.syntax().text_trimmed_range());
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_analyze/src/lint/a11y/use_iframe_title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Rule for UseIframeTitle {
if let Some(lang_attribute) = element.find_attribute_by_name("title") {
if !lang_attribute
.as_static_value()
.map_or(true, |attribute| attribute.is_not_string_constant(""))
.is_none_or(|attribute| attribute.is_not_string_constant(""))
&& !element.has_trailing_spread_prop(&lang_attribute)
{
return Some(());
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_js_analyze/src/lint/a11y/use_valid_anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Rule for UseValidAnchor {
}

let static_value = anchor_attribute.as_static_value()?;
if static_value.as_string_constant().map_or(true, |const_str| {
if static_value.as_string_constant().is_none_or(|const_str| {
const_str.is_empty()
|| const_str.contains('#')
|| const_str.contains("javascript:")
Expand All @@ -176,7 +176,7 @@ impl Rule for UseValidAnchor {
}

let static_value = anchor_attribute.as_static_value()?;
if static_value.as_string_constant().map_or(true, |const_str| {
if static_value.as_string_constant().is_none_or(|const_str| {
const_str.is_empty()
|| const_str == "#"
|| const_str.contains("javascript:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ fn capture_needs_to_be_in_the_dependency_list(
// ... they are declared outside of the component function
if component_function_range
.intersect(declaration_range)
.map_or(true, TextRange::is_empty)
.is_none_or(TextRange::is_empty)
{
return false;
}
Expand Down Expand Up @@ -552,7 +552,7 @@ fn capture_needs_to_be_in_the_dependency_list(
// ... they are declared outside of the component function
if component_function_range
.intersect(declaration_range)
.map_or(true, TextRange::is_empty)
.is_none_or(TextRange::is_empty)
{
return false;
}
Expand All @@ -562,7 +562,7 @@ fn capture_needs_to_be_in_the_dependency_list(
if declarator
.initializer()
.and_then(|initializer| initializer.expression().ok())
.map_or(true, |expr| model.is_constant(&expr))
.is_none_or(|expr| model.is_constant(&expr))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,5 +599,5 @@ fn is_undefined(model: &SemanticModel, node: &JsIdentifierExpression) -> SyntaxR
/// Check the referenced variable is in the global scope.
fn is_global_reference(model: &SemanticModel, node: &JsReferenceIdentifier) -> bool {
node.binding(model)
.map_or(true, |b| b.scope().is_global_scope())
.is_none_or(|b| b.scope().is_global_scope())
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Rule for NoStaticElementInteractions {
if let Some(value) = node.find_attribute_by_name(handler) {
value
.as_static_value()
.map_or(true, |value| value.text() != "null")
.is_none_or(|value| value.text() != "null")
} else {
false
}
Expand Down Expand Up @@ -153,7 +153,7 @@ fn is_hidden_from_screen_reader(node: &AnyJsxElement, element_name: &str) -> boo
node.find_attribute_by_name("aria-hidden")
.is_some_and(|attr| {
attr.as_static_value()
.map_or(true, |val| val.text() == "true")
.is_none_or(|val| val.text() == "true")
})// <div aria-hidden />
|| (element_name == "input"
&& node.find_attribute_by_name("type").is_some_and(|attr| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Rule for UseSelfClosingElements {
let prev_token = r_angle_token.prev_token();
let need_extra_whitespace = prev_token
.as_ref()
.map_or(true, |token| !token.trailing_trivia().text().ends_with(' '));
.is_none_or(|token| !token.trailing_trivia().text().ends_with(' '));

// drop the leading trivia of `r_angle_token`
r_angle_token = r_angle_token.with_leading_trivia([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn is_global_object(semantic: &SemanticModel) -> bool {
semantic
.scopes()
.find(|s| s.get_binding("Object").is_some())
.map_or(true, |s| s.is_global_scope())
.is_none_or(|s| s.is_global_scope())
}

/// Checks if the given node is considered to be an access to a property of `Object.prototype`.
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_formatter/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ fn handle_import_named_clause_comments(
// ```
let is_after_from_keyword = comment
.following_token()
.map_or(true, |token| token.kind() != JsSyntaxKind::FROM_KW);
.is_none_or(|token| token.kind() != JsSyntaxKind::FROM_KW);
if is_after_from_keyword {
if let Some(following_node) = comment.following_node() {
return CommentPlacement::leading(following_node.clone(), comment);
Expand Down
45 changes: 22 additions & 23 deletions crates/biome_js_formatter/src/js/expressions/call_arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,29 +1073,28 @@ fn can_group_expression_argument(
// (type: ObjectType): Provider<Opts> => {}
// );
// }
let can_group_type =
return_type_annotation
.and_then(|rty| rty.ty().ok())
.map_or(true, |any_type| match any_type {
AnyTsReturnType::AnyTsType(AnyTsType::TsReferenceType(_)) => match &body {
AnyJsFunctionBody::JsFunctionBody(body) => {
body.statements().iter().any(|statement| match statement {
AnyJsStatement::JsEmptyStatement(s) => {
// When the body contains an empty statement, comments in
// the body will get attached to that statement rather than
// the body itself, so they need to be checked for comments
// as well to ensure that the body is still considered
// groupable when those empty statements are removed by the
// printer.
comments.has_comments(s.syntax())
}
_ => true,
}) || comments.has_dangling_comments(body.syntax())
}
_ => false,
},
_ => true,
});
let can_group_type = return_type_annotation
.and_then(|rty| rty.ty().ok())
.is_none_or(|any_type| match any_type {
AnyTsReturnType::AnyTsType(AnyTsType::TsReferenceType(_)) => match &body {
AnyJsFunctionBody::JsFunctionBody(body) => {
body.statements().iter().any(|statement| match statement {
AnyJsStatement::JsEmptyStatement(s) => {
// When the body contains an empty statement, comments in
// the body will get attached to that statement rather than
// the body itself, so they need to be checked for comments
// as well to ensure that the body is still considered
// groupable when those empty statements are removed by the
// printer.
comments.has_comments(s.syntax())
}
_ => true,
}) || comments.has_dangling_comments(body.syntax())
}
_ => false,
},
_ => true,
});

let can_group_body = match &body {
AnyJsFunctionBody::JsFunctionBody(_)
Expand Down
15 changes: 6 additions & 9 deletions crates/biome_js_formatter/src/utils/conditional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,30 +407,27 @@ impl FormatJsAnyConditionalRule {
let argument = match parent.kind() {
JsSyntaxKind::JS_INITIALIZER_CLAUSE => {
let initializer = JsInitializerClause::unwrap_cast(parent);
initializer.expression().ok().map(AnyJsExpression::from)
initializer.expression().ok()
}
JsSyntaxKind::JS_RETURN_STATEMENT => {
let return_statement = JsReturnStatement::unwrap_cast(parent);
return_statement.argument().map(AnyJsExpression::from)
return_statement.argument()
}
JsSyntaxKind::JS_THROW_STATEMENT => {
let throw_statement = JsThrowStatement::unwrap_cast(parent);
throw_statement.argument().ok().map(AnyJsExpression::from)
throw_statement.argument().ok()
}
JsSyntaxKind::JS_UNARY_EXPRESSION => {
let unary_expression = JsUnaryExpression::unwrap_cast(parent);
unary_expression.argument().ok().map(AnyJsExpression::from)
unary_expression.argument().ok()
}
JsSyntaxKind::JS_YIELD_ARGUMENT => {
let yield_argument = JsYieldArgument::unwrap_cast(parent);
yield_argument.expression().ok().map(AnyJsExpression::from)
yield_argument.expression().ok()
}
JsSyntaxKind::JS_ASSIGNMENT_EXPRESSION => {
let assignment_expression = JsAssignmentExpression::unwrap_cast(parent);
assignment_expression
.right()
.ok()
.map(AnyJsExpression::from)
assignment_expression.right().ok()
}
_ => None,
};
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_js_syntax/src/jsx_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ impl AnyJsxElement {
.is_some_and(|attribute| {
attribute
.as_static_value()
.map_or(true, |value| !(value.is_falsy() || value.text() == "false"))
.is_none_or(|value| !(value.is_falsy() || value.text() == "false"))
&& !self.has_trailing_spread_prop(&attribute)
})
}
Expand Down Expand Up @@ -590,7 +590,7 @@ impl AnyJsxChild {
let expression = expression.expression()?;
expression
.as_static_value()
.map_or(true, |value| !value.is_falsy())
.is_none_or(|value| !value.is_falsy())
}
AnyJsxChild::JsxElement(element) => {
let opening_element = element.opening_element().ok()?;
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_service/src/file_handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ impl<'a, 'b> LintVisitor<'a, 'b> {
}

fn finish(mut self) -> (FxHashSet<RuleFilter<'a>>, FxHashSet<RuleFilter<'a>>) {
let has_only_filter = self.only.map_or(true, |only| !only.is_empty());
let has_only_filter = self.only.is_none_or(|only| !only.is_empty());
let rules = self
.settings
.and_then(|settings| settings.as_linter_rules(self.path.expect("Path to be set")))
Expand Down Expand Up @@ -1310,7 +1310,7 @@ impl<'a, 'b> AssistsVisitor<'a, 'b> {
}

fn finish(mut self) -> (Vec<RuleFilter<'a>>, Vec<RuleFilter<'a>>) {
let has_only_filter = self.only.map_or(true, |only| !only.is_empty());
let has_only_filter = self.only.is_none_or(|only| !only.is_empty());
let rules = self
.settings
.and_then(|settings| settings.as_assist_actions(self.path.expect("Path to be set")))
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_service/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl From<OverrideFormatterConfiguration> for OverrideFormatSettings {
Self {
enabled: conf.enabled,
format_with_errors: conf.format_with_errors,
indent_style: conf.indent_style.map(Into::into),
indent_style: conf.indent_style,
indent_width: conf.indent_width,
line_ending: conf.line_ending,
line_width: conf.line_width,
Expand Down Expand Up @@ -1624,7 +1624,7 @@ impl TryFrom<OverrideFormatterConfiguration> for FormatSettings {
Some(IndentStyle::Space) => IndentStyle::Space,
None => IndentStyle::default(),
};
let indent_width = conf.indent_width.map(Into::into).unwrap_or_default();
let indent_width = conf.indent_width.unwrap_or_default();

Ok(Self {
enabled: conf.enabled,
Expand Down
18 changes: 9 additions & 9 deletions crates/biome_string_case/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ pub enum Case {
/// ASCII numbers
Number = 1 << 0,
/// Alphanumeric Characters that cannot be in lowercase or uppercase (numbers and syllabary)
Uni = Case::Number as u16 | 1 << 1,
Uni = Case::Number as u16 | (1 << 1),
/// A, B1, C42
NumberableCapital = 1 << 2,
/// UPPERCASE
Upper = Case::NumberableCapital as u16 | 1 << 3,
Upper = Case::NumberableCapital as u16 | (1 << 3),
// CONSTANT_CASE
Constant = Case::Upper as u16 | 1 << 4,
Constant = Case::Upper as u16 | (1 << 4),
/// PascalCase
Pascal = Case::NumberableCapital as u16 | 1 << 5,
Pascal = Case::NumberableCapital as u16 | (1 << 5),
/// lowercase
Lower = Case::Number as u16 | 1 << 6,
Lower = Case::Number as u16 | (1 << 6),
/// snake_case
Snake = Case::Lower as u16 | 1 << 7,
Snake = Case::Lower as u16 | (1 << 7),
/// kebab-case
Kebab = Case::Lower as u16 | 1 << 8,
Kebab = Case::Lower as u16 | (1 << 8),
// camelCase
Camel = Case::Lower as u16 | 1 << 9,
Camel = Case::Lower as u16 | (1 << 9),
/// Unknown case
#[default]
Unknown = Case::Camel as u16
Expand All @@ -60,7 +60,7 @@ pub enum Case {
| Case::Pascal as u16
| Case::Constant as u16
| Case::Uni as u16
| 1 << 10,
| (1 << 10),
}

impl Case {
Expand Down
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 @@
# The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy.
# https://rust-lang.github.io/rustup/concepts/profiles.html
profile = "default"
channel = "1.84.0"
channel = "1.85.0"
Loading

0 comments on commit c60ef4a

Please sign in to comment.