Skip to content

bytes!(..).to_owned() does not work in statement position #8770

Closed

Description

@lilyball

The expression bytes!("foo").to_owned() works when placed in an expression position, as in let x = bytes!("foo").to_owned(). However, it does not work in a statement position, as in just bytes!("foo").to_owned() by itself:

error: unexpected token: `.`
 bytes!("/bar").to_owned()
               ^

Activity

  1. lilyball commented on Aug 26, 2013

    @lilyball
    ContributorAuthor

    Looks like env!() has the same problem. I'm guessing this is common to all normal syntax extensions.

  2. lilyball commented on Aug 26, 2013

    @lilyball
    ContributorAuthor

    This affects macros as well

    macro_rules! foo(() => ([3]))
    foo().to_owned()
    
    Untitled.rs:3:10: 3:11 error: unexpected token: `.`
    Untitled.rs:3     foo!().to_owned()
                            ^
    
  3. huonw commented on Aug 26, 2013

    @huonw
    Contributor

    Looks like a dup of #5941. (foo!()).to_owned() should work.

  4. added a commit that references this issue on Jul 18, 2022
    7142a59
  5. added a commit that references this issue on Aug 21, 2026
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

      Issue actions