Fix msg for verbose suggestions with confusable capitalization · rust-lang/rust@8d4d572 (original) (raw)

`@@ -1742,9 +1742,17 @@ impl HumanEmitter {

`

1742

1742

` buffer.append(0, level.to_str(), Style::Level(*level));

`

1743

1743

` buffer.append(0, ": ", Style::HeaderMsg);

`

1744

1744

``

``

1745

`+

let mut msg = vec![(suggestion.msg.to_owned(), Style::NoStyle)];

`

``

1746

`+

if suggestions

`

``

1747

`+

.iter()

`

``

1748

`+

.take(MAX_SUGGESTIONS)

`

``

1749

`+

.any(|(_, _, _, only_capitalization)| *only_capitalization)

`

``

1750

`+

{

`

``

1751

`+

msg.push((" (notice the capitalization difference)".into(), Style::NoStyle));

`

``

1752

`+

}

`

1745

1753

`self.msgs_to_buffer(

`

1746

1754

`&mut buffer,

`

1747

``

`-

&[(suggestion.msg.to_owned(), Style::NoStyle)],

`

``

1755

`+

&msg,

`

1748

1756

` args,

`

1749

1757

` max_line_num_len,

`

1750

1758

`"suggestion",

`

`@@ -1753,12 +1761,8 @@ impl HumanEmitter {

`

1753

1761

``

1754

1762

`let mut row_num = 2;

`

1755

1763

`draw_col_separator_no_space(&mut buffer, 1, max_line_num_len + 1);

`

1756

``

`-

let mut notice_capitalization = false;

`

1757

``

`-

for (complete, parts, highlights, only_capitalization) in

`

1758

``

`-

suggestions.iter().take(MAX_SUGGESTIONS)

`

1759

``

`-

{

`

``

1764

`+

for (complete, parts, highlights, _) in suggestions.iter().take(MAX_SUGGESTIONS) {

`

1760

1765

`debug!(?complete, ?parts, ?highlights);

`

1761

``

`-

notice_capitalization |= only_capitalization;

`

1762

1766

``

1763

1767

`let has_deletion = parts.iter().any(|p| p.is_deletion(sm));

`

1764

1768

`let is_multiline = complete.lines().count() > 1;

`

`@@ -2057,9 +2061,6 @@ impl HumanEmitter {

`

2057

2061

`let others = suggestions.len() - MAX_SUGGESTIONS;

`

2058

2062

`let msg = format!("and {} other candidate{}", others, pluralize!(others));

`

2059

2063

` buffer.puts(row_num, max_line_num_len + 3, &msg, Style::NoStyle);

`

2060

``

`-

} else if notice_capitalization {

`

2061

``

`-

let msg = "notice the capitalization difference";

`

2062

``

`-

buffer.puts(row_num, max_line_num_len + 3, msg, Style::NoStyle);

`

2063

2064

`}

`

2064

2065

`emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;

`

2065

2066

`Ok(())

`