@@ -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 smallvec:: SmallVec ;
5252use tracing:: { debug, instrument} ;
@@ -844,11 +844,8 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
844844 // These do not actually affect borrowck
845845 StatementKind :: ConstEvalCounter | StatementKind :: StorageLive ( ..) => { }
846846 // This does not affect borrowck
847- StatementKind :: BackwardIncompatibleDropHint {
848- place,
849- reason : BackwardIncompatibleDropReason :: Edition2024 ,
850- } => {
851- self . check_backward_incompatible_drop ( location, * * place, state) ;
847+ StatementKind :: BackwardIncompatibleDropHint { place, reason } => {
848+ self . check_backward_incompatible_drop ( location, * * place, * reason, state) ;
852849 }
853850 StatementKind :: StorageDead ( local) => {
854851 self . access_place (
@@ -1391,6 +1388,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
13911388 & mut self ,
13921389 location : Location ,
13931390 place : Place < ' tcx > ,
1391+ reason : BackwardIncompatibleDropReason ,
13941392 state : & BorrowckDomain ,
13951393 ) {
13961394 let tcx = self . infcx . tcx ;
@@ -1424,17 +1422,36 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
14241422 borrow,
14251423 Some ( ( WriteKind :: StorageDeadOrDrop , place) ) ,
14261424 ) ;
1427- this. infcx . tcx . emit_node_span_lint (
1428- TAIL_EXPR_DROP_ORDER ,
1429- CRATE_HIR_ID ,
1430- borrowed,
1431- session_diagnostics:: TailExprDropOrder {
1432- borrowed,
1433- callback : |diag| {
1434- explain. add_explanation_to_diagnostic ( & this, diag, "" , None , None ) ;
1435- } ,
1436- } ,
1437- ) ;
1425+ match reason {
1426+ BackwardIncompatibleDropReason :: Edition2024 => {
1427+ this. infcx . tcx . emit_node_span_lint (
1428+ TAIL_EXPR_DROP_ORDER ,
1429+ CRATE_HIR_ID ,
1430+ borrowed,
1431+ session_diagnostics:: TailExprDropOrder {
1432+ borrowed,
1433+ callback : |diag| {
1434+ explain
1435+ . add_explanation_to_diagnostic ( & this, diag, "" , None , None ) ;
1436+ } ,
1437+ } ,
1438+ ) ;
1439+ }
1440+ BackwardIncompatibleDropReason :: UnwindStorageDead => {
1441+ this. infcx . tcx . emit_node_span_lint (
1442+ UNWIND_DROP_ORDER ,
1443+ CRATE_HIR_ID ,
1444+ borrowed,
1445+ session_diagnostics:: UnwindDropOrder {
1446+ borrowed,
1447+ callback : |diag| {
1448+ explain
1449+ . add_explanation_to_diagnostic ( & this, diag, "" , None , None ) ;
1450+ } ,
1451+ } ,
1452+ ) ;
1453+ }
1454+ }
14381455 // We may stop at the first case
14391456 ControlFlow :: Break ( ( ) )
14401457 } ,
0 commit comments