@@ -150,6 +150,7 @@ macro_rules! extract_msrv_attr {
150150
151151/// If the given expression is a local binding, find the initializer expression.
152152/// If that initializer expression is another local binding, find its initializer again.
153+ ///
153154/// This process repeats as long as possible (but usually no more than once). Initializer
154155/// expressions with adjustments are ignored. If this is not desired, use [`find_binding_init`]
155156/// instead.
@@ -180,6 +181,7 @@ pub fn expr_or_init<'a, 'b, 'tcx: 'b>(cx: &LateContext<'tcx>, mut expr: &'a Expr
180181}
181182
182183/// Finds the initializer expression for a local binding. Returns `None` if the binding is mutable.
184+ ///
183185/// By only considering immutable bindings, we guarantee that the returned expression represents the
184186/// value of the binding wherever it is referenced.
185187///
@@ -428,12 +430,12 @@ pub fn qpath_generic_tys<'tcx>(qpath: &QPath<'tcx>) -> impl Iterator<Item = &'tc
428430 } )
429431}
430432
431- /// THIS METHOD IS DEPRECATED and will eventually be removed since it does not match against the
433+ /// THIS METHOD IS DEPRECATED. Matches a `QPath` against a slice of segment string literals.
434+ ///
435+ /// This method is deprecated and will eventually be removed since it does not match against the
432436/// entire path or resolved `DefId`. Prefer using `match_def_path`. Consider getting a `DefId` from
433437/// `QPath::Resolved.1.res.opt_def_id()`.
434438///
435- /// Matches a `QPath` against a slice of segment string literals.
436- ///
437439/// There is also `match_path` if you are dealing with a `rustc_hir::Path` instead of a
438440/// `rustc_hir::QPath`.
439441///
@@ -482,12 +484,12 @@ pub fn is_path_diagnostic_item<'tcx>(
482484 path_def_id ( cx, maybe_path) . map_or ( false , |id| cx. tcx . is_diagnostic_item ( diag_item, id) )
483485}
484486
485- /// THIS METHOD IS DEPRECATED and will eventually be removed since it does not match against the
487+ /// THIS METHOD IS DEPRECATED. Matches a `Path` against a slice of segment string literals.
488+ ///
489+ /// This method is deprecated and will eventually be removed since it does not match against the
486490/// entire path or resolved `DefId`. Prefer using `match_def_path`. Consider getting a `DefId` from
487491/// `QPath::Resolved.1.res.opt_def_id()`.
488492///
489- /// Matches a `Path` against a slice of segment string literals.
490- ///
491493/// There is also `match_qpath` if you are dealing with a `rustc_hir::QPath` instead of a
492494/// `rustc_hir::Path`.
493495///
@@ -903,6 +905,7 @@ pub fn is_default_equivalent_call(cx: &LateContext<'_>, repl_func: &Expr<'_>) ->
903905}
904906
905907/// Returns true if the expr is equal to `Default::default()` of it's type when evaluated.
908+ ///
906909/// It doesn't cover all cases, for example indirect function calls (some of std
907910/// functions are supported) but it is the best we have.
908911pub fn is_default_equivalent ( cx : & LateContext < ' _ > , e : & Expr < ' _ > ) -> bool {
@@ -1059,6 +1062,7 @@ impl std::ops::BitOrAssign for CaptureKind {
10591062}
10601063
10611064/// Given an expression referencing a local, determines how it would be captured in a closure.
1065+ ///
10621066/// Note as this will walk up to parent expressions until the capture can be determined it should
10631067/// only be used while making a closure somewhere a value is consumed. e.g. a block, match arm, or
10641068/// function argument (other than a receiver).
@@ -2361,8 +2365,9 @@ pub fn fn_def_id_with_node_args<'tcx>(
23612365}
23622366
23632367/// Returns `Option<String>` where String is a textual representation of the type encapsulated in
2364- /// the slice iff the given expression is a slice of primitives (as defined in the
2365- /// `is_recursively_primitive_type` function) and `None` otherwise.
2368+ /// the slice iff the given expression is a slice of primitives.
2369+ ///
2370+ /// (As defined in the `is_recursively_primitive_type` function.) Returns `None` otherwise.
23662371pub fn is_slice_of_primitives ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> Option < String > {
23672372 let expr_type = cx. typeck_results ( ) . expr_ty_adjusted ( expr) ;
23682373 let expr_kind = expr_type. kind ( ) ;
0 commit comments