Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor rewrite_array, pair, tuple, call #6248

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

ding-young
Copy link
Contributor

Tracked by #6206

Description

  • This pr modifies following functions to return RewriteResult
    : rewrite_array, rewrite_pair, rewrite_tuple, rewrite_call
    and rewrite_with_*** in src/overflow.rs
  • Impl rewrite_result for ast::MetaItem in src/attrs.rs

Question & TODO

I used DUMMY_SP for generating dummy span of max_width_error in rewrite_pair, rewrite_all_pairs and its callees. There might be a better way to manually create an appropriate span for PairPart, and I need to give it more thought.

@ytmimi ytmimi added the GSoC Google Summer of Code label Jul 22, 2024
@ytmimi
Copy link
Contributor

ytmimi commented Jul 22, 2024

I used DUMMY_SP for generating dummy span of max_width_error in rewrite_pair, rewrite_all_pairs and its callees. There might be a better way to manually create an appropriate span for PairPart, and I need to give it more thought.

@ding-young When I took a quick look at the code I was surprised to see DUMMY_SP being used. I'd really like to avoid using DUMMY_SP if possible because it would mean that we can't guarantee that the spans in RewriteError::ExceedsMaxWidth are even valid. Could you look into how hard it would be to update the bounds on rewrite_pairs_multiline and rewrite_pair to add a bound for our Spanned trait.

If it's not possible, or just too much effort to add the Spanned bound right now, then I'd probable want to add another RewriteError variant that captures the fact that "this is a max_width issue, but we can't accurately report the span".

@ding-young ding-young force-pushed the rw-with-bracket branch 2 times, most recently from 138f4d4 to 8339bbd Compare July 25, 2024 05:24
@ding-young
Copy link
Contributor Author

I removed DUMMY_SP by updating PairList and RangeOperand to hold corresponding span as follows. I'll mark the code line ranges.

src/pairs.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ytmimi ytmimi left a comment

Choose a reason for hiding this comment

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

I kicked off the Diff-Check job. Assuming it passes I think we're good to go on this one.

Edit: The job passed ✅

@ytmimi ytmimi merged commit e21c1e2 into rust-lang:master Jul 26, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC Google Summer of Code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants