Skip to content

Commit

Permalink
Rollup merge of #82468 - osa1:pick_by_value_method_docs, r=petrochenkov
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JohnTitor committed Feb 24, 2021
2 parents c5a3305 + 9c5f684 commit 56fc3c5
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions compiler/rustc_typeck/src/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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>>,
}

Expand Down Expand Up @@ -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<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;
}
Expand Down

0 comments on commit 56fc3c5

Please sign in to comment.