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

span: allow ambiguous_negative_literals #51

Merged
merged 1 commit into from
Jul 27, 2024
Merged

Conversation

BurntSushi
Copy link
Owner

This was bad timing. The lang team just stabilized (in nightly) a new
deny-by-default lint, named ambiguous_negative_literals, which
triggers an error for things like -1.hour(). While such things can be
confusingly ambiguous in some cases, in Jiff, -1.hour(), (-1).hour()
and -(1.hour()) are all, very intentionally, precisely equivalent.

For now we just allow the lint. If the lint stays, we'll likely want
to recommend allowing it in the Jiff docs.

See: rust-lang/rust#121364

@BurntSushi
Copy link
Owner Author

Ug. There's also a billion doc tests that will need to have this lint allow'd too.

This was bad timing. The lang team just stabilized (in nightly) a new
deny-by-default lint, named `ambiguous_negative_literals`, which
triggers an error for things like `-1.hour()`. While such things can be
confusingly ambiguous in some cases, in Jiff, `-1.hour()`, `(-1).hour()`
and `-(1.hour())` are all, very intentionally, precisely equivalent.

For now we just `allow` the lint. If the lint stays, we'll likely want
to recommend allowing it in the Jiff docs.

See: rust-lang/rust#121364
@BurntSushi BurntSushi merged commit a8cf3be into master Jul 27, 2024
14 checks passed
@BurntSushi BurntSushi deleted the ag/fix-nightly-lint branch July 27, 2024 13:09
@@ -1367,6 +1367,8 @@ impl Date {
/// # Example: negative spans are supported
///
/// ```
/// # // See: https://github.com/rust-lang/rust/pull/121364
/// # #![allow(unknown_lints, ambiguous_negative_literals)]
Copy link

Choose a reason for hiding this comment

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

All of those manual allow-attr can be replaced with a single #![doc(test(attr(...)))] attr: #![doc(test(attr(allow(unknown_lints, ambiguous_negative_literals))))]

Copy link
Owner Author

Choose a reason for hiding this comment

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

Oh wow, that's great to know! Thank you.

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