Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle "Show invisible delimeters (within comments)" change in rustc #47

Merged
merged 1 commit into from May 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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