@@ -2995,7 +2995,7 @@ declare_lint_pass! {
29952995 UNSUPPORTED_NAKED_FUNCTIONS ,
29962996 MISSING_ABI ,
29972997 SEMICOLON_IN_EXPRESSIONS_FROM_MACROS ,
2998- DISJOINT_CAPTURE_DROP_REORDER ,
2998+ DISJOINT_CAPTURE_MIGRATION ,
29992999 LEGACY_DERIVE_HELPERS ,
30003000 PROC_MACRO_BACK_COMPAT ,
30013001 OR_PATTERNS_BACK_COMPAT ,
@@ -3027,14 +3027,17 @@ declare_lint! {
30273027}
30283028
30293029declare_lint ! {
3030- /// The `disjoint_capture_drop_reorder ` lint detects variables that aren't completely
3030+ /// The `disjoint_capture_migration ` lint detects variables that aren't completely
30313031 /// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop
30323032 /// order of at least one path starting at this variable.
3033+ /// It can also detect when a variable implements a trait, but one of its field does not and
3034+ /// the field is captured by a closure and used with the assumption that said field implements
3035+ /// the same trait as the root variable.
30333036 ///
3034- /// ### Example
3037+ /// ### Example of drop reorder
30353038 ///
30363039 /// ```rust,compile_fail
3037- /// # #![deny(disjoint_capture_drop_reorder )]
3040+ /// # #![deny(disjoint_capture_migration )]
30383041 /// # #![allow(unused)]
30393042 /// struct FancyInteger(i32);
30403043 ///
@@ -3065,10 +3068,35 @@ declare_lint! {
30653068 ///
30663069 /// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if
30673070 /// the feature `capture_disjoint_fields` is enabled.
3068- pub DISJOINT_CAPTURE_DROP_REORDER ,
3071+ ///
3072+ /// ### Example of auto-trait
3073+ ///
3074+ /// ```rust,compile_fail
3075+ /// #![deny(disjoint_capture_migration)]
3076+ /// use std::thread;
3077+ ///
3078+ /// struct Pointer (*mut i32);
3079+ /// unsafe impl Send for Pointer {}
3080+ ///
3081+ /// fn main() {
3082+ /// let mut f = 10;
3083+ /// let fptr = Pointer(&mut f as *mut i32);
3084+ /// thread::spawn(move || unsafe {
3085+ /// *fptr.0 = 20;
3086+ /// });
3087+ /// }
3088+ /// ```
3089+ ///
3090+ /// {{produces}}
3091+ ///
3092+ /// ### Explanation
3093+ ///
3094+ /// In the above example `fptr.0` is captured when feature `capture_disjoint_fields` is enabled.
3095+ /// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the
3096+ /// field cannot be sent between thread safely.
3097+ pub DISJOINT_CAPTURE_MIGRATION ,
30693098 Allow ,
3070- "Drop reorder because of `capture_disjoint_fields`"
3071-
3099+ "Drop reorder and auto traits error because of `capture_disjoint_fields`"
30723100}
30733101
30743102declare_lint_pass ! ( UnusedDocComment => [ UNUSED_DOC_COMMENTS ] ) ;
0 commit comments