about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/infer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_trait_selection/src/infer.rs')
-rw-r--r--compiler/rustc_trait_selection/src/infer.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/infer.rs b/compiler/rustc_trait_selection/src/infer.rs
index bacb3b1b1b8..e91574fa1af 100644
--- a/compiler/rustc_trait_selection/src/infer.rs
+++ b/compiler/rustc_trait_selection/src/infer.rs
@@ -60,6 +60,18 @@ impl<'tcx> InferCtxt<'tcx> {
     ///
     /// Invokes `evaluate_obligation`, so in the event that evaluating
     /// `Ty: Trait` causes overflow, EvaluatedToAmbigStackDependent will be returned.
+    ///
+    /// `type_implements_trait` is a convenience function for simple cases like
+    ///
+    /// ```ignore (illustrative)
+    /// let copy_trait = infcx.tcx.require_lang_item(LangItem::Copy, span);
+    /// let implements_copy = infcx.type_implements_trait(copy_trait, [ty], param_env)
+    /// .must_apply_modulo_regions();
+    /// ```
+    ///
+    /// In most cases you should instead create an [Obligation](traits::Obligation)
+    /// and check whether it holds, because it properly handles higher ranked traits
+    /// and it is more convenient and safer when your `params` are inside a `Binder`.
     #[instrument(level = "debug", skip(self, params), ret)]
     fn type_implements_trait(
         &self,