@@ -14,15 +14,14 @@ use rustc_span::edition::Edition;
14
14
use crate :: { LateContext , LateLintPass } ;
15
15
16
16
declare_lint ! {
17
- /// The `tail_expr_drop_order` lint looks for those values generated at the tail expression location, that of type
18
- /// with a significant `Drop` implementation, such as locks .
19
- /// In case there are also local variables of type with significant `Drop` implementation as well,
20
- /// this lint warns you of a potential transposition in the drop order .
21
- /// Your discretion on the new drop order introduced by Edition 2024 is required.
17
+ /// The `tail_expr_drop_order` lint looks for those values generated at the tail expression location,
18
+ /// that runs a custom `Drop` destructor .
19
+ /// Some of them may be dropped earlier in Edition 2024 that they used to in Edition 2021 and prior.
20
+ /// This lint detects those cases and provides you information on those values and their custom destructor implementations .
21
+ /// Your discretion on this information is required.
22
22
///
23
23
/// ### Example
24
- /// ```rust,edition2024
25
- /// #![feature(shorter_tail_lifetimes)]
24
+ /// ```rust,edition2021
26
25
/// #![warn(tail_expr_drop_order)]
27
26
/// struct Droppy(i32);
28
27
/// impl Droppy {
@@ -37,12 +36,12 @@ declare_lint! {
37
36
/// println!("loud drop {}", self.0);
38
37
/// }
39
38
/// }
40
- /// fn edition_2024 () -> i32 {
39
+ /// fn edition_2021 () -> i32 {
41
40
/// let another_droppy = Droppy(0);
42
41
/// Droppy(1).get()
43
42
/// }
44
43
/// fn main() {
45
- /// edition_2024 ();
44
+ /// edition_2021 ();
46
45
/// }
47
46
/// ```
48
47
///
@@ -137,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for TailExprDropOrder {
137
136
_: Span ,
138
137
def_id : rustc_span:: def_id:: LocalDefId ,
139
138
) {
140
- if cx . tcx . sess . at_least_rust_2024 ( ) && cx . tcx . features ( ) . shorter_tail_lifetimes ( ) {
139
+ if !body . value . span . edition ( ) . at_least_rust_2024 ( ) {
141
140
Self :: check_fn_or_closure ( cx, fn_kind, body, def_id) ;
142
141
}
143
142
}
@@ -185,8 +184,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LintVisitor<'a, 'tcx> {
185
184
186
185
impl < ' a , ' tcx > LintVisitor < ' a , ' tcx > {
187
186
fn check_block_inner ( & mut self , block : & Block < ' tcx > ) {
188
- if ! block. span . at_least_rust_2024 ( ) {
189
- // We only lint for Edition 2024 onwards
187
+ if block. span . at_least_rust_2024 ( ) {
188
+ // We only lint up to Edition 2021
190
189
return ;
191
190
}
192
191
let Some ( tail_expr) = block. expr else { return } ;
0 commit comments