Skip to content

Commit 2a4e05a

Browse files
author
Lukas Markeffsky
committed
add example to predicate_must_hold_considering_regions
1 parent e580ae6 commit 2a4e05a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
4444
/// are required. Therefore, this version should only be used for
4545
/// optimizations or diagnostics and be treated as if it can always
4646
/// return `false`.
47+
///
48+
/// # Example
49+
///
50+
/// ```
51+
/// # #![allow(dead_code)]
52+
/// trait Trait {}
53+
///
54+
/// fn check<T: Trait>() {}
55+
///
56+
/// fn foo<T: 'static>()
57+
/// where
58+
/// &'static T: Trait,
59+
/// {
60+
/// // Evaluating `&'?0 T: Trait` adds a `'?0: 'static` outlives obligation,
61+
/// // which means that `predicate_must_hold_considering_regions` will return
62+
/// // `false`.
63+
/// check::<&'_ T>();
64+
/// }
65+
/// ```
4766
fn predicate_must_hold_considering_regions(
4867
&self,
4968
obligation: &PredicateObligation<'tcx>,

0 commit comments

Comments
 (0)