File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -134,13 +134,13 @@ impl LateLintPass for StringLitAsBytes {
134
134
fn check_expr ( & mut self , cx : & LateContext , e : & Expr ) {
135
135
use std:: ascii:: AsciiExt ;
136
136
use syntax:: ast:: Lit_ :: LitStr ;
137
- use utils:: snippet;
137
+ use utils:: { snippet, in_macro } ;
138
138
139
139
if let ExprMethodCall ( ref name, _, ref args) = e. node {
140
140
if name. node . as_str ( ) == "as_bytes" {
141
141
if let ExprLit ( ref lit) = args[ 0 ] . node {
142
142
if let LitStr ( ref lit_content, _) = lit. node {
143
- if lit_content. chars ( ) . all ( |c| c. is_ascii ( ) ) {
143
+ if lit_content. chars ( ) . all ( |c| c. is_ascii ( ) ) && ! in_macro ( cx , e . span ) {
144
144
let msg = format ! ( "calling `as_bytes()` on a string literal. \
145
145
Consider using a byte string literal instead: \
146
146
`b{}`",
You can’t perform that action at this time.
0 commit comments