Skip to content

Parse results of block doc comments are different between 1.0.13 and 1.0.14 #242

@magurotuna

Description

@magurotuna

Let me take the following code (focusing on a block doc comment) as an example:

/** foo */
fn bar() {}

I attempted to parse the above code using syn::parse_file.

In proc-macro2 v1.0.14+, the output of parsing looks like:

Attribute {
    pound_token: Pound,
    style: Outer,
    bracket_token: Bracket,
    path: Path {
        leading_colon: None,
        segments: [
            PathSegment {
                ident: Ident(
                    doc,
                ),
                arguments: None,
            },
        ],
    },
    tokens: TokenStream [
        Punct {
            op: '=',
            spacing: Alone,
        },
        Literal {
            lit: " foo ", // <------------ (*)
        },
    ],
},

while in v1.0.13, the output is:

Attribute {
    pound_token: Pound,
    style: Outer,
    bracket_token: Bracket,
    path: Path {
        leading_colon: None,
        segments: [
            PathSegment {
                ident: Ident(
                    doc,
                ),
                arguments: None,
            },
        ],
    },
    tokens: TokenStream [
        Punct {
            op: '=',
            spacing: Alone,
        },
        Literal {
            lit: "/** foo */", // <------------ (*)
        },
    ],
},

Seeing the line marked with <--- (*), the results are different. This is probably a breaking change to the users.
In my opinion, according to semantic versioning, the major version should have been updated. What do you think about it?

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