-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[RFC] Clarify (and improve) rules for projections and well-formedness #1214
Merged
nikomatsakis
merged 10 commits into
rust-lang:master
from
nikomatsakis:projection-and-lifetimes
Aug 7, 2015
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7902a6d
Initial version.
nikomatsakis bcc727f
Correct issue #.
nikomatsakis 6b07c20
add clause that says that an object type is WF only if the
nikomatsakis ffeccfd
discuss type aliases a bit more
nikomatsakis fb3ef33
Apply various clarifications based on suggestions
nikomatsakis 5614b94
Add text documenting the impact on crates.io
nikomatsakis b17fdb8
pnkfelix nits
nikomatsakis af21352
correct some out of date text that Ralf identified
nikomatsakis abcd4be
rewrite the inference section to be less reliant on the compiler
nikomatsakis a3d22d8
clarify object type fragments
nikomatsakis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
pnkfelix nits
- Loading branch information
commit b17fdb8aa491834f8f0fe2bbefa6d87597714404
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,8 +412,8 @@ These are inference rules written in a primitive ASCII notation. :) As | |
part of defining the outlives relation, we need to track the set of | ||
lifetimes that are bound within the type we are looking at. Let's | ||
call that set `R=<r0..rn>`. Initially, this set `R` is empty, but it | ||
will grow as we traverse through types like fns or objects, which can | ||
bind region names. | ||
will grow as we traverse through types like fns or object fragments, | ||
which can bind region names via `for<..>`. | ||
|
||
#### Simple outlives rules | ||
|
||
|
@@ -455,22 +455,29 @@ or projections are involved: | |
|
||
The outlives relation for lifetimes depends on whether the lifetime in | ||
question was bound within a type or not. In the usual case, we decide | ||
the relationship between two lifetimes by consulting the environment. | ||
Lifetimes representing scopes within the current fn have a | ||
relationship derived from the code itself, while lifetime parameters | ||
have relationships defined by where-clauses and implied bounds. | ||
the relationship between two lifetimes by consulting the environment, | ||
or using the reflexive property. Lifetimes representing scopes within | ||
the current fn have a relationship derived from the code itself, while | ||
lifetime parameters have relationships defined by where-clauses and | ||
implied bounds. | ||
|
||
OutlivesRegionEnv: | ||
'x ∉ R // not a bound region | ||
('x: 'a) in Env // derivable from where-clauses etc | ||
-------------------------------------------------- | ||
R ⊢ 'x: 'a | ||
|
||
|
||
OutlivesRegionReflexive: | ||
-------------------------------------------------- | ||
R ⊢ 'a: 'a | ||
|
||
For higher-ranked lifetimes, we simply ignore the relation, since the | ||
lifetime is not yet known. This means for example that `fn<'a> fn(&'a | ||
lifetime is not yet known. This means for example that `for<'a> fn(&'a | ||
i32): 'x` holds, even though we do not yet know what region `'a` is | ||
(and in fact it may be instantiated many times with different values | ||
on each call to the fn). | ||
|
||
OutlivesRegionBound: | ||
'x ∈ R // bound region | ||
-------------------------------------------------- | ||
R ⊢ 'x: 'a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these supposed to be the same |
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Env being "the union of all in scope where clauses and implied bounds"? Unclear.
Also unclear what the significance of
'x not in R
is? Are saying that R can only use facts from the environment to prove bounds for otherwise unbound lifetimes?