- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
Closed
Description
Problem
The masterror crate (v0.24.17) generates code that triggers Rust 2024 edition's non_shorthand_field_patterns lint when using the #[source] attribute on enum variant fields.
Reproduction
// Cargo.toml
[package]
edition = "2024"
[dependencies]
masterror = "0.24"
// main.rs
use masterror::Error;
#[derive(Debug, Error)]
pub enum MyError {
    #[error("failed to parse: {source}")]
    ParseError {
        #[source]
        source: std::num::ParseIntError
    }
}Error
error: the `source:` in this pattern is redundant
  --> src/main.rs:8:9
   |
8  |         source: std::num::ParseIntError
   |         ^^^^^^ help: use shorthand field pattern: `source`
   |
   = note: `-D non-shorthand-field-patterns` implied by `-D warnings`
Root Cause
Rust 2024 edition changed the field pattern rules (see rust-lang/rust#123808). The #[source] macro expansion generates code that conflicts with these new rules.
Workaround
Currently using module-level #![allow(non_shorthand_field_patterns)] with documentation:
// TEMPORARY: Disable `non_shorthand_field_patterns` lint for this module.
//
// The `masterror` crate (v0.24) generates code that triggers this Rust 2024
// edition lint when using the `#[source]` attribute on error enum fields.
// This is a known compatibility issue between the macro-generated code and
// Rust 2024 field pattern rules.
//
// Once `masterror` is updated to support Rust 2024 edition properly, or if we
// migrate to an alternative error handling crate (e.g., `thiserror`), this
// allow attribute should be removed.
//
// Related: https://github.com/rust-lang/rust/issues/123808
#![allow(non_shorthand_field_patterns)]Expected Behavior
The macro should generate code that is compatible with Rust 2024 edition without triggering lints.
Environment
- Rust version: 1.90.0 (and later)
 - masterror version: 0.24.17
 - Edition: 2024
 
Related
- codegen tests: Tolerate 
nuwnswontruncrust-lang/rust#123808 - Rust 2024 edition field pattern changes 
Thank you for maintaining this crate!
Metadata
Metadata
Assignees
Labels
No labels