File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 11// error-pattern:cargo-clippy
22
3+ #![ feature( bind_by_move_pattern_guards) ] // proposed to be stabilized in Rust v1.39
34#![ feature( box_syntax) ]
45#![ feature( box_patterns) ]
56#![ feature( never_type) ]
Original file line number Diff line number Diff line change @@ -430,15 +430,13 @@ impl EarlyLintPass for MiscEarlyLints {
430430
431431impl MiscEarlyLints {
432432 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.
434438 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,
442440 _ => return ,
443441 } ;
444442
You can’t perform that action at this time.
0 commit comments