diff options
| author | Jorge Martin Juarez <50276574+jmj0502@users.noreply.github.com> | 2022-07-17 21:39:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-17 21:39:25 -0400 |
| commit | a7bf0090347d8523dd62c0508a4c8413cdba099a (patch) | |
| tree | 92a96a7e1d7b1f32fd3eaf252aba6c61a74215fc /src | |
| parent | 85fdf8ecec5551e79dc5ac3a8babaf514a58ef86 (diff) | |
| download | rust-a7bf0090347d8523dd62c0508a4c8413cdba099a.tar.gz rust-a7bf0090347d8523dd62c0508a4c8413cdba099a.zip | |
Fix/comments inside trait generics gets duplicated (#5446)
* Bugfix: Now slash/start comments aren't duplicated on trait parameters. * Removing unnecesary comment. * Improvements: Improving the BytePos offset. * Improvements: Improving the description of the test cases.
Diffstat (limited to 'src')
| -rw-r--r-- | src/items.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/items.rs b/src/items.rs index 6ab02e7f923..a76e88b77d4 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1084,7 +1084,11 @@ pub(crate) fn format_trait( let item_snippet = context.snippet(item.span); if let Some(lo) = item_snippet.find('/') { // 1 = `{` - let comment_hi = body_lo - BytePos(1); + let comment_hi = if generics.params.len() > 0 { + generics.span.lo() - BytePos(1) + } else { + body_lo - BytePos(1) + }; let comment_lo = item.span.lo() + BytePos(lo as u32); if comment_lo < comment_hi { match recover_missing_comment_in_span( |
