Skip to content

Commit d718865

Browse files
committed
Skip name replacement in comments and strings
1 parent 9cc0388 commit d718865

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/macros.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use syntax::tokenstream::{Cursor, ThinTokenStream, TokenStream, TokenTree};
3333
use syntax::util::ThinVec;
3434

3535
use codemap::SpanUtils;
36-
use comment::{contains_comment, remove_trailing_white_spaces, FindUncommented};
36+
use comment::{contains_comment, remove_trailing_white_spaces, CharClasses, FindUncommented,
37+
FullCodeCharKind};
3738
use expr::rewrite_array;
3839
use lists::{itemize_list, write_list, ListFormatting};
3940
use overflow;
@@ -409,8 +410,10 @@ fn replace_names(input: &str) -> Option<(String, HashMap<String, String>)> {
409410
let mut dollar_count = 0;
410411
let mut cur_name = String::new();
411412

412-
for c in input.chars() {
413-
if c == '$' {
413+
for (kind, c) in CharClasses::new(input.chars()) {
414+
if kind != FullCodeCharKind::Normal {
415+
result.push(c);
416+
} else if c == '$' {
414417
dollar_count += 1;
415418
} else if dollar_count == 0 {
416419
result.push(c);

0 commit comments

Comments
 (0)