From b007006d3bd2e3f0744656cf14298ffc4a1ba94d Mon Sep 17 00:00:00 2001 From: Matthew Woodcraft Date: Tue, 1 Feb 2022 22:34:39 +0000 Subject: [PATCH 1/2] Document pre-Rust-2021 special case for IntoIterator method lookup This is the #[rustc_skip_array_during_method_dispatch] special case. --- src/expressions/method-call-expr.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/expressions/method-call-expr.md b/src/expressions/method-call-expr.md index 748e7dc1e..5a6cc455f 100644 --- a/src/expressions/method-call-expr.md +++ b/src/expressions/method-call-expr.md @@ -66,6 +66,11 @@ Once a method is looked up, if it can't be called for one (or more) of those rea If a step is reached where there is more than one possible method, such as where generic methods or traits are considered the same, then it is a compiler error. These cases require a [disambiguating function call syntax] for method and function invocation. +> **Edition Differences**: Before the 2021 edition, during the search for visible methods, if the candidate receiver type is an [array type], methods provided by the standard library [`IntoIterator`] trait are ignored. +> +> The edition used for this purpose is determined by the token representing the method name. + +
***Warning:*** For [trait objects], if there is an inherent method of the same name as a trait method, it will give a compiler error when trying to call the method in a method call expression. @@ -79,9 +84,11 @@ Just don't define inherent methods on trait objects with the same name as a trai [_Expression_]: ../expressions.md [_PathExprSegment_]: ../paths.md#paths-in-expressions [visible]: ../visibility-and-privacy.md +[array type]: ../types/array.md [trait objects]: ../types/trait-object.md [disambiguate call]: call-expr.md#disambiguating-function-calls [disambiguating function call syntax]: call-expr.md#disambiguating-function-calls [dereference]: operator-expr.md#the-dereference-operator [methods]: ../items/associated-items.md#methods [unsized coercion]: ../type-coercions.md#unsized-coercions +[`IntoIterator`]: ../../std/iter/trait.IntoIterator.html From e4964a0a951ec7b468992acac50645b443ee4f1d Mon Sep 17 00:00:00 2001 From: Matthew Woodcraft Date: Sun, 6 Feb 2022 17:35:19 +0000 Subject: [PATCH 2/2] Note about the future of the IntoIterator special case --- src/expressions/method-call-expr.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/expressions/method-call-expr.md b/src/expressions/method-call-expr.md index 5a6cc455f..8a2f68cc3 100644 --- a/src/expressions/method-call-expr.md +++ b/src/expressions/method-call-expr.md @@ -69,6 +69,8 @@ These cases require a [disambiguating function call syntax] for method and funct > **Edition Differences**: Before the 2021 edition, during the search for visible methods, if the candidate receiver type is an [array type], methods provided by the standard library [`IntoIterator`] trait are ignored. > > The edition used for this purpose is determined by the token representing the method name. +> +> This special case may be removed in the future.