about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-26 01:09:02 +0000
committerbors <bors@rust-lang.org>2018-05-26 01:09:02 +0000
commit49a97ef010c731974f167174bb2e10465dfe745b (patch)
tree4b05c9e184d5d8735b55741d9049628911f96429 /src/doc
parent07c415c2154f29d6dce8da0154ef41c8a5497fbf (diff)
parent3da712381d0d264e31dcfaf9b29bbe8d4a8d1474 (diff)
downloadrust-49a97ef010c731974f167174bb2e10465dfe745b.tar.gz
rust-49a97ef010c731974f167174bb2e10465dfe745b.zip
Auto merge of #50070 - toidiu:ak-2093-outlives, r=nikomatsakis
2093 infer outlives requirements

Tracking issue:  #44493
RFC: https://github.com/rust-lang/rfcs/pull/2093

- [x] add `rustc_attrs` flag
- [x] use `RequirePredicates` type
- [x]  handle explicit predicates on `dyn` Trait
- [x] handle explicit predicates on projections
- [x] more tests
- [x]  remove `unused`, `dead_code` and etc..
- [x]  documentation
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/language-features/infer-outlives-requirements.md67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md b/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md
new file mode 100644
index 00000000000..73c7eafdb98
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md
@@ -0,0 +1,67 @@
+# `infer_outlives_requirements`
+
+The tracking issue for this feature is: [#44493]
+
+[#44493]: https://github.com/rust-lang/rust/issues/44493
+
+------------------------
+The `infer_outlives_requirements` feature indicates that certain
+outlives requirements can be infered by the compiler rather than
+stating them explicitly.
+
+For example, currently generic struct definitions that contain
+references, require where-clauses of the form T: 'a. By using
+this feature the outlives predicates will be infered, although
+they may still be written explicitly.
+
+```rust,ignore (pseudo-Rust)
+struct Foo<'a, T>
+  where T: 'a // <-- currently required
+  {
+      bar: &'a T,
+  }
+```
+
+
+## Examples:
+
+
+```rust,ignore (pseudo-Rust)
+#![feature(infer_outlives_requirements)]
+
+// Implicitly infer T: 'a
+struct Foo<'a, T> {
+    bar: &'a T,
+}
+```
+
+```rust,ignore (pseudo-Rust)
+#![feature(infer_outlives_requirements)]
+
+// Implicitly infer `U: 'b`
+struct Foo<'b, U> {
+    bar: Bar<'b, U>
+}
+
+struct Bar<'a, T> where T: 'a {
+    x: &'a (),
+    y: T,
+}
+```
+
+```rust,ignore (pseudo-Rust)
+#![feature(infer_outlives_requirements)]
+
+// Implicitly infer `b': 'a`
+struct Foo<'a, 'b, T> {
+    x: &'a &'b T
+}
+```
+
+```rust,ignore (pseudo-Rust)
+#![feature(infer_outlives_requirements)]
+
+// Implicitly infer `<T as std::iter::Iterator>::Item : 'a`
+struct Foo<'a, T: Iterator> {
+    bar: &'a T::Item
+```