Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiangfei2009 committed Oct 21, 2024
1 parent 0e60076 commit d51b702
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 3 additions & 5 deletions compiler/rustc_lint/src/tail_expr_drop_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ use rustc_span::edition::Edition;
use crate::{LateContext, LateLintPass};

declare_lint! {
/// The `tail_expr_drop_order` lint looks for those values generated at the tail expression location, that of type
/// with a significant `Drop` implementation, such as locks.
/// In case there are also local variables of type with significant `Drop` implementation as well,
/// this lint warns you of a potential transposition in the drop order.
/// The `tail_expr_drop_order` lint looks for those values generated at the tail expression location,
/// that of type with a custom `Drop` destructor implementation, which will be dropped earlier in Edition 2024.
/// Your discretion on the new drop order introduced by Edition 2024 is required.
///
/// ### Example
Expand Down Expand Up @@ -185,7 +183,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LintVisitor<'a, 'tcx> {
impl<'a, 'tcx> LintVisitor<'a, 'tcx> {
fn check_block_inner(&mut self, block: &Block<'tcx>) {
if block.span.at_least_rust_2024() {
// We only lint for Edition 2024 onwards
// We only lint for up to Edition 2021
return;
}
let Some(tail_expr) = block.expr else { return };
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/drop/lint-tail-expr-drop-order-gated.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This test is to demonstrate that the lint is gated behind Edition and
// is triggered only for Edition 2021 and before.

//@ check-pass
//@ edition: 2024
//@ compile-flags: -Z unstable-options
Expand Down

0 comments on commit d51b702

Please sign in to comment.