Skip to content

optimize attribute can be applied to anything #128488

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
oli-obk opened this issue Aug 1, 2024 · 5 comments
Open

optimize attribute can be applied to anything #128488

oli-obk opened this issue Aug 1, 2024 · 5 comments
Assignees
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. F-optimize_attribute `#![feature(optimize_attribute)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Aug 1, 2024

I tried this code:

#![feature(optimize_attribute)]
#[optimize(cake, bar, foo, bop)]
type Foo = ();

I expected to see this happen: compilation failure because of attribute on an item where it makes no sense

Instead, this happened: compiled successfully

Meta

rustc --version --verbose:

1.82.0-nightly

2024-07-31 28a58f2fa7f0c46b8fab

cc #54882

see #128444 for where to fix this issue

@oli-obk oli-obk added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. C-bug Category: This is a bug. labels Aug 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 1, 2024
@clubby789
Copy link
Contributor

I think #128458 should have fixed this

@clubby789
Copy link
Contributor

warning: attribute should be applied to function or closure
 --> poc.rs:2:1
  |
2 | #[optimize(cake, bar, foo, bop)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default

It emits unused_attributes since that's what's specified in the RFC. Perhaps that should be amended to an error, which would be more consistent with other diagnostics like this

@clubby789 clubby789 removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 1, 2024
@fmease fmease added A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 1, 2024
@ibilalkayy
Copy link
Contributor

Is this issue still available to work on?

@Borgerr
Copy link
Contributor

Borgerr commented Aug 10, 2024

@rustbot claim

@Borgerr
Copy link
Contributor

Borgerr commented Aug 10, 2024

I'll be submitting a PR for this in case the RFC dictates errors in place of warnings, at least in this instance.

Borgerr added a commit to Borgerr/rust that referenced this issue Aug 10, 2024
Borgerr added a commit to Borgerr/rust that referenced this issue Aug 11, 2024
@jieyouxu jieyouxu added T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Aug 13, 2024
Borgerr added a commit to Borgerr/rust that referenced this issue Oct 17, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 20, 2024
…ute, r=jieyouxu

`optimize` attribute applied to things other than methods/functions/c…

…losures gives an error (rust-lang#128488)

Duplicate of rust-lang#128943, which I had accidentally closed when rebasing.

cc. `@jieyouxu` `@compiler-errors` `@nikomatsakis` `@traviscross` `@pnkfelix.`
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 21, 2024
Rollup merge of rust-lang#131814 - Borgerr:misapplied-optimize-attribute, r=jieyouxu

`optimize` attribute applied to things other than methods/functions/c…

…losures gives an error (rust-lang#128488)

Duplicate of rust-lang#128943, which I had accidentally closed when rebasing.

cc. `@jieyouxu` `@compiler-errors` `@nikomatsakis` `@traviscross` `@pnkfelix.`
@Noratrieb Noratrieb added the F-optimize_attribute `#![feature(optimize_attribute)]` label Mar 9, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. F-optimize_attribute `#![feature(optimize_attribute)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants