Skip to content

Commit b88cebf

Browse files
committed
Add macro check
1 parent 01eda52 commit b88cebf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/strings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ impl LateLintPass for StringLitAsBytes {
134134
fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
135135
use std::ascii::AsciiExt;
136136
use syntax::ast::Lit_::LitStr;
137-
use utils::snippet;
137+
use utils::{snippet, in_external_macro};
138138

139139
if let ExprMethodCall(ref name, _, ref args) = e.node {
140140
if name.node.as_str() == "as_bytes" {
141141
if let ExprLit(ref lit) = args[0].node {
142142
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_external_macro(cx, e.span) {
144144
let msg = format!("calling `as_bytes()` on a string literal. \
145145
Consider using a byte string literal instead: \
146146
`b{}`",

0 commit comments

Comments
 (0)