google / google/xls

Formatting an `impl` with a trailing comment is impossible

Open
#1,858 0 comments 0 reactions 0 assignees View on GitHub
bug dslx dslx:fmt
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**

If there is a comment between the end of the last function and the end of an impl, the impl cannot be formatted.

**To Reproduce**
Steps to reproduce the behavior:
1. Format
```
struct MyStruct{}

impl MyStruct {
fn my_function() -> u32 { u32:3 }
// Format
}
```
2. See error

```
Formatting failed: Error: INTERNAL: Formatting was skipped because a comment at (filename) would be deleted by the formatter: // Format
This is probably due to a bug (which may not have been reported yet). To complete formatting, try moving the comment to a different line.
```

**Expected behavior**
It formats it

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.