@@ -2968,6 +2968,7 @@ declare_lint_pass! {
2968
2968
UNSUPPORTED_NAKED_FUNCTIONS ,
2969
2969
MISSING_ABI ,
2970
2970
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS ,
2971
+ DISJOINT_CAPTURE_DROP_REORDER ,
2971
2972
]
2972
2973
}
2973
2974
@@ -2994,6 +2995,51 @@ declare_lint! {
2994
2995
"detects doc comments that aren't used by rustdoc"
2995
2996
}
2996
2997
2998
+ declare_lint ! {
2999
+ /// The `disjoint_capture_drop_reorder` lint detects variables that aren't completely
3000
+ /// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop
3001
+ /// order of at least one path starting at this variable.
3002
+ ///
3003
+ /// ### Example
3004
+ ///
3005
+ /// ```rust
3006
+ /// # #![deny(disjoint_capture_drop_reorder)]
3007
+ /// # #![allow(unused)]
3008
+ /// struct FancyInteger(i32);
3009
+ ///
3010
+ /// impl Drop for FancyInteger {
3011
+ /// fn drop(&mut self) {
3012
+ /// println!("Just dropped {}", self.0);
3013
+ /// }
3014
+ /// }
3015
+ ///
3016
+ /// struct Point { x: FancyInteger, y: FancyInteger }
3017
+ ///
3018
+ /// fn main() {
3019
+ /// let p = Point { x: FancyInteger(10), y: FancyInteger(20) };
3020
+ ///
3021
+ /// let c = || {
3022
+ /// let x = p.x;
3023
+ /// };
3024
+ ///
3025
+ /// c();
3026
+ ///
3027
+ /// // ... More code ...
3028
+ /// }
3029
+ /// ```
3030
+ ///
3031
+ /// {{produces}}
3032
+ ///
3033
+ /// ### Explanation
3034
+ ///
3035
+ /// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if
3036
+ /// the feature `capture_disjoint_fields` is enabled.
3037
+ pub DISJOINT_CAPTURE_DROP_REORDER ,
3038
+ Allow ,
3039
+ "Drop reorder because of `capture_disjoint_fields`"
3040
+
3041
+ }
3042
+
2997
3043
declare_lint_pass ! ( UnusedDocComment => [ UNUSED_DOC_COMMENTS ] ) ;
2998
3044
2999
3045
declare_lint ! {
0 commit comments