File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
compiler/rustc_trait_selection/src Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,18 @@ impl<'tcx> InferCtxt<'tcx> {
6060 ///
6161 /// Invokes `evaluate_obligation`, so in the event that evaluating
6262 /// `Ty: Trait` causes overflow, EvaluatedToAmbigStackDependent will be returned.
63+ ///
64+ /// `type_implements_trait` is a convenience function for simple cases like
65+ ///
66+ /// ```ignore (illustrative)
67+ /// let copy_trait = infcx.tcx.require_lang_item(LangItem::Copy, span);
68+ /// let implements_copy = infcx.type_implements_trait(copy_trait, [ty], param_env)
69+ /// .must_apply_modulo_regions();
70+ /// ```
71+ ///
72+ /// In most cases you should instead create an [Obligation](traits::Obligation)
73+ /// and check whether it holds, because it properly handles higher ranked traits
74+ /// and it is more convenient and safer when your `params` are inside a `Binder`.
6375 #[ instrument( level = "debug" , skip( self , params) , ret) ]
6476 fn type_implements_trait (
6577 & self ,
You can’t perform that action at this time.
0 commit comments