Skip to content

Commit 138e70b

Browse files
authored
Upgrade to Rust 1.80 (#12586)
1 parent ee103ff commit 138e70b

File tree

29 files changed

+57
-48
lines changed

29 files changed

+57
-48
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ zip = { version = "0.6.6", default-features = false, features = ["zstd"] }
156156
[workspace.lints.rust]
157157
unsafe_code = "warn"
158158
unreachable_pub = "warn"
159+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
159160

160161
[workspace.lints.clippy]
161162
pedantic = { level = "warn", priority = -2 }

clippy.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ doc-valid-idents = [
1111
"SQLAlchemy",
1212
"StackOverflow",
1313
]
14+
15+
ignore-interior-mutability = [
16+
# Interned is read-only. The wrapped `Rc` never gets updated.
17+
"ruff_formatter::format_element::Interned",
18+
19+
# The expression is read-only.
20+
"ruff_python_ast::hashable::HashableExpr",
21+
]

crates/red_knot_python_semantic/src/semantic_index/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ where
330330
function_def.type_params.as_deref(),
331331
|builder| {
332332
builder.visit_parameters(&function_def.parameters);
333-
for expr in &function_def.returns {
333+
if let Some(expr) = &function_def.returns {
334334
builder.visit_annotation(expr);
335335
}
336336

crates/ruff_formatter/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
//!
88
//! * [`Format`]: Implemented by objects that can be formatted.
99
//! * [`FormatRule`]: Rule that knows how to format an object of another type. Useful in the situation where
10-
//! it's necessary to implement [Format] on an object from another crate. This module defines the
11-
//! [`FormatRefWithRule`] and [`FormatOwnedWithRule`] structs to pass an item with its corresponding rule.
10+
//! it's necessary to implement [Format] on an object from another crate. This module defines the
11+
//! [`FormatRefWithRule`] and [`FormatOwnedWithRule`] structs to pass an item with its corresponding rule.
1212
//! * [`FormatWithRule`] implemented by objects that know how to format another type. Useful for implementing
13-
//! some reusable formatting logic inside of this module if the type itself doesn't implement [Format]
13+
//! some reusable formatting logic inside of this module if the type itself doesn't implement [Format]
1414
//!
1515
//! ## Formatting Macros
1616
//!

crates/ruff_formatter/src/printer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ impl Indentation {
982982
/// The behaviour depends on the [`indent_style`][IndentStyle] if this is an [`Indent::Align`]:
983983
/// - **Tabs**: `align` is converted into an indent. This results in `level` increasing by two: once for the align, once for the level increment
984984
/// - **Spaces**: Increments the `level` by one and keeps the `align` unchanged.
985-
/// Keeps any the current value is [`Indent::Align`] and increments the level by one.
985+
/// Keeps any the current value is [`Indent::Align`] and increments the level by one.
986986
fn increment_level(self, indent_style: IndentStyle) -> Self {
987987
match self {
988988
Indentation::Level(count) => Indentation::Level(count + 1),

crates/ruff_linter/src/checkers/ast/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
719719
self.visit_expr(expr);
720720
}
721721
}
722-
for expr in returns {
722+
if let Some(expr) = returns {
723723
match annotation {
724724
AnnotationContext::RuntimeRequired => {
725725
self.visit_runtime_required_annotation(expr);
@@ -1240,7 +1240,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
12401240
for arg in args {
12411241
self.visit_type_definition(arg);
12421242
}
1243-
for keyword in arguments.keywords.iter() {
1243+
for keyword in &*arguments.keywords {
12441244
let Keyword {
12451245
arg,
12461246
value,
@@ -1286,7 +1286,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
12861286
}
12871287
}
12881288

1289-
for keyword in arguments.keywords.iter() {
1289+
for keyword in &*arguments.keywords {
12901290
let Keyword { arg, value, .. } = keyword;
12911291
match (arg.as_ref(), value) {
12921292
// Ex) NamedTuple("a", **{"a": int})
@@ -1331,7 +1331,7 @@ impl<'a> Visitor<'a> for Checker<'a> {
13311331
}
13321332

13331333
// Ex) TypedDict("a", a=int)
1334-
for keyword in arguments.keywords.iter() {
1334+
for keyword in &*arguments.keywords {
13351335
let Keyword { value, .. } = keyword;
13361336
self.visit_type_definition(value);
13371337
}
@@ -1345,13 +1345,13 @@ impl<'a> Visitor<'a> for Checker<'a> {
13451345
for arg in args {
13461346
self.visit_non_type_definition(arg);
13471347
}
1348-
for keyword in arguments.keywords.iter() {
1348+
for keyword in &*arguments.keywords {
13491349
let Keyword { value, .. } = keyword;
13501350
self.visit_non_type_definition(value);
13511351
}
13521352
} else {
13531353
// Ex) DefaultNamedArg(type="bool", name="some_prop_name")
1354-
for keyword in arguments.keywords.iter() {
1354+
for keyword in &*arguments.keywords {
13551355
let Keyword {
13561356
value,
13571357
arg,
@@ -1369,10 +1369,10 @@ impl<'a> Visitor<'a> for Checker<'a> {
13691369
// If we're in a type definition, we need to treat the arguments to any
13701370
// other callables as non-type definitions (i.e., we don't want to treat
13711371
// any strings as deferred type definitions).
1372-
for arg in arguments.args.iter() {
1372+
for arg in &*arguments.args {
13731373
self.visit_non_type_definition(arg);
13741374
}
1375-
for keyword in arguments.keywords.iter() {
1375+
for keyword in &*arguments.keywords {
13761376
let Keyword { value, .. } = keyword;
13771377
self.visit_non_type_definition(value);
13781378
}

crates/ruff_linter/src/message/json_lines.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ impl Emitter for JsonLinesEmitter {
1313
messages: &[Message],
1414
context: &EmitterContext,
1515
) -> anyhow::Result<()> {
16-
let mut w = writer;
1716
for message in messages {
18-
serde_json::to_writer(&mut w, &message_to_json_value(message, context))?;
19-
w.write_all(b"\n")?;
17+
serde_json::to_writer(&mut *writer, &message_to_json_value(message, context))?;
18+
writer.write_all(b"\n")?;
2019
}
2120
Ok(())
2221
}

crates/ruff_linter/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<'a> Visitor<'a> for SuspiciousVariablesVisitor<'a> {
132132
match func.as_ref() {
133133
Expr::Name(ast::ExprName { id, .. }) => {
134134
if matches!(id.as_str(), "filter" | "reduce" | "map") {
135-
for arg in arguments.args.iter() {
135+
for arg in &*arguments.args {
136136
if arg.is_lambda_expr() {
137137
self.safe_functions.push(arg);
138138
}
@@ -143,7 +143,7 @@ impl<'a> Visitor<'a> for SuspiciousVariablesVisitor<'a> {
143143
if attr == "reduce" {
144144
if let Expr::Name(ast::ExprName { id, .. }) = value.as_ref() {
145145
if id == "functools" {
146-
for arg in arguments.args.iter() {
146+
for arg in &*arguments.args {
147147
if arg.is_lambda_expr() {
148148
self.safe_functions.push(arg);
149149
}
@@ -155,7 +155,7 @@ impl<'a> Visitor<'a> for SuspiciousVariablesVisitor<'a> {
155155
_ => {}
156156
}
157157

158-
for keyword in arguments.keywords.iter() {
158+
for keyword in &*arguments.keywords {
159159
if keyword.arg.as_ref().is_some_and(|arg| arg == "key")
160160
&& keyword.value.is_lambda_expr()
161161
{

crates/ruff_linter/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn is_infinite_iterator(arg: &Expr, semantic: &SemanticModel) -> bool {
116116
}
117117

118118
// Ex) `iterools.repeat(1, times=None)`
119-
for keyword in keywords.iter() {
119+
for keyword in &**keywords {
120120
if keyword.arg.as_ref().is_some_and(|name| name == "times") {
121121
if keyword.value.is_none_literal_expr() {
122122
return true;

crates/ruff_linter/src/rules/flake8_django/rules/nullable_model_string_field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn is_nullable_field<'a>(value: &'a Expr, semantic: &'a SemanticModel) -> Option
8888
let mut null_key = false;
8989
let mut blank_key = false;
9090
let mut unique_key = false;
91-
for keyword in call.arguments.keywords.iter() {
91+
for keyword in &*call.arguments.keywords {
9292
let Some(argument) = &keyword.arg else {
9393
continue;
9494
};

0 commit comments

Comments
 (0)