Add allowed list check on EII implementations attributes#159173
Conversation
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
23be887 to
9c36383
Compare
This comment has been minimized.
This comment has been minimized.
9c36383 to
81a1b49
Compare
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_hir/src/attrs |
81a1b49 to
c7cb405
Compare
This comment has been minimized.
This comment has been minimized.
|
Maybe we ought to have an allowlist of attributes rather than error on these particular attributes? I'm also a bit worried about someone later down the line adding some new (possibly link related) attribute and not including it in this check. |
c7cb405 to
8e3fe6d
Compare
maybe allowlist contains |
|
Seems like a reasonable list. |
I tried to get a more overwhole status on eii, this #125418 is the best place to track. |
|
I don't know if the current EII syntax is expected to be stabilized eventually or if the intent is for the syntax from the RFC to be implemented eventually with |
|
For reference, attributes on eii declarations are handled via allowlist: rust/compiler/rustc_builtin_macros/src/eii.rs Lines 180 to 228 in da80ed0 I would expect attributes on implementations to be handled similarly.
It's an experiment so we can diverge from the original proposal. Once we are happy with the implementation the rfc should be updated accordingly. |
35bc796 to
30cc6b4
Compare
| } | ||
|
|
||
| // Check EII implementation attributes with a allowed list | ||
| fn check_eii_impl_attrs(&self, attrs: &[Attribute], eii_impls: &[EiiImpl]) { |
There was a problem hiding this comment.
I moved the checking to here in ast_validation, since macro expansion finished,
and leaves the final attributes, similar with
https://github.com/chenyukang/rust/blob/30cc6b46e8bb20318b05443cb80f1e50119ba971/compiler/rustc_ast_passes/src/ast_validation.rs#L522-L532
the old place where depends on HIR, HIR converts some attributes into variants without a uniform path or span.
There was a problem hiding this comment.
I think the current location is the best we can currently do.
Integrating this into the attribute parsing system somehow would be ideal, but I don't see a way to do this. Doing this after attribute parsing (like in the HIR) is not desirable since the spans are gone then.
This comment has been minimized.
This comment has been minimized.
30cc6b4 to
265407a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| sym::cfg_trace, | ||
| sym::cfg_attr_trace, |
There was a problem hiding this comment.
no, we need to remove them.
265407a to
4e53ac1
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@bors r=JonathanBrouwer |
…ngle-eii, r=JonathanBrouwer Add allowed list check on EII implementations attributes Fixes rust-lang#158293 Fixes rust-lang#159015 r? @bjorn3
Rollup of 18 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #150161 (Remove 'static requirement on try_as_dyn) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159466 (cmse: clear variant-dependent padding in `enum`s) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs) - #159041 (Reorganize `tests/ui/issues` [22/N]) - #159108 (Reorganize `tests/ui/issues` [23/N]) - #159138 (doc: document wasm import symbol mangling) - #159531 (Reorganize `tests/ui/issues` [28/N]) - #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable) - #159612 (Reorganize `tests/ui/issues` [29/N]) - #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`) - #159759 (rustc-dev-guide subtree update) - #159761 (Remove outdated comment for resolve_vars_with_obligations)
…ngle-eii, r=JonathanBrouwer Add allowed list check on EII implementations attributes Fixes rust-lang#158293 Fixes rust-lang#159015 r? @bjorn3
…ngle-eii, r=JonathanBrouwer Add allowed list check on EII implementations attributes Fixes rust-lang#158293 Fixes rust-lang#159015 r? @bjorn3
Rollup of 19 pull requests Successful merges: - #150161 (Remove 'static requirement on try_as_dyn) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159466 (cmse: clear variant-dependent padding in `enum`s) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159041 (Reorganize `tests/ui/issues` [22/N]) - #159108 (Reorganize `tests/ui/issues` [23/N]) - #159138 (doc: document wasm import symbol mangling) - #159531 (Reorganize `tests/ui/issues` [28/N]) - #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable) - #159612 (Reorganize `tests/ui/issues` [29/N]) - #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`) - #159667 (Make some parser structured suggestions verbose and tweak their wording) - #159759 (rustc-dev-guide subtree update) - #159761 (Remove outdated comment for resolve_vars_with_obligations)
…ngle-eii, r=JonathanBrouwer Add allowed list check on EII implementations attributes Fixes rust-lang#158293 Fixes rust-lang#159015 r? @bjorn3
…ngle-eii, r=JonathanBrouwer Add allowed list check on EII implementations attributes Fixes rust-lang#158293 Fixes rust-lang#159015 r? @bjorn3
…ngle-eii, r=JonathanBrouwer Add allowed list check on EII implementations attributes Fixes rust-lang#158293 Fixes rust-lang#159015 r? @bjorn3
…ngle-eii, r=JonathanBrouwer Add allowed list check on EII implementations attributes Fixes rust-lang#158293 Fixes rust-lang#159015 r? @bjorn3
Rollup of 12 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
Rollup of 14 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #158372 (rustfmt: Discover modules via `cfg_select!`) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #159731 (std: Implement futex on wasip3 targets, update target spec) - #159755 (Improve consistency of attribute error messages) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
View all comments
Fixes #158293
Fixes #159015
r? @bjorn3