Change:
Code: output: Note that in the attempted fix is incorrect syntax (it ate a colon). Edit: it probably actually isn't. Version info:
thanks for feedback :) it seems a rustfix bug, could you please file a issue there? cc
Will do. Is it intentional that suggests filing a bug in this repo (see the error message), or should that be changed?
This is the correct place to file the issue, it is a bug in . The issue is that the lint is providing a bad suggestion. Either the span needs to encompass the entire binding, or the suggested text needs to be the empty string.

Discussion:
// (Issue #49588) continue; } <del> if let PatKind::Binding(_, _, ident, None) = fieldpat.pat.kind { </del> <ins> if let PatKind::Binding(binding_annot, _, ident, None) = fieldpat.pat.kind { </ins> if cx.tcx.find_field_index(ident, &variant) == Some(cx.tcx.field_index(fieldpat.hir_id, cx.tables)) { let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span, &format!("the `{}:` in this pattern is redundant", ident)); <del> let subspan = cx.tcx.sess.source_map().span_through_char(fieldpat.span, ':'); err.span_suggestion_short( subspan, "remove this", ident.to_string(), </del> <ins> let binding = match binding_annot { hir::BindingAnnotation::Unannotated => None, hir::BindingAnnotation::Mutable => Some("mut"), hir::BindingAnnotation::Ref => Some("ref"), hir::BindingAnnotation::RefMut => Some("ref mut"), }; let ident = if let Some(binding) = binding { format!("{} {}", binding, ident) } else { ident.to_string() }; err.span_suggestion( fieldpat.span, "use shorthand field pattern", ident, </ins> Applicability::MachineApplicable ); err.emit();

<ins> // run-rustfix #![allow(nonstandard_style, unused_variables, unused_mut)] #![deny(non_shorthand_field_patterns)] struct Foo { x: isize, y: isize, } fn main() { { let Foo { x, //~ ERROR the `x:` in this pattern is redundant ref y, //~ ERROR the `y:` in this pattern is redundant } = Foo { x: 0, y: 0 }; let Foo { x, ref y, } = Foo { x: 0, y: 0 }; } { const x: isize = 1; match (Foo { x: 1, y: 1 }) { Foo { x: x, ..} => {}, _ => {}, } } { struct Bar { x: x, } struct x; match (Bar { x: x }) { Bar { x: x } => {}, } } { struct Bar { x: Foo, } enum Foo { x } match (Bar { x: Foo::x }) { Bar { x: Foo::x } => {}, } } { struct Baz { x: isize, y: isize, z: isize, } let Baz { mut x, //~ ERROR the `x:` in this pattern is redundant ref y, //~ ERROR the `y:` in this pattern is redundant ref mut z, //~ ERROR the `z:` in this pattern is redundant } = Baz { x: 0, y: 0, z: 0 }; } } </ins>

<del> #![allow(nonstandard_style, unused_variables)] </del> <ins> // run-rustfix #![allow(nonstandard_style, unused_variables, unused_mut)] </ins> #![deny(non_shorthand_field_patterns)] struct Foo {

Bar { x: Foo::x } => {}, } } <ins> { struct Baz { x: isize, y: isize, z: isize, } let Baz { x: mut x, //~ ERROR the `x:` in this pattern is redundant y: ref y, //~ ERROR the `y:` in this pattern is redundant z: ref mut z, //~ ERROR the `z:` in this pattern is redundant } = Baz { x: 0, y: 0, z: 0 }; } </ins> }

error: the `x:` in this pattern is redundant <del> --> $DIR/lint-shorthand-field.rs:12:13 </del> <ins> --> $DIR/lint-shorthand-field.rs:14:13 </ins> | LL |             x: x, <del> |             --^^ |             | |             help: remove this </del> <ins> |             ^^^^ help: use shorthand field pattern: `x` </ins> | note: lint level defined here <del> --> $DIR/lint-shorthand-field.rs:2:9 </del> <ins> --> $DIR/lint-shorthand-field.rs:4:9 </ins> | LL | #![deny(non_shorthand_field_patterns)] |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `y:` in this pattern is redundant <del> --> $DIR/lint-shorthand-field.rs:13:13 </del> <ins> --> $DIR/lint-shorthand-field.rs:15:13 </ins> | LL |             y: ref y, <del> |             --^^^^^^ |             | |             help: remove this </del> <ins> |             ^^^^^^^^ help: use shorthand field pattern: `ref y` </ins> <del> error: aborting due to 2 previous errors </del> <ins> error: the `x:` in this pattern is redundant --> $DIR/lint-shorthand-field.rs:65:13 | LL |             x: mut x, |             ^^^^^^^^ help: use shorthand field pattern: `mut x` error: the `y:` in this pattern is redundant --> $DIR/lint-shorthand-field.rs:66:13 | LL |             y: ref y, |             ^^^^^^^^ help: use shorthand field pattern: `ref y` error: the `z:` in this pattern is redundant --> $DIR/lint-shorthand-field.rs:67:13 | LL |             z: ref mut z, |             ^^^^^^^^^^^^ help: use shorthand field pattern: `ref mut z` error: aborting due to 5 previous errors </ins>

match d { Equinox { warp_factor: warp_factor } => {} //~^ WARN this pattern is redundant <del> //~| HELP remove this </del> <ins> //~| HELP use shorthand field pattern </ins> } println!("{} {}", registry_no, b); }

--> $DIR/suggestions.rs:61:23 | LL |             Equinox { warp_factor: warp_factor } => {} <del> |                       ------------^^^^^^^^^^^^ |                       | |                       help: remove this </del> <ins> |                       ^^^^^^^^^^^^^^^^^^^^^^^^ help: use shorthand field pattern: `warp_factor` </ins> | = note: `#[warn(non_shorthand_field_patterns)]` on by default