about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2020-03-24 17:06:40 -0700
committerTyler Mandry <tmandry@gmail.com>2020-04-13 18:48:55 -0700
commitb129b32afa3fa896f1464b9a529c30116a7a4e5c (patch)
treed22a91aba8d74cd136b4831b9dcef33f17cd28b4
parent8e18e26f12b1e8b3e913b15278bf6185f0f61add (diff)
downloadrust-b129b32afa3fa896f1464b9a529c30116a7a4e5c.tar.gz
rust-b129b32afa3fa896f1464b9a529c30116a7a4e5c.zip
Use inner/outer generator naming instead of first/last
I personally find this clearer.
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/suggestions.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
index 14029f29151..c923d9e16fe 100644
--- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
@@ -127,8 +127,8 @@ pub trait InferCtxtExt<'tcx> {
         scope_span: &Option<Span>,
         expr: Option<hir::HirId>,
         snippet: String,
-        first_generator: DefId,
-        last_generator: Option<DefId>,
+        inner_generator: DefId,
+        outer_generator: Option<DefId>,
         trait_ref: ty::TraitRef<'_>,
         target_ty: Ty<'tcx>,
         tables: &ty::TypeckTables<'_>,
@@ -1118,8 +1118,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
         // - `BindingObligation` with `impl_send (Send requirement)
         //
         // The first obligation in the chain is the most useful and has the generator that captured
-        // the type. The last generator has information about where the bound was introduced. At
-        // least one generator should be present for this diagnostic to be modified.
+        // the type. The last generator (`outer_generator` below) has information about where the
+        // bound was introduced. At least one generator should be present for this diagnostic to be
+        // modified.
         let (mut trait_ref, mut target_ty) = match obligation.predicate {
             ty::Predicate::Trait(p, _) => {
                 (Some(p.skip_binder().trait_ref), Some(p.skip_binder().self_ty()))
@@ -1127,7 +1128,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
             _ => (None, None),
         };
         let mut generator = None;
-        let mut last_generator = None;
+        let mut outer_generator = None;
         let mut next_code = Some(&obligation.cause.code);
         while let Some(code) = next_code {
             debug!("maybe_note_obligation_cause_for_async_await: code={:?}", code);
@@ -1144,7 +1145,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                     match ty.kind {
                         ty::Generator(did, ..) => {
                             generator = generator.or(Some(did));
-                            last_generator = Some(did);
+                            outer_generator = Some(did);
                         }
                         ty::GeneratorWitness(..) => {}
                         _ if generator.is_none() => {
@@ -1248,7 +1249,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                 *expr,
                 snippet,
                 generator_did,
-                last_generator,
+                outer_generator,
                 trait_ref,
                 target_ty,
                 tables,
@@ -1270,8 +1271,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
         scope_span: &Option<Span>,
         expr: Option<hir::HirId>,
         snippet: String,
-        first_generator: DefId,
-        last_generator: Option<DefId>,
+        inner_generator: DefId,
+        outer_generator: Option<DefId>,
         trait_ref: ty::TraitRef<'_>,
         target_ty: Ty<'tcx>,
         tables: &ty::TypeckTables<'_>,
@@ -1282,14 +1283,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
 
         let is_async_fn = self
             .tcx
-            .parent(first_generator)
+            .parent(inner_generator)
             .map(|parent_did| self.tcx.asyncness(parent_did))
             .map(|parent_asyncness| parent_asyncness == hir::IsAsync::Async)
             .unwrap_or(false);
         let is_async_move = self
             .tcx
             .hir()
-            .as_local_hir_id(first_generator)
+            .as_local_hir_id(inner_generator)
             .and_then(|hir_id| self.tcx.hir().maybe_body_owned_by(hir_id))
             .map(|body_id| self.tcx.hir().body(body_id))
             .and_then(|body| body.generator_kind())
@@ -1318,7 +1319,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
             let original_span = err.span.primary_span().unwrap();
             let mut span = MultiSpan::from_span(original_span);
 
-            let message = if let Some(name) = last_generator
+            let message = if let Some(name) = outer_generator
                 .and_then(|generator_did| self.tcx.parent(generator_did))
                 .and_then(|parent_did| hir.as_local_hir_id(parent_did))
                 .and_then(|parent_hir_id| hir.opt_name(parent_hir_id))