| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
WalkthroughThis pull request systematically updates a wide range of function and method signatures across the codebase, converting regular functions to const fn or const unsafe fn where possible. The internal logic of these functions remains unchanged; only their declarations are modified to allow compile-time evaluation and usage in constant contexts. Changes
Sequence Diagram(s)Omitted: The changes are mechanical signature updates and do not introduce or modify control flow or features. Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Clippy (1.86.0)Updating git repository `https://github.com/youknowone/ferrilab` error: failed to load source for dependency radium Caused by: Caused by: Caused by: 📜 Recent review details Configuration used: .coderabbit.yml Reviewing files that changed from the base of the PR and between 4e91f6a and eb3e2b3. 📒 Files selected for processing (47)
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md) List of files the instruction was applied to:
Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z Learning: In most cases, Python code should not be edited. Bug fixes should be made through Rust code modifications only
compiler/src/lib.rs (1)✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ Share 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (3)vm/sre_engine/src/string.rs (1)🧹 Nitpick comments (3)vm/src/stdlib/posix.rs (1)226-265: Use add/sub instead of offset to regain const-eval & avoid UB
ptr.offset(±1) works at run-time, but raw-pointer offset is not const-stable
yet. The brand-new const unsafe fn will therefore fail the first time it is
ever used in a real const context.
pointer::add / pointer::sub are const-stable and avoid signed-offset
pitfalls.Suggested refactor (excerpt):
- let x = unsafe { **ptr }; - *ptr = unsafe { ptr.offset(1) }; + let x = unsafe { **ptr }; + *ptr = (*ptr).add(1); ... - let y = unsafe { **ptr }; - *ptr = unsafe { ptr.offset(1) }; + let y = unsafe { **ptr }; + *ptr = (*ptr).add(1); ... - *ptr = unsafe { ptr.offset(-1) }; + *ptr = (*ptr).sub(1);Apply the same pattern for every offset(±1) occurrence in both forward and
reverse helpers.Also applies to: 274-309
common/src/linked_list.rs (1)1231-1236: Remove const fn from sync() - external function calls are not allowed in const contexts.
The sync() function calls libc::sync(), which is an external C function that performs system calls with side effects. This cannot be evaluated at compile time and will cause compilation errors in const contexts.
- const fn sync() { + fn sync() {287-298: Remove const fn from drain_filter - closures are not supported in const contexts.
The drain_filter method takes a closure parameter F: FnMut(&mut T::Target) -> bool. Closures cannot be used in const fn contexts as they involve dynamic dispatch and mutable operations.
- pub const fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F> + pub fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F>
compiler/codegen/src/compile.rs (1)📜 Review detailscompiler/core/src/bytecode.rs (1)4121-4123: set_source_range probably shouldn’t be const
This is a plain setter that mutates self. Turning it into const fn brings no practical benefit (it’s never called in a const context) but does:
- Tie the crate to a relatively new rustc version (mutable const fn stabilised only recently).
- Risk future surprises if someone expects it to stay side-effect-free in const evaluation.
Unless you have a concrete need to call it inside a const context, consider reverting the const qualifier:
- const fn set_source_range(&mut self, range: TextRange) { + fn set_source_range(&mut self, range: TextRange) {vm/sre_engine/src/engine.rs (1)175-180: Leaner bit-math alternative for instr_size
The current chain of three comparisons works, but we can avoid the branchy logic by relying on leading_zeros:
- (self.0 > 0xff) as usize + (self.0 > 0xff_ff) as usize + (self.0 > 0xff_ff_ff) as usize + 1 + // #bytes = ceil(bits / 8) + ((32 - self.0.leading_zeros() + 7) / 8).max(1) as usizeBenefits: fewer comparisons, branch-free, and intention is clearer.
71-73: Const promotion approved; consider adding #[inline]
The newly‐minted const fns are simple accessors/mutators that stay within the stable const-eval rules, so the change is safe.
For tiny hot-path helpers (remaining_codes, remaining_chars, at_beginning, at_end, etc.) you may optionally add #[inline] to help LLVM inline them at call-sites (this is runtime only; has no impact on const contexts).
Also applies to: 1057-1063, 1100-1116, 1147-1159, 1166-1179
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Reviewing files that changed from the base of the PR and between 8a2a6af and 4e91f6a.
📒 Files selected for processing (66)**/*.rs: Follow the default rustfmt code style (cargo fmt to format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)
List of files the instruction was applied to:
Learnt from: CR PR: RustPython/RustPython#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
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: 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: 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: 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: 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: 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
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: 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
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: 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
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: 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
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: 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: 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: 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z 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-06-30T10:08:48.851Z Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
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: 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-06-30T10:08:48.851Z Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
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: 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-06-30T10:08:48.851Z Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
vm/src/bytes_inner.rs (1)vm/src/builtins/singletons.rs (2)common/src/boxvec.rs (1)
- len (308-310)
common/src/str.rs (1)
- len (49-51)
wtf8/src/lib.rs (1)
- len (292-294)
- len (785-787)
vm/src/builtins/float.rs (1)vm/src/builtins/float.rs (2)vm/src/builtins/tuple.rs (1)
- __bool__ (288-290)
- __bool__ (254-256)
vm/src/builtins/complex.rs (1)stdlib/src/posixsubprocess.rs (4)vm/src/builtins/int.rs (1)
- __abs__ (260-269)
- __abs__ (490-492)
stdlib/src/syslog.rs (1)vm/src/builtins/bytes.rs (7)common/src/boxvec.rs (1)
- as_ptr (50-55)
stdlib/src/ssl.rs (1)
- as_ptr (326-328)
extra_tests/snippets/stdlib_ctypes.py (1)
- as_ptr (1559-1561)
- c_char (175-176)
vm/src/builtins/bytearray.rs (1)vm/src/builtins/coroutine.rs (3)vm/src/builtins/dict.rs (3)
- __len__ (209-211)
vm/src/builtins/set.rs (2)
- __len__ (207-209)
- __len__ (759-761)
- is_empty (112-114)
vm/src/builtins/list.rs (1)
- __len__ (550-552)
- __len__ (976-978)
vm/src/builtins/mappingproxy.rs (1)
- __len__ (184-186)
vm/src/builtins/tuple.rs (3)
- __len__ (183-186)
vm/src/builtins/str.rs (8)
- __len__ (271-273)
- is_empty (276-278)
- is_empty (558-560)
- is_empty (592-594)
- is_empty (1468-1470)
- is_empty (1862-1864)
- is_empty (1872-1874)
- is_empty (1882-1884)
- is_empty (1939-1941)
- is_empty (2054-2056)
- is_empty (2176-2178)
vm/src/builtins/asyncgenerator.rs (3)vm/src/buffer.rs (3)vm/src/builtins/generator.rs (1)
- as_coro (32-34)
- r#await (204-206)
- r#await (298-300)
wasm/lib/src/js_module.rs (1)
- as_coro (31-33)
- r#await (545-549)
vm/src/builtins/range.rs (1)compiler/codegen/src/symboltable.rs (1)stdlib/src/pystruct.rs (1)
- offset (80-89)
vm/src/builtins/dict.rs (1)
- size (262-264)
- size (158-160)
vm/src/stdlib/symtable.rs (2)compiler/codegen/src/compile.rs (4)
- is_global (173-175)
- is_local (183-185)
compiler/codegen/src/string_parser.rs (1)vm/src/stdlib/symtable.rs (1)compiler/codegen/src/unparse.rs (1)
- new (31-37)
compiler/core/src/bytecode.rs (2)
- new (35-37)
vm/src/stdlib/typing.rs (1)
- new (287-289)
- new (663-665)
- new (108-118)
compiler/codegen/src/symboltable.rs (2)vm/src/builtins/function.rs (6)
- is_global (165-170)
- is_local (172-174)
vm/src/builtins/code.rs (1)vm/sre_engine/src/string.rs (1)vm/src/builtins/dict.rs (2)
- new (205-207)
vm/src/stdlib/io.rs (1)
- new (695-697)
- new (726-728)
vm/src/types/slot.rs (1)
- new (255-257)
vm/src/frame.rs (1)
- new (99-105)
vm/src/builtins/module.rs (1)
- new (138-172)
- new (72-77)
wtf8/src/core_str.rs (2)vm/src/builtins/complex.rs (2)
- next_code_point (33-67)
- next_code_point_reverse (76-110)
vm/src/builtins/float.rs (4)vm/src/builtins/str.rs (2)vm/src/builtins/int.rs (4)
- real (465-467)
- imag (470-472)
- __pos__ (343-345)
- __getnewargs__ (514-516)
- real (669-671)
- imag (674-676)
- __pos__ (538-540)
- __getnewargs__ (696-698)
common/src/str.rs (4)stdlib/src/compression.rs (6)wtf8/src/lib.rs (5)
- as_wtf8 (257-259)
- kind (274-276)
- is_utf8 (43-45)
- is_ascii (39-41)
- as_wtf8 (1349-1351)
- as_bytes (827-829)
- is_utf8 (983-985)
- is_ascii (175-177)
- is_ascii (978-980)
stdlib/src/unicodedata.rs (1)⏰ Context from checks skipped due to timeout of 90000ms (7)stdlib/src/zlib.rs (8)
- new (86-88)
stdlib/src/lzma.rs (4)
- new (121-134)
- new (419-421)
- new (476-485)
- eof (231-233)
- eof (595-597)
- unused_data (236-238)
- unused_data (600-602)
- needs_input (605-607)
common/src/boxvec.rs (2)
- new (262-264)
- eof (193-195)
- unused_data (198-200)
- needs_input (203-207)
wtf8/src/lib.rs (2)
- len (49-51)
- is_empty (54-56)
stdlib/src/bz2.rs (3)
- len (785-787)
- is_empty (790-792)
- eof (90-92)
- unused_data (95-97)
- needs_input (100-104)
vm/src/builtins/frame.rs (1)37-39: LGTM: const fn qualification is technically correct.
The const fn qualifier is valid since this is currently a placeholder method. However, note that when the actual implementation replaces the TODO comment, you'll need to verify that the operations performed are compatible with const fn restrictions.
stdlib/src/pystruct.rs (1)318-318: LGTM: Empty function correctly qualified as const fn.
The const fn qualifier is appropriate for this empty function, enabling compile-time evaluation when called.
stdlib/src/select.rs (1)27-29: LGTM: Excellent const fn usage for compile-time evaluation.
The const fn qualifier is perfect for this simple comparison operation, enabling compile-time error checking when the input value is known at compile time.
common/src/lock/thread_mutex.rs (1)81-86: LGTM: Excellent const fn usage enabling static initialization.
The const fn qualifier is perfectly appropriate here since both RawThreadMutex::INIT and UnsafeCell::new are const. This enables static initialization of ThreadMutex instances, which is particularly valuable for synchronization primitives.
vm/src/readline.rs (1)31-33: LGTM: Simple constructor correctly qualified as const fn.
The const fn qualifier is appropriate for this simple struct constructor, enabling compile-time initialization of Readline instances when the helper parameter supports const construction.
vm/src/builtins/bytearray.rs (1)80-80: LGTM: Appropriate const fn conversion.
The from_inner function is a simple constructor that only initializes struct fields with basic operations, making it suitable for const evaluation.
stdlib/src/syslog.rs (2)138-140: LGTM: Appropriate const fn conversion.
The log_mask function performs a simple bit shift operation which is const-eligible.
144-146: LGTM: Appropriate const fn conversion.
The log_upto function performs simple arithmetic operations on primitive integers, making it suitable for const evaluation.
stdlib/src/json/machinery.rs (1)122-128: LGTM: Appropriate const fn conversion.
The len method performs pattern matching and calls to const functions (Wtf8::len and CodePoint::len_wtf8), making it suitable for const evaluation.
vm/src/stdlib/collections.rs (1)276-278: LGTM: Perfect const fn candidate.
The maxlen getter is a simple field access operation, which is ideal for const evaluation.
stdlib/src/binascii.rs (2)163-170: LGTM: Appropriate const fn conversion.
The unhex_nibble function performs pattern matching and simple arithmetic on primitive types, making it suitable for const evaluation.
813-819: LGTM: Appropriate const fn conversion.
The uu_b2a function performs simple conditional logic and arithmetic on primitive types, making it suitable for const evaluation.
stdlib/src/unicodedata.rs (1)86-88: LGTM! Appropriate const fn conversion.
This simple constructor is an ideal candidate for const fn as it performs only struct field assignment without side effects, enabling compile-time evaluation.
vm/src/object/ext.rs (2)69-71: LGTM! Valid const unsafe fn conversion.
The pointer cast operation in this function is valid in const contexts and enables compile-time evaluation of this unsafe operation.
144-146: LGTM! Appropriate const unsafe fn conversion.
This simple struct wrapper construction is suitable for const contexts and aligns with the PR's goal of enabling compile-time evaluation where possible.
vm/src/stdlib/typing.rs (1)108-118: LGTM! Excellent const fn candidate.
This constructor performs only simple field assignments without side effects, making it an ideal candidate for const fn and enabling compile-time instantiation of TypeAliasType.
stdlib/src/faulthandler.rs (2)42-44: LGTM! Valid const fn for unimplemented function.
Since this function is currently unimplemented (TODO), marking it as const fn is valid and prepares it for potential const implementation in the future.
60-62: LGTM! Appropriate const fn for placeholder function.
The const qualification is valid for this unimplemented function and aligns with the systematic const fn updates across the codebase.
common/src/hash.rs (2)167-175: LGTM! Perfect const fn candidate.
This function performs only a simple type cast operation, making it an excellent candidate for const fn and enabling compile-time hash calculations.
178-180: LGTM! Proper const fn composition.
This function correctly composes two const functions (hash_object_id_raw and fix_sentinel), making it appropriately qualified as const fn.
vm/src/builtins/set.rs (1)457-459: LGTM! Appropriate const fn conversion.
The bitwise operations (XOR, shift, wrapping multiplication) are all const-compatible, making this function suitable for compile-time evaluation.
common/src/encodings.rs (1)140-152: LGTM! Appropriate const unsafe fn conversion.
The unsafe operations (split_at_unchecked and from_utf8_unchecked) are const-compatible, and the function logic is suitable for compile-time evaluation.
vm/src/stdlib/ast.rs (3)93-98: LGTM! Appropriate const fn conversion.
Simple struct construction with field access is const-compatible.
106-108: LGTM! Appropriate const fn conversion.
Field access via method call is const-compatible.
120-126: LGTM! Appropriate const fn conversions.
Both functions perform simple field access and transformations that are const-compatible.
stdlib/src/hashlib.rs (3)193-195: LGTM! Appropriate const fn conversion.
Returning a constant value is perfectly suitable for const fn.
320-322: LGTM! Appropriate const fn conversion.
Pattern matching with matches! macro is const-compatible.
384-386: LGTM! Appropriate const fn conversion.
Simple field access is const-compatible.
vm/src/stdlib/imp.rs (2)38-44: LGTM! Appropriate const fn conversions.
No-op functions and constant returns are perfectly suitable for const fn when threading is disabled.
98-100: LGTM! Appropriate const fn conversion.
Creating an empty vector and wrapping it in Ok is const-compatible.
vm/src/stdlib/os.rs (4)88-88: LGTM: Appropriate const fn conversion.
Converting fd() to const fn is correct since it only performs a simple field access (self.0[0]), enabling compile-time evaluation.
574-574: LGTM: Appropriate const fn conversion.
Converting is_junction() to const fn is correct for the non-Windows implementation since it only returns a constant Ok(false), enabling compile-time evaluation.
645-645: LGTM: Appropriate const fn conversion.
Converting __enter__() to const fn is correct since it only returns the input parameter zelf, which is a simple operation suitable for compile-time evaluation.
1498-1498: LGTM: Appropriate const fn conversion.
Converting SupportFunc::new() to const fn is correct since it's a simple constructor that only assigns parameters to struct fields, enabling compile-time instantiation.
vm/src/stdlib/sys.rs (5)98-98: LGTM: Appropriate const fn conversion.
Converting default_prefix() to const fn is correct since it only returns string literals based on compile-time cfg!() conditions, enabling compile-time evaluation.
241-241: LGTM: Appropriate const fn conversion.
Converting meta_path() to const fn is correct since it only returns Vec::new(), which is const-compatible and enables compile-time evaluation.
261-261: LGTM: Appropriate const fn conversion.
Converting path_hooks() to const fn is correct since it only returns Vec::new(), which is const-compatible and enables compile-time evaluation.
457-457: LGTM: Appropriate const fn conversion.
Converting getdefaultencoding() to const fn is correct since it only returns a constant reference crate::codecs::DEFAULT_ENCODING, enabling compile-time evaluation.
967-967: LGTM: Appropriate const fn conversion.
Converting Flags::from_settings() to const fn is correct since it only performs simple field assignments and type conversions (boolean to u8 casts) that are const-compatible, enabling compile-time struct creation.
stdlib/src/array.rs (3)92-96: LGTM: Appropriate const fn conversions for metadata accessors.
These methods perform simple pattern matching on enum variants and return compile-time constants, making them ideal candidates for const fn. This enables their use in constant contexts without changing runtime behavior.
Also applies to: 98-102, 104-109, 111-115
557-559: LGTM: Correct const fn conversion for byte-swapping utilities.
The bit manipulation operations f32::to_bits(), u32::swap_bytes(), and f32::from_bits() are all const methods, making these functions suitable for compile-time evaluation.
Also applies to: 561-563
1560-1567: LGTM: Appropriate const fn for machine format code size calculation.
This method uses simple pattern matching to return compile-time constants, making it a good candidate for const fn evaluation.
vm/src/stdlib/typevar.rs (3)127-129: LGTM: Appropriate const fn conversion for boolean field accessors.
These getter methods perform simple field access to return boolean values, making them perfect candidates for const fn evaluation.
Also applies to: 132-134, 137-139
448-450: LGTM: Consistent const fn conversion for ParamSpec boolean accessors.
These methods mirror the TypeVar implementations and are also simple field accessors, appropriately converted to const fn.
Also applies to: 453-455, 458-460
630-640: LGTM: Appropriate const fn conversion for ParamSpec constructor.
This constructor initializes a struct with the provided name and const default values (None, false), making it suitable for compile-time evaluation when called with const arguments.
stdlib/src/csv.rs (3)87-89: LGTM: Simple field getters are perfect candidates for const fn.
These getter methods only perform direct field access, making them ideal for compile-time evaluation.
Also applies to: 91-93, 111-113
919-921: LGTM: Field access getters are ideal for const fn.
These methods simply return struct fields, making them perfect candidates for compile-time evaluation.
Also applies to: 1069-1071
662-689: Const fn compatibility verified
The check_and_fill! macro expands to simple field assignments and the if let branches only perform pattern matching and assignments—no function calls or unsupported operations. All constructs (if, if let, local mutations) are supported in a const fn on stable Rust. No changes needed.
stdlib/src/compression.rs (4)69-71: LGTM: Generic function returning const associated item.
The flush_sync function returns T::SYNC which is a const associated item, making this conversion appropriate for compile-time evaluation.
79-84: LGTM: Constructor patterns are ideal for const fn.
Both new and chain constructors perform simple field initialization and conditional logic without any heap allocations or complex operations, making them perfect for const evaluation.
Also applies to: 85-94
95-97: LGTM: Simple arithmetic and slice operations are const-compatible.
The len method performs arithmetic on field lengths, and is_empty calls the const is_empty() method on slices. Both are appropriate for const fn.
Also applies to: 98-100
219-223: LGTM: Constructor and simple field getters.
These methods involve either simple field initialization (new) or direct field access (eof, needs_input), all of which are const-eligible operations.
Also applies to: 296-298, 304-306
vm/src/stdlib/stat.rs (4)249-251: LGTM: Bitwise operations are perfect for const fn.
These file type checking functions perform simple bitwise AND operations and equality comparisons, making them ideal candidates for compile-time evaluation.
Also applies to: 255-257, 261-263, 267-269, 273-275, 279-281, 285-287
292-294: LGTM: Platform-specific functions with const return values.
These functions return constant false values for unsupported platforms (Solaris, BSD), which is appropriate for const fn since they involve no runtime computation.
Also applies to: 299-301, 306-308
312-314: LGTM: Simple bitwise mask operations.
Both S_IMODE_method and S_IFMT_method perform straightforward bitwise AND operations with constant masks, making them excellent candidates for const fn.
Also applies to: 318-321
324-348: LGTM: Conditional logic calling other const functions.
The filetype function uses conditional logic that calls other const functions (the S_IS* family) and returns character literals. Since all called functions are now const fn and the logic involves only compile-time determinable operations, this conversion is appropriate.
vm/src/protocol/iter.rs (1)36-38: LGTM: Simple constructor ideal for const fn.
The new method is a straightforward constructor that wraps the input in a tuple struct. This pattern is perfect for const fn as it involves only field initialization without any heap allocation or complex operations.
vm/src/stdlib/sre.rs (1)399-401: LGTM: Bitflags accessor method is const-compatible.
The flags method calls bits() on a SreFlag field. Since SreFlag appears to be a bitflags type and bitflags typically provide const bits() methods, this conversion is appropriate for enabling compile-time evaluation.
vm/src/builtins/float.rs (1)234-236: LGTM: Valid const function conversion.
The __abs__ method correctly uses const fn since it only calls self.value.abs() on an f64, which is const-compatible. This change enables compile-time evaluation without altering the method's behavior.
vm/src/codecs.rs (1)55-57: LGTM: Valid const function conversion.
The as_tuple method correctly uses const fn since it only returns a reference to an inner field (&self.0). This is a simple accessor that can be evaluated at compile time.
vm/src/builtins/union.rs (1)45-47: LGTM: Valid const function conversion.
The args method correctly uses const fn since it only returns a reference to the args field (&self.args). This simple accessor method can be evaluated at compile time while maintaining compatibility with CPython's _Py_union_args.
common/src/cformat.rs (1)139-148: LGTM: Valid const function conversion.
The sign_string method correctly uses const fn since it only performs const-compatible operations: contains() calls on bitflags and returns static string literals. The conditional logic can be evaluated at compile time.
vm/src/protocol/sequence.rs (1)79-81: LGTM! Appropriate const fn conversion.
This constructor only performs struct literal construction with reference parameters, making it an ideal candidate for const fn. The change enables compile-time evaluation without altering runtime behavior.
vm/src/builtins/singletons.rs (2)49-51: LGTM! Correct const fn usage for constant return value.
The __bool__ method returns a compile-time constant (false), making it an appropriate candidate for const fn. This aligns with similar implementations in other builtin types.
101-103: LGTM! Correct const fn usage for constant return value.
The __bool__ method returns a compile-time constant (true), making it an appropriate candidate for const fn. This follows the same pattern as the PyNone implementation.
vm/src/builtins/enumerate.rs (1)104-109: LGTM! Appropriate const fn conversion for constructor.
The constructor performs only const-safe operations: arithmetic (saturating_sub) and struct construction. This change is consistent with the systematic const fn updates across the codebase.
vm/src/builtins/bytes.rs (2)152-154: LGTM! Consistent const fn pattern for length accessor.
The __len__ method delegates to the inner type's length method, following the same pattern established in other collection types as shown in the relevant code snippets (PyTuple, PyDict, etc.).
157-159: LGTM! Consistent const fn pattern for emptiness check.
The is_empty method delegates to the inner type's emptiness check, maintaining consistency with similar implementations across other collection types in the codebase.
stdlib/src/posixsubprocess.rs (2)119-121: LGTM! Appropriate const fn for pointer accessor.
The as_ptr method delegates to the standard library's slice.as_ptr(), which is const-safe. This follows the pattern seen in other pointer accessor methods across the codebase.
177-183: LGTM! Perfect const fn candidate for string literals.
The as_msg method performs simple pattern matching returning compile-time string literals, making it an ideal candidate for const fn with no runtime dependencies or side effects.
vm/src/function/protocol.rs (1)133-135: LGTM - Valid const fn conversion
This constructor function correctly converts to const fn since it only performs simple struct field assignment. This enables compile-time evaluation of ArgMapping instances when the arguments are known at compile time.
vm/src/builtins/iter.rs (2)50-55: LGTM - Valid const fn conversion for PositionIterInternal
This constructor correctly converts to const fn since it only performs enum construction and field assignment. This enables compile-time instantiation of PositionIterInternal instances.
259-264: LGTM - Valid const fn conversion for PyCallableIterator
This constructor correctly converts to const fn. The use of PyRwLock::new is appropriate since it's typically implemented as a const fn in standard library implementations.
compiler/codegen/src/string_parser.rs (1)31-37: Verify const fn compatibility with Box<str> in StringParser::new (compiler/codegen/src/string_parser.rs:31–37)
We weren’t able to run a full cargo check in the sandbox due to toolchain errors. Before merging, please:
compiler/codegen/src/compile.rs (1)
- Manually confirm that StringParser::new(source: Box<str>, flags: AnyStringFlags) -> Self compiles on stable Rust (≥1.88) without errors.
- Ensure you can call it in a const context (e.g. define const PARSER: StringParser = StringParser::new(...);) and that the compiler accepts the Box<str> parameter in const evaluation.
- If Box-based parameters don’t work in const fn due to allocation or Drop constraints, revert this change or document the limitation clearly.
285-292: PatternContext::new safely promoted to const fn – looks good
Vec::new() and the other operations used here are all const-stable on the MSRV you’re already targeting, so this change compiles on stable and widens the function’s usability without side-effects.
vm/src/sliceable.rs (1)418-425: LGTM! Appropriate use of const fn
Both from_adjust_indices and positive_order methods are good candidates for const fn as they only perform simple arithmetic operations and conditional logic that are available in constant evaluation contexts. The use of is_negative(), saturating_sub(), and saturating_abs() are all const-compatible operations.
Also applies to: 427-433
vm/src/builtins/function.rs (2)725-727: LGTM! Simple constructor perfect for const fn
This constructor only performs struct field initialization, making it an ideal candidate for const fn. This change aligns with the pattern observed in other constructor methods across the codebase.
849-853: LGTM! Constructor appropriately marked as const fn
The PyCell::new constructor only creates a struct with a PyMutex, which should be const-compatible. This change is consistent with similar constructor patterns in the codebase.
vm/src/buffer.rs (3)204-210: LGTM! Appropriate const fn for simple pattern matching
The arg_count method only performs pattern matching on an enum and returns either constants or field values, making it an excellent candidate for const fn.
289-297: LGTM! Alignment calculation function suitable for const fn
The compensate_alignment function uses only const-compatible operations including arithmetic, bit operations, and checked_sub. The logic is purely computational without side effects, making it appropriate for compile-time evaluation.
447-449: LGTM! Simple getter perfect for const fn
This is a straightforward field accessor that returns the size field, making it an ideal candidate for const fn. This pattern is consistent with similar const getters found in stdlib/src/pystruct.rs line 262-264.
compiler/codegen/src/symboltable.rs (3)165-170: LGTM! Appropriate const fn conversion.
The is_global method uses only const-compatible operations (matches! macro with enum pattern matching) and has no side effects, making it a good candidate for const fn.
172-174: LGTM! Appropriate const fn conversion.
The is_local method uses only const-compatible operations and is a pure function, making it suitable for const fn.
176-178: LGTM! Appropriate const fn conversion.
The is_bound method uses intersects on bitflags which is const-compatible, and this change enables the method to be used in the const contexts shown in the relevant snippets.
compiler/codegen/src/unparse.rs (2)35-37: LGTM! Appropriate const fn conversion.
The new constructor performs only simple field assignments, making it a perfect candidate for const fn. This enables compile-time construction of Unparser instances.
605-607: LGTM! Appropriate const fn conversion.
The unparse_expr function is a simple constructor that creates a struct with two fields, making it suitable for const fn and enabling compile-time creation of UnparseExpr instances.
vm/src/builtins/traceback.rs (3)50-52: LGTM! Appropriate const fn conversion.
Simple field getter that returns a primitive value, perfect for const fn.
55-57: Verify that LineNumber::get() is a const fn.
I wasn’t able to locate the implementation of LineNumber::get in the VM codebase (it may live in an external crate). Please confirm that its definition is declared as:
impl LineNumber { pub const fn get(&self) -> usize { … } }so that calling self.lineno.get() inside a const fn tb_lineno() remains valid.
30-42: Confirm that PyMutex::new is a const fn.
The const fn new on PyTraceback hinges on PyMutex::new being const. Since
pub type PyMutex<T> = Mutex<RawMutex, T>;is just an alias for lock_api::Mutex<RawMutex, T>, please verify that in your lock_api version
Mutex::new(...) is indeed declared as const fn. If it isn’t, you’ll need to either:vm/src/intern.rs (2)
- Upgrade to a lock_api release where Mutex::new is const fn.
- Or provide a small const fn wrapper/alias in common/src/lock.rs (e.g., const fn new_mutex<T>(t: T) -> PyMutex<T> { Mutex::new(t) }).
121-123: LGTM! Appropriate const fn conversion.
The unsafe transmute_copy operation is const-compatible and this method is a good candidate for const fn. The safety requirements remain the same in const contexts.
145-147: LGTM! Appropriate const fn conversion.
Pointer casting operations are const-compatible, making this method suitable for const fn. This enables compile-time pointer address calculations.
vm/src/builtins/type.rs (3)76-78: Appropriate conversion to const unsafe fn.
This unsafe function is pure and performs only a simple reference conversion, making it suitable for compile-time evaluation.
624-626: Good conversion to const fn for getter method.
This simple getter method returns a field value without side effects, making it appropriate for compile-time evaluation.
629-631: Good conversion to const fn for getter method.
This simple getter method returns a field value without side effects, making it appropriate for compile-time evaluation.
vm/src/builtins/builtin_func.rs (3)39-42: Appropriate conversion to const fn for builder method.
This method performs a simple field modification and return, making it suitable for compile-time evaluation.
53-58: Good conversion to const fn for conditional getter.
This method performs simple flag checking and returns a reference conditionally, which is appropriate for compile-time evaluation.
122-125: Appropriate conversion to const fn for simple getter.
This method returns a static string field without side effects, making it suitable for compile-time evaluation.
vm/src/stdlib/symtable.rs (4)32-34: Appropriate conversion to const fn for constructor.
This simple wrapper constructor performs no side effects and is suitable for compile-time evaluation.
173-175: Good conversion to const fn for predicate method.
This method calls self.symbol.is_global() (which is const fn based on the relevant code snippet from compiler/codegen/src/symboltable.rs) and performs boolean logic, making it appropriate for compile-time evaluation.
183-185: Good conversion to const fn for predicate method.
This method calls self.symbol.is_local() (which is const fn based on the relevant code snippet from compiler/codegen/src/symboltable.rs) and performs boolean logic, making it appropriate for compile-time evaluation.
193-196: Appropriate conversion to const fn for trivial function.
This method simply returns a constant value, making it clearly suitable for compile-time evaluation.
vm/src/builtins/dict.rs (2)60-62: LGTM: Appropriate const fn usage for simple accessor.
This method simply returns a reference to an internal field, making it an ideal candidate for const fn. The change enables compile-time evaluation without altering the method's behavior.
379-391: LGTM: Consistent const fn application for view constructors.
These methods create dictionary view objects using simple constructors. The const fn qualifier is appropriate here since the constructors (as seen in the macro expansion at line 779) are also const-compatible, enabling compile-time evaluation of these view creations.
vm/src/builtins/coroutine.rs (3)28-30: LGTM: Consistent const fn pattern across coroutine types.
This accessor method returns a reference to the internal Coro field, which is appropriate for const fn. The change aligns with identical patterns in generator.rs and asyncgenerator.rs (as shown in relevant snippets), maintaining consistency across coroutine-related types.
49-51: LGTM: Appropriate const fn for simple struct construction.
This method creates a PyCoroutineWrapper through simple struct construction, making it suitable for const fn. The pattern aligns with similar async implementations in the codebase while enabling compile-time evaluation.
72-74: LGTM: Const fn appropriate for constant return value.
This placeholder method always returns None, making it an ideal candidate for const fn. The unused _vm parameter doesn't prevent const evaluation since the method body only returns a compile-time constant.
vm/src/builtins/str.rs (3)416-424: Accessor safely promoted to const fn – looks good
The new const qualifier on as_wtf8 / as_bytes is correct:
• both simply delegate to already-const helpers on StrData / Wtf8;
• no proc-macro attributes are attached, so nothing blocks compile-time evaluation.No further action required.
459-471: kind() / is_utf8() now const – LGTM
These trivial getters don’t rely on anything non-const and will be usable in
const contexts immediately.
604-606: Verify #[pymethod] const fn macro expansion
The sandbox build failed due to a missing C linker (cc not found), so we couldn’t confirm that the #[pymethod] proc-macro still handles const fn. Please verify on your local machine:
vm/sre_engine/src/string.rs (1)
- Install a C linker (e.g. gcc / build-essential).
- Run cargo check or cargo test to ensure the build succeeds.
- Optionally use cargo expand on the is_ascii method in vm/src/builtins/str.rs (lines 604–606) to inspect the generated binding named "isascii".
370-373: Constifying simple predicates is fine
is_linebreak / is_uni_linebreak are pure value checks; marking them const
poses no problems.Also applies to: 436-441
vm/src/builtins/code.rs (2)205-208: Constructor can safely be const
PyCode::new is a plain struct literal – upgrading to const is harmless and
useful for embedding byte‐code blobs in future const contexts.
245-258: Const getters with #[pygetset] are supported
vm/src/types/slot.rs (5)
Inspected the pygetset procedural macro (in derive/src/lib.rs → derive-impl) and confirmed it forwards the complete function signature (including const) via #sig. There’s no special pattern-match excluding const fn, so your const-qualified getters will be preserved correctly. No changes required.152-154: LGTM: Appropriate const fn conversion
The has_feature method only performs bitwise operations via contains(), making it suitable for const fn.
157-159: LGTM: Appropriate const fn conversion
The is_created_with_flags method only performs bitwise flag checking, making it suitable for const fn.
328-330: LGTM: Appropriate const fn conversion
The self_iter function only returns its parameter wrapped in Ok(), making it suitable for const fn.
1112-1119: LGTM: Appropriate const fn conversion
The eval_ord method only performs pattern matching and bitwise operations, making it suitable for const fn.
1121-1130: LGTM: Appropriate const fn conversion
The swapped method only performs pattern matching and returns enum variants, making it suitable for const fn.
vm/src/builtins/complex.rs (6)31-33: LGTM: Appropriate const fn conversion
The to_complex64 method only returns a field value, making it suitable for const fn.
239-241: LGTM: Appropriate const fn conversion
The to_complex method only returns a field value, making it suitable for const fn.
250-252: LGTM: Appropriate const fn conversion
The real getter only returns a field from the complex value, making it suitable for const fn.
255-257: LGTM: Appropriate const fn conversion
The imag getter only returns a field from the complex value, making it suitable for const fn.
349-351: LGTM: Appropriate const fn conversion
The __pos__ method only returns the complex value, making it suitable for const fn.
387-390: LGTM: Appropriate const fn conversion
The __getnewargs__ method only destructures the complex value and returns a tuple of primitives, making it suitable for const fn. Note that this differs from the float/int implementations which take a VM parameter, but this implementation is simpler and can be const.
vm/src/object/core.rs (6)424-428: LGTM: Appropriate const fn conversion
The InstanceDict::new method only wraps the parameter in a PyRwLock::new(), which is const in Rust standard library.
515-519: LGTM: Appropriate const fn conversion
The into_raw method only extracts the pointer and forgets self, which are compile-time operations suitable for const fn.
527-529: LGTM: Appropriate const unsafe fn conversion
The from_raw method only creates a struct from a raw pointer, which is a compile-time operation suitable for const unsafe fn.
666-671: LGTM: Appropriate const unsafe fn conversion
The payload_unchecked method only performs pointer casting operations, which are compile-time operations suitable for const unsafe fn.
1029-1033: LGTM: Appropriate const unsafe fn conversion
The from_raw method only creates a struct from a raw pointer using NonNull::new_unchecked, which are compile-time operations suitable for const unsafe fn.
1053-1057: LGTM: Appropriate const fn conversion
The leak method only extracts the pointer and forgets the object, which are compile-time operations suitable for const fn.
vm/src/stdlib/posix.rs (2)214-220: LGTM: Simple bitwise operations are appropriate for const fn.
This function only performs bitwise operations on primitive types, which is well-suited for compile-time evaluation.
1606-1633: Verify const-evaluability of libc macros
The CI environment couldn’t complete the Rust compilation test, so you’ll need to manually confirm that these wrappers actually compile as const fn on your supported targets. If any of the following macros aren’t const-evaluable, you’ll need to remove the const qualifier or gate the wrapper behind a platform-specific cfg:
• libc::WIFSIGNALED
• libc::WIFSTOPPED
• libc::WIFEXITED
• libc::WTERMSIG
• libc::WSTOPSIG
• libc::WEXITSTATUSRecommendations:
common/src/linked_list.rs (3)
- Add a minimal compile-time assertion in a test crate (e.g. const _: bool = your_wrapper(0);) and include it in CI.
- If a macro fails to be const on any supported platform, convert its wrapper to a regular fn or use #[cfg(...)] to only apply const fn where supported.
196-204: LGTM: Simple Option check is appropriate for const fn.
This function only checks if an Option is None, which is well-suited for compile-time evaluation.
326-334: UnsafeCell::new() is const-evaluable in current Rust
Tests confirm that UnsafeCell::new() can be used within a const fn (it compiles without errors when built as a library), so Pointers::new() is valid as written.
336-371: Const pointer operations are const-evaluable – no changes needed
I verified that both ptr::read and ptr::write can be used in const fn on current stable Rust (compiled as a library with metadata-only emission), so these getters and setters compile cleanly in a const context.
– No further action required.
vm/src/builtins/asyncgenerator.rs (4)32-34: LGTM: Simple reference return is appropriate for const fn.
This getter method only returns a reference to an existing field, which is well-suited for compile-time evaluation.
79-81: LGTM: Returning self is appropriate for const fn.
This method simply returns the receiver, which is well-suited for compile-time evaluation.
204-206: LGTM: Returning self is appropriate for const fn.
These __await__ methods simply return the receiver, which is well-suited for compile-time evaluation.
Also applies to: 298-300
89-95: Verify AtomicCell::new Is Const-Evaluable
The asend constructor is a const fn and uses AtomicCell::new(...). Depending on your crossbeam-utils version, AtomicCell::new may not be marked const, causing a compilation error.
• Check your Cargo.toml for the crossbeam-utils version in use.
compiler/core/src/bytecode.rs (2)
• Confirm in that crate’s src/atomic/cell.rs that pub const fn new(...) is defined (added in ≥0.8.x).
• If your version predates the const fn change, either bump crossbeam-utils or refactor asend to avoid requiring const.217-219: const fn with interior mutation looks good
reset only performs a single assignment; this is accepted by stable const evaluation, so the new qualifier is safe. No action needed.
283-285: Const-qualification of pure helpers LGTM
Marking Arg::marker, CodeUnit::new, Instruction::label_arg, and Instruction::unconditional_branch as const fn is valid; they are side-effect free (or take only immutable args) and don’t call non-const APIs. This increases compile-time usability without affecting runtime behaviour.
Also applies to: 663-665, 1153-1169, 1180-1190
vm/src/stdlib/io.rs (9)292-294: Double-check MSRV for Cursor::position being const
const fn tell now calls Cursor::position(). This is only legal if the MSRV you advertise already provides const fn position (stabilised in 1.77). If you still support an older toolchain the build will fail.
No change requested – just make sure the CI matrix covers the oldest supported compiler.
785-804: BufferedData flag helpers converted to const fn – looks good
All helpers merely read bit-flags and do arithmetic; bitflags 2.x exposes const fn contains, so this compiles fine and allows use in other const contexts.
806-813: raw_offset promoted to const – all operations are const-safe
The implementation only does comparisons and arithmetic on plain integers, so the new qualifier is sound.
815-822: readahead const-ification is safe
Same reasoning as above; no hidden I/O or heap work.
823-830: reset_read / reset_write are now const but mutate &mut self
Mutating fields is allowed inside a const fn with a &mut self receiver, so this is fine.
1281-1286: adjust_position const-ready
Simple field updates only; no concerns.
2099-2101: textio_encode_utf8 as const fn – harmless
Constructing an enum variant is allowed in const context. No objections.
2267-2270: TextIOCookie::set_num_to_skip const-ification OK
Pure field assignments; approved.
1908-1914: Const getters on pyclass methods – verify macro support
#[pymethod] const fn ... relies on the pymethod macro accepting the const keyword. RustPython’s proc-macro already handles this for other modules, so this should compile, but keep an eye on CI in case of a downstream macro regression.
Also applies to: 3515-3527, 3641-3653
Sorry, something went wrong.
|
|
||
| #[pyfunction] | ||
| fn sync() { | ||
| const fn sync() { |
There was a problem hiding this comment.
#[pyfunction], #[pymethod], #[pygetset] etc will have no change to be called in const context. you don't need to spend too much effort about them.
const fn to rust-context functions is a good idea
Sorry, something went wrong.
There was a problem hiding this comment.
#[pyfunction], #[pymethod], #[pygetset] etc will have no change to be called in const context. you don't need to spend too much effort about them.
It's a simple clippy command:)
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary by CodeRabbit