Skip to content

Commit 5bd7a3c

Browse files
committed
fix: Only special case single line item attribute suggestions
1 parent dc1feab commit 5bd7a3c

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,7 @@ impl HumanEmitter {
21522152

21532153
let line_start = sm.lookup_char_pos(parts[0].original_span.lo()).line;
21542154
let mut lines = complete.lines();
2155+
let lines_len = lines.clone().count();
21552156
if lines.clone().next().is_none() {
21562157
// Account for a suggestion to completely remove a line(s) with whitespace (#94192).
21572158
let line_end = sm.lookup_char_pos(parts[0].original_span.hi()).line;
@@ -2192,6 +2193,7 @@ impl HumanEmitter {
21922193
if highlight_parts.len() == 1
21932194
&& line.trim().starts_with("#[")
21942195
&& line.trim().ends_with(']')
2196+
&& lines_len == 1
21952197
{
21962198
is_item_attribute = true;
21972199
}

src/tools/clippy/tests/ui/new_without_default.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ LL + fn default() -> Self {
191191
LL + Self::new()
192192
LL + }
193193
LL + }
194-
LL | impl NewWithCfg {
195194
|
196195

197196
error: you should consider adding a `Default` implementation for `NewWith2Cfgs`
@@ -212,7 +211,6 @@ LL + fn default() -> Self {
212211
LL + Self::new()
213212
LL + }
214213
LL + }
215-
LL | impl NewWith2Cfgs {
216214
|
217215

218216
error: you should consider adding a `Default` implementation for `NewWithExtraneous`
@@ -250,7 +248,6 @@ LL + fn default() -> Self {
250248
LL + Self::new()
251249
LL + }
252250
LL + }
253-
LL | impl NewWithCfgAndExtraneous {
254251
|
255252

256253
error: aborting due to 13 previous errors

0 commit comments

Comments
 (0)