Skip to content

Commit c1a2f62

Browse files
committed
Adjust rules to say that trailing lifetimes may only be shortened
1 parent 773b7f6 commit c1a2f62

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/expressions/operator-expr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ r[expr.as.pointer.unsized.trait]
746746
- When `T` and `U` are unsized with trait object metadata, the metadata is compatible only when all of the following holds:
747747
1. The principal trait must be the same. (you can't cast from `dyn Foo` to `dyn Bar`)
748748
2. Auto traits may be removed, but not added. (you can cast `dyn Foo + Send` to `dyn Foo`, but the opposite is not legal)
749-
3. Trailing lifetimes may be changed. (you can cast `dyn Foo + 'a` to `dyn Foo + 'b` for any `'a`,`'b`)
749+
3. Trailing lifetimes may only be shortened. (you can cast `dyn Foo + 'long` to `dyn Foo + 'short`, but the opposite is not legal)
750750
4. Generics (including lifetimes) and associated types must match exactly. (`*dyn T<'a, A>` -> `*dyn T<'b, B>` requires `'a = 'b` and `A = B`)
751751

752752
Note that [trait upcasting][coerce.unsize.trait-upcast] (including the addition of auto traits) requires a coercion and is not supported by `as` casts.

0 commit comments

Comments
 (0)