@@ -46,7 +46,7 @@ use rustc_mir_dataflow::move_paths::{
4646} ;
4747use rustc_mir_dataflow:: points:: DenseLocationMap ;
4848use rustc_mir_dataflow:: { Analysis , EntryStates , Results , ResultsVisitor , visit_results} ;
49- use rustc_session:: lint:: builtin:: { TAIL_EXPR_DROP_ORDER , UNUSED_MUT } ;
49+ use rustc_session:: lint:: builtin:: { TAIL_EXPR_DROP_ORDER , UNUSED_MUT , UNWIND_DROP_ORDER } ;
5050use rustc_span:: { ErrorGuaranteed , Span , Symbol } ;
5151use rustc_trait_selection:: traits:: query:: type_op:: { QueryTypeOp , TypeOp , TypeOpOutput } ;
5252use smallvec:: SmallVec ;
@@ -853,11 +853,8 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
853853 // These do not actually affect borrowck
854854 StatementKind :: ConstEvalCounter | StatementKind :: StorageLive ( ..) => { }
855855 // This does not affect borrowck
856- StatementKind :: BackwardIncompatibleDropHint {
857- place,
858- reason : BackwardIncompatibleDropReason :: Edition2024 ,
859- } => {
860- self . check_backward_incompatible_drop ( location, * * place, state) ;
856+ StatementKind :: BackwardIncompatibleDropHint { place, reason } => {
857+ self . check_backward_incompatible_drop ( location, * * place, * reason, state) ;
861858 }
862859 StatementKind :: StorageDead ( local) => {
863860 self . access_place (
@@ -1400,6 +1397,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
14001397 & mut self ,
14011398 location : Location ,
14021399 place : Place < ' tcx > ,
1400+ reason : BackwardIncompatibleDropReason ,
14031401 state : & BorrowckDomain ,
14041402 ) {
14051403 let tcx = self . infcx . tcx ;
@@ -1433,17 +1431,36 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
14331431 borrow,
14341432 Some ( ( WriteKind :: StorageDeadOrDrop , place) ) ,
14351433 ) ;
1436- this. infcx . tcx . emit_node_span_lint (
1437- TAIL_EXPR_DROP_ORDER ,
1438- CRATE_HIR_ID ,
1439- borrowed,
1440- session_diagnostics:: TailExprDropOrder {
1441- borrowed,
1442- callback : |diag| {
1443- explain. add_explanation_to_diagnostic ( & this, diag, "" , None , None ) ;
1444- } ,
1445- } ,
1446- ) ;
1434+ match reason {
1435+ BackwardIncompatibleDropReason :: Edition2024 => {
1436+ this. infcx . tcx . emit_node_span_lint (
1437+ TAIL_EXPR_DROP_ORDER ,
1438+ CRATE_HIR_ID ,
1439+ borrowed,
1440+ session_diagnostics:: TailExprDropOrder {
1441+ borrowed,
1442+ callback : |diag| {
1443+ explain
1444+ . add_explanation_to_diagnostic ( & this, diag, "" , None , None ) ;
1445+ } ,
1446+ } ,
1447+ ) ;
1448+ }
1449+ BackwardIncompatibleDropReason :: UnwindStorageDead => {
1450+ this. infcx . tcx . emit_node_span_lint (
1451+ UNWIND_DROP_ORDER ,
1452+ CRATE_HIR_ID ,
1453+ borrowed,
1454+ session_diagnostics:: UnwindDropOrder {
1455+ borrowed,
1456+ callback : |diag| {
1457+ explain
1458+ . add_explanation_to_diagnostic ( & this, diag, "" , None , None ) ;
1459+ } ,
1460+ } ,
1461+ ) ;
1462+ }
1463+ }
14471464 // We may stop at the first case
14481465 ControlFlow :: Break ( ( ) )
14491466 } ,
0 commit comments