Stream: t-compiler/rust-analyzer

Topic: Difference between Name and NameRef


Lukas Wirth (Nov 03 2020 at 19:21, on Zulip):

I might be blind and just didn't see anything explaining it but what exactly is the difference between ast::Name and ast::NameRef?

matklad (Nov 03 2020 at 19:23, on Zulip):
fn foo() { foo() }

The first foo is Name, the second one is NameRef

matklad (Nov 03 2020 at 19:23, on Zulip):

Names define things in scope, NameRefs use previously defined names

matklad (Nov 03 2020 at 19:23, on Zulip):

You mostly can figure which is which syntactically

Lukas Wirth (Nov 03 2020 at 19:23, on Zulip):

Ah so it is just that, alright.

Lukas Wirth (Nov 03 2020 at 19:23, on Zulip):

Is there a way to go from one to the other?

Lukas Wirth (Nov 03 2020 at 19:24, on Zulip):

I seem to need that for the make module

Lukas Wirth (Nov 03 2020 at 19:24, on Zulip):

for make::record_field to be precise, it currently takes a ast::NameRef due to one use

matklad (Nov 03 2020 at 19:24, on Zulip):

Yup, you need make for that

Lukas Wirth (Nov 03 2020 at 19:24, on Zulip):

but i only got an ast::Name now

Lukas Wirth (Nov 03 2020 at 19:25, on Zulip):

ah oaky i guess i can do it via make :sweat_smile:

matklad (Nov 03 2020 at 19:25, on Zulip):

make::name_ref(name.text()) or smth along this lines would work

Lukas Wirth (Nov 03 2020 at 19:25, on Zulip):

thanks :thumbs_up:

Last update: Jul 29 2021 at 20:30UTC