Improve find_binding_init docs

This commit is contained in:
Cameron Steffen 2021-03-15 08:51:23 -05:00
parent ecf0c76c36
commit 59dba04ccb

View file

@ -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 /// By only considering immutable bindings, we guarantee that the returned expression represents the
/// value of the binding wherever it is referenced. /// value of the binding wherever it is referenced.
/// ///
/// Example: /// Example: For `let x = 1`, if the `HirId` of `x` is provided, the `Expr` `1` is returned.
/// ```ignore /// Note: If you have an expression that references a binding `x`, use `path_to_local` to get the
/// let abc = 1; /// canonical binding `HirId`.
/// // ^ output
/// dbg!(abc)
/// // ^^^ input
/// ```
pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> { pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> {
let hir = cx.tcx.hir(); let hir = cx.tcx.hir();
if_chain! { if_chain! {