GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — no_std clippy by youknowone · Pull Request #7043 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Feb 8, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

finish #6380

Summary by CodeRabbit

Release Notes

  • Refactor

    • Reduced reliance on the standard library to improve compatibility with restricted/no-std environments and broaden platform support.
    • Multiple internal imports and memory/pointer handling paths migrated to core/alloc equivalents with no behavioral changes.
  • Chores

    • Enabled additional Clippy lints (including suspicious and correctness) and clarified lint annotations for cross-platform code.
  • Compatibility

    • Small, targeted public type adjustments to threading/module state to align with the allocator/core changes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Feb 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR enables additional Clippy lints and systematically replaces many std:: usages with core:: and alloc:: equivalents across the codebase (memory, pointers, atomics, collections, FFI and threading types) to align with no-std/no-std-like constraints.

Changes

Cohort / File(s) Summary
Clippy Configuration
Cargo.toml
Uncommented/enabled clippy lints: alloc_instead_of_core, std_instead_of_alloc, std_instead_of_core; added suspicious and correctness lint groups set to warn.
Memory & Pointer core:: Migration
crates/.../codegen/src/compile.rs, crates/common/src/crt_fd.rs, crates/common/src/fileutils.rs, crates/stdlib/src/mmap.rs, crates/vm/src/stdlib/nt.rs, crates/vm/src/stdlib/sys.rs, crates/vm/src/windows.rs, crates/vm/src/stdlib/winapi.rs, crates/vm/src/stdlib/winreg.rs
Replaced std::mem::*, std::ptr::*, std::mem::MaybeUninit, std::mem::zeroed, and std::mem::size_of* usages with core:: equivalents for initialization, sizing, and null pointers.
Slices / Iterators / Formatting Migration
crates/stdlib/src/_sqlite3.rs, crates/stdlib/src/math.rs, crates/stdlib/src/socket.rs, crates/stdlib/src/ssl.rs, crates/vm/src/stdlib/io.rs, crates/vm/src/stdlib/msvcrt.rs
Swapped std::slice, std::iter, std::fmt and related calls with core::slice, core::iter, core::fmt equivalents (including Debug impl updates).
Atomic Types Migration
crates/stdlib/src/_asyncio.rs, crates/stdlib/src/posixsubprocess.rs, crates/vm/src/builtins/template.rs, crates/vm/src/stdlib/_abc.rs, crates/vm/src/stdlib/signal.rs, crates/vm/src/vm/interpreter.rs, crates/vm/src/vm/mod.rs
Replaced std::sync::atomic::{...} imports and usages with core::sync::atomic counterparts; updated struct fields/initializers and Ordering references (notably PyTemplateIter fields).
Arc/Weak & Collections Migration
crates/stdlib/src/multiprocessing.rs, crates/stdlib/src/overlapped.rs, crates/stdlib/src/thread.rs, crates/vm/src/vm/thread.rs, crates/vm/src/vm/interpreter.rs, crates/vm/src/vm/mod.rs
Replaced std::sync::Arc/Weak with alloc::sync::{Arc, Weak} and moved std::collections::BTreeMap uses to alloc::collections::BTreeMap/local imports; several public struct fields/types updated accordingly (thread-related types).
FFI / CString / c_void Migration
crates/common/src/fileutils.rs, crates/stdlib/src/multiprocessing.rs, crates/stdlib/src/os.rs, crates/vm/src/stdlib/ctypes.rs
Replaced std::ffi::CString with alloc::ffi::CString in allocation contexts; switched std::ffi::c_void to core::ffi::c_void in function-pointer signatures.
Duration / Time types Migration
crates/stdlib/src/ssl.rs, crates/vm/src/stdlib/time.rs
Replaced std::time::Duration with core::time::Duration in function parameters/usage and corresponding duration computations.
Clippy allow attributes & minor annotations
crates/vm/src/stdlib/ctypes/base.rs, crates/vm/src/stdlib/ctypes/function.rs, crates/vm/src/stdlib/ctypes/pointer.rs, crates/vm/src/stdlib/ctypes/simple.rs, crates/vm/src/stdlib/io.rs
Added/expanded clippy allow attributes (e.g., clippy::useless_conversion, clippy::unnecessary_cast) with reason strings for platform-specific wchar_t conversions and added small comment/lint tweaks.
Small std→core/alloc swaps in VM internals
crates/vm/src/builtins/function.rs, crates/vm/src/builtins/tuple.rs, crates/vm/src/frame.rs, crates/vm/src/signal.rs, crates/vm/src/builtins/template.rs, crates/vm/src/stdlib/ctypes/*, crates/vm/src/stdlib/io.rs, crates/vm/src/stdlib/msvcrt.rs
Replaced scattered std:: usages (e.g., mem::take, mem::replace, hint::unreachable_unchecked, cell::Cell, ptr::null_mut) with core:: equivalents; atomic and field signature adjustments where applicable.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • finish no_std clippy #6587: Similar no-std/core+alloc migration across many stdlib modules (strong overlap in approach and affected files).
  • Fix asyncio related compiler/library issues #6837: Touches crates/codegen/src/compile.rs and may conflict with changes around t-string/template handling.
  • Upgrade threading to 3.13.11; sys.setprofile & impl more threading #6691: Changes threading types/APIs (ThreadHandle/ShutdownEntry/Arc/Weak) similar to the thread-related type migrations here.

Suggested reviewers

  • ShaharNaveh
  • arihant2math

"🐰 I hopped through code at break of dawn,
Swapped std for core before the lawn,
Pointers neat and atomics bright,
Clippy nods as I take flight —
A tiny hop, a cleaner night."

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'no_std clippy' is vague and generic, using non-descriptive terms that don't clearly convey the changeset's main objective despite referencing a related initiative. Revise the title to be more specific and descriptive of the primary changes, such as 'Replace std library imports with core/alloc equivalents for no_std compatibility' or reference the issue more explicitly.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 96.75% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone force-pushed the no_std branch from 1c50a3e to 987295c Compare February 8, 2026 03:43
@github-actions

github-actions Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Code has been automatically formatted

The code in this PR has been formatted using:

  • cargo fmt --all
    Please pull the latest changes before pushing again:
git pull origin no_std
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone force-pushed the no_std branch 5 times, most recently from 44bf6bf to da9ad35 Compare February 8, 2026 06:21
ShaharNaveh
ShaharNaveh reviewed Feb 8, 2026
View reviewed changes
Comment thread crates/vm/src/stdlib/ctypes/function.rs Outdated
#[cfg(not(windows))]
{
// wchar_t is i32 on some platforms and u32 on others
#[allow(clippy::useless_conversion)]

@ShaharNaveh ShaharNaveh Feb 8, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[allow(clippy::useless_conversion)]
#[allow(clippy::useless_conversion, reason = "wchar_t is i32 on some platforms and u32 on others")]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@youknowone youknowone Feb 8, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ShaharNaveh
ShaharNaveh reviewed Feb 8, 2026
View reviewed changes
Comment thread crates/vm/src/stdlib/ctypes/function.rs Outdated
#[cfg(not(windows))]
{
// wchar_t is i32 on some platforms and u32 on others
#[allow(clippy::useless_conversion)]

@ShaharNaveh ShaharNaveh Feb 8, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ShaharNaveh
ShaharNaveh reviewed Feb 8, 2026
View reviewed changes
Comment thread crates/vm/src/stdlib/ctypes/pointer.rs Outdated
let addr = (ptr_value as isize + cur * wchar_size as isize) as *const libc::wchar_t;
unsafe {
// wchar_t is i32 on some platforms and u32 on others
#[allow(clippy::unnecessary_cast)]

@ShaharNaveh ShaharNaveh Feb 8, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ShaharNaveh ShaharNaveh Feb 8, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@youknowone you missed this one:)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@youknowone youknowone Feb 8, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran a project-wide appliance task. Let's handle this there

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@youknowone youknowone Feb 8, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, that task didn't catch this one 🤦

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ShaharNaveh
ShaharNaveh reviewed Feb 8, 2026
View reviewed changes
Comment thread crates/vm/src/stdlib/ctypes/simple.rs Outdated
#[cfg(not(windows))]
{
// wchar_t is i32 on some platforms and u32 on others
#[allow(clippy::useless_conversion)]

@ShaharNaveh ShaharNaveh Feb 8, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
youknowone force-pushed the no_std branch from da9ad35 to b351f28 Compare February 8, 2026 07:17
@youknowone
youknowone marked this pull request as ready for review February 8, 2026 07:18
@youknowone
youknowone requested a review from ShaharNaveh February 8, 2026 07:18
@youknowone
youknowone enabled auto-merge (squash) February 8, 2026 07:18
ShaharNaveh
ShaharNaveh requested changes Feb 8, 2026
View reviewed changes
Comment thread crates/vm/src/stdlib/ctypes/pointer.rs Outdated
let addr = (ptr_value as isize + cur * wchar_size as isize) as *const libc::wchar_t;
unsafe {
// wchar_t is i32 on some platforms and u32 on others
#[allow(clippy::unnecessary_cast)]

@ShaharNaveh ShaharNaveh Feb 8, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@youknowone you missed this one:)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
coderabbitai[bot]
coderabbitai Bot reviewed Feb 8, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@crates/vm/src/stdlib/thread.rs`:
- Around line 20-23: The import is pulling fmt from alloc which triggers the
alloc_instead_of_core lint; change the use to import fmt from core (so types
like fmt::Debug, fmt::Formatter, fmt::Result come from core::fmt) while keeping
sync::{Arc, Weak} from alloc; update the use statement that currently reads use
alloc::{ fmt, sync::{Arc, Weak}, }; to import core::fmt instead and leave Arc
and Weak unchanged, and ensure any references to fmt types (Debug, Formatter,
Result) remain correct.
🧹 Nitpick comments (1)
crates/vm/src/stdlib/signal.rs (1)

31-31: Nit: use the existing atomic alias for brevity.

Line 15 already imports core::sync::atomic::{self, Ordering}, so the fully qualified core::sync::atomic::AtomicBool can be simplified.

♻️ Suggested simplification
-            static WAKEUP_IS_SOCKET: core::sync::atomic::AtomicBool = core::sync::atomic::AtomicBool::new(false);
+            static WAKEUP_IS_SOCKET: atomic::AtomicBool = atomic::AtomicBool::new(false);

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/vm/src/stdlib/thread.rs
Comment on lines +20 to +23
use alloc::{
fmt,
sync::{Arc, Weak},
};

@coderabbitai coderabbitai Bot Feb 8, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check the current imports at lines 20-23
sed -n '15,30p' crates/vm/src/stdlib/thread.rs

# Search for Clippy lint allow/deny configuration
rg -n 'allow|deny|warn' crates/vm/src/stdlib/thread.rs | head -20

# Check if there's a clippy.toml or Cargo.toml with lint configuration
find . -name "clippy.toml" -o -name "Cargo.toml" | grep -E "(^./Cargo.toml|clippy)" | head -5

# Check for Clippy lint configuration in the workspace Cargo.toml
rg -A 20 '\[lints\]' crates/vm/Cargo.toml

Repository: RustPython/RustPython

Length of output: 932


🏁 Script executed:

# Check the workspace Cargo.toml for lint configuration
rg -A 50 '\[lints\]' Cargo.toml

# Check for alloc_instead_of_core and std_instead_of_alloc lint settings
rg 'alloc_instead_of_core|std_instead_of_alloc' Cargo.toml

# Examine what fmt is actually used for in the file
rg -n 'fmt::' crates/vm/src/stdlib/thread.rs | head -20

Repository: RustPython/RustPython

Length of output: 570


🏁 Script executed:

# Double-check the full [lints] section to understand the context
sed -n '/\[lints\]/,/^\[/p' Cargo.toml | head -50

# Verify this is the workspace lints
head -20 Cargo.toml

Repository: RustPython/RustPython

Length of output: 827


🏁 Script executed:

# Find the workspace Cargo.toml and check the [lints] section
find . -name "Cargo.toml" -type f | xargs grep -l "workspace = true" | head -1

# Look for [lints] in the root Cargo.toml
rg -B 5 -A 20 'alloc_instead_of_core' .

# Also check if alloc::fmt is re-exported from core::fmt
python3 <<'EOF'
# Verify that alloc::fmt re-exports from core::fmt
# This is Rust standard library fact-checking
print("In Rust standard library:")
print("- alloc::fmt re-exports core::fmt and adds format! macro")
print("- core::fmt contains: Debug, Formatter, Result, etc.")
print("- alloc_instead_of_core lint warns when using alloc for types from core")
print("- std_instead_of_alloc lint warns when using std for types from alloc")
print("\nFor fmt::Debug, fmt::Formatter, fmt::Result -> these are core::fmt types")
print("Using alloc::fmt for these would trigger alloc_instead_of_core lint")
EOF

Repository: RustPython/RustPython

Length of output: 961


Use core::fmt instead of alloc::fmt to comply with the alloc_instead_of_core Clippy lint.

The workspace has alloc_instead_of_core = "warn" enabled. Since fmt::Debug, fmt::Formatter, and fmt::Result are core::fmt types (not alloc::fmt), importing from alloc::fmt triggers this lint. The alloc::sync::{Arc, Weak} import is correct.

Suggested fix
-use alloc::{
-    fmt,
-    sync::{Arc, Weak},
-};
+use alloc::sync::{Arc, Weak};
+use core::fmt;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use alloc::{
fmt,
sync::{Arc, Weak},
};
use alloc::sync::{Arc, Weak};
use core::fmt;
🤖 Prompt for AI Agents
In `@crates/vm/src/stdlib/thread.rs` around lines 20 - 23, The import is pulling
fmt from alloc which triggers the alloc_instead_of_core lint; change the use to
import fmt from core (so types like fmt::Debug, fmt::Formatter, fmt::Result come
from core::fmt) while keeping sync::{Arc, Weak} from alloc; update the use
statement that currently reads use alloc::{ fmt, sync::{Arc, Weak}, }; to import
core::fmt instead and leave Arc and Weak unchanged, and ensure any references to
fmt types (Debug, Formatter, Result) remain correct.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
youknowone requested a review from ShaharNaveh February 8, 2026 07:32
@youknowone
no_std clippy
360fb1f
@youknowone
youknowone force-pushed the no_std branch from b351f28 to 360fb1f Compare February 8, 2026 07:36
@github-actions
Auto-format: cargo fmt --all
4e8cf97
ShaharNaveh
ShaharNaveh approved these changes Feb 8, 2026
View reviewed changes

@ShaharNaveh ShaharNaveh left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
youknowone disabled auto-merge February 8, 2026 07:49
@youknowone
youknowone merged commit 07fc6ee into RustPython:main Feb 8, 2026
12 of 13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone deleted the no_std branch February 8, 2026 07:49
This was referenced Feb 8, 2026
no_std for wtf8, sre_engine, compiler-core, literal #7051
Merged
no_std for common, pylib, codegen #7056
Merged
This was referenced Jul 29, 2026
host_env: Fix wcslen, leverage NonNull<T> more #8386
Merged
Fix x86_64-pc-windows-gnu build #8411
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Aug 12, 2026
Allow and document clippy::drain_collect #8500
Merged
1 of 2 tasks
youknowone added a commit that referenced this pull request Sep 16, 2026
@youknowone
no_std clippy (#7043)
9d563ce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@ShaharNaveh ShaharNaveh ShaharNaveh approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@youknowone @ShaharNaveh
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.