@@ -2918,6 +2918,7 @@ declare_lint_pass! {
2918
2918
USELESS_DEPRECATED ,
2919
2919
UNSUPPORTED_NAKED_FUNCTIONS ,
2920
2920
MISSING_ABI ,
2921
+ DISJOINT_CAPTURE_DROP_REORDER ,
2921
2922
]
2922
2923
}
2923
2924
@@ -2944,6 +2945,51 @@ declare_lint! {
2944
2945
"detects doc comments that aren't used by rustdoc"
2945
2946
}
2946
2947
2948
+ declare_lint ! {
2949
+ /// The `disjoint_capture_drop_reorder` lint detects variables that aren't completely
2950
+ /// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop
2951
+ /// order of at least one path starting at this variable.
2952
+ ///
2953
+ /// ### Example
2954
+ ///
2955
+ /// ```rust
2956
+ /// # #![deny(disjoint_capture_drop_reorder)]
2957
+ /// # #![allow(unused)]
2958
+ /// struct FancyInteger(i32);
2959
+ ///
2960
+ /// impl Drop for FancyInteger {
2961
+ /// fn drop(&mut self) {
2962
+ /// println!("Just dropped {}", self.0);
2963
+ /// }
2964
+ /// }
2965
+ ///
2966
+ /// struct Point { x: FancyInteger, y: FancyInteger }
2967
+ ///
2968
+ /// fn main() {
2969
+ /// let p = Point { x: FancyInteger(10), y: FancyInteger(20) };
2970
+ ///
2971
+ /// let c = || {
2972
+ /// let x = p.x;
2973
+ /// };
2974
+ ///
2975
+ /// c();
2976
+ ///
2977
+ /// // ... More code ...
2978
+ /// }
2979
+ /// ```
2980
+ ///
2981
+ /// {{produces}}
2982
+ ///
2983
+ /// ### Explanation
2984
+ ///
2985
+ /// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if
2986
+ /// the feature `capture_disjoint_fields` is enabled.
2987
+ pub DISJOINT_CAPTURE_DROP_REORDER ,
2988
+ Allow ,
2989
+ "Drop reorder because of `capture_disjoint_fields`"
2990
+
2991
+ }
2992
+
2947
2993
declare_lint_pass ! ( UnusedDocComment => [ UNUSED_DOC_COMMENTS ] ) ;
2948
2994
2949
2995
declare_lint ! {
0 commit comments