Skip to content

Commit

Permalink
Ensure generated expressions parse as block expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jul 25, 2023
1 parent 4c47778 commit cd283d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cast_checks/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ fn checked_float() {
fn inferred_type(x: f64) -> i32 {
x as _
}

#[allow(dead_code, clippy::cast_lossless)]
#[cast_checks::enable]
fn block_expression(x: u32) -> f64 {
x as f64 / 2.0
}
4 changes: 2 additions & 2 deletions macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl VisitMut for Visitor {
let msg = { String::from("invalid cast") };

*expr = parse_quote_spanned! { expr.span() =>
{
({
#[allow(unused_imports)]
use cast_checks::MaybeTryIntoFallback;

Expand All @@ -95,7 +95,7 @@ impl VisitMut for Visitor {
} else {
#operand as #ty
}
}
})
};
}
}
Expand Down

0 comments on commit cd283d9

Please sign in to comment.