mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Improve find_binding_init
docs
This commit is contained in:
parent
ecf0c76c36
commit
59dba04ccb
1 changed files with 3 additions and 7 deletions
|
@ -173,13 +173,9 @@ pub fn expr_or_init<'a, 'b, 'tcx: 'b>(cx: &LateContext<'tcx>, mut expr: &'a Expr
|
|||
/// By only considering immutable bindings, we guarantee that the returned expression represents the
|
||||
/// value of the binding wherever it is referenced.
|
||||
///
|
||||
/// Example:
|
||||
/// ```ignore
|
||||
/// let abc = 1;
|
||||
/// // ^ output
|
||||
/// dbg!(abc)
|
||||
/// // ^^^ input
|
||||
/// ```
|
||||
/// Example: For `let x = 1`, if the `HirId` of `x` is provided, the `Expr` `1` is returned.
|
||||
/// Note: If you have an expression that references a binding `x`, use `path_to_local` to get the
|
||||
/// canonical binding `HirId`.
|
||||
pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> {
|
||||
let hir = cx.tcx.hir();
|
||||
if_chain! {
|
||||
|
|
Loading…
Reference in a new issue