Skip to content

Commit 59dba04

Browse files
committed
Improve find_binding_init docs
1 parent ecf0c76 commit 59dba04

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

clippy_utils/src/lib.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,9 @@ pub fn expr_or_init<'a, 'b, 'tcx: 'b>(cx: &LateContext<'tcx>, mut expr: &'a Expr
173173
/// By only considering immutable bindings, we guarantee that the returned expression represents the
174174
/// value of the binding wherever it is referenced.
175175
///
176-
/// Example:
177-
/// ```ignore
178-
/// let abc = 1;
179-
/// // ^ output
180-
/// dbg!(abc)
181-
/// // ^^^ input
182-
/// ```
176+
/// Example: For `let x = 1`, if the `HirId` of `x` is provided, the `Expr` `1` is returned.
177+
/// Note: If you have an expression that references a binding `x`, use `path_to_local` to get the
178+
/// canonical binding `HirId`.
183179
pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> {
184180
let hir = cx.tcx.hir();
185181
if_chain! {

0 commit comments

Comments
 (0)