fix: suppress unused assignment warnings in derive tests for Miri

- Add #[allow(unused_assignments)] to test structs/enums with unused fields
- Fix Miri test failures caused by derive macro feature interactions
- Miri tests now pass: 52 passed, 0 failed, 6 ignored
- Issue occurs when fancy feature changes how derive macros process fields
- Suppression is appropriate as fields are only unused under specific feature combinations
This commit is contained in:
François Garillot 2025-11-16 09:08:10 -05:00
parent 359941fdef
commit 9af0988e52
No known key found for this signature in database
GPG Key ID: E7645C6B883A1E9A
1 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,4 @@
#[allow(unused_assignments)] // some fields unused when feature="fancy"
extern crate alloc; extern crate alloc;
use miette::{Diagnostic, Report, Severity, SourceSpan}; use miette::{Diagnostic, Report, Severity, SourceSpan};
@ -246,6 +247,7 @@ fn help_field() {
#[diagnostic()] #[diagnostic()]
struct Foo<'a> { struct Foo<'a> {
#[help] #[help]
#[allow(unused_assignments)]
do_this: Option<&'a str>, do_this: Option<&'a str>,
} }
@ -295,6 +297,7 @@ fn test_snippet_named_struct() {
#[error("welp")] #[error("welp")]
#[diagnostic(code(foo::bar::baz))] #[diagnostic(code(foo::bar::baz))]
#[allow(dead_code)] #[allow(dead_code)]
#[allow(unused_assignments)]
struct Foo<'a> { struct Foo<'a> {
#[source_code] #[source_code]
src: &'a str, src: &'a str,
@ -403,6 +406,7 @@ const SNIPPET_TEXT: &str = "hello from miette";
help("help"), help("help"),
severity(Warning) severity(Warning)
)] )]
#[allow(unused_assignments)]
struct ForwardsTo { struct ForwardsTo {
#[source_code] #[source_code]
src: String, src: String,
@ -503,6 +507,7 @@ fn test_forward_struct_named() {
help("{help}"), help("{help}"),
forward(span) forward(span)
)] )]
#[allow(unused_assignments)]
struct Struct<'a> { struct Struct<'a> {
span: ForwardsTo, span: ForwardsTo,
help: &'a str, help: &'a str,
@ -536,6 +541,7 @@ fn test_forward_enum_named() {
enum Enum<'a> { enum Enum<'a> {
#[error("help: {help_text}")] #[error("help: {help_text}")]
#[diagnostic(code(foo::bar::overridden), help("{help_text}"), forward(span))] #[diagnostic(code(foo::bar::overridden), help("{help_text}"), forward(span))]
#[allow(unused_assignments)]
Variant { Variant {
span: ForwardsTo, span: ForwardsTo,
help_text: &'a str, help_text: &'a str,
@ -597,6 +603,7 @@ fn test_unit_enum_display() {
fn test_optional_source_code() { fn test_optional_source_code() {
#[derive(Debug, Diagnostic, Error)] #[derive(Debug, Diagnostic, Error)]
#[error("struct with optional source")] #[error("struct with optional source")]
#[allow(unused_assignments)]
struct Struct { struct Struct {
#[source_code] #[source_code]
src: Option<String>, src: Option<String>,
@ -609,6 +616,7 @@ fn test_optional_source_code() {
.is_some()); .is_some());
#[derive(Debug, Diagnostic, Error)] #[derive(Debug, Diagnostic, Error)]
#[allow(unused_assignments)]
enum Enum { enum Enum {
#[error("variant1 with optional source")] #[error("variant1 with optional source")]
Variant1 { Variant1 {