-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide access to item attributes #83
Comments
@rustbot claim |
My plan:
Is this design okay? |
That's a great start! Maybe add I would like to eventually expose the |
Or we could provide a |
Good idea. Perhaps I should start with
|
Support fetching `Attribute` of items. Fixes [https://github.com/rust-lang/project-stable-mir/issues/83](https://github.com/rust-lang/project-stable-mir/issues/83) `rustc_ast::ast::Attribute` doesn't impl `Hash` and `Eq`. Thus it cannot be directly used as key of `IndexMap` in `rustc_smir::rustc_smir::Tables` and we cannot define stable `Attribute` as index to `rustc_ast::ast::Attribute` like `Span` and many other stable definitions. Since an string (or tokens) and its span contain all info about an attribute, I defined a simple `Attribute` struct on stable side. I choose to fetch attributes via `tcx::get_attrs_by_path()` due to `get_attrs()` is marked as deprecated and `get_attrs_by_name()` cannot handle name of multiple segments like `rustfmt::skip`. r? `@celinval`
Rollup merge of rust-lang#127022 - adwinwhite:attrs, r=celinval Support fetching `Attribute` of items. Fixes [https://github.com/rust-lang/project-stable-mir/issues/83](https://github.com/rust-lang/project-stable-mir/issues/83) `rustc_ast::ast::Attribute` doesn't impl `Hash` and `Eq`. Thus it cannot be directly used as key of `IndexMap` in `rustc_smir::rustc_smir::Tables` and we cannot define stable `Attribute` as index to `rustc_ast::ast::Attribute` like `Span` and many other stable definitions. Since an string (or tokens) and its span contain all info about an attribute, I defined a simple `Attribute` struct on stable side. I choose to fetch attributes via `tcx::get_attrs_by_path()` due to `get_attrs()` is marked as deprecated and `get_attrs_by_name()` cannot handle name of multiple segments like `rustfmt::skip`. r? `@celinval`
Let's resolve this for now. We can always add |
A definition in Rust can have attributes attached to them, .e.g., tool attributes. They are used by different tools to add metadata to the user code that can provide more information on how the code must be analyzed.
StableMIR should provide an API to retrieve the attributes of a crate definition. We can probably add a new method to the
CrateDef
that returns a list ofAttributes
attached to them.The text was updated successfully, but these errors were encountered: