8000 static infer feature gate by toidiu · Pull Request #52761 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

static infer feature gate #52761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 28, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add section in book
  • Loading branch information
toidiu committed Jul 27, 2018
commit 130e3ab31b28c9839e2f04c98c4b62c6f1c215a3
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# `infer_static_outlives_requirements`

The tracking issue for this feature is: [#44493]

[#44493]: https://github.com/rust-lang/rust/issues/44493

------------------------
The `infer_static_outlives_requirements` feature indicates that certain
`'static` outlives requirements can be infered by the compiler rather than
stating them explicitly.

Note: It is an accompanying feature to `infer_outlives_requirements`,
which must be enabled to infer outlives requirements.

For example, currently generic struct definitions that contain
references, require where-clauses of the form T: 'static. By using
this feature the outlives predicates will be infered, although
they may still be written explicitly.

```rust,ignore (pseudo-Rust)
struct Foo<U> where U: 'static { // <-- currently required
bar: Bar<U>
}
struct Bar<T: 'static> {
x: T,
}
```


## Examples:

```rust,ignore (pseudo-Rust)
#![feature(infer_outlives_requirements)]
#![feature(infer_static_outlives_requirements)]

#[rustc_outlives]
// Implicitly infer U: 'static
struct Foo<U> {
bar: Bar<U>
}
struct Bar<T: 'static> {
x: T,
}
```

0