| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 3f7cb52a-f8d4-4426-9e50-2fea90e7c0d7 📥 CommitsReviewing files that changed from the base of the PR and between 03bfd70 and ef45416. 📒 Files selected for processing (1)
📝 Walkthrough WalkthroughThe PR simplifies wchar_len calculation in codec error handling and adds targeted Clippy allowances for intentional drain-and-collect operations in the VM trampoline. ChangesTail-call reference handling
Code-page error handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: youknowone, shaharnaveh 🚥 Pre-merge checks | ✅ 5 ✅ Passed checks (5 passed)
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. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agentsVerify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@crates/vm/src/vm/mod.rs`: - Line 1471: Replace the remaining pending tail-call reference `.drain(..).collect()` in the exception-unwind tail-call branch with the same `mem::take` ownership transfer used by `initial_refs` and the analogous branches. Preserve the existing behavior and run `cargo clippy` afterward.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 34fd5b4d-baa6-4d5c-b1e3-c931476ab6a6
📥 CommitsReviewing files that changed from the base of the PR and between 81df1ff and 03bfd70.
📒 Files selected for processing (2)
Sorry, something went wrong.
There was a problem hiding this comment.
great!
not a blocker: can we enforce this with the clippy rules if it's not already been done?
Sorry, something went wrong.
RustPython's tail call machinery pre-allocates and reuses a vector. The code drains the vector into a new vector which is stored elsewhere. Clippy warns that this pattern causes a spurious location. Clippy is usually right that this pattern is suspect, but in this case the initial vector is reused so we want to keep the initial location.
|
@ShaharNaveh I went through the code in depth to check if the lint was necessary. It turns out that Clippy is overzealous here. The original code pre-allocates a buffer to reuse. The drain/collect idiom is intentional and correct. Instead, I documented the behavior and allowed the lint so that anyone else who encounters it knows not to fix the lint. I also fixed a totally unrelated but small lint. 😁 I used #[allow] instead of #[expect] because the lint doesn't trigger on my stable compiler but does trigger on nightly. CI would fail with #[expect]. |
Sorry, something went wrong.
tysm for looking into it! |
Sorry, something went wrong.
|
@joshuamegnauth54 can we still add this rule? so future places would get flagged |
Sorry, something went wrong.
There was a problem hiding this comment.
adding the rule is not a blocker (for me)
Sorry, something went wrong.
@coderabbitai Can #[expect] be used within #[cfg] so that #[expect] only applies when built with the nightly compiler? |
Sorry, something went wrong.
|
Tip For best results, initiate chat on the files or code changes. 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '== Rust toolchain and project policy files =='
fd -HI -t f '^(rust-toolchain(\.toml)?|Cargo\.toml|clippy\.toml|CONTRIBUTING\.md|README\.md)$' . \
| sed -n '1,160p'
printf '%s\n' '== Compiler-version and nightly configuration references =='
rg -n -i -C 3 \
'(rust-version|rustup|nightly|stable|rustversion|check-cfg|unexpected_cfgs|drain_collect)' \
-g 'Cargo.toml' -g 'rust-toolchain*' -g 'clippy.toml' -g '*.rs' -g '*.md' . \
| sed -n '1,280p'
printf '%s\n' '== Tail-call source map =='
ast-grep outline crates/vm/src/vm/mod.rs --items all --match 'trampoline|tail|call' --view expanded || true
printf '%s\n' '== Changed lines in relevant files =='
git diff -- crates/vm/src/vm/mod.rs crates/vm/src/stdlib/_codecs.rsLength of output: 18513 🤖 web_search executed: site:doc.rust-lang.org/reference conditional compilation cfg Rust built-in cfg nightly stable compiler channel Length of output: 5066 🤖 web_search executed: site:doc.rust-lang.org rustc lint expect attribute unfulfilled_lint_expect documentation Length of output: 8212 @fanninpm Yes, but Rust does not define a built-in cfg predicate for the compiler channel. This attribute is valid if the build defines a custom nightly configuration option: #[cfg_attr(nightly, expect(clippy::drain_collect))]
let refs: Vec<_> = refs.drain(..).collect();A build script or CI must then define nightly only for nightly builds. A build script must also declare the option for check-cfg: println!("cargo::rustc-check-cfg=cfg(nightly)");
println!("cargo::rustc-cfg=nightly");The second line must run only when the selected rustc is nightly. I do not recommend this for this PR. RustPython selects stable in rust-toolchain.toml and supports the latest stable Rust. The Clippy lint does not trigger consistently across those compiler versions. The documented #[allow(clippy::drain_collect)] therefore states the intended behavior without adding custom compiler-channel detection. #[expect] is best when the lint is expected to trigger on every supported toolchain. You are interacting with an AI system. |
Sorry, something went wrong.
|
Sorry, something went wrong.
|
@ShaharNaveh Do you mean enabling the lint or denying the lint? The lint should already be enabled by default, yet I'm unsure why it didn't trigger. Here's a Playground lint that demonstrates that it triggers on stable. 🤔 |
Sorry, something went wrong.
oh, it didn't trigger due to clippy bug, nvm... tysm! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
RustPython's tail call machinery pre-allocates and reuses a vector. The code drains the vector into a new vector which is stored elsewhere.
Clippy warns that this pattern causes a spurious location. Clippy is usually right that this pattern is suspect, but in this case the initial vector is reused so we want to keep the initial location.
Summary
Summary by CodeRabbit