Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update ruff to 0.11.12
  • Loading branch information
ShaharNaveh committed Sep 20, 2025
commit 735f172e995c6eb8b8949aa3f2c94d19ee7d6568
107 changes: 26 additions & 81 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ rustpython-sre_engine = { path = "vm/sre_engine", version = "0.4.0" }
rustpython-wtf8 = { path = "wtf8", version = "0.4.0" }
rustpython-doc = { git = "https://github.com/RustPython/__doc__", tag = "0.3.0", version = "0.3.0" }

ruff_python_parser = { git = "https://github.com/astral-sh/ruff.git", tag = "0.11.0" }
ruff_python_ast = { git = "https://github.com/astral-sh/ruff.git", tag = "0.11.0" }
ruff_text_size = { git = "https://github.com/astral-sh/ruff.git", tag = "0.11.0" }
ruff_source_file = { git = "https://github.com/astral-sh/ruff.git", tag = "0.11.0" }
ruff_python_parser = { git = "https://github.com/astral-sh/ruff.git", tag = "0.11.12" }
ruff_python_ast = { git = "https://github.com/astral-sh/ruff.git", tag = "0.11.12" }
ruff_text_size = { git = "https://github.com/astral-sh/ruff.git", tag = "0.11.12" }
ruff_source_file = { git = "https://github.com/astral-sh/ruff.git", tag = "0.11.12" }

ahash = "0.8.12"
ascii = "1.1"
Expand Down
1 change: 1 addition & 0 deletions compiler/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rustpython-literal = {workspace = true }
rustpython-wtf8 = { workspace = true }
ruff_python_ast = { workspace = true }
ruff_text_size = { workspace = true }
ruff_source_file = { workspace = true }

ahash = { workspace = true }
bitflags = { workspace = true }
Expand Down
25 changes: 13 additions & 12 deletions compiler/codegen/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use ruff_python_ast::{
TypeParam, TypeParamParamSpec, TypeParamTypeVar, TypeParamTypeVarTuple, TypeParams, UnaryOp,
WithItem,
};
use ruff_source_file::PositionEncoding;
use ruff_text_size::{Ranged, TextRange};
use rustpython_compiler_core::{
Mode, OneIndexed, SourceFile, SourceLocation,
Expand Down Expand Up @@ -240,18 +241,18 @@ fn eprint_location(zelf: &Compiler) {
let start = zelf
.source_file
.to_source_code()
.source_location(zelf.current_source_range.start());
.source_location(zelf.current_source_range.start(), PositionEncoding::Utf8);
let end = zelf
.source_file
.to_source_code()
.source_location(zelf.current_source_range.end());
.source_location(zelf.current_source_range.end(), PositionEncoding::Utf8);
eprintln!(
"LOCATION: {} from {}:{} to {}:{}",
zelf.source_file.name(),
start.row,
start.column,
end.row,
end.column
start.line,
start.character_offset,
end.line,
end.character_offset
);
}

Expand Down Expand Up @@ -531,7 +532,7 @@ impl Compiler {
let location = self
.source_file
.to_source_code()
.source_location(range.start());
.source_location(range.start(), PositionEncoding::Utf8);
CodegenError {
error,
location: Some(location),
Expand Down Expand Up @@ -631,8 +632,8 @@ impl Compiler {
) -> CompileResult<()> {
// Create location
let location = SourceLocation {
row: OneIndexed::new(lineno as usize).unwrap_or(OneIndexed::MIN),
column: OneIndexed::new(1).unwrap(),
line: OneIndexed::new(lineno as usize).unwrap_or(OneIndexed::MIN),
character_offset: OneIndexed::new(1).unwrap(),
};

// Allocate a new compiler unit
Expand Down Expand Up @@ -769,8 +770,8 @@ impl Compiler {
let _resume_loc = if scope_type == CompilerScope::Module {
// Module scope starts with lineno 0
SourceLocation {
row: OneIndexed::MIN,
column: OneIndexed::MIN,
line: OneIndexed::MIN,
character_offset: OneIndexed::MIN,
}
} else {
location
Expand Down Expand Up @@ -5334,7 +5335,7 @@ impl Compiler {
let location = self
.source_file
.to_source_code()
.source_location(range.start());
.source_location(range.start(), PositionEncoding::Utf8);
// TODO: insert source filename
self.current_block().instructions.push(ir::InstructionInfo {
instr,
Expand Down
4 changes: 2 additions & 2 deletions compiler/codegen/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ fn generate_linetable(locations: &[SourceLocation], first_line: i32) -> Box<[u8]

// Get line and column information
// SourceLocation always has row and column (both are OneIndexed)
let line = loc.row.get() as i32;
let col = (loc.column.get() as i32) - 1; // Convert 1-based to 0-based
let line = loc.line.get() as i32;
let col = (loc.character_offset.get() as i32) - 1; // Convert 1-based to 0-based

let line_delta = line - prev_line;

Expand Down
7 changes: 4 additions & 3 deletions compiler/codegen/src/symboltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use ruff_python_ast::{
PatternMatchMapping, PatternMatchOr, PatternMatchSequence, PatternMatchStar, PatternMatchValue,
Stmt, TypeParam, TypeParamParamSpec, TypeParamTypeVar, TypeParamTypeVarTuple, TypeParams,
};
use ruff_source_file::PositionEncoding;
use ruff_text_size::{Ranged, TextRange};
use rustpython_compiler_core::{SourceFile, SourceLocation};
use std::{borrow::Cow, fmt};
Expand Down Expand Up @@ -1046,7 +1047,7 @@ impl SymbolTableBuilder {
location: Some(
self.source_file
.to_source_code()
.source_location(expression.range().start()),
.source_location(expression.range().start(), PositionEncoding::Utf8),
),
});
}
Expand Down Expand Up @@ -1282,7 +1283,7 @@ impl SymbolTableBuilder {
if let ExpressionContext::IterDefinitionExp = context {
return Err(SymbolTableError {
error: "assignment expression cannot be used in a comprehension iterable expression".to_string(),
location: Some(self.source_file.to_source_code().source_location(target.range().start())),
location: Some(self.source_file.to_source_code().source_location( target.range().start(), PositionEncoding::Utf8)),
});
}

Expand Down Expand Up @@ -1565,7 +1566,7 @@ impl SymbolTableBuilder {
let location = self
.source_file
.to_source_code()
.source_location(range.start());
.source_location(range.start(), PositionEncoding::Utf8);
let location = Some(location);
let scope_depth = self.tables.len();
let table = self.tables.last_mut().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions compiler/core/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,14 +1190,14 @@ impl<C: Constant> CodeObject<C> {
level: usize,
) -> fmt::Result {
let label_targets = self.label_targets();
let line_digits = (3).max(self.locations.last().unwrap().row.to_string().len());
let line_digits = (3).max(self.locations.last().unwrap().line.to_string().len());
let offset_digits = (4).max(self.instructions.len().to_string().len());
let mut last_line = OneIndexed::MAX;
let mut arg_state = OpArgState::default();
for (offset, &instruction) in self.instructions.iter().enumerate() {
let (instruction, arg) = arg_state.get(instruction);
// optional line number
let line = self.locations[offset].row;
let line = self.locations[offset].line;
if line != last_line {
if last_line != OneIndexed::MAX {
writeln!(f)?;
Expand Down
8 changes: 4 additions & 4 deletions compiler/core/src/marshal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ pub fn deserialize_code<R: Read, Bag: ConstantBag>(
let locations = (0..len)
.map(|_| {
Ok(SourceLocation {
row: OneIndexed::new(rdr.read_u32()? as _).ok_or(MarshalError::InvalidLocation)?,
column: OneIndexed::from_zero_indexed(rdr.read_u32()? as _),
line: OneIndexed::new(rdr.read_u32()? as _).ok_or(MarshalError::InvalidLocation)?,
character_offset: OneIndexed::from_zero_indexed(rdr.read_u32()? as _),
})
})
.collect::<Result<Box<[SourceLocation]>>>()?;
Expand Down Expand Up @@ -656,8 +656,8 @@ pub fn serialize_code<W: Write, C: Constant>(buf: &mut W, code: &CodeObject<C>)

write_len(buf, code.locations.len());
for loc in &*code.locations {
buf.write_u32(loc.row.get() as _);
buf.write_u32(loc.column.to_zero_indexed() as _);
buf.write_u32(loc.line.get() as _);
buf.write_u32(loc.character_offset.to_zero_indexed() as _);
}

buf.write_u16(code.flags.bits());
Expand Down
Loading
Loading