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

"use std" before #[link(...)] in .rc file causes an error #2243

Closed
erickt opened this issue Apr 19, 2012 · 8 comments
Closed

"use std" before #[link(...)] in .rc file causes an error #2243

erickt opened this issue Apr 19, 2012 · 8 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@erickt
Copy link
Contributor

erickt commented Apr 19, 2012

rustc errors out when compiling a ".rc" file if use std comes before the #link(...):

test:rc

use std;

#[link(name="test", vers="0.1")];

mod test;

test.rs:

fn main() {}

Errors with:

test.rc:3:32: 3:33 error: expecting mod, found ;
test.rc:3 #[link(name="test", vers="0.1")];
@brson
Copy link
Contributor

brson commented Apr 19, 2012

That inner attributes (attributes terminated with a semi) must come before any module contents is intentional, but this gotcha has come up before. Should we allow attributes anywhere in a module to apply to that module? It seems like too much action at a distance if, e.g. 2000 lines into parser.rs you wrote #[cfg(target_os = "macos")];.

Maybe we could have a better error message.

@ghost ghost assigned brson Apr 19, 2012
@jbclements
Copy link
Contributor

Agreed. Would it be worth while to have a "better error message please" category? Similar to #1208 . Also, #2569 seems to be the canonical bug on the topic of inner attributes.

@pcwalton
Copy link
Contributor

I don't believe this is backwards incompatible, renominating.

@graydon
Copy link
Contributor

graydon commented Jun 6, 2013

just a bug, removing milestone/nomination.

@bblum
Copy link
Contributor

bblum commented Aug 12, 2013

It's definitely a worse gotcha to have accidental semicolons cause entire modules to be #[ignore]d or whatever. Improved error message is the way to go.

@flaper87
Copy link
Contributor

Visiting for triage: @cmr are you planing to create a PR for those commits?

@emberian
Copy link
Member

Oops. I'll get to it in ~2 weeks.

@alexcrichton
Copy link
Member

I believe this has been satisfactorily fixed with unused attribute warnings.

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
Pass --color=always through cargo-miri

Closes rust-lang/miri#2037

I just implemented the fix suggested in that issue and it seems to work without issue.
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Automatically create pull requests from the result of updating the CBMC
release version checks every Monday morning.

Resolves rust-lang#2243.
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 A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

9 participants