[refurb] Preserve comments (FURB171)#15521
[refurb] Preserve comments (FURB171)#15521InSyncWithFoo wants to merge 2 commits intoastral-sh:mainfrom
refurb] Preserve comments (FURB171)#15521Conversation
|
| let iterable_start_to_item_start = TextRange::new(iterable.start(), item_range.start()); | ||
| let item_end_to_iterable_end = TextRange::new(item_range.end(), iterable.end()); | ||
|
|
||
| tokens |
There was a problem hiding this comment.
I'm not sure if we should add more token based fixes. They add a fair amount of complexity.
There was a problem hiding this comment.
I'm unaware of a better solution (how else can I collect the comments from a range?). What do you suggest?
There was a problem hiding this comment.
I haven't looked at the fix in detail but my general preference is to accept the removal of comments and instead mark the fix as unsafe if it removes a comment.
There was a problem hiding this comment.
This wouldn't be resolving #10063, then. Might as well close it.
There was a problem hiding this comment.
There's some discussion around comment handling in fixes here: #9790
There was a problem hiding this comment.
That's fair, although there's a reference to the discussion #9790 that wasn't resolved back then.
I'm still leaning towards making the fix as unsafe if there's a comment over implementing all this token handling. While impressive, it's just a lot of complexity, especially if we add it to every rule.
I agree with this take. I think eventually we should develop a more holistic approach to handling comments, and for now prefer to mark as unsafe (unless the comment handling is very straightforward). Gonna close this for now, but thank you for the implementation! Maybe it can inspire the future, general approach to comment handling! |
Summary
Resolves #10063.
Test Plan
cargo nextest runandcargo insta test.