Skip to content
Merged
Changes from all commits
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
15 changes: 15 additions & 0 deletions text/0000-fn-lifetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,19 @@ What other designs have been considered? What is the impact of not doing this?
# Unresolved questions
[unresolved]: #unresolved-questions

- Should we allow `break 'fn ..` with the same semantics as `return ..`. In
[RFC 1624](https://github.com/rust-lang/rfcs/blob/master/text/1624-loop-break-value.md)
we got breaking with a value out of loops, so the value part is already
established. This provides one canonnical syntax for breaking out of a loops
or functions, leaving `return` just a convenience. In a future with full
lifetime ascription, this would further generalize to supporting all labeled
blocks, not just loops and functions.

A downside is `continue 'a` will still only make sense when `'a` is bound to a
loop, and `break 'a` won't make sense when `'a` is a lifetime parameter. That
means users will need to understand their are three tiers of lifetimes: loop,
block (including `'fn`), and, parameter, where each is less usable than the
last. Today loop lables and lifetimes are disjoint in that neither can be used
where the other is expected, though they do share the same syntax.

What parts of the design are still TBD?