@@ -2968,6 +2968,7 @@ declare_lint_pass! {
29682968 UNSUPPORTED_NAKED_FUNCTIONS ,
29692969 MISSING_ABI ,
29702970 SEMICOLON_IN_EXPRESSIONS_FROM_MACROS ,
2971+ DISJOINT_CAPTURE_DROP_REORDER ,
29712972 ]
29722973}
29732974
@@ -2994,6 +2995,51 @@ declare_lint! {
29942995 "detects doc comments that aren't used by rustdoc"
29952996}
29962997
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+
29973043declare_lint_pass ! ( UnusedDocComment => [ UNUSED_DOC_COMMENTS ] ) ;
29983044
29993045declare_lint ! {
0 commit comments