diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2021-02-25 16:06:22 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-25 16:06:22 -0500 |
| commit | 9a540cb6e4c97a74a03fea3f57e48dfddbabb90f (patch) | |
| tree | e8136ba549c0c1ac9c0916827fa08cda6d96fd3f | |
| parent | befa2dffdafe77fdd344690558f1334e721b42db (diff) | |
| parent | 9c5f684e83018f990d067ea44d5204ca3762b722 (diff) | |
| download | rust-9a540cb6e4c97a74a03fea3f57e48dfddbabb90f.tar.gz rust-9a540cb6e4c97a74a03fea3f57e48dfddbabb90f.zip | |
Rollup merge of #82468 - osa1:pick_by_value_method_docs, r=petrochenkov
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.
| -rw-r--r-- | compiler/rustc_typeck/src/check/method/probe.rs | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs index 2bfd697e4cd..c25aec5b2b7 100644 --- a/compiler/rustc_typeck/src/check/method/probe.rs +++ b/compiler/rustc_typeck/src/check/method/probe.rs @@ -160,21 +160,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<hir::Mutability>, - // 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<Ty<'tcx>>, } @@ -1091,19 +1091,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<PickResult<'tcx>> { - //! 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; } |
