Skip to content

Commit

Permalink
Merge pull request #47 from dtolnay/invisible
Browse files Browse the repository at this point in the history
Handle "Show invisible delimeters (within comments)" change in rustc
  • Loading branch information
dtolnay committed May 6, 2022
2 parents 6366908 + 09cdeb4 commit 14f7e7e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib.rs
Expand Up @@ -323,7 +323,17 @@ fn try_expand(input: TokenStream, mode: Macro) -> Result<TokenStream> {

fn lit_indoc(token: TokenTree, mode: Macro) -> Result<Literal> {
let repr = token.to_string();
let repr = repr.trim();
let mut repr = repr.trim();

// https://github.com/rust-lang/rust/pull/96682
let invisible_delimiter_prefix = "/*«*/";
let invisible_delimiter_suffix = "/*»*/";
if repr.starts_with(invisible_delimiter_prefix) && repr.ends_with(invisible_delimiter_suffix) {
repr = repr
[invisible_delimiter_prefix.len()..repr.len() - invisible_delimiter_suffix.len()]
.trim();
}

let is_string = repr.starts_with('"') || repr.starts_with('r');
let is_byte_string = repr.starts_with("b\"") || repr.starts_with("br");

Expand Down

0 comments on commit 14f7e7e

Please sign in to comment.