Skip to content

Exclude closures defined in formula_fn from analysis and borrowck#67

Open
coord-e wants to merge 2 commits intomainfrom
coord-e/closure-formula-fn-fix
Open

Exclude closures defined in formula_fn from analysis and borrowck#67
coord-e wants to merge 2 commits intomainfrom
coord-e/closure-formula-fn-fix

Conversation

@coord-e
Copy link
Copy Markdown
Owner

@coord-e coord-e commented Apr 30, 2026

follow-up of #64
extracted from #57

formula_fn with existential quantification would contain closures. They're syntactically contained in the formula_fn f, but are expanded to top-level function in MIR and are processed as usual by Thrust and rustc, which is undesired. This PR makes it skip analysis and borrowck if the function is a closure defined within formula_fn.

This PR also deal with closures defined within #[thrust::ignored] or some other functions that are skipped by Thrust

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts Thrust’s analysis pipeline to ignore MIR bodies generated for closures that originate inside #[thrust::formula_fn] functions, avoiding unintended analysis/borrowck work on compiler-generated closure items.

Changes:

  • Skip local refinement/analysis for MIR items whose typeck_root_def_id is already marked as skipped.
  • Skip mir_borrowck not only for #[thrust::formula_fn] items themselves, but also for their generated closure bodies (via typeck_root_def_id).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/analyze/crate_.rs Adds a root-def-id based early return to skip analysis of closures/synthetic bodies under already-skipped defs.
src/analyze.rs Extends borrowck skipping to closures whose root def is annotated #[thrust::formula_fn].

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/analyze/crate_.rs
Comment thread src/analyze/crate_.rs
Comment thread src/analyze.rs
@coord-e coord-e force-pushed the coord-e/closure-formula-fn-fix branch from db0411a to 75d8b48 Compare April 30, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants