File tree 1 file changed +45
-0
lines changed
src/doc/unstable-book/src/language-features
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ` infer_static_outlives_requirements `
2
+
3
+ The tracking issue for this feature is: [ #44493 ]
4
+
5
+ [ #44493 ] : https://github.com/rust-lang/rust/issues/44493
6
+
7
+ ------------------------
8
+ The ` infer_static_outlives_requirements ` feature indicates that certain
9
+ ` 'static ` outlives requirements can be infered by the compiler rather than
10
+ stating them explicitly.
11
+
12
+ Note: It is an accompanying feature to ` infer_outlives_requirements ` ,
13
+ which must be enabled to infer outlives requirements.
14
+
15
+ For example, currently generic struct definitions that contain
16
+ references, require where-clauses of the form T: 'static. By using
17
+ this feature the outlives predicates will be infered, although
18
+ they may still be written explicitly.
19
+
20
+ ``` rust,ignore (pseudo-Rust)
21
+ struct Foo<U> where U: 'static { // <-- currently required
22
+ bar: Bar<U>
23
+ }
24
+ struct Bar<T: 'static> {
25
+ x: T,
26
+ }
27
+ ```
28
+
29
+
30
+ ## Examples:
31
+
32
+ ``` rust,ignore (pseudo-Rust)
33
+ #![feature(infer_outlives_requirements)]
34
+ #![feature(infer_static_outlives_requirements)]
35
+
36
+ #[rustc_outlives]
37
+ // Implicitly infer U: 'static
38
+ struct Foo<U> {
39
+ bar: Bar<U>
40
+ }
41
+ struct Bar<T: 'static> {
42
+ x: T,
43
+ }
44
+ ```
45
+
You can’t perform that action at this time.
0 commit comments