Skip to content

Commit ac48e09

Browse files
committed
Simplify snippet body by forwarding to snippet_opt
1 parent a33930f commit ac48e09

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clippy_lints/src/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ pub fn get_item_name(cx: &LateContext, expr: &Expr) -> Option<Name> {
385385
/// snippet(cx, expr.span, "..")
386386
/// ```
387387
pub fn snippet<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
388-
cx.sess().codemap().span_to_snippet(span).map(From::from).unwrap_or_else(|_| Cow::Borrowed(default))
388+
snippet_opt(cx, span).map_or_else(|| Cow::Borrowed(default), From::from)
389389
}
390390

391391
/// Convert a span to a code snippet. Returns `None` if not available.

0 commit comments

Comments
 (0)