Function rustc_borrowck::borrowck::gather_loans::gather_moves::get_pattern_source [−][src]
fn get_pattern_source<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
pat: &Pat
) -> PatternSource<'tcx>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Analyzes the context where the pattern appears to determine the
kind of hint we want to give. In particular, if the pattern is in a match
or nested within other patterns, we want to suggest a ref
binding:
let (a, b) = v[0]; // like the `a` and `b` patterns here match v[0] { a => ... } // or the `a` pattern here
But if the pattern is the outermost pattern in a let
, we would rather
suggest that the author add a &
to the initializer:
let x = v[0]; // suggest `&v[0]` here
In this latter case, this function will return PatternSource::LetDecl
with a reference to the let