Skip to content

Commit

Permalink
Upgrade Rust toolchain to 1.84.0 (astral-sh#15408)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Jan 11, 2025
1 parent 2d82445 commit c39ca8f
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 45 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ redundant_clone = "warn"
debug_assert_with_mut_call = "warn"
unused_peekable = "warn"

# Diagnostics are not actionable: Enable once https://github.com/rust-lang/rust-clippy/issues/13774 is resolved.
large_stack_arrays = "allow"

[profile.release]
# Note that we set these explicitly, and these values
# were chosen based on a trade-off between compile times
Expand Down
2 changes: 1 addition & 1 deletion crates/red_knot_server/src/session/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Index {
DocumentKey::NotebookCell(url)
} else if Path::new(url.path())
.extension()
.map_or(false, |ext| ext.eq_ignore_ascii_case("ipynb"))
.is_some_and(|ext| ext.eq_ignore_ascii_case("ipynb"))
{
DocumentKey::Notebook(url)
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/red_knot_workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl Workspace {
open_files.contains(&file)
} else if let Some(system_path) = file.path(db).as_system_path() {
self.package(db, system_path)
.map_or(false, |package| package.contains_file(db, file))
.is_some_and(|package| package.contains_file(db, file))
} else {
file.path(db).is_system_virtual_path()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ A `--config` flag must either be a path to a `.toml` configuration file
// We want to display the most helpful error to the user as possible.
if Path::new(value)
.extension()
.map_or(false, |ext| ext.eq_ignore_ascii_case("toml"))
.is_some_and(|ext| ext.eq_ignore_ascii_case("toml"))
{
if !value.contains('=') {
tip.push_str(&format!(
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff_db/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ pub trait System: Debug {
/// Returns `true` if `path` exists and is a directory.
fn is_directory(&self, path: &SystemPath) -> bool {
self.path_metadata(path)
.map_or(false, |metadata| metadata.file_type.is_directory())
.is_ok_and(|metadata| metadata.file_type.is_directory())
}

/// Returns `true` if `path` exists and is a file.
fn is_file(&self, path: &SystemPath) -> bool {
self.path_metadata(path)
.map_or(false, |metadata| metadata.file_type.is_file())
.is_ok_and(|metadata| metadata.file_type.is_file())
}

/// Returns the current working directory
Expand Down
7 changes: 1 addition & 6 deletions crates/ruff_formatter/src/printer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,7 @@ impl<'a> Printer<'a> {
dest: self.state.buffer.text_len(),
};

if self
.state
.source_markers
.last()
.map_or(true, |last| last != &marker)
{
if self.state.source_markers.last() != Some(&marker) {
self.state.source_markers.push(marker);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/docstrings/sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ fn is_docstring_section(
// The return value of the function.
// """
// ```
if previous_line.map_or(false, |line| line.trim().is_empty()) {
if previous_line.is_some_and(|line| line.trim().is_empty()) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/fix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub(crate) fn fix_file(
diagnostic
.fix
.as_ref()
.map_or(false, |fix| fix.applies(required_applicability))
.is_some_and(|fix| fix.applies(required_applicability))
})
.peekable();

Expand Down
6 changes: 1 addition & 5 deletions crates/ruff_linter/src/noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ impl<'a> Directive<'a> {
comment_start = text[..comment_start].trim_end().len();

// The next character has to be the `#` character.
if text[..comment_start]
.chars()
.last()
.map_or(true, |c| c != '#')
{
if !text[..comment_start].ends_with('#') {
continue;
}
comment_start -= '#'.len_utf8();
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ pub(crate) fn f_strings(checker: &mut Checker, call: &ast::ExprCall, summary: &F
checker
.semantic()
.resolve_qualified_name(call.func.as_ref())
.map_or(false, |qualified_name| {
.is_some_and(|qualified_name| {
matches!(
qualified_name.segments(),
["django", "utils", "translation", "gettext" | "gettext_lazy"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub(crate) fn super_call_with_parameters(checker: &mut Checker, call: &ast::Expr
.resolve_qualified_name(func)
.is_some_and(|name| name.segments() == ["dataclasses", "dataclass"])
{
arguments.find_keyword("slots").map_or(false, |keyword| {
arguments.find_keyword("slots").is_some_and(|keyword| {
matches!(
keyword.value,
Expr::BooleanLiteral(ast::ExprBooleanLiteral { value: true, .. })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn in_subscript_index(expr: &ExprSubscript, semantic: &SemanticModel) -> bool {
}

// E.g., `Generic[DType, Unpack[int]]`.
if parent.slice.as_tuple_expr().map_or(false, |slice| {
if parent.slice.as_tuple_expr().is_some_and(|slice| {
slice
.elts
.iter()
Expand All @@ -144,5 +144,5 @@ fn in_vararg(expr: &ExprSubscript, semantic: &SemanticModel) -> bool {
.as_ref()
.and_then(|vararg| vararg.annotation.as_ref())
.and_then(|annotation| annotation.as_subscript_expr())
.map_or(false, |annotation| annotation == expr)
== Some(expr)
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub(crate) fn print_empty_string(checker: &mut Checker, call: &ast::ExprCall) {
let empty_separator = call
.arguments
.find_keyword("sep")
.map_or(false, |keyword| is_empty_string(&keyword.value));
.is_some_and(|keyword| is_empty_string(&keyword.value));
if !empty_separator {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_python_ast/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ impl StringLiteralValue {
pub fn is_unicode(&self) -> bool {
self.iter()
.next()
.map_or(false, |part| part.flags.prefix().is_unicode())
.is_some_and(|part| part.flags.prefix().is_unicode())
}

/// Returns a slice of all the [`StringLiteral`] parts contained in this value.
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_python_formatter/src/comments/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub(crate) struct FormatLeadingAlternateBranchComments<'a> {

impl Format<PyFormatContext<'_>> for FormatLeadingAlternateBranchComments<'_> {
fn fmt(&self, f: &mut PyFormatter) -> FormatResult<()> {
if self.last_node.map_or(false, |preceding| {
if self.last_node.is_some_and(|preceding| {
should_insert_blank_line_after_class_in_stub_file(preceding, None, f.context())
}) {
write!(f, [empty_line(), leading_comments(self.comments)])?;
Expand Down
33 changes: 15 additions & 18 deletions crates/ruff_python_semantic/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,24 +1002,21 @@ impl<'a> SemanticModel<'a> {
let value_name = UnqualifiedName::from_expr(value)?;
let (_, tail) = value_name.segments().split_first()?;

let resolved: QualifiedName = if qualified_name
.segments()
.first()
.map_or(false, |segment| *segment == ".")
{
from_relative_import(
self.module.qualified_name()?,
qualified_name.segments(),
tail,
)?
} else {
qualified_name
.segments()
.iter()
.chain(tail)
.copied()
.collect()
};
let resolved: QualifiedName =
if qualified_name.segments().first().copied() == Some(".") {
from_relative_import(
self.module.qualified_name()?,
qualified_name.segments(),
tail,
)?
} else {
qualified_name
.segments()
.iter()
.chain(tail)
.copied()
.collect()
};
Some(resolved)
}
BindingKind::Builtin => {
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_server/src/session/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Index {
DocumentKey::NotebookCell(url)
} else if Path::new(url.path())
.extension()
.map_or(false, |ext| ext.eq_ignore_ascii_case("ipynb"))
.is_some_and(|ext| ext.eq_ignore_ascii_case("ipynb"))
{
DocumentKey::Notebook(url)
} else {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.83"
channel = "1.84"

0 comments on commit c39ca8f

Please sign in to comment.