about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-09-11 17:20:56 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-09-14 12:51:25 -0700
commitc6f2ddf1cb1e328245da59a4fb42f90403389a07 (patch)
tree8fbd111f0fc88fe7b9631e974c34dc0ef1b546cf
parentdc53cfea7eb75b941e05e45fc7d8c412fd2a1bcd (diff)
downloadrust-c6f2ddf1cb1e328245da59a4fb42f90403389a07.tar.gz
rust-c6f2ddf1cb1e328245da59a4fb42f90403389a07.zip
Fix rebase and add comments
-rw-r--r--compiler/rustc_typeck/src/check/_match.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_typeck/src/check/_match.rs b/compiler/rustc_typeck/src/check/_match.rs
index 08cf178c813..836a4ff78c7 100644
--- a/compiler/rustc_typeck/src/check/_match.rs
+++ b/compiler/rustc_typeck/src/check/_match.rs
@@ -6,7 +6,7 @@ use rustc_infer::traits::Obligation;
 use rustc_middle::ty::{self, ToPredicate, Ty};
 use rustc_span::Span;
 use rustc_trait_selection::opaque_types::InferCtxtExt as _;
-use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
+use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
 use rustc_trait_selection::traits::{
     IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
 };
@@ -153,12 +153,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                                 );
                                 suggest_box &= self.infcx.predicate_must_hold_modulo_regions(&obl);
                                 if !suggest_box {
+                                    // We've encountered some obligation that didn't hold, so the
+                                    // return expression can't just be boxed. We don't need to
+                                    // evaluate the rest of the obligations.
                                     break;
                                 }
                             }
                             _ => {}
                         }
                     }
+                    // If all the obligations hold (or there are no obligations) the tail expression
+                    // we can suggest to return a boxed trait object instead of an opaque type.
                     if suggest_box { self.ret_type_span.clone() } else { None }
                 }
                 _ => None,