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

Remove conditional compilation from mascot constants #50

Merged
merged 3 commits into from
Mar 30, 2024

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Jan 14, 2024

Using #[cfg(...)] is not ideal here because it harms compile-time checking. For example, in order to be sure there isn't a type error, one must separately compile with and without "clippy" when making changes to the crate.

Rust supports if in constants since version 1.46.0 and it's a better fit for this code.

Using #[cfg(...)] is not ideal here because it harms compile-time
checking. For example, in order to be sure there isn't a type error, one
must separately compile with and without "clippy" when making changes to
the crate.

Rust supports `if` in constants since version 1.46.0.
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

Thanks! A small nit and then it should be ready for merge 👍

src/lib.rs Outdated
@@ -10,18 +10,17 @@ use unicode_width::UnicodeWidthStr;
// Constants! :D
const ENDSL: &[u8] = b"| ";
const ENDSR: &[u8] = b" |\n";
#[cfg(not(feature = "clippy"))]
const FERRIS: &[u8] = br#"
const MASCOT: &[u8] = if !cfg!(feature = "clippy") {
Copy link
Contributor

Choose a reason for hiding this comment

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

consider flipping the branches instead of inverting the condition

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Good call.

@lcnr
Copy link
Contributor

lcnr commented Mar 30, 2024

Thanks!

@lcnr lcnr merged commit 0e29bca into rust-lang:main Mar 30, 2024
5 checks passed
@dtolnay dtolnay deleted the mascot branch March 30, 2024 23:15
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.

2 participants