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 — Remove duplicated code in `compile.rs` by ShaharNaveh · Pull Request #8141 · RustPython/RustPython

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jun 22, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • Closes #xxxx
  • This PR follows our AI policy

Summary

Summary by CodeRabbit

  • Refactor
    • Refactored constant expression detection logic to improve code organization and maintainability without affecting user-facing functionality.

Sorry, something went wrong.

Uh oh!

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

All reactions
@ShaharNaveh
Remove duplicated code in compile.rs
3bcfd74
@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 7104264e-6bb8-4440-9a4f-b66b0a1f8b98

📥 Commits

Reviewing files that changed from the base of the PR and between 55b96f9 and 3bcfd74.

📒 Files selected for processing (1)
  • crates/codegen/src/compile.rs

📝 Walkthrough

Walkthrough

In compile.rs, the standalone is_const_expression helper function is removed. A new ExprExt trait method is_constant takes over constant-literal detection. The interactive-mode branch that guards Instruction::Nop emission is updated to call value.is_constant() instead of the removed helper.

Changes

Constant detection refactor in compile.rs

Layer / File(s) Summary
ExprExt contract, call site update, and helper removal
crates/codegen/src/compile.rs
Adds ExprExt::is_constant method contract, replaces Self::is_const_expression(value) with value.is_constant() in the interactive-mode Nop-guard branch, and removes the now-redundant is_const_expression(expr: &ast::Expr) -> bool helper function.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • RustPython/RustPython#7541: Directly related — both PRs touch the ExprExt::is_constant method in crates/codegen/src/compile.rs, with that PR extending the semantics that this PR's call site now relies on.

Poem

🐇 A helper once lived in a function so plain,
Matching literals again and again.
Now the trait takes the wheel with is_constant in tow,
The old code deleted, the logic aglow.
Less is more, little bunny, hop hop away! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing a duplicated is_const_expression function and consolidating constant-checking logic into an ExprExt extension trait method.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 approved these changes Jun 22, 2026
View reviewed changes
@youknowone
youknowone merged commit 73b0c9f into RustPython:main Jun 22, 2026
26 checks passed

Uh oh!

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

youknowone pushed a commit that referenced this pull request Sep 16, 2026
@ShaharNaveh
Remove duplicated code in compile.rs (#8141)
c95b48c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@youknowone youknowone youknowone 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

@ShaharNaveh @youknowone
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 01402503 — 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.