Skip to content

Comments

util/attributes: Error on malformed lint attributes#4358

Merged
P-E-P merged 1 commit intoRust-GCC:masterfrom
Pasta-coder:fix/allow-malformed-4225
Jan 27, 2026
Merged

util/attributes: Error on malformed lint attributes#4358
P-E-P merged 1 commit intoRust-GCC:masterfrom
Pasta-coder:fix/allow-malformed-4225

Conversation

@Pasta-coder
Copy link
Contributor

The lint attributes (allow, deny, warn, forbid) require arguments specifying which lints to affect. Using them without arguments (e.g. #[allow]) is invalid. This patch adds validation to reject empty lint attributes.

Fixes #4225

gcc/rust/ChangeLog:

* util/rust-attributes.cc: Check for empty lint attributes.

gcc/testsuite/ChangeLog:

* rust/compile/allow-malformed.rs: New test.

@Pasta-coder Pasta-coder force-pushed the fix/allow-malformed-4225 branch from e2442c7 to a047314 Compare January 5, 2026 08:04
@Pasta-coder Pasta-coder marked this pull request as draft January 6, 2026 13:26
@Pasta-coder
Copy link
Contributor Author

drafted to resolve merge conflicts

Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 16, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes Rust-GCC#4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/allow-malformed.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@Pasta-coder Pasta-coder force-pushed the fix/allow-malformed-4225 branch from a047314 to f262c54 Compare January 16, 2026 16:58
@Pasta-coder Pasta-coder marked this pull request as ready for review January 16, 2026 16:58
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 16, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes Rust-GCC#4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@Pasta-coder Pasta-coder force-pushed the fix/allow-malformed-4225 branch from f262c54 to c84343e Compare January 16, 2026 17:06
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 16, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes Rust-GCC#4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@Pasta-coder Pasta-coder force-pushed the fix/allow-malformed-4225 branch from c84343e to 4278810 Compare January 16, 2026 17:49
@Pasta-coder
Copy link
Contributor Author

@P-E-P please review .

thankyou

Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 25, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes Rust-GCC#4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@Pasta-coder Pasta-coder force-pushed the fix/allow-malformed-4225 branch from 4278810 to 753a832 Compare January 25, 2026 21:33
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 25, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes Rust-GCC#4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@Pasta-coder Pasta-coder force-pushed the fix/allow-malformed-4225 branch from 753a832 to e00541c Compare January 25, 2026 21:34
@Pasta-coder
Copy link
Contributor Author

@P-E-P requested line added .

thankyou

@P-E-P P-E-P added this pull request to the merge queue Jan 26, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 26, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes #4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 26, 2026
@P-E-P
Copy link
Member

P-E-P commented Jan 26, 2026

Argh, forgot I just merged a PR that kinda breaks most tests. You need to prefix your test with those two lines:

#![feature(no_core)]
#![no_core]

We're now injecting it by default in every crate that does not have the #![no_core] attribute. Sorry for the inconvenience.

Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes Rust-GCC#4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@Pasta-coder Pasta-coder force-pushed the fix/allow-malformed-4225 branch from e00541c to 2db7449 Compare January 26, 2026 22:16
@Pasta-coder
Copy link
Contributor Author

@P-E-P no problem .

i added those lines .

@P-E-P P-E-P added this pull request to the merge queue Jan 27, 2026
Merged via the queue into Rust-GCC:master with commit b98bdc9 Jan 27, 2026
12 checks passed
@Pasta-coder Pasta-coder deleted the fix/allow-malformed-4225 branch January 27, 2026 14:36
dkm pushed a commit that referenced this pull request Jan 28, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes #4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
dkm pushed a commit that referenced this pull request Feb 14, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes #4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
dkm pushed a commit that referenced this pull request Feb 14, 2026
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].

Fixes #4358

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_lint_attribute): New helper.
	(AttributeChecker::visit): Call helper for lint attributes on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4225.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

malformed allow attribute should give error

2 participants