Skip to content

Fix: mark relevant spans (ex: ident.span) with macro expansion context #66095

@Quantumplation

Description

@Quantumplation
Contributor

In #65830 it was discovered that hir::Item.ident.span isn't marked with_ctxt of being part of a macro expansion. This had two effects that we saw there:

  • error messages don't include the "in this macro invocation" hints
  • cases where the dead_code error was suppressed because of foreign macros were no longer suppressed

To solve that there, we're going to just use the old behavior when we're in the middle of a macro expansion already, so we don't use the un-marked span. As @estebank suggested, we should probably clean this up in a separate change.

Activity

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-cleanupCategory: PRs that clean code up or issues documenting cleanup.
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
on Nov 5, 2019
Quantumplation

Quantumplation commented on Nov 6, 2019

@Quantumplation
ContributorAuthor

@estebank when you get a chance could you (or someone else) provide some light mentorship here?
Specifically,

  • Where does item.span get constructed (so I can look at how the macro context gets attached)
  • Where does item.ident.span get filled in?
  • What other relevant spans should inherit this context?
  • Are there any gotchas I should consider?
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

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.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

        Participants

        @Quantumplation@Centril

        Issue actions

          Fix: mark relevant spans (ex: ident.span) with macro expansion context · Issue #66095 · rust-lang/rust