Fix a splat legacy demangling display bug - #160050
Conversation
|
r? @camelid rustbot has assigned @camelid. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| if let Some(index) = splatted_arg_index { | ||
| self.comma_sep((&mut input_iter).take(usize::from(index)))?; | ||
| write!(self, ", #[splat]")?; | ||
| write!(self, "#[splat] ")?; |
There was a problem hiding this comment.
Won't this break any cases where there are arguments before the splat? Like fn foo(x: i32, #[splat] ...). This is the first time I'm hearing about this feature, but the code still seems wrong here.
There was a problem hiding this comment.
It seems like a good idea to have some tests for splatting with regular arguments before and/or after the the splatted argument -- assuming that that's supported. If it's not supported, then I'm confused why splatted_arg_index exists and is not just always None or 0.
There was a problem hiding this comment.
Won't this break any cases where there are arguments before the splat? Like fn foo(x: i32, #[splat] ...). This is the first time I'm hearing about this feature, but the code still seems wrong here.
Turns out comma-separated lists are hard 😭
I fixed the logic and added a comment for future maintainers, this is my third try at getting this right.
It seems like a good idea to have some tests for splatting with regular arguments before and/or after the the splatted argument
I also added tests to make sure to cover leading, trailing, middle, and internal splats. (The original tests were adapted from tests for a symbol mangling clash, so I didn't really think about splat positioning at the time.)
|
Reminder, once the PR becomes ready for a review, use |
c82af0a to
980ae5d
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
980ae5d to
1099c87
Compare
Tracking issue: #153629
This PR fixes a splat legacy demangling display bug, where the comma is in the wrong place in the argument list.
It also does a cleanup from @folkertdev's PR #159643 review:
@rustbot label +F-splat +C-bug +A-name-mangling