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

Attributes at the beginning of a file have confusing semantics #2568

Closed
catamorphism opened this issue Jun 11, 2012 · 5 comments
Closed

Attributes at the beginning of a file have confusing semantics #2568

catamorphism opened this issue Jun 11, 2012 · 5 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@catamorphism
Copy link
Contributor

I was trying to add a #warn attribute to a test case in order to turn a warning into an error, and I spent an embarrassingly large amount of time trying to debug why the warning still seemed to be treated as a warning. The reason was that I put: #[warn(err_non_implicitly_copyable_typarams)]

at the very beginning of the file, which of course meant it applied to only the first item in the file -- which wasn't the one containing the code that triggers the warning. I'd forgotten that attributes only apply to the next item, not the whole file (or module). But I'm sure I'm not the only one who will get confused by this.

I'm not sure what a good solution would be, but I thought I would report it as a potential source of confusion. Maybe when the compiler prints a lint warning or error, it could also print something like "Printing a warning because this is the default setting for item fn quux(...", or "Printing an error because the item class foo {... has a #[warn(err_no_cats_allowed)] attribute"?

@brson
Copy link
Contributor

brson commented Jun 11, 2012

This is sort of related to #2498 - I want to add javadoc comments (to the parser probably as a special type of attribute), but attributes can either be 'outer' or 'inner' types so that needs to be indicated by the javadocs as well.

Adding significant semicolons after comments is bizarre so I was going to use doxygen's /**< ... */ comments to indicate that a comment is associated with what came before, not what comes after. I was also thinking to change attribute syntax to match. This doesn't fix your problem at all that having two different syntaxes is just confusing, but at least something with the differentiating character in front (#<) would be more visible than the trailing semi.

@bstrie
Copy link
Contributor

bstrie commented Jun 11, 2012

+1 for getting rid of the significant semicolon on attributes. Those may very well be the most frightening thing in the language.

@brson
Copy link
Contributor

brson commented Jun 11, 2012

Added #2569 for changing the inner attribute syntax

@catamorphism
Copy link
Contributor Author

I didn't even know you could put a semicolon after an attribute, so there you go.

@graydon
Copy link
Contributor

graydon commented Jun 13, 2012

This is now effectively a dupe of #2498 and #2569, closing.

@graydon graydon closed this as completed Jun 13, 2012
oli-obk pushed a commit to oli-obk/rust that referenced this issue Sep 28, 2022
Merge rustc changes back into the miri repo

This uses https://github.com/josh-project/josh (RIIR ftw)

The first time it looks a bit odd with the merges and so, all future syncs will work just like the instructions say. I'll add instructions for the sync from miri to rustc, too, starting to do that right now.

Initial cache building now takes 5 mins 🥳
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

4 participants