Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

Does not preserve invisible delimiters from declarative macros #85

@Kyuuhachi

Description

@Kyuuhachi

The below example requires parentheses around the $val to compile, which it doesn't without paste.

macro_rules! clone {
  ($val:expr) => {
    paste::paste! {
      $val.clone()
    }
  }
}

#[derive(Clone)]
struct A;

impl A {
  fn consume_self(self) {}
}

fn main() {
  clone!(&A).consume_self();
}

The correct resulting token tree would be ⟦⟦&A⟧.clone()⟧.consume_self(), but with paste, it appears to be flattened to ⟦&A.clone()⟧.consume_self().

The docs do say null delimiters might not survive roundtripping, but I think it should be possible to avoid here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions