Skip to content

Commit 77fb540

Browse files
author
Lukas Markeffsky
committedFeb 5, 2024
extend docs for predicate_must_hold_considering_regions
1 parent 8c0b4f6 commit 77fb540

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed
 

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

+22-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,28 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
4141
/// not entirely accurate if inference variables are involved.
4242
///
4343
/// This version may conservatively fail when outlives obligations
44-
/// are required.
44+
/// are required. Therefore, this version should only be used for
45+
/// optimizations or diagnostics and be treated as if it can always
46+
/// 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+
/// ```
4566
fn predicate_must_hold_considering_regions(
4667
&self,
4768
obligation: &PredicateObligation<'tcx>,

0 commit comments

Comments
 (0)