Skip to content

Missing span information for inner attributes in input TokenStream of procedural macro attribute. #52162

@peterhuene

Description

@peterhuene

Overview

When an outer procedural macro attribute is executed, the provided TokenStream is missing span information for the inner attributes.

Example:

#[repro]
#[magic(foo = "bar")]
pub fn test() {}

For the above, the repro attribute is a procedural macro attribute. The magic attribute is actually something that the repro attribute respects and strips off when generating the code.

However, the span information for the magic attribute is missing from the TokenStream given to the repro procedural macro attribute.

Repro Steps

  1. git clone https://github.com/peterhuene/inner-attr-span-repro
  2. cargo build

Expected Results

The inner magic attribute has span information in the input TokenStream.

Actual Results

The inner magic attribute has span information that is #0 bytes(0..0) for all tokens of the inner attribute.

This prevents useful diagnostics on the inner attributes since only error messages can be emitted.

System Information

$ rustc --version
rustc 1.29.0-nightly (9fd3d7899 2018-07-07)
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.13.5
BuildVersion:   17F77

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