Skip to content

More information on attributes #104

Open
@phansch

Description

@phansch

I recently wrote a clippy lint that deals with attributes (mostly outer attributes) and found very little information on how they are implemented. Most of the information I gathered through PR comments and issues in the rust repo. The reference only explains how to use the different attributes.

Do you think it would make sense to have a chapter on attributes in the guide?

Some weird things and questions I came across:

  • The AST seems to contain attributes that are not in the actual source code (Is this because of macro expansion?) (Warn on empty lines after outer attributes rust-clippy#2340 (comment))
  • some expanded attributes seem to have an empty TokenStream and some not
  • cfg_attr is special somehow
  • In general lots of inconsistencies in the data from the syntax crate?

I would be happy to start something myself, but would need some pointers as to where the attribute stuff happens.

Metadata

Metadata

Assignees

Labels

A-ASTArea: abstract syntax treeA-HIRArea: high-level intermediate representation (HIR)A-attributesArea: attributesC-enhancementCategory: enhancementE-hardDifficulty: might require advanced knowledgeT-compilerRelevant to compiler team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions