rust-lang / rust-lang/reference

Unsized coercion of TyCtor(T) clarity issue

Open
#1,258 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-coercions
Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

In type-coercions.md, the following is really not clear:

* TyCtor(`T`) to TyCtor(`U`), where TyCtor(`T`) is one of
    - `&T`
    - `&mut T`
    - `*const T`
    - `*mut T`
    - `Box<T>`

    and where `U` can be obtained from `T` by [unsized coercion](#unsized-coercions).

    <!--In the future, coerce_inner will be recursively extended to tuples and
    structs. In addition, coercions from subtraits to supertraits will be
    added. See [RFC 401] for more details.-->

Ideally, the text should not require deciphering. It seems to be redundantly stating that &T can be coerced to &U. However, is it merely stating that &, &mut, *const, *mut, and Box have special permissibility when unsized coercions exists for their argument types.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the unsized coercions section in type-coercions.md and read the quoted TyCtor(T) rule in context. Clarify whether the rule describes coercions through &, &mut, *const, *mut, and Box, so the permitted behavior is unambiguous. Done means the documentation explains the rule without requiring readers to decipher the notation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.