11use clippy_utils:: diagnostics:: span_lint_and_then;
22use clippy_utils:: is_from_proc_macro;
3+ use rustc_errors:: Applicability ;
34use rustc_lint:: LateLintPass ;
45use rustc_middle:: ty;
56use rustc_session:: declare_lint_pass;
@@ -10,7 +11,7 @@ declare_clippy_lint! {
1011 /// ### What it does
1112 /// Disallow the use of rest patterns for accesible fields
1213 ///
13- /// ### Why is this bad ?
14+ /// ### Why restrict this?
1415 /// It might lead to unhandled fields when the struct changes.
1516 ///
1617 /// ### Example
@@ -37,17 +38,17 @@ declare_clippy_lint! {
3738 ///
3839 /// let S { a, b, c: _ } = s;
3940 /// ```
40- #[ clippy:: version = "1.94 .0" ]
41+ #[ clippy:: version = "1.98 .0" ]
4142 pub REST_PATTERN_ACCESSIBLE_FIELD ,
4243 restriction,
43- "rest (.. ) used for accessible field"
44+ "rest pattern (`..` ) used for accessible field"
4445}
4546
4647declare_clippy_lint ! {
4748 /// ### What it does
48- /// Disallow the use of rest patterns that are unnecessary .
49+ /// Disallow the use of rest patterns that don't capture any fields .
4950 ///
50- /// ### Why is this bad ?
51+ /// ### Why restrict this?
5152 /// It might lead to unhandled fields when the struct changes.
5253 ///
5354 /// ### Example
@@ -74,10 +75,10 @@ declare_clippy_lint! {
7475 ///
7576 /// let S { a, b, c } = s;
7677 /// ```
77- #[ clippy:: version = "1.94 .0" ]
78+ #[ clippy:: version = "1.98 .0" ]
7879 pub UNNECESSARY_REST_PATTERN ,
7980 restriction,
80- "unnecessary rest (.. ) in destructuring expression"
81+ "unnecessary rest pattern (`..` ) in destructuring expression"
8182}
8283
8384declare_lint_pass ! ( RestWhenDestructuringStruct => [
@@ -116,7 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for RestWhenDestructuringStruct {
116117 }
117118
118119 // Filter out results from macros
119- if ( ( missing_suggestions . is_empty ( ) && !needs_dotdot) || !missing_suggestions. is_empty ( ) )
120+ if ( !needs_dotdot || !missing_suggestions. is_empty ( ) )
120121 && pat. span . in_external_macro ( cx. tcx . sess . source_map ( ) )
121122 || is_from_proc_macro ( cx, pat)
122123 {
@@ -147,7 +148,7 @@ impl<'tcx> LateLintPass<'tcx> for RestWhenDestructuringStruct {
147148 suggestion_span,
148149 message,
149150 & missing_suggestions,
150- rustc_errors :: Applicability :: MachineApplicable ,
151+ Applicability :: MachineApplicable ,
151152 ) ;
152153 } ,
153154 ) ;
@@ -161,12 +162,7 @@ impl<'tcx> LateLintPass<'tcx> for RestWhenDestructuringStruct {
161162 pat. span ,
162163 "unnecessary rest pattern (`..`)" ,
163164 |diag| {
164- diag. span_suggestion_verbose (
165- dotdot,
166- message,
167- "" ,
168- rustc_errors:: Applicability :: MachineApplicable ,
169- ) ;
165+ diag. span_suggestion_verbose ( dotdot, message, "" , Applicability :: MachineApplicable ) ;
170166 } ,
171167 ) ;
172168 }
0 commit comments