Skip to content

Commit

Permalink
Revert "Permit multiple lifetime bounds on parameter types",
Browse files Browse the repository at this point in the history
which was pushed accidentally.

This reverts commit 5e8d273.
  • Loading branch information
nikomatsakis committed Sep 16, 2014
1 parent 5e8d273 commit b1d1bfd
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions active/0049-bounds-on-object-and-generic-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ declared:
Here, the constraint `T:'a` indicates that the data being iterated
over must live at least as long as the collection (logically enough).

### At most one explicit lifetime bound is permitted

For simplicity, we permit at most one *explicit* lifetime bound on any
given parameter type. That means that the following function is illegal:

fn foo<'a,'b,A:'a+'b>() { ... }

Remember that if there are multiple lifetime bounds, it implies that
all of them must hold. That means that if, in fact, `A` outlives both
`'a` and `'b` then either one of them is shorter than the other, the
two are the same, or there is a third lifetime that outlives them
both. Therefore, the function above can be rewritten as follows (using
explicit lifetime bounds, specified below):

fn foo<'a,'b,'c:'a+'b,A:'c>() { ... }

As far as I know, this situation has not arisen once in the codebase.

## Lifetime bounds on object types

Like parameters, all object types have a lifetime bound. Unlike
Expand All @@ -95,9 +113,9 @@ Here are some examples:
// IsStatic+'a 'static+'a
// IsStatic+Is<'a>+'b 'static,'a,'b

Object types must have exactly one bound -- zero bounds is not
acceptable. Therefore, if an object type with no derivable bounds
appears, we will supply a default lifetime using the normal rules:
In general no object type is permitted to have zero bounds. Therefore,
if an object type with no derivable bounds appears, we will supply a
default lifetime using the normal rules:

trait Writer { /* no derivable bounds */ }
struct Foo<'a> {
Expand Down

0 comments on commit b1d1bfd

Please sign in to comment.