From 5ac6935974d72e28c0b9c49af45f771de1b4d4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 24 Feb 2021 09:36:07 +0300 Subject: [PATCH 1/2] Move pick_by_value_method docs above function header - Currently style triggers #81183 so we can't add `#[instrument]` to this function. - Having docs above the header is more consistent with the rest of the code base. --- compiler/rustc_typeck/src/check/method/probe.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs index 158c214759db2..09863e9e7c9c6 100644 --- a/compiler/rustc_typeck/src/check/method/probe.rs +++ b/compiler/rustc_typeck/src/check/method/probe.rs @@ -1090,19 +1090,17 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { .next() } + /// For each type `T` in the step list, this attempts to find a method where + /// the (transformed) self type is exactly `T`. We do however do one + /// transformation on the adjustment: if we are passing a region pointer in, + /// we will potentially *reborrow* it to a shorter lifetime. This allows us + /// to transparently pass `&mut` pointers, in particular, without consuming + /// them for their entire lifetime. fn pick_by_value_method( &mut self, step: &CandidateStep<'tcx>, self_ty: Ty<'tcx>, ) -> Option> { - //! For each type `T` in the step list, this attempts to find a - //! method where the (transformed) self type is exactly `T`. We - //! do however do one transformation on the adjustment: if we - //! are passing a region pointer in, we will potentially - //! *reborrow* it to a shorter lifetime. This allows us to - //! transparently pass `&mut` pointers, in particular, without - //! consuming them for their entire lifetime. - if step.unsize { return None; } From 9c5f684e83018f990d067ea44d5204ca3762b722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 24 Feb 2021 10:36:43 +0300 Subject: [PATCH 2/2] Turn Pick field comments into documentation --- .../rustc_typeck/src/check/method/probe.rs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs index 09863e9e7c9c6..52cdbde0e9816 100644 --- a/compiler/rustc_typeck/src/check/method/probe.rs +++ b/compiler/rustc_typeck/src/check/method/probe.rs @@ -159,21 +159,21 @@ pub struct Pick<'tcx> { pub kind: PickKind<'tcx>, pub import_ids: SmallVec<[LocalDefId; 1]>, - // Indicates that the source expression should be autoderef'd N times - // - // A = expr | *expr | **expr | ... + /// Indicates that the source expression should be autoderef'd N times + /// + /// A = expr | *expr | **expr | ... pub autoderefs: usize, - // Indicates that an autoref is applied after the optional autoderefs - // - // B = A | &A | &mut A + /// Indicates that an autoref is applied after the optional autoderefs + /// + /// B = A | &A | &mut A pub autoref: Option, - // Indicates that the source expression should be "unsized" to a - // target type. This should probably eventually go away in favor - // of just coercing method receivers. - // - // C = B | unsize(B) + /// Indicates that the source expression should be "unsized" to a + /// target type. This should probably eventually go away in favor + /// of just coercing method receivers. + /// + /// C = B | unsize(B) pub unsize: Option>, }