@@ -14,15 +14,14 @@ use rustc_span::edition::Edition;
1414use crate :: { LateContext , LateLintPass } ;
1515
1616declare_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.
2222 ///
2323 /// ### Example
24- /// ```rust,edition2024
25- /// #![feature(shorter_tail_lifetimes)]
24+ /// ```rust,edition2021
2625 /// #![warn(tail_expr_drop_order)]
2726 /// struct Droppy(i32);
2827 /// impl Droppy {
@@ -37,12 +36,12 @@ declare_lint! {
3736 /// println!("loud drop {}", self.0);
3837 /// }
3938 /// }
40- /// fn edition_2024 () -> i32 {
39+ /// fn edition_2021 () -> i32 {
4140 /// let another_droppy = Droppy(0);
4241 /// Droppy(1).get()
4342 /// }
4443 /// fn main() {
45- /// edition_2024 ();
44+ /// edition_2021 ();
4645 /// }
4746 /// ```
4847 ///
@@ -137,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for TailExprDropOrder {
137136 _: Span ,
138137 def_id : rustc_span:: def_id:: LocalDefId ,
139138 ) {
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 ( ) {
141140 Self :: check_fn_or_closure ( cx, fn_kind, body, def_id) ;
142141 }
143142 }
@@ -185,8 +184,8 @@ impl<'a, 'tcx> Visitor<'tcx> for LintVisitor<'a, 'tcx> {
185184
186185impl < ' a , ' tcx > LintVisitor < ' a , ' tcx > {
187186 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
190189 return ;
191190 }
192191 let Some ( tail_expr) = block. expr else { return } ;
0 commit comments