Skip to content

syntax: improve message for misused inner attributes #18766

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

Merged
merged 1 commit into from
Nov 11, 2014

Conversation

liigo
Copy link
Contributor

@liigo liigo commented Nov 8, 2014

for the code:

use std::io;

#![crate_type="rlib"] // ERROR: an inner attribute is not permitted in this context

fn say_hello() {
    println!("hello");
}

this PR provides another note to help programmer fixing this error more easily:

hello.rs:6:3: 6:4 error: an inner attribute is not permitted in this context
hello.rs:6 #![crate_type="rlib"]
             ^
hello.rs:6:3: 6:4 note: put inner attribute in top of file or block
hello.rs:6 #![crate_type="rlib"]
             ^

@emberian
Copy link
Member

emberian commented Nov 9, 2014

Thanks!

@@ -75,6 +75,8 @@ impl<'a> ParserAttr for Parser<'a> {
self.span_err(span,
"an inner attribute is not permitted in \
this context");
self.span_note(span,
"put inner attribute in top of file or block");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this message to "place inner attribute at the top of the module or block"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should also be a span_help instead of a span_note.

@liigo liigo force-pushed the improve-inner-attr-msg branch from 450588a to 0a52cc3 Compare November 11, 2014 00:55
@liigo
Copy link
Contributor Author

liigo commented Nov 11, 2014

@huonw I have changed the message to what you suggested, and changed to span_help as @P1start suggested. Rebased. r?

bors added a commit that referenced this pull request Nov 11, 2014
for the code:
```
use std::io;

#![crate_type="rlib"] // ERROR: an inner attribute is not permitted in this context

fn say_hello() {
	println!("hello");
}
```

this PR provides another note to help programmer fixing this error more easily:
```
hello.rs:6:3: 6:4 error: an inner attribute is not permitted in this context
hello.rs:6 #![crate_type="rlib"]
             ^
hello.rs:6:3: 6:4 note: put inner attribute in top of file or block
hello.rs:6 #![crate_type="rlib"]
             ^
```
@bors bors closed this Nov 11, 2014
@bors bors merged commit 0a52cc3 into rust-lang:master Nov 11, 2014
lnicola pushed a commit to lnicola/rust that referenced this pull request Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants