Skip to content

Commit 533a86d

Browse files
committed
chore: Bump MSRV to 1.88.0, use let chains
1 parent f4a9639 commit 533a86d

3 files changed

Lines changed: 37 additions & 43 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resolver = "3"
55
repository = "https://github.com/rust-lang/annotate-snippets-rs"
66
license = "MIT OR Apache-2.0"
77
edition = "2024"
8-
rust-version = "1.85.0" # MSRV
8+
rust-version = "1.88.0" # MSRV
99
include = [
1010
"build.rs",
1111
"src/**/*",

src/renderer/render.rs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,8 +1098,7 @@ fn render_source_line(
10981098
if annotations_position
10991099
.iter()
11001100
.all(|(_, ann)| matches!(ann.annotation_type, LineAnnotationType::MultilineStart(_)))
1101-
{
1102-
if let Some(max_pos) = annotations_position.iter().map(|(pos, _)| *pos).max() {
1101+
&& let Some(max_pos) = annotations_position.iter().map(|(pos, _)| *pos).max() {
11031102
// Special case the following, so that we minimize overlapping multiline spans.
11041103
//
11051104
// 3 │ X0 Y0 Z0
@@ -1119,7 +1118,6 @@ fn render_source_line(
11191118
// one line of vertical space.
11201119
line_len = line_len.saturating_sub(1);
11211120
}
1122-
}
11231121

11241122
// Write the column separator.
11251123
//
@@ -1447,41 +1445,38 @@ fn emit_suggestion_default(
14471445
let (complete, parts, highlights) = spliced_lines;
14481446
let is_multiline = complete.lines().count() > 1;
14491447

1450-
match suggestion.path.as_ref() {
1451-
Some(path) if suggestion.path.as_ref() != primary_path && !matches_previous_suggestion => {
1452-
let (loc, _) = sm.span_to_locations(parts[0].span.clone());
1453-
let origin = Origin::path(path.as_ref())
1454-
.line(loc.line)
1455-
.char_column(loc.char + 1);
1456-
1457-
render_origin(
1458-
renderer,
1459-
buffer,
1460-
max_line_num_len,
1461-
&origin,
1462-
true,
1463-
is_first,
1464-
!is_cont,
1465-
row_num - 1,
1466-
);
1467-
row_num += 1;
1468-
1469-
draw_col_separator_no_space(renderer, buffer, row_num - 1, max_line_num_len + 1);
1470-
}
1448+
if suggestion.path.as_ref() != primary_path
1449+
&& let Some(path) = suggestion.path.as_ref()
1450+
&& !matches_previous_suggestion
1451+
{
1452+
let (loc, _) = sm.span_to_locations(parts[0].span.clone());
1453+
let origin = Origin::path(path.as_ref())
1454+
.line(loc.line)
1455+
.char_column(loc.char + 1);
14711456

1472-
_ if matches_previous_suggestion => {
1473-
buffer.puts(
1474-
row_num - 1,
1475-
max_line_num_len + 1,
1476-
renderer.decor_style.multi_suggestion_separator(),
1477-
ElementStyle::LineNumber,
1478-
);
1479-
}
1457+
render_origin(
1458+
renderer,
1459+
buffer,
1460+
max_line_num_len,
1461+
&origin,
1462+
true,
1463+
is_first,
1464+
!is_cont,
1465+
row_num - 1,
1466+
);
14801467

1481-
_ => {
1482-
draw_col_separator_start(renderer, buffer, row_num - 1, max_line_num_len + 1);
1483-
}
1484-
}
1468+
draw_col_separator_no_space(renderer, buffer, row_num, max_line_num_len + 1);
1469+
row_num += 1;
1470+
} else if matches_previous_suggestion {
1471+
buffer.puts(
1472+
row_num - 1,
1473+
max_line_num_len + 1,
1474+
renderer.decor_style.multi_suggestion_separator(),
1475+
ElementStyle::LineNumber,
1476+
);
1477+
} else {
1478+
draw_col_separator_start(renderer, buffer, row_num - 1, max_line_num_len + 1);
1479+
}
14851480

14861481
if let DisplaySuggestion::Diff = show_code_change {
14871482
row_num += 1;

src/renderer/styled_buffer.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,11 @@ impl StyledBuffer {
159159
style: ElementStyle,
160160
overwrite: bool,
161161
) {
162-
if let Some(ref mut line) = self.lines.get_mut(line) {
163-
if let Some(StyledChar { style: s, .. }) = line.get_mut(col) {
164-
if overwrite || matches!(s, ElementStyle::NoStyle | ElementStyle::Quotation) {
165-
*s = style;
166-
}
167-
}
162+
if let Some(ref mut line) = self.lines.get_mut(line)
163+
&& let Some(StyledChar { style: s, .. }) = line.get_mut(col)
164+
&& (overwrite || matches!(s, ElementStyle::NoStyle | ElementStyle::Quotation))
165+
{
166+
*s = style;
168167
}
169168
}
170169
}

0 commit comments

Comments
 (0)