Skip to content

Commit f15ac79

Browse files
committed
fix literal_string_with_formatting_args FP on format inside assert
1 parent 998c780 commit f15ac79

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clippy_lints/src/literal_string_with_formatting_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn emit_lint(cx: &LateContext<'_>, expr: &Expr<'_>, spans: &[(Span, Option<Strin
8181

8282
impl LateLintPass<'_> for LiteralStringWithFormattingArg {
8383
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
84-
if expr.span.from_expansion() {
84+
if expr.span.from_expansion() || expr.span.is_dummy() {
8585
return;
8686
}
8787
if let ExprKind::Lit(lit) = expr.kind {

tests/ui/literal_string_with_formatting_arg.rs

+6
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ fn main() {
3535
let x: Option<usize> = Some(0);
3636
x.expect("{…}");
3737
}
38+
39+
fn issue_13885() {
40+
let value = 0;
41+
dbg!(format!("{value}").is_empty()); // Nothing should happen
42+
assert!(format!("{value}").is_empty()); // Nothing should happen
43+
}

0 commit comments

Comments
 (0)