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

Incorrect link attibute allowed #53901

Closed
bjorn3 opened this issue Sep 2, 2018 · 4 comments
Closed

Incorrect link attibute allowed #53901

bjorn3 opened this issue Sep 2, 2018 · 4 comments
Labels
A-attributes Area: #[attributes(..)] A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Sep 2, 2018

#[link="reiojregioergioregiojrge"]
extern "C" {}

fn main() {}

(Playground)

Output:

   Compiling playground v0.0.1 (file:///playground)
    Finished dev [unoptimized + debuginfo] target(s) in 1.18s
     Running `target/debug/playground`

@Havvy Havvy added the A-attributes Area: #[attributes(..)] label Sep 3, 2018
bors added a commit that referenced this issue Dec 29, 2018
Report error for #[link] without arguments

- Report an error for `#[link = "foo"]` (rather than `#[link(name = "foo")]`).
- Report an error for duplicate arguments.
- Improve feature gate diagnostics for `#[link]`.
Fixes #53901.
@varkor varkor added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 31, 2018
@varkor
Copy link
Member

varkor commented Dec 31, 2018

Nominating for team discussion because it seems bad that this is silently ignored, but we can't make this an error without breaking code that currently compiles on stable (see the discussion in #57139).

The pull request #57139 adds an allow-by-default future incompatibility lint for #[link = "name"]: it would be good to check this is the best solution.

@varkor
Copy link
Member

varkor commented Jan 10, 2019

We're going to wait until #57321 lands and then following up on any part of this issue that doesn't fix, separately.

@varkor
Copy link
Member

varkor commented Feb 5, 2019

The example in the original post now produces a warning, but more subtle issues covered by #57139, such as duplicate parameters are still not warned, so it's worth keeping this issue open until that's addressed.

@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. labels Dec 8, 2019
@bjorn3
Copy link
Member Author

bjorn3 commented Apr 2, 2020

Fixed:

error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ cfg = "...")]`
 --> src/main.rs:1:1
  |
1 | #[link="reiojregioergioregiojrge"]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[deny(ill_formed_attribute_input)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

error: aborting due to previous error

@bjorn3 bjorn3 closed this as completed Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: #[attributes(..)] A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants