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

Add linting for crate_type attribute values. #11264

Closed
wants to merge 1 commit into from

Conversation

am0d
Copy link
Contributor

@am0d am0d commented Jan 1, 2014

This ensures that the crate_type attribute always contains a value,
and does not contain an invalid value.

Fixes #11256.

@alexcrichton
Copy link
Member

I'd like to avoid duplicating valid crate_type values across the compiler, so I think this should use the add_lint api from here: https://github.com/mozilla/rust/blob/master/src/librustc/driver/session.rs#L429 instead

@am0d
Copy link
Contributor Author

am0d commented Jan 1, 2014

Are you suggesting that collect_outputs should be the one to call add_lint if the crate_type doesn't match?
I can move the code there if so.

@alexcrichton
Copy link
Member

Indeed, the None case means that it wasn't of the form crate_type = "value" and the Some(s) fall through case means that it wasn't recognized.

@am0d
Copy link
Contributor Author

am0d commented Jan 1, 2014

Ok. The only thing I can't work out is how to get a reference to a Session object in collect_outputs so that I can call the add_lint method on it. The options parameter doesn't have any reference to the session, and collect_outputs is not a method on Sesssion.

@alexcrichton
Copy link
Member

I would recommend adding a parameter of type Session.

@am0d
Copy link
Contributor Author

am0d commented Jan 1, 2014

Ok. There are only a couple of spots that collect_outputs is called, so I will try that.

@am0d
Copy link
Contributor Author

am0d commented Jan 2, 2014

@alexcrichton I've re-written this PR with your suggestions. This also now adds a new lint type unknown-crate-type which is set to deny by default.

This ensures that the `crate_type` attribute always contains a value,
and does not contain an invalid value.
bors added a commit that referenced this pull request Jan 3, 2014
This ensures that the `crate_type` attribute always contains a value,
and does not contain an invalid value.

Fixes #11256.
@bors bors closed this Jan 3, 2014
@am0d am0d deleted the crate_type_lint branch January 9, 2014 02:43
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 6, 2023
…es, r=llogiq

Don't escape unicode escape braces in `print_literal`

Fixes rust-lang#11264

changelog: none
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.

No error on invalid #[crate_type]
3 participants