Switch to Rust 2024 edition (#18129)

This commit is contained in:
Micha Reiser 2025-05-16 13:25:28 +02:00 committed by GitHub
parent e67b35743a
commit 9ae698fe30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
1082 changed files with 4211 additions and 3300 deletions

View file

@ -217,11 +217,11 @@ impl From<&Expr> for ResolvedPythonType {
) {
// Ex) `"Hello" % "world"`
(ResolvedPythonType::Atom(PythonType::String), _) => {
return ResolvedPythonType::Atom(PythonType::String)
return ResolvedPythonType::Atom(PythonType::String);
}
// Ex) `b"Hello" % b"world"`
(ResolvedPythonType::Atom(PythonType::Bytes), _) => {
return ResolvedPythonType::Atom(PythonType::Bytes)
return ResolvedPythonType::Atom(PythonType::Bytes);
}
// Ex) `1 % 2`
(
@ -452,7 +452,7 @@ impl NumberLike {
#[cfg(test)]
mod tests {
use ruff_python_ast::ModExpression;
use ruff_python_parser::{parse_expression, Parsed};
use ruff_python_parser::{Parsed, parse_expression};
use crate::analyze::type_inference::{NumberLike, PythonType, ResolvedPythonType};

View file

@ -15,7 +15,7 @@ use ruff_python_stdlib::typing::{
is_typed_dict, is_typed_dict_member,
};
use ruff_text_size::Ranged;
use smallvec::{smallvec, SmallVec};
use smallvec::{SmallVec, smallvec};
use crate::analyze::type_inference::{NumberLike, PythonType, ResolvedPythonType};
use crate::model::SemanticModel;
@ -1161,7 +1161,7 @@ pub fn find_binding_value<'a>(binding: &Binding, semantic: &'a SemanticModel) ->
Some(Stmt::Assign(ast::StmtAssign { value, targets, .. })) => {
return targets
.iter()
.find_map(|target| match_value(binding, target, value))
.find_map(|target| match_value(binding, target, value));
}
Some(Stmt::AnnAssign(ast::StmtAnnAssign {
value: Some(value),

View file

@ -4,17 +4,17 @@ use std::ops::{Deref, DerefMut};
use bitflags::bitflags;
use crate::all::DunderAllName;
use ruff_index::{newtype_index, IndexSlice, IndexVec};
use ruff_index::{IndexSlice, IndexVec, newtype_index};
use ruff_python_ast::helpers::extract_handled_exceptions;
use ruff_python_ast::name::QualifiedName;
use ruff_python_ast::{self as ast, Stmt};
use ruff_text_size::{Ranged, TextRange};
use crate::ScopeId;
use crate::context::ExecutionContext;
use crate::model::SemanticModel;
use crate::nodes::NodeId;
use crate::reference::ResolvedReferenceId;
use crate::ScopeId;
#[derive(Debug, Clone)]
pub struct Binding<'a> {

View file

@ -1,6 +1,6 @@
use std::ops::Index;
use ruff_index::{newtype_index, IndexVec};
use ruff_index::{IndexVec, newtype_index};
/// ID uniquely identifying a branch in a program.
///

View file

@ -1,7 +1,7 @@
use ruff_index::{newtype_index, IndexVec};
use ruff_index::{IndexVec, newtype_index};
use ruff_python_ast::Stmt;
use ruff_text_size::{Ranged, TextRange};
use smallvec::{smallvec, SmallVec};
use smallvec::{SmallVec, smallvec};
/// Returns the control flow graph associated to an array of statements
pub fn build_cfg(stmts: &[Stmt]) -> ControlFlowGraph<'_> {

View file

@ -208,7 +208,7 @@ impl<'stmt> MermaidGraph<'stmt> for CFGWithSource<'stmt> {
return MermaidNode {
content: "EXIT".to_string(),
shape: MermaidNodeShape::DoubleCircle,
}
};
}
};

View file

@ -5,17 +5,17 @@ use std::fmt::Debug;
use std::ops::Deref;
use std::path::Path;
use ruff_index::{newtype_index, IndexSlice, IndexVec};
use ruff_index::{IndexSlice, IndexVec, newtype_index};
use ruff_python_ast::name::QualifiedName;
use ruff_python_ast::{self as ast, Stmt, StmtFunctionDef};
use ruff_text_size::{Ranged, TextRange};
use crate::SemanticModel;
use crate::analyze::visibility::{
class_visibility, function_visibility, is_property, method_visibility, module_visibility,
Visibility,
Visibility, class_visibility, function_visibility, is_property, method_visibility,
module_visibility,
};
use crate::model::all::DunderAllName;
use crate::SemanticModel;
/// Id uniquely identifying a definition in a program.
#[newtype_index]

View file

@ -8,8 +8,8 @@ use ruff_python_ast::{self as ast, Stmt};
use ruff_text_size::{Ranged, TextRange};
use rustc_hash::FxHashMap;
use ruff_index::{newtype_index, IndexVec};
use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor};
use ruff_index::{IndexVec, newtype_index};
use ruff_python_ast::statement_visitor::{StatementVisitor, walk_stmt};
/// Id uniquely identifying the set of global names for a given scope.
#[newtype_index]

View file

@ -273,7 +273,7 @@ impl schemars::JsonSchema for NameImports {
"NameImports".to_string()
}
fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
schemars::schema::SchemaObject {
instance_type: Some(schemars::schema::InstanceType::String.into()),
..Default::default()

View file

@ -8,6 +8,7 @@ use ruff_python_ast::name::{QualifiedName, UnqualifiedName};
use ruff_python_ast::{self as ast, Expr, ExprContext, PySourceType, Stmt};
use ruff_text_size::{Ranged, TextRange, TextSize};
use crate::Imported;
use crate::binding::{
Binding, BindingFlags, BindingId, BindingKind, Bindings, Exceptions, FromImport, Import,
SubmoduleImport,
@ -22,7 +23,6 @@ use crate::reference::{
UnresolvedReferenceFlags, UnresolvedReferences,
};
use crate::scope::{Scope, ScopeId, ScopeKind, Scopes};
use crate::Imported;
pub mod all;

View file

@ -2,7 +2,7 @@
use bitflags::bitflags;
use ruff_python_ast::{self as ast, helpers::map_subscript, Expr, Stmt};
use ruff_python_ast::{self as ast, Expr, Stmt, helpers::map_subscript};
use ruff_text_size::{Ranged, TextRange};
use crate::SemanticModel;

View file

@ -1,6 +1,6 @@
use std::ops::Index;
use ruff_index::{newtype_index, IndexVec};
use ruff_index::{IndexVec, newtype_index};
use ruff_python_ast::{Expr, Stmt};
use ruff_text_size::{Ranged, TextRange};

View file

@ -2,7 +2,7 @@ use std::ops::Deref;
use bitflags::bitflags;
use ruff_index::{newtype_index, IndexSlice, IndexVec};
use ruff_index::{IndexSlice, IndexVec, newtype_index};
use ruff_python_ast::ExprContext;
use ruff_text_size::{Ranged, TextRange};

View file

@ -4,7 +4,7 @@ use bitflags::bitflags;
use ruff_python_ast as ast;
use rustc_hash::FxHashMap;
use ruff_index::{newtype_index, Idx, IndexSlice, IndexVec};
use ruff_index::{Idx, IndexSlice, IndexVec, newtype_index};
use crate::binding::BindingId;
use crate::globals::GlobalsId;