Incorrect statement about unsized coercion in method lookup

Open
#819 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the method-call expression section linked in the issue and reproduce the Rust Playground example to verify how method lookup handles trait-object and slice coercions. Update the explanation to match the observed behavior and clarify whether slices are a special case; done means the reference no longer claims unsupported general unsized coercion.

Written by the indexing model from the issue text.

Description

A-method-call

When explaining method lookup, the reference says:

The first step is to build a list of candidate receiver types. Obtain these by repeatedly dereferencing the receiver expression's type, adding each type encountered to the list, then finally attempting an unsized coercion at the end, and adding the result type if that is successful.

However, general unsized coercions are not allowed for method call. In particular, this example shows unsized coercion to a trait object is not performed during method lookup. It seems it was mentioned when this paragraph of the reference was written that the unsized coercion is only performed for slices, but it does not seem to have been changed accordingly. It would be good if it could be fixed to reflect what actually happens during method lookup, and if we could clarify whether slices are truly a special case.

Dominant language
Rust
Stars
1.6k
Forks
607
Avg merge
1d 1h
Merged PRs (30d)
12

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.

More from rust-lang/reference

All issues in rust-lang/reference

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.