File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
rustc_error_messages/locales/en-US Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -291,3 +291,6 @@ lint-builtin-while-true = denote infinite loops with `loop {"{"} ... {"}"}`
291291 .suggestion = use `loop`
292292
293293lint-builtin-box-pointers = type uses owned (Box type) pointers: { $ty }
294+
295+ lint-builtin-non-shorthand-field-patterns = the `{ $ident } :` in this pattern is redundant
296+ .suggestion = use shorthand field pattern
Original file line number Diff line number Diff line change @@ -256,26 +256,26 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
256256 == Some ( cx. tcx . field_index ( fieldpat. hir_id , cx. typeck_results ( ) ) )
257257 {
258258 cx. struct_span_lint ( NON_SHORTHAND_FIELD_PATTERNS , fieldpat. span , |lint| {
259- let mut err = lint
260- . build ( & format ! ( "the `{}:` in this pattern is redundant" , ident) ) ;
261259 let binding = match binding_annot {
262260 hir:: BindingAnnotation :: Unannotated => None ,
263261 hir:: BindingAnnotation :: Mutable => Some ( "mut" ) ,
264262 hir:: BindingAnnotation :: Ref => Some ( "ref" ) ,
265263 hir:: BindingAnnotation :: RefMut => Some ( "ref mut" ) ,
266264 } ;
267- let ident = if let Some ( binding) = binding {
265+ let suggested_ident = if let Some ( binding) = binding {
268266 format ! ( "{} {}" , binding, ident)
269267 } else {
270268 ident. to_string ( )
271269 } ;
272- err. span_suggestion (
273- fieldpat. span ,
274- "use shorthand field pattern" ,
275- ident,
276- Applicability :: MachineApplicable ,
277- ) ;
278- err. emit ( ) ;
270+ lint. build ( fluent:: lint:: builtin_non_shorthand_field_patterns)
271+ . set_arg ( "ident" , ident. clone ( ) )
272+ . span_suggestion (
273+ fieldpat. span ,
274+ fluent:: lint:: suggestion,
275+ suggested_ident,
276+ Applicability :: MachineApplicable ,
277+ )
278+ . emit ( ) ;
279279 } ) ;
280280 }
281281 }
You can’t perform that action at this time.
0 commit comments