From 9284776a08b3feeb5a751f9ba3b861541463a3a0 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Aug 2024 09:20:49 +0700 Subject: [PATCH 1/5] Fix `clippy::doc_lazy_continuation` lints --- README.md | 16 ++++++++-------- src/lib.rs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ef351f2..33022f8 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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}; @@ -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 diff --git a/src/lib.rs b/src/lib.rs index 8946990..a42f4fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 //! @@ -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}; @@ -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}; From a279561d9b927d4f0715a24ae6cbca0b0625b0c4 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Aug 2024 09:30:05 +0700 Subject: [PATCH 2/5] Fix `dead_code` warnings in tests. Protect code used in some tests based on features with feature checks. --- tests/test_diagnostic_source_macro.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_diagnostic_source_macro.rs b/tests/test_diagnostic_source_macro.rs index 4f15ea0..bbc2179 100644 --- a/tests/test_diagnostic_source_macro.rs +++ b/tests/test_diagnostic_source_macro.rs @@ -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 { @@ -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 { From 21e8bb32b84ae58dfdab768657c21bad0f72db43 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Aug 2024 09:32:17 +0700 Subject: [PATCH 3/5] Fix `clippy::needless_borrows_for_generic_args` lints --- tests/graphical.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/graphical.rs b/tests/graphical.rs index c6b5e1a..2b29f15 100644 --- a/tests/graphical.rs +++ b/tests/graphical.rs @@ -2000,10 +2000,10 @@ 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: NamedSource::new(filename, file_src.clone()), src_span: SourceSpan::new(offset, LEN.into()), }; From 1c562b7094bfa41a86fa09dfcb4c22840988ef15 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Aug 2024 09:32:47 +0700 Subject: [PATCH 4/5] Remove a useless conversion --- tests/graphical.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/graphical.rs b/tests/graphical.rs index 2b29f15..7221a70 100644 --- a/tests/graphical.rs +++ b/tests/graphical.rs @@ -2004,7 +2004,7 @@ fn syntax_highlighter_on_real_file() { 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_span: SourceSpan::new(offset, LEN), }; let mut out = String::new(); From fefe6c558a4059b4269997782ba10e7a9bc4cd44 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Tue, 6 Aug 2024 09:36:09 +0700 Subject: [PATCH 5/5] Remove a cfg_attr check for `track_caller` This shouldn't be needed here as the test is already ignored. --- tests/test_fmt.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_fmt.rs b/tests/test_fmt.rs index 8f18216..abf3873 100644 --- a/tests/test_fmt.rs +++ b/tests/test_fmt.rs @@ -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()));