Uh oh!
There was an error while loading. Please reload this page.
Generalize object and type parameter bounds - #16453
Merged
Merged
Conversation
nikomatsakis
commented
Aug 12, 2014
ContributorAuthor
r? @pnkfelix Note: there are still a lot of commits here. I got tired of grouping them together. I will likely come back and group them some more later, but I'd also like to walk you through the code a bit. |
nikomatsakis
commented
Aug 13, 2014
ContributorAuthor
Per discussion with @nick29581 and @pnkfelix, we're going to delay review (or at least landing) somewhat so as to try and avoid conflicts with DST branch. |
Closed
nikomatsakis
commented
Aug 13, 2014
ContributorAuthor
OK, I cleaned up the set of commits, grouping things together as best I could. It's reasonably clean now, though the commits will not build independently. |
nikomatsakis
commented
Aug 14, 2014
ContributorAuthor
Closes #16462 |
nikomatsakisforce-pushed
the
type-bounds-3
branch
from
August 23, 2014 05:01
1a584c0 to
d12d394Comparenikomatsakisforce-pushed
the
type-bounds-3
branch
from
August 25, 2014 14:41
48887b6 to
e336eafComparenikomatsakisforce-pushed
the
type-bounds-3
branch
from
August 28, 2014 01:48
1bd83ce to
1b487a8Comparenikomatsakis
commented
Aug 28, 2014
ContributorAuthor
Rebased over DST. At this point the history is ruined, so I squashed down to a single commit now that the review has been done. |
bors added a commit
that referenced
this pull request
Aug 28, 2014
Implements rust-lang/rfcs#192. In particular: 1. type parameters can have lifetime bounds and objects can close over borrowed values, presuming that they have suitable bounds. 2. objects must have a bound, though it may be derived from the trait itself or from a `Send` bound. 3. all types must be well-formed. 4. type parameters and lifetime parameters may themselves have lifetimes as bounds. Something like `T:'a` means "the type T outlives 'a`" and something like `'a:'b`" means "'a outlives 'b". Outlives here means "all borrowed data has a lifetime at least as long". This is a [breaking-change]. The most common things you have to fix after this change are: 1. Introduce lifetime bounds onto type parameters if your type (directly or indirectly) contains a reference. Thus a struct like `struct Ref<'a, T> { x: &'a T }` would be changed to `struct Ref<'a, T:'a> { x: &'a T }`. 2. Introduce lifetime bounds onto lifetime parameters if your type contains a double reference. Thus a type like `struct RefWrapper<'a, 'b> { r: &'a Ref<'b, int> }` (where `Ref` is defined as before) would need to be changed to `struct RefWrapper<'a, 'b:'a> { ... }`. 2. Explicitly give object lifetimes in structure definitions. Most commonly, this means changing something like `Box<Reader>` to `Box<Reader+'static>`, so as to indicate that this is a reader without any borrowed data. (Note: you may wish to just change to `Box<Reader+Send>` while you're at it; it's a more restrictive type, technically, but means you can send the reader between threads.) The intuition for points 1 and 2 is that a reference must never outlive its referent (the thing it points at). Therefore, if you have a type `&'a T`, we must know that `T` (whatever it is) outlives `'a`. And so on. Closes#5723.
emberian added a commit
to gfx-rs/gfx
that referenced
this pull request
Aug 30, 2014
carllerche added a commit
to alexcrichton/curl-rust
that referenced
this pull request
Sep 1, 2014
Now that rust-lang/rust#16453 has landed, the body API can be improved to not require hard casting to trait objects
cburgdorf added a commit
to nickel-org/nickel.rs
that referenced
this pull request
Sep 11, 2014
This is due to a breaking change from: rust-lang/rust#16453
matthiaskrgr pushed a commit
to matthiaskrgr/rust
that referenced
this pull request
Feb 5, 2024
internal: Undo special bracket classification for attributes in vscode config I changed this thinking the `#` could be considered part of the bracket but on second though I don't think that's quite right in general. Fixesrust-lang/rust-analyzer#16449
flip1995 pushed a commit
to flip1995/rust
that referenced
this pull request
Feb 12, 2026
Closesrust-lang/rust-clippy#16446 changelog: [`doc_markdown`] add PowerShell to whitelist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements rust-lang/rfcs#192.
In particular:
Sendbound.T:'ameans "the type T outlives 'a" and something like'a:'b`" means "'a outlives 'b". Outlives here means "all borrowed data has a lifetime at least as long".This is a [breaking-change]. The most common things you have to fix after this change are:
struct Ref<'a, T> { x: &'a T }would be changed tostruct Ref<'a, T:'a> { x: &'a T }.struct RefWrapper<'a, 'b> { r: &'a Ref<'b, int> }(whereRefis defined as before) would need to be changed tostruct RefWrapper<'a, 'b:'a> { ... }.Box<Reader>toBox<Reader+'static>, so as to indicate that this is a reader without any borrowed data. (Note: you may wish to just change toBox<Reader+Send>while you're at it; it's a more restrictive type, technically, but means you can send the reader between threads.)The intuition for points 1 and 2 is that a reference must never outlive its referent (the thing it points at). Therefore, if you have a type
&'a T, we must know thatT(whatever it is) outlives'a. And so on.Closes#5723.