Skip to content

Commit efe86a4

Browse files
committed
Remove raw pre and suffixes from string attr literals
1 parent 1caaa20 commit efe86a4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/hir_def/src/attr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,11 @@ impl Attr {
195195
fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> {
196196
let path = ModPath::from_src(ast.path()?, hygiene)?;
197197
let input = if let Some(lit) = ast.literal() {
198-
// FIXME: escape? raw string?
199-
let value = lit.syntax().first_token()?.text().trim_matches('"').into();
198+
let value = if let ast::LiteralKind::String(string) = lit.kind() {
199+
string.value()?.into()
200+
} else {
201+
lit.syntax().first_token()?.text().trim_matches('"').into()
202+
};
200203
Some(AttrInput::Literal(value))
201204
} else if let Some(tt) = ast.token_tree() {
202205
Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0))

0 commit comments

Comments
 (0)