Skip to content

stringify! space adds strange space before :tt symbol #65940

@stevenroose

Description

@stevenroose

Ok sorry for the strange title at first, that was my search query entered in a wrong text box.

So I'm trying to use a macro to use a string and prefix it for usage in a build tag.

But the issue is quite well summed up in this code snippet:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9905252de14993fa6a31b3c73c5d0a01

The result is prefix_ doe. Note the space.

Seems to be related to #55658. But in his example he does some much more complex things.

Activity

changed the title [-]stringify space[/-] [+]stringify! space adds strange space before :tt symbol[/+] on Oct 29, 2019
ExpHP

ExpHP commented on Oct 29, 2019

@ExpHP
Contributor

Yes. You stringified two identifiers, so the output deliberately contains a space to ensure it contains two identifiers.

If you need to concatenate identifiers, look at the paste crate.

Alternatively, since you're already stringifying:

concat!("prefix_", stringify!($symbol))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @stevenroose@Centril@ExpHP

        Issue actions

          stringify! space adds strange space before :tt symbol · Issue #65940 · rust-lang/rust