Skip to content

Do not convert doc comments into #[doc = "..."] form unless necessary for macros #60935

Closed

Description

@petrochenkov

Keep them as tokens in AST, this may partially mitigate the perf impact from turning normal comments into doc comments (#60930).

pub struct Attribute {
    pub id: AttrId,
    pub style: AttrStyle,
    pub path: Path,
    pub tokens: TokenStream,
    pub is_sugared_doc: bool,
    pub span: Span,
}

=>

pub struct Attribute {
    pub kind: AttrKind,
    pub span: Span,
    pub id: AttrId,
}

pub enum AttrKind {
    Normal(Path, TokenStream, AttrStyle),
    Doc(Symbol),
}

Activity

  1. added
    I-slowIssue: Problems and improvements with respect to performance of generated code.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on May 18, 2019
  2. added
    I-compiletimeIssue: Problems and improvements with respect to compile times.
    and removed
    I-slowIssue: Problems and improvements with respect to performance of generated code.
    on May 18, 2019
  3. nnethercote commented on Oct 23, 2019

    @nnethercote
    Contributor

    Because TokenStream contains a Lrc<Vec<TreeAndJoint>>, this would avoid two allocations per doc comment line: one for the Lrc and one for the Vec. That would get a big chunk of the potential saving. (We would still need one symbol interning per line, which involves a TLS access and a hash table.)

  4. nnethercote commented on Oct 23, 2019

    @nnethercote
    Contributor

    I have a local patch that changes TokenStream to a Lrc<SmallVec<[TreeAndJoint; 2]>>. It's a clear win, but it only gets rid of one of the allocations, so the approach suggested in this PR has a greater potential.

  5. nnethercote commented on Oct 24, 2019

    @nnethercote
    Contributor

    I have implemented this idea in #65750. It works well!

  6. added a commit that references this issue on Nov 6, 2019
    eea6f23
  7. added a commit that references this issue on Nov 7, 2019
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

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions