File tree 2 files changed +7
-8
lines changed
2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 1
1
// error-pattern:cargo-clippy
2
2
3
+ #![ feature( bind_by_move_pattern_guards) ] // proposed to be stabilized in Rust v1.39
3
4
#![ feature( box_syntax) ]
4
5
#![ feature( box_patterns) ]
5
6
#![ feature( never_type) ]
Original file line number Diff line number Diff line change @@ -430,15 +430,13 @@ impl EarlyLintPass for MiscEarlyLints {
430
430
431
431
impl MiscEarlyLints {
432
432
fn check_lit ( self , cx : & EarlyContext < ' _ > , lit : & Lit ) {
433
- // The `line!()` macro is compiler built-in and a special case for these lints.
433
+ // We test if first character in snippet is a number, because the snippet could be an expansion
434
+ // from a built-in macro like `line!()` or a proc-macro like `#[wasm_bindgen]`.
435
+ // Note that this check also covers special case that `line!()` is eagerly expanded by compiler.
436
+ // See <https://github.com/rust-lang/rust-clippy/issues/4507> for a regression.
437
+ // FIXME: Find a better way to detect those cases.
434
438
let lit_snip = match snippet_opt ( cx, lit. span ) {
435
- Some ( snip) => {
436
- // The snip could be empty in case of expand from procedure macro
437
- if snip. is_empty ( ) || snip. contains ( '!' ) {
438
- return ;
439
- }
440
- snip
441
- } ,
439
+ Some ( snip) if snip. chars ( ) . next ( ) . map_or ( false , |c| c. is_digit ( 10 ) ) => snip,
442
440
_ => return ,
443
441
} ;
444
442
You can’t perform that action at this time.
0 commit comments