Skip to content

Commit 8d1762e

Browse files
committed
implement simple clippy recommendations
1 parent 629d35a commit 8d1762e

6 files changed

Lines changed: 12 additions & 13 deletions

File tree

codespan-reporting/examples/custom_files.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ mod files {
6060
use std::cmp::Ordering;
6161

6262
match line_index.cmp(&self.line_starts.len()) {
63-
Ordering::Less => Ok(self
63+
Ordering::Less => Ok(*self
6464
.line_starts
6565
.get(line_index)
66-
.expect("failed despite previous check")
67-
.clone()),
66+
.expect("failed despite previous check")),
6867
Ordering::Equal => Ok(self.source.len()),
6968
Ordering::Greater => Err(files::Error::LineTooLarge {
7069
given: line_index,

codespan-reporting/examples/readme_preview.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn main() -> anyhow::Result<()> {
8787
};
8888

8989
for diagnostic in &diagnostics {
90-
term::emit(&mut writer, &config, &file, &diagnostic)?;
90+
term::emit(&mut writer, &config, &file, diagnostic)?;
9191
}
9292

9393
let num_lines = buffer.iter().filter(|byte| **byte == b'\n').count() + 1;
@@ -178,7 +178,7 @@ fn main() -> anyhow::Result<()> {
178178
let writer = StandardStream::stderr(color.into());
179179
let config = codespan_reporting::term::Config::default();
180180
for diagnostic in &diagnostics {
181-
term::emit(&mut writer.lock(), &config, &file, &diagnostic)?;
181+
term::emit(&mut writer.lock(), &config, &file, diagnostic)?;
182182
}
183183
}
184184
}
@@ -294,7 +294,7 @@ impl<W: Write> WriteColor for SvgWriter<W> {
294294
}
295295

296296
Ok(false)
297-
};
297+
}
298298

299299
fn write_color<W: Write>(color: &Color, writer: &mut SvgWriter<W>) -> io::Result<()> {
300300
match color {
@@ -309,7 +309,7 @@ impl<W: Write> WriteColor for SvgWriter<W> {
309309
// TODO: other colors
310310
_ => Ok(()),
311311
}
312-
};
312+
}
313313

314314
if let Some(fg) = spec.fg() {
315315
first = write_first(first, self)?;

codespan-reporting/examples/term.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn main() -> anyhow::Result<()> {
168168
let writer = StandardStream::stderr(opts.color.into());
169169
let config = codespan_reporting::term::Config::default();
170170
for diagnostic in &diagnostics {
171-
term::emit(&mut writer.lock(), &config, &files, &diagnostic)?;
171+
term::emit(&mut writer.lock(), &config, &files, diagnostic)?;
172172
}
173173

174174
Ok(())

codespan-reporting/src/term.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ impl FromStr for ColorArg {
7272
}
7373
}
7474

75-
impl Into<ColorChoice> for ColorArg {
76-
fn into(self) -> ColorChoice {
77-
self.0
75+
impl From<ColorArg> for ColorChoice {
76+
fn from(x: ColorArg) -> Self {
77+
x.0
7878
}
7979
}
8080

codespan-reporting/src/term/renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl<'writer, 'config> Renderer<'writer, 'config> {
212212
self.reset()?;
213213

214214
write!(self, " ")?;
215-
self.snippet_locus(&locus)?;
215+
self.snippet_locus(locus)?;
216216

217217
writeln!(self)?;
218218

codespan-reporting/tests/support/color_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl WriteColor for ColorBuffer {
9292
}
9393

9494
Ok(false)
95-
};
95+
}
9696

9797
if let Some(fg) = spec.fg() {
9898
first = write_first(first, self)?;

0 commit comments

Comments
 (0)