Skip to content
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

unused attribute warning when using multiple crate_type #95902

Closed
gheoan opened this issue Apr 10, 2022 · 1 comment · Fixed by #95910
Closed

unused attribute warning when using multiple crate_type #95902

gheoan opened this issue Apr 10, 2022 · 1 comment · Fixed by #95910
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gheoan
Copy link
Contributor

gheoan commented Apr 10, 2022

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cfb35aa70ccef56dfbb931a7c093d42b

The current output is:

warning: unused attribute
 --> ./temp.rs:2:1
  |
2 | #![crate_type = "lib"]
  | ^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
  |
  = note: `#[warn(unused_attributes)]` on by default
note: attribute also specified here
 --> ./temp.rs:1:1
  |
1 | #![crate_type = "dylib"]
  | ^^^^^^^^^^^^^^^^^^^^^^^^
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

Ideally there should be no output. When using command line arguments instead of the crate_type attributes, there is no output.

Note that the compilation process is successful: even with the warning, both an dylib and a rlib is produced.
May be related to #92933.

Tested with rustc 1.60.0 (7737e0b 2022-04-04).

@gheoan gheoan added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 10, 2022
@ehuss ehuss self-assigned this Apr 10, 2022
@ehuss
Copy link
Contributor

ehuss commented Apr 10, 2022

I have posted #95910 to fix this.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 12, 2022
…ylan-DPC

Fix crate_type attribute to not warn on duplicates

In rust-lang#88681 I accidentally marked the `crate_type` attribute as only allowing a single attribute. However, multiple attributes are allowed (they are joined together [here](https://github.com/rust-lang/rust/blob/027a232755fa9728e9699337267f6675dfd0a8ba/compiler/rustc_interface/src/util.rs#L530-L542)). This fixes it to not report a warning if duplicates are found.

Closes rust-lang#95902
@bors bors closed this as completed in 1b364ae Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants