extend docs for predicate_must_hold_considering_regions

This commit is contained in:
Lukas Markeffsky 2024-02-05 13:38:57 +01:00
parent 8c0b4f67c9
commit 77fb540684

View file

@ -41,7 +41,28 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
/// not entirely accurate if inference variables are involved.
///
/// This version may conservatively fail when outlives obligations
/// are required.
/// are required. Therefore, this version should only be used for
/// optimizations or diagnostics and be treated as if it can always
/// return `false`.
///
/// # Example
///
/// ```
/// # #![allow(dead_code)]
/// trait Trait {}
///
/// fn check<T: Trait>() {}
///
/// fn foo<T: 'static>()
/// where
/// &'static T: Trait,
/// {
/// // Evaluating `&'?0 T: Trait` adds a `'?0: 'static` outlives obligation,
/// // which means that `predicate_must_hold_considering_regions` will return
/// // `false`.
/// check::<&'_ T>();
/// }
/// ```
fn predicate_must_hold_considering_regions(
&self,
obligation: &PredicateObligation<'tcx>,