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

the book attributes page isn't practically useful #28643

Closed
mdinger opened this issue Sep 24, 2015 · 3 comments
Closed

the book attributes page isn't practically useful #28643

mdinger opened this issue Sep 24, 2015 · 3 comments

Comments

@mdinger
Copy link
Contributor

mdinger commented Sep 24, 2015

The attributes section doesn't cover how these rules are applied to typically used libraries or binaries and should be expanded. For example, why does this case fail? It's trying to apply that feature to the enclosing module which seems reasonable:

pub mod inner {
    // Not valid. `feature` is only applicable to crates.
    #![feature(step_by)]
    pub fn threes() {
        for i in (0..10).step_by(3) { println!("{}", i); }
    }
}

fn main() {
    inner::threes();
}

It would be useful to expand it to include examples that show actual usage patterns like how to enable #![feature()], #[test], and #[cfg] patterns on a lib.rs and main.rs files in a practical fashion. This seems like it would enable people much more than it does currently.

My attempt at answering such a question is here in case it's useful.

@mdinger mdinger changed the title the book attributes isn't practically useful the book attributes page isn't practically useful Sep 25, 2015
@sanxiyn
Copy link
Member

sanxiyn commented Sep 26, 2015

On the other hand, we do say this:

foo.rs:3:5: 3:25 warning: crate-level attribute should be in the root module, #[warn(unused_attributes)] on by default
foo.rs:3     #![feature(step_by)]
             ^~~~~~~~~~~~~~~~~~~~

@sanxiyn sanxiyn added the A-book label Sep 26, 2015
@mdinger
Copy link
Contributor Author

mdinger commented Sep 26, 2015

Yeah, the compiler is pretty helpful but when you go to the book looking for explanations about why, it's slightly lacking in that regard.

@steveklabnik
Copy link
Member

This is good feedback, but given my work on the next-gen of the book, I'm not likely to fix it. If anyone wants to flesh out this section with more, please feel free!

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

No branches or pull requests

3 participants