reference icon indicating copy to clipboard operation
reference copied to clipboard

Incorrect statement about unsized coercion in method lookup

Open jameseb7 opened this issue 5 years ago • 2 comments

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.

jameseb7 avatar May 25 '20 19:05 jameseb7

CC @matthewjasper @Havvy: The issue to be accurate about which unsizing coercions apply that you requested in PR #190 was never created, but this issue could serve as that. It continues to cause confusion. It is a counter-factual statement in the reference.

(Not sure if bots patrol these parts but let's try...) @rustbot label +Bug +T-lang

QuineDot avatar Nov 10 '22 09:11 QuineDot

Error: Label T-lang can only be set by Rust team members

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

rustbot avatar Nov 10 '22 09:11 rustbot