Skip to content
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

Object lifetime defaults (RFC 599) #22230

Merged
merged 8 commits into from
Feb 16, 2015

Conversation

nikomatsakis
Copy link
Contributor

Implement rules described in rust-lang/rfcs#599.

Fixes #22211.

Based atop PR #22182, so the first few commits (up to and including "Pacify the mercilous nrc") have already been reviewed.

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@nikomatsakis
Copy link
Contributor Author

Rebased.

@pnkfelix
Copy link
Member

@nikomatsakis okay, r=me . I had a couple absurdly minor nits, but really, you could probably just land this.

…ol closures are gone and type parameters can now have multiple region bounds (and hence use a different path). Should have no effect on the external behavior of the compiler.
complete set of regions are available when converting types.
…o be mostly improved, to my eye.

Nonetheless, as this commit demonstrates, the previous commits was a [breaking-change].

In practice, breakage is focused on functions of this form:

```rust
fn foo(..., object: Box<FnMut()>)
````

where `FnMut()` could be any trait object type. The older scheme defaulted objects in argument
position so that they were bounded by a fresh lifetime:

```rust
fn foo<'a>(..., object: Box<FnMut()+'a>)
```

This meant that the object could contain borrowed data. The newer
scheme defaults to a lifetime bound of `'static`:

```rust
fn foo(..., object: Box<FnMut()+'static>)
```

This means that the object cannot contain borrowed data. In some cases, the best fix
is to stop using `Box`:

```rust
fn foo(..., object: &mut FnMut())
```

but another option is to write an explicit annotation for the `'a`
lifetime that used to be implicit.  Both fixes are demonstrated in
this commit.
@nikomatsakis
Copy link
Contributor Author

@bors r=pnkfelix 503e15b

bors added a commit that referenced this pull request Feb 16, 2015
…felix

Implement rules described in rust-lang/rfcs#599.

Fixes #22211.

~~Based atop PR #22182, so the first few commits (up to and including "Pacify the mercilous nrc") have already been reviewed.~~
@bors
Copy link
Contributor

bors commented Feb 16, 2015

⌛ Testing commit 503e15b with merge 81bce52...

@bors bors merged commit 503e15b into rust-lang:master Feb 16, 2015
@nikomatsakis nikomatsakis deleted the object-lifetime-defaults-2 branch March 30, 2016 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking issue for Introduce a default object lifetime bound (RFC 599)
4 participants