Skip to content

Commit

Permalink
Improve find_binding_init docs
Browse files Browse the repository at this point in the history
  • Loading branch information
camsteffen committed Mar 15, 2021
1 parent ecf0c76 commit 59dba04
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down

0 comments on commit 59dba04

Please sign in to comment.