Skip to content

Commit

Permalink
fix(clippy): fix clippy::doc_lazy_continuation lints (#395)
Browse files Browse the repository at this point in the history
* Fix `clippy::doc_lazy_continuation` lints

* Fix `dead_code` warnings in tests.

Protect code used in some tests based on features with feature
checks.

* Fix `clippy::needless_borrows_for_generic_args` lints

* Remove a useless conversion

* Remove a cfg_attr check for `track_caller`

This shouldn't be needed here as the test is already ignored.
  • Loading branch information
waywardmonkeys authored Aug 6, 2024
1 parent bf5aa37 commit 15beec4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ diagnostic error code: ruget::api::bad_json
" />

> **NOTE: You must enable the `"fancy"` crate feature to get fancy report
output like in the screenshots above.** You should only do this in your
toplevel crate, as the fancy feature pulls in a number of dependencies that
libraries and such might not want.
> output like in the screenshots above.** You should only do this in your
> toplevel crate, as the fancy feature pulls in a number of dependencies that
> libraries and such might not want.
### Table of Contents <!-- omit in toc -->

Expand Down Expand Up @@ -288,9 +288,9 @@ There are also similar [bail!] and [ensure!] macros.
automatically.

> **NOTE:** You must enable the `"fancy"` crate feature to get fancy report
output like in the screenshots here.** You should only do this in your
toplevel crate, as the fancy feature pulls in a number of dependencies that
libraries and such might not want.
> output like in the screenshots here.** You should only do this in your
> toplevel crate, as the fancy feature pulls in a number of dependencies that
> libraries and such might not want.
```rust
use miette::{IntoDiagnostic, Result};
Expand Down Expand Up @@ -645,8 +645,8 @@ customize!
If you...
- ...don't know all the possible errors upfront
- ...need to serialize/deserialize errors
then you may want to use [`miette!`], [`diagnostic!`] macros or
[`MietteDiagnostic`] directly to create diagnostic on the fly.
then you may want to use [`miette!`], [`diagnostic!`] macros or
[`MietteDiagnostic`] directly to create diagnostic on the fly.

```rust

Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
//! " />
//!
//! > **NOTE: You must enable the `"fancy"` crate feature to get fancy report
//! output like in the screenshots above.** You should only do this in your
//! toplevel crate, as the fancy feature pulls in a number of dependencies that
//! libraries and such might not want.
//! > output like in the screenshots above.** You should only do this in your
//! > toplevel crate, as the fancy feature pulls in a number of dependencies that
//! > libraries and such might not want.
//!
//! ## Table of Contents <!-- omit in toc -->
//!
Expand Down Expand Up @@ -288,9 +288,9 @@
//! automatically.
//!
//! > **NOTE:** You must enable the `"fancy"` crate feature to get fancy report
//! output like in the screenshots here.** You should only do this in your
//! toplevel crate, as the fancy feature pulls in a number of dependencies that
//! libraries and such might not want.
//! > output like in the screenshots here.** You should only do this in your
//! > toplevel crate, as the fancy feature pulls in a number of dependencies that
//! > libraries and such might not want.
//!
//! ```rust
//! use miette::{IntoDiagnostic, Result};
Expand Down Expand Up @@ -645,8 +645,8 @@
//! If you...
//! - ...don't know all the possible errors upfront
//! - ...need to serialize/deserialize errors
//! then you may want to use [`miette!`], [`diagnostic!`] macros or
//! [`MietteDiagnostic`] directly to create diagnostic on the fly.
//! then you may want to use [`miette!`], [`diagnostic!`] macros or
//! [`MietteDiagnostic`] directly to create diagnostic on the fly.
//!
//! ```rust,ignore
//! # use miette::{miette, LabeledSpan, Report};
Expand Down
6 changes: 3 additions & 3 deletions tests/graphical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2000,11 +2000,11 @@ fn syntax_highlighter_on_real_file() {
// SourceSpan constants for column and length
const CO: usize = 28;
const LEN: usize = 27;
let file_src = std::fs::read_to_string(&filename).unwrap();
let file_src = std::fs::read_to_string(filename).unwrap();
let offset = miette::SourceOffset::from_location(&file_src, line, CO);
let err = Test {
src: NamedSource::new(&filename, file_src.clone()),
src_span: SourceSpan::new(offset, LEN.into()),
src: NamedSource::new(filename, file_src.clone()),
src_span: SourceSpan::new(offset, LEN),
};

let mut out = String::new();
Expand Down
2 changes: 2 additions & 0 deletions tests/test_diagnostic_source_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ fn test_diagnostic_source_is_output() {
assert_eq!(expected, out);
}

#[cfg(feature = "fancy-no-backtrace")]
#[derive(Debug, miette::Diagnostic, thiserror::Error)]
#[error("A nested error happened")]
struct NestedError {
Expand Down Expand Up @@ -212,6 +213,7 @@ fn test_nested_diagnostic_source_is_output() {
assert_eq!(expected, out);
}

#[cfg(feature = "fancy-no-backtrace")]
#[derive(Debug, miette::Diagnostic, thiserror::Error)]
#[error("A multi-error happened")]
struct MultiError {
Expand Down
1 change: 0 additions & 1 deletion tests/test_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ fn test_altdisplay() {

#[test]
#[ignore = "not really gonna work with the current printers"]
#[cfg_attr(track_caller, ignore)]
fn test_debug() {
assert_eq!(EXPECTED_DEBUG_F, format!("{:?}", f().unwrap_err()));
assert_eq!(EXPECTED_DEBUG_G, format!("{:?}", g().unwrap_err()));
Expand Down

0 comments on commit 15beec4

Please sign in to comment.