Repository navigation
Report unknown attributes and unknown #[test] arguments - #2041
Open
vaibhav4046 wants to merge 1 commit into
Open
vaibhav4046 wants to merge 1 commit into
vaibhav4046 wants to merge 1 commit into
Conversation
An attribute name the compiler doesn't act on anywhere, such as a misspelled `#[mustuse]`, was accepted silently, so a typo could turn off the check the attribute stands for. It is now an error (12-0008) on every item, associated item, field, variant, msg variant and for loop, with a "did you mean" suggestion when a known name is close. Recv arms, init blocks and recv blocks keep their existing restricted-context check (12-0004), so they are not reported twice. Items dropped by a `#[cfg]` that doesn't hold are not checked. `#[test(..)]` now accepts only the keys `fe test` reads (`should_revert`, `panic`, `selector`, `balance`); an unknown key such as `#[test(timestamp = 1000)]` was ignored and is now reported as an invalid form (12-0002). Values are still checked by `fe test`.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2035.
An attribute name the compiler doesn't act on anywhere, such as a misspelled
#[mustuse], is accepted silently today, so a typo turns off the check the attribute stands for. Recv arms already refuse unknown attributes (12-0004); this extends that to everything else.12-0008) on every item, associated item, field, variant, msg variant andforloop, with a "did you mean" suggestion when a known name is close (#[mustuse]->#[must_use]).#[cfg]that doesn't hold are not checked.#[test(..)]accepts only the keysfe testreads (should_revert,panic,selector,balance). An unknown key such as#[test(timestamp = 1000)]was ignored and is now an invalid form (12-0002). Values are still checked byfe test.An error rather than a warning, to match the recv-arm check; happy to make it a warning if you prefer.
Tests
New uitest fixtures
ty_check/unknown_attrandty_check/attr_test_args. No existing snapshot changes, and std/core build unchanged, so no attribute in the repo was unknown to the list.cargo test --release --workspace --exclude fe-bench --no-fail-faston Windows: 2672 passed, 1 failed (mock_client_tests::mock_lsp_checks_for_the_project_target, which fails the same way on unmodifiedmasterthere).Found while building HARDSTOP, a Fe Builders Challenge entry, whose CI also applies this patch and runs these fixtures. Written with AI assistance (Claude); the tests above were run locally on this branch.