-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
unused_results
is stricter on Nightly and Beta than on Stable
#44119
Comments
This is specific to booleans. Not intentional. (I could see a case for the new behavior, but that doesn't matter; if we're going to change this, it should be on purpose.) Fix forthcoming (if it doesn't make the 1.21 beta branch cut, it would need to be backported). Very sorry for regression. 😞 😰 ☠️ |
This, as rust-lang#43813, is due to the author of rust-lang#43728 (specifically, 3645b06) being a damnably contemptible fool. Before this entire fiasco, we would return early from the unusedness late lints pass if the type of the expression within the `hir::StmtSemi` was `!`, `()`, or a boolean: these types would never get to the point of being marked as unused results. That is, until the dunce who somehow (!?) came to be trusted with the plum responsibility of implementing RFC 1940 (`#[must_use]` for functions) went and fouled everything up, removing the early returns based on the (stupid) thought that there would be no harm in it, since we would need to continue to check these types being returned from must_use functions (which was true for the booleans, at least). But there was harm—harm that any quarter-way-competent programmer would have surely forseen! For after the new functional-must-use checks, there was nothing to stop the previously-returned-early types from falling through to be marked by the unused-results lint!—a monumentally idiotic error that has cost the project tens of precious developer- and reviewer-minutes dealing with the fallout here and in rust-lang#43813. If 3645b06 is representative of the standard of craftsmanship the rising generation of software engineers holds themselves to, I weep for the future of our technological civilization. Resolves rust-lang#44119.
FWIW lint changes are not considered backwards-compatibility breaking. |
@eddyb Then we should mention that Rust's (or perhaps rustc's?) backwards compatibility guarantee only holds with |
@whitequark Yeah, |
@alexcrichton This isn't just a regression from stable to nightly, it is a regression from stable to beta.
OTOH, this is probably the most common lint for which |
@briansmith As @whitequark mentioned above, lints can't break dependencies from compiling. |
1.21 is now beta - this needs to be backported. |
I think this issue is treated wrongly by reverting behaviour (#44122). Rustc needs the ability to add and remove lints in any way wanted, otherwise there won't be any improvement of lints in the future. E.g. I've seen the "unused_mut" lint become more powerful, it detected some non required mut annotations. Why shouldn't it be possible to improve it? Stability? If you say Of course though, @zackmdavis is right, a lint change should be done knowingly and on purpose. |
unused_results
is stricter on Nightly than on Beta or Stableunused_results
is stricter on Nightly and Beta than on Stable
Wait, I am a bit confused. The |
The booleans-are-not-unused-results behavior dates back to the introduction of the (default allow) lint itself in the 0.10 timeframe. No explicit justification seems to be given, although one might imagine that APIs that do something and return a bool that the caller is likely to not care about (e.g., |
Can I get confirmation that I understand the situation? My impression is that #43728 was an incorrect implementation of rust-lang/rfcs#1940. The What we agreed was to allow you to tag specific functions with Unless I've misunderstood the situation, it seems to me that we need to backport the revert because we have not decided to consider bool a must_use type. |
@withoutboats That's my understanding; i.e. the fix for this should be in 1.20 that is being released this week. |
@briansmith Agreed. I just want to make the distinction that we can add new lints (in particular, we agreed to add this lint to |
Almost (skip or skim details below if uninterested)—
Yes.
Not quite. There are two relevant lints here:
The libs team has also approved |
@zackmdavis Oh wow! I was unaware of this default-allow lint, that explains how no one found this. Its unfortunate this was found so close to the release; I'd like to consider whether its actually worth backporting a revert but we only have a day or two to decide what to do. |
…_results, r=eddyb un-regress behavior of `unused_results` lint for booleans Resolves rust-lang#44119.
I was confusing |
Wait now I'm curious, what is |
unused_results warns on every non unit return type like gcc's |
@eddyb It appears that |
@rfcbot fcp close I want to propose we treat this as a bugfix in the unused_result lint (hence closing this issue). We kind of have to decide within the next 24 hours, but I'll try to bring it to everyone's attention tomorrow. |
|
Team member @withoutboats has proposed to close this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I thought @alexcrichton was talking about beta being already branched off somewhere else? |
First, thanks for the detailed summary. With respect to the question at hand, I personally consider exempting Anyway, on a different topic:
I can probably help with this. =) Where should I comment? (Tracking issue?) |
…_results, r=eddyb un-regress behavior of `unused_results` lint for booleans Resolves rust-lang#44119.
Nothing like trying to remember a commit from three years ago! Nah unfortunately though I don't remember why
Yes beta branched a few days ago so this, but with the current disposition to close I don't think we're going to backport/stop anything at this point. |
…_results, r=eddyb un-regress behavior of `unused_results` lint for booleans Resolves rust-lang#44119.
…_results, r=eddyb un-regress behavior of `unused_results` lint for booleans Resolves rust-lang#44119.
…_results, r=eddyb un-regress behavior of `unused_results` lint for booleans Resolves rust-lang#44119.
Tracking issue is #43302, although I would argue that the currently-unreviewed #44103 (having the lint look at the operators) adequately solves the problem even if it's not the "automatic" implementation folks originally imagined. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
1 similar comment
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period is now complete. |
Closing, seems we've sufficiently figured this out and no objections were raised. |
This compiles fine on stable, but fails on nightly and beta:
https://play.rust-lang.org/?gist=9504fbb631c253be8e43bcb872524e0e&version=nightly
Nightly results:
Regardless of whether the change in behavior is an intentional backward compatibility break, it should be documented in the release notes.
See also #43806.
The text was updated successfully, but these errors were encountered: