Try all stable method candidates first before trying unstable ones by nbdd0121 · Pull Request #90329 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation21 Commits3 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

nbdd0121

Currently we try methods in this order in each step:

This PR changes it to first try pick methods without any unstable candidates, and if none is found, try again to pick unstable ones.

Fix #90320
CC #88971, hopefully would allow us to rename the "unstable_*" methods for integer impls back.

@rustbot label T-compiler T-libs-api

@rust-highfive

r? @nagisa

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot rustbot added T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

labels

Oct 26, 2021

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid

@rust-timer

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@bors

⌛ Trying commit dc459da71aef6031e787b78b7f240f5b1d0618f0 with merge bb00c9b6276be74811d40eea0b7b6da7a6780c42...

@bors

☀️ Try build successful - checks-actions
Build commit: bb00c9b6276be74811d40eea0b7b6da7a6780c42 (bb00c9b6276be74811d40eea0b7b6da7a6780c42)

@rust-timer

@rust-timer

Finished benchmarking commit (bb00c9b6276be74811d40eea0b7b6da7a6780c42): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@jyn514 jyn514 changed the titleTry all stable candidates first before trying unstable ones Try all stable candidates for autoref first before trying unstable ones

Oct 27, 2021

@joshtriplett

Seems reasonable to me! I look forward to a PR un-renaming the integer rounding methods.

@camelid camelid changed the titleTry all stable candidates for autoref first before trying unstable ones Try all stable method candidates first before trying unstable ones

Oct 30, 2021

nagisa

Choose a reason for hiding this comment

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

I don't see an inherent issue with the idea – the unstable methods are… unstable, so I don't see a huge problem in de-emphasizing them, even if it could change the behaviour of the code that targets nightly rustc.

With that in mind, though, I would like to see a couple other changes to the PR:

First is a -Z debug flag to revert to the previous order of pick priority. Such a flag would help significantly with a potential situation where we receive a bug about a behaviour change to somebody's nightly code.

And then I would love to see a test that verifies this new pick order between stable and unstable items expanded significantly. The existing test seems pretty anemic to me in that it only verifies a stable autorefd method is preferred to an unstable by-value one. But then there are cases like mutable vs immutable autoref (e.g. do we still pick an unstable method autoref if a mutable autoref necessary for a stable method is not valid?), const ptr methods, etc.

@nbdd0121

I don't see an inherent issue with the idea – the unstable methods are… unstable, so I don't see a huge problem in de-emphasizing them, even if it could change the behaviour of the code that targets nightly rustc.

No; this wouldn't change the behaviour. A unstable method with corresponding feature enabled is not considered an "unstable_candidate"; only unstable methods with feature gates not enabled are considered unstable candidates. So code that already compiles shouldn't be affected.

With that in mind, though, I would like to see a couple other changes to the PR:

First is a -Z debug flag to revert to the previous order of pick priority. Such a flag would help significantly with a potential situation where we receive a bug about a behaviour change to somebody's nightly code.

Added.

And then I would love to see a test that verifies this new pick order between stable and unstable items expanded significantly. The existing test seems pretty anemic to me in that it only verifies a stable autorefd method is preferred to an unstable by-value one. But then there are cases like mutable vs immutable autoref (e.g. do we still pick an unstable method autoref if a mutable autoref necessary for a stable method is not valid?), const ptr methods, etc.

I expanded the test a bit. For unstable autoref vs a stable mutable autoref on a non-mutable variable scenario, the code will now pick the stable mutable autoref instead of the unstable autoref (method picking doesn't have this information; actually whether Deref or DerefMut is used depends on which method gets picked). So the error will change in this scenario. But as explained above, this wouldn't affect code that currently compiles.

@nagisa

Nice, thanks!

@bors r+ rollup=never

@bors

📌 Commit 6ad626f has been approved by nagisa

@bors bors added the S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

label

Nov 19, 2021

@nagisa

Is my understanding correct that we may want to consider this for a backport to beta?

@bors

@nbdd0121

Is my understanding correct that we may want to consider this for a backport to beta?

We have #90320 which is deemed acceptable breakage by libs team, and #88971 which is reverted in #89184, so I don't think this needs backport.

@bors

@rust-timer

Finished benchmarking commit (ce3f3a5): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Dec 19, 2021

@matthiaskrgr

Revert "Temporarily rename int_roundings functions to avoid conflicts"

This reverts commit 3ece63b.

This should be okay because rust-lang#90329 has been merged.

r? @joshtriplett

tmandry added a commit to tmandry/rust that referenced this pull request

Jan 5, 2022

@tmandry

wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request

Jan 22, 2022

@he32

Pkgsrc changes:

(For some reason I've not figured out yet, cargo is a lot more verbose while building, echoes the rustc invocation.)

Upstream changes:

Version 1.58.1 (2022-01-19)

Version 1.58.0 (2022-01-13)

Language

Compiler

* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These APIs are now usable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Mar 1, 2022

@he32

Pkgsrc changes:

Upstream changes:

Version 1.58.1 (2022-01-19)

Version 1.58.0 (2022-01-13)

Language

Compiler

* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These APIs are now usable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request

Feb 21, 2023

@Dylan-DPC

…unstable_flag, r=oli-obk

remove unstable pick_stable_methods_before_any_unstable flag

This flag was only added in rust-lang#90329 in case there was any issue with the impl so that it would be easy to tell nightly users to use the flag to disable the new logic to fix their code. It's now been enabled for two years and also I can't find any issues corresponding to this new functionality? This flag made it way harder to understand how this code works so it would be nice to remove it and simplify what's going on.

cc @nbdd0121

r? @oli-obk

Labels

merged-by-bors

This PR was explicitly merged by bors.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.