mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Encode ident rawness and literal kind separately in tt::Leaf
This commit is contained in:
parent
5784915618
commit
e846c04fbe
33 changed files with 860 additions and 412 deletions
|
@ -605,7 +605,7 @@ impl<'attr> AttrQuery<'attr> {
|
|||
.nth(2);
|
||||
|
||||
match name {
|
||||
Some(tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal{ ref text, ..}))) => Some(text),
|
||||
Some(tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal{ text, kind: tt::LitKind::Str | tt::LitKind::StrRaw(_) , ..}))) => Some(text),
|
||||
_ => None
|
||||
}
|
||||
})
|
||||
|
|
|
@ -250,7 +250,7 @@ pub(crate) fn parse(
|
|||
}
|
||||
}
|
||||
ArgRef::Name(name, span) => {
|
||||
let name = Name::new(name, call_ctx);
|
||||
let name = Name::new(name, tt::IdentIsRaw::No, call_ctx);
|
||||
if let Some((index, _)) = args.by_name(&name) {
|
||||
record_usage(name, span);
|
||||
// Name found in `args`, so we resolve it to its index.
|
||||
|
|
|
@ -460,13 +460,13 @@ fn test_concat_expand() {
|
|||
#[rustc_builtin_macro]
|
||||
macro_rules! concat {}
|
||||
|
||||
fn main() { concat!("fo", "o", 0, r#"bar"#, "\n", false, '"', '\0'); }
|
||||
fn main() { concat!("fo", "o", 0, r#""bar""#, "\n", false, '"', '\0'); }
|
||||
"##,
|
||||
expect![[r##"
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! concat {}
|
||||
|
||||
fn main() { "foo0bar\nfalse\"\u{0}"; }
|
||||
fn main() { "foo0\"bar\"\nfalse\"\u{0}"; }
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
@ -478,13 +478,13 @@ fn test_concat_bytes_expand() {
|
|||
#[rustc_builtin_macro]
|
||||
macro_rules! concat_bytes {}
|
||||
|
||||
fn main() { concat_bytes!(b'A', b"BC", [68, b'E', 70]); }
|
||||
fn main() { concat_bytes!(b'A', b"BC\"", [68, b'E', 70], br#"G""#,b'\0'); }
|
||||
"##,
|
||||
expect![[r#"
|
||||
#[rustc_builtin_macro]
|
||||
macro_rules! concat_bytes {}
|
||||
|
||||
fn main() { [b'A', 66, 67, 68, b'E', 70]; }
|
||||
fn main() { b"ABC\"DEFG\"\x00"; }
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1058,7 +1058,7 @@ macro_rules! concat {}
|
|||
macro_rules! line {}
|
||||
|
||||
fn main() {
|
||||
"event 0u32";
|
||||
"event 0";
|
||||
}
|
||||
|
||||
"##]],
|
||||
|
@ -1084,7 +1084,7 @@ fn main() {
|
|||
macro_rules! concat_bytes {}
|
||||
|
||||
fn main() {
|
||||
let x = /* error: unexpected token in input */[];
|
||||
let x = /* error: unexpected token in input */b"";
|
||||
}
|
||||
|
||||
"#]],
|
||||
|
|
|
@ -82,7 +82,7 @@ pub(super) fn collect_defs(db: &dyn DefDatabase, def_map: DefMap, tree_id: TreeI
|
|||
.iter()
|
||||
.enumerate()
|
||||
.map(|(idx, it)| {
|
||||
let name = Name::new(&it.name, ctx);
|
||||
let name = Name::new(&it.name, tt::IdentIsRaw::No, ctx);
|
||||
(
|
||||
name,
|
||||
if !db.expand_proc_attr_macros() {
|
||||
|
@ -2144,7 +2144,7 @@ impl ModCollector<'_, '_> {
|
|||
let name;
|
||||
let name = match attrs.by_key("rustc_builtin_macro").string_value_with_span() {
|
||||
Some((it, span)) => {
|
||||
name = Name::new(it, span.ctx);
|
||||
name = Name::new(it, tt::IdentIsRaw::No, span.ctx);
|
||||
&name
|
||||
}
|
||||
None => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue