summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorJoshua Nelson <jnelson@cloudflare.com>2022-06-21 19:43:46 -0500
committerJoshua Nelson <jnelson@cloudflare.com>2022-06-21 19:44:53 -0500
commitb052d76586988040c6ae8aef609794ae16cc28dc (patch)
treef9b230c65df00910ef0cf41f603310165f573f5a /compiler/rustc_trait_selection/src
parent1deca0425db3e74a61cb732e729c0777904e549c (diff)
downloadrust-b052d76586988040c6ae8aef609794ae16cc28dc.tar.gz
rust-b052d76586988040c6ae8aef609794ae16cc28dc.zip
Address review comments from #98259
It got merged so fast I didn't have time to make changes xD
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs26
1 files changed, 4 insertions, 22 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index 159fcf932a1..19318a85a01 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -8,7 +8,6 @@ use crate::infer::InferCtxt;
 use crate::traits::normalize_to;
 
 use hir::HirId;
-use rustc_ast::Movability;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::stack::ensure_sufficient_stack;
 use rustc_errors::{
@@ -2406,19 +2405,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                     }
                 };
 
-                let future_trait = self.tcx.lang_items().future_trait().unwrap();
-                let opaque_ty_is_future = |def_id| {
-                    self.tcx.explicit_item_bounds(def_id).iter().any(|(predicate, _)| {
-                        if let ty::PredicateKind::Trait(trait_predicate) =
-                            predicate.kind().skip_binder()
-                        {
-                            trait_predicate.trait_ref.def_id == future_trait
-                        } else {
-                            false
-                        }
-                    })
-                };
-
                 let from_generator = tcx.lang_items().from_generator_fn().unwrap();
 
                 // Don't print the tuple of capture types
@@ -2444,13 +2430,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
 
                                 // If the previous type is `from_generator`, this is the future generated by the body of an async function.
                                 // Avoid printing it twice (it was already printed in the `ty::Generator` arm below).
-                                let is_future = opaque_ty_is_future(def_id);
+                                let is_future = tcx.ty_is_opaque_future(ty);
                                 debug!(
                                     ?obligated_types,
                                     ?is_future,
                                     "note_obligation_cause_code: check for async fn"
                                 );
-                                if opaque_ty_is_future(def_id)
+                                if is_future
                                     && obligated_types.last().map_or(false, |ty| match ty.kind() {
                                         ty::Opaque(last_def_id, _) => {
                                             tcx.parent(*last_def_id) == from_generator
@@ -2475,15 +2461,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                                 }
                                 err.note(msg.trim_end_matches(", "))
                             }
-                            ty::Generator(def_id, _, movability) => {
+                            ty::Generator(def_id, _, _) => {
                                 let sp = self.tcx.def_span(def_id);
 
                                 // Special-case this to say "async block" instead of `[static generator]`.
-                                let kind = if *movability == Movability::Static {
-                                    "async block"
-                                } else {
-                                    "generator"
-                                };
+                                let kind = tcx.generator_kind(def_id).unwrap();
                                 err.span_note(
                                     sp,
                                     &format!("required because it's used within this {}", kind),