Export `ruff_source_file` types in `rustpython_compiler_core` by ShaharNaveh · Pull Request #6020 · RustPython/RustPython
vm/src/lib.rs (1)
54-57: Stylistic newline insertions look fine
The added blank lines around selected pub mod declarations improve visual grouping and do not affect behaviour. cargo fmt will keep this layout stable, so no further action needed.
Also applies to: 67-70, 73-76, 90-93
compiler/codegen/src/ir.rs (2)
3-10: Import consolidation is correct and follows the new re-export path
Switching to rustpython_compiler_core::{ OneIndexed, SourceLocation, bytecode::… } removes the external ruff_source_file dependency and matches the core crate’s public re-exports. No functional impact; compilation should succeed as long as rustpython_compiler_core is in the workspace members list.
39-40: Whitespace tweaks only
The extra blank lines between impl blocks aid readability and are neutral regarding generated code.
Also applies to: 48-49, 54-55, 62-63, 85-86, 117-118
vm/src/builtins/traceback.rs (1)
7-8: Updated import path is accurate
OneIndexed now comes from rustpython_compiler_core; the rest of the file already depends on that crate via other modules. 👍
vm/src/builtins/code.rs (2)
18-18: Import path change acknowledged
The switch to rustpython_compiler_core::OneIndexed is consistent with the global refactor.
358-361: Type consistency remains intact
OneIndexed::new(first_line_number as _) still yields an Option<OneIndexed>, matching the first_line_number field’s type; no further change required.
vm/src/stdlib/ast/node.rs (1)
2-2: Import source relocation is correct
SourceFile is now re-exported from rustpython_compiler_core; the rest of the AST helpers remain unchanged.
compiler/codegen/src/error.rs (2)
1-1: Import path update looks correct
Switching to rustpython_compiler_core::SourceLocation aligns with the new re-export strategy. No further action needed here.
1-1: Replace remaining ruff_source_file imports
We still have direct references to the old crate throughout the workspace. Please update these to use the rustpython_compiler_core exports and remove the ruff_source_file dependency:
• Files importing from ruff_source_file:
- compiler/core/src/lib.rs
- compiler/src/lib.rs
- compiler/source/src/lib.rs
Change, for example:
pub use ruff_source_file::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};
to
pub use rustpython_compiler_core::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};
• Cargo.toml entries pulling in ruff_source_file:
- Cargo.toml (root)
- compiler/core/Cargo.toml
- compiler/Cargo.toml
- compiler/source/Cargo.toml
Remove the ruff_source_file = { … } lines and replace them with your local path or workspace reference to rustpython_compiler_core if needed.
After making these changes, run cargo update to regenerate Cargo.lock and verify that no ruff_source_file remains in your lock file.
⛔ Skipped due to learnings
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.py : Use ruff for linting Python code
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/test/**/*.py : When tests fail due to unsupported syntax, keep the test as `@unittest.expectedFailure`, document that it requires PEP 695 support, and focus on tests that can be fixed through Rust code changes only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: In most cases, Python code should not be edited. Bug fixes should be made through Rust code modifications only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Always run clippy to lint code (`cargo clippy`) before completing tasks. Fix any warnings or lints that are introduced by your changes
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/**/*.py : Minimize modifications to CPython standard library files in `Lib/`
vm/src/stdlib/ast/constant.rs (1)
4-4: Import updated successfully
SourceFile is now taken from rustpython_compiler_core; matches the new public re-export.
vm/src/stdlib/ast/type_parameters.rs (1)
2-2: Consistent with refactor
Import path change looks good and keeps this module in sync with the rest of the tree.
vm/src/stdlib/ast/operator.rs (1)
2-2: LGTM
Import source updated; no further issues spotted.
vm/src/stdlib/ast/pattern.rs (1)
2-2: Import path aligned
Matches the crate consolidation; everything compiles as expected.
vm/src/stdlib/ast/statement.rs (1)
3-3: All SourceFile imports updated correctly
Ran rg -n "ruff_source_file::SourceFile" and found no remaining references to the old path. No further changes are needed in vm/src/stdlib/ast/statement.rs.
LGTM.
vm/src/stdlib/ast/parameter.rs (1)
2-2: Import path updated correctly
SourceFile now comes from rustpython_compiler_core, which matches the new re-export strategy. No further action required.
vm/src/stdlib/ast/elif_else_clause.rs (1)
2-2: Consistent migration to rustpython_compiler_core
The import swap is straightforward and keeps the file in sync with the rest of the workspace.
vm/src/stdlib/ast.rs (1)
25-27: Migrate residual ruff_source_file imports to rustpython_compiler_core
The search uncovered three remaining ruff_source_file:: imports that need updating. Please replace them with the corresponding rustpython_compiler_core re-exports:
• compiler/src/lib.rs:1
- use ruff_source_file::{SourceFile, SourceFileBuilder, SourceLocation}; + use rustpython_compiler_core::{SourceFile, SourceFileBuilder, SourceLocation};
• compiler/source/src/lib.rs:1
- pub use ruff_source_file::{LineIndex, OneIndexed as LineNumber, SourceLocation}; + pub use rustpython_compiler_core::{LineIndex, OneIndexed as LineNumber, SourceLocation};
• compiler/core/src/lib.rs:11
- pub use ruff_source_file::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation}; + pub use rustpython_compiler_core::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};
After making these changes, rerun your grep check to confirm no further ruff_source_file:: references remain.
⛔ Skipped due to learnings
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.py : Use ruff for linting Python code
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/test/**/*.py : When tests fail due to unsupported syntax, keep the test as `@unittest.expectedFailure`, document that it requires PEP 695 support, and focus on tests that can be fixed through Rust code changes only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: In most cases, Python code should not be edited. Bug fixes should be made through Rust code modifications only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/**/*.py : Minimize modifications to CPython standard library files in `Lib/`
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Always run clippy to lint code (`cargo clippy`) before completing tasks. Fix any warnings or lints that are introduced by your changes
vm/src/frame.rs (1)
25-25: Import aligns with the new core crate
SourceLocation now resolves via rustpython_compiler_core; looks good.
vm/src/vm/vm_new.rs (1)
15-15: Replace all remaining ruff_source_file imports with rustpython_compiler_core
The search revealed three straggling references that need updating:
- compiler/src/lib.rs:1
- compiler/core/src/lib.rs:11
- compiler/source/src/lib.rs:1
Suggested replacements:
--- a/compiler/src/lib.rs +++ b/compiler/src/lib.rs -use ruff_source_file::{SourceFile, SourceFileBuilder, SourceLocation}; +use rustpython_compiler_core::{SourceFile, SourceFileBuilder, SourceLocation};
--- a/compiler/core/src/lib.rs +++ b/compiler/core/src/lib.rs -pub use ruff_source_file::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation}; +pub use rustpython_compiler_core::{LineIndex, OneIndexed, SourceFile, SourceFileBuilder, SourceLocation};
--- a/compiler/source/src/lib.rs +++ b/compiler/source/src/lib.rs -pub use ruff_source_file::{LineIndex, OneIndexed as LineNumber, SourceLocation}; +pub use rustpython_compiler_core::{LineIndex, OneIndexed as LineNumber, SourceLocation};
After applying these changes, rerun rg -n "ruff_source_file::" to verify no remaining references.
⛔ Skipped due to learnings
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.py : Use ruff for linting Python code
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to Lib/test/**/*.py : When tests fail due to unsupported syntax, keep the test as `@unittest.expectedFailure`, document that it requires PEP 695 support, and focus on tests that can be fixed through Rust code changes only
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style (`cargo fmt` to format)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: In most cases, Python code should not be edited. Bug fixes should be made through Rust code modifications only
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration using #ifdef checks rather than providing fallback values for other platforms.
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-19T03:16:56.511Z
Learning: Applies to **/*.rs : Always run clippy to lint code (`cargo clippy`) before completing tasks. Fix any warnings or lints that are introduced by your changes
Learnt from: moreal
PR: RustPython/RustPython#5847
File: vm/src/stdlib/stat.rs:547-567
Timestamp: 2025-06-27T14:47:28.810Z
Learning: In RustPython's stat module implementation, platform-specific constants like SF_SUPPORTED and SF_SYNTHETIC should be conditionally declared only for the platforms where they're available (e.g., macOS), following CPython's approach of optional declaration rather than providing fallback values for other platforms.
vm/src/stdlib/ast/expression.rs (1)
7-7: Consistent crate swap – no further action required.
SourceFile is now re-exported from rustpython_compiler_core; all downstream calls remain unchanged, so the edit is correct.
vm/src/stdlib/ast/basic.rs (1)
2-3: Import additions align with usage.
ruff_int_to_bigint and the new SourceFile path are both consumed below, so clippy shouldn’t complain about unused imports.
compiler/codegen/src/unparse.rs (1)
1-4: Import refactor is correct – keep cargo fmt happy.
Switching to the granular ruff_python_ast list plus the new SourceFile path removes the dependency on ruff_source_file without changing behaviour. Make sure the long list still respects rustfmt’s line-wrap rules after reformatting.
Also applies to: 6-6
vm/src/stdlib/ast/other.rs (1)
3-3: Combined import is accurate.
Both SourceFile and bytecode are used below; combining into one line is stylistically fine.
compiler/core/src/bytecode.rs (1)
4-4: Import path switch looks good.
Moving OneIndexed & SourceLocation to crate::{…} correctly leverages the new re-exports and removes the external dependency from this module. No functional impact.
Also applies to: 10-10
compiler/codegen/src/symboltable.rs (1)
22-22: Correct crate switch; check that compiler/codegen no longer depends on ruff_source_file.
The new import matches the public re-exports in rustpython_compiler_core.
Verify that compiler/codegen/Cargo.toml had its ruff_source_file entry removed, otherwise the dependency graph will still include it unnecessarily.
compiler/core/src/lib.rs (1)
11-11: Public re-export is fine, but ensure ruff_source_file remains an explicit dependency of this crate.
rustpython_compiler_core now acts as the single import hub for these types—great for ergonomics.
However, because you’re re-exporting directly from ruff_source_file, compiler/core/Cargo.toml must still list that crate; otherwise downstream crates relying only on rustpython_compiler_core might build but the core crate itself will fail.
compiler/codegen/src/compile.rs (2)
34-36: Imports correctly re-pointed to rustpython_compiler_core
The switch from the external ruff_source_file crate to the public re-exports in rustpython_compiler_core looks clean and keeps the external surface unchanged at the call-sites. Good catch on importing Mode alongside the three re-exported types.
5843-5844: Test helper import LGTM
The tests now pull SourceFileBuilder from the unified crate; compilation path is consistent with the production code.