@@ -48,28 +48,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4848 /// Produces warning on the given node, if the current point in the
4949 /// function is unreachable, and there hasn't been another warning.
5050 pub ( crate ) fn warn_if_unreachable ( & self , id : HirId , span : Span , kind : & str ) {
51- // If span arose from a desugaring of `if` or `while`, then it is the condition itself,
52- // which diverges, that we are about to lint on. This gives suboptimal diagnostics.
53- // Instead, stop here so that the `if`- or `while`-expression's block is linted instead.
54- if span. is_desugaring ( DesugaringKind :: CondTemporary ) {
51+ let Diverges :: Always { span : orig_span, custom_note } = self . diverges . get ( ) else {
5552 return ;
56- }
53+ } ;
5754
58- // Don't lint if the result of an async block or async function is `!`.
59- // This does not affect the unreachable lints *within* the body.
60- if span. is_desugaring ( DesugaringKind :: Async ) {
61- return ;
62- }
55+ match span. desugaring_kind ( ) {
56+ // If span arose from a desugaring of `if` or `while`, then it is the condition
57+ // itself, which diverges, that we are about to lint on. This gives suboptimal
58+ // diagnostics. Instead, stop here so that the `if`- or `while`-expression's
59+ // block is linted instead.
60+ Some ( DesugaringKind :: CondTemporary ) => return ,
6361
64- // Don't lint *within* the `.await` operator, since that's all just desugaring junk.
65- // We only want to lint if there is a subsequent expression after the `.await`.
66- if span. is_desugaring ( DesugaringKind :: Await ) {
67- return ;
68- }
62+ // Don't lint if the result of an async block or async function is `!`.
63+ // This does not affect the unreachable lints *within* the body.
64+ Some ( DesugaringKind :: Async ) => return ,
6965
70- let Diverges :: Always { span : orig_span, custom_note } = self . diverges . get ( ) else {
71- return ;
72- } ;
66+ // Don't lint *within* the `.await` operator, since that's all just desugaring
67+ // junk. We only want to lint if there is a subsequent expression after the
68+ // `.await` operator.
69+ Some ( DesugaringKind :: Await ) => return ,
70+
71+ _ => { }
72+ }
7373
7474 // Don't warn twice.
7575 self . diverges . set ( Diverges :: WarnedAlways ) ;
0 commit comments