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

Implement #[deprecated_safe] #95025

Closed
wants to merge 7 commits into from
Closed

Implement #[deprecated_safe] #95025

wants to merge 7 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Mar 16, 2022

cc #94978

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 16, 2022
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 16, 2022
@ghost ghost changed the title Implement #[deprecated_safe], cc #94978 Implement #[deprecated_safe] Mar 16, 2022
@ghost ghost marked this pull request as draft March 16, 2022 21:50
@ghost
Copy link
Author

ghost commented Mar 16, 2022

This doesn't need a reviewer yet, I meant to create this is in the draft state. I just wanted a PR to push to while I work.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@estebank
Copy link
Contributor

@skippy10110 no problem, I'll ignore it until you ping me to let me know it is ready for review

@estebank estebank added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 16, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 23, 2022

☔ The latest upstream changes (presumably #94901) made this pull request unmergeable. Please resolve the merge conflicts.

@jhpratt
Copy link
Member

jhpratt commented Mar 23, 2022

I'm assuming the skippy_log stuff is just for debugging purposes?

@ghost
Copy link
Author

ghost commented Mar 23, 2022

haha, most definitely :) you should have seen the horrible things i did to the compiler before this!

at one point i also had an atomic id slapped on ObligationCause, and then every creation of ObligationCause or Obligation logged to try and figure out how all this data was moving around... i think i had close to 200 logging points at one time, which made just compiling the compiler itself slow, hence skippy_log :)

@jhpratt
Copy link
Member

jhpratt commented Mar 23, 2022

Oh, I'm sure! I don't see anything that's clearly wrong in your code so far. Just the obvious todos and whatnot.

@ghost
Copy link
Author

ghost commented Mar 23, 2022

that's awesome to hear :) i was pretty much just winging it, but now i feel like i can actually justify how the code works and understand all the trait stuff (a little) better

@ghost
Copy link
Author

ghost commented Mar 23, 2022

i do have a question about reviews and my commit history

once i get things more wrapped up with a proper implementation of the attribute itself (e.g. a functioning "since" version, can only be used in the right places, etc.) and with lots of tests, proper error messages, etc.... should i rewrite the entire commit history to add each change piecemeal as if i knew what i was doing from the start?

this commit especially "THIS IS A GARBAGE COMMIT, just stashing due to data loss paranoia :)" is one i just kept force pushing over and over again as a snapshot of my whatever my current local state was

@jhpratt
Copy link
Member

jhpratt commented Mar 23, 2022

Ultimately that's up to the reviewer. Personally I'm a fan of cleaning up history, as it makes it clearer if anyone wants to come back later on to look at things.

@ghost
Copy link
Author

ghost commented Mar 23, 2022

cool, i'm a fan of tidy things so i'll make sure i do that up then

@ghost
Copy link
Author

ghost commented Mar 23, 2022

since you're following along, @jhpratt, i figured i'd ask your opinion on this (copied from the zulip stream):

i have a functioning since key for #[deprecated_safe] now, the semantics i chose are:

  • outside of libstd since has no semantic meaning, just like #[deprecated] (applies immediately)
  • within libstd, when called by 3rd party code, since will have meaning (doesn't apply until the since version)
  • within libstd, when called by libstd itself, since will not have meaning (applies immediately)

so libstd can apply the attribute with e.g. a version of "TBD" without affecting 3rd party code, but it will need to update itself immediately

i felt like adding DEPRECATED_SAFE_IN_FUTURE for use within libstd was overkill, but i could do that if it's warranted

@jhpratt
Copy link
Member

jhpratt commented Mar 23, 2022

That would be in line with how #[deprecated] works to my understanding.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 10, 2022
@bors
Copy link
Contributor

bors commented Apr 10, 2022

⌛ Trying commit e9b4f751ac203500dafff3e3f22b2a54bb61f8e4 with merge 2456894a32f493d26aee0f03d9c17897c452d786...

@bors
Copy link
Contributor

bors commented Apr 10, 2022

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

@rust-timer
Copy link
Collaborator

Queued 2456894a32f493d26aee0f03d9c17897c452d786 with parent 027a232, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2456894a32f493d26aee0f03d9c17897c452d786): comparison url.

Summary:

  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: no relevant changes found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 3 0 0 0 3
mean2 0.2% N/A N/A N/A 0.2%
max 0.2% N/A N/A N/A 0.2%

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 may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 11, 2022
@jhpratt
Copy link
Member

jhpratt commented Apr 11, 2022

Nice work! Appears to be no difference overall.

@ghost
Copy link
Author

ghost commented Apr 11, 2022

thanks! there's a cheat 😊, the code does essentially zero work unless:
a) your code was about to fail with a compile error anyway, because #[deprecated_safe] wasn't applied
or b) #[deprecated_safe] was applied, but you haven't updated yet, and you're about to get a warning

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.

I've long wanted to look into adding a lint if certain predicates are used, mostly to deprecate the Eq and PartialEq impls for function pointers.

While the approach of linting when not in canonical queries works right now, my goal - and of @rust-lang/wg-traits afaik - is to slowly work towards always using queries for trait solving. At this point your code would break.

My expected solution here is to add "this should lint" to the output of a successful selection then let the caller emit the error. I didn't yet look into what's the best way to do this, but without too much thought it might make sense to just change the output of https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/struct.SelectionContext.html#method.confirm_candidate to have a lint_on_use: Option<SelectionLint> field. We would then have to propagate this upwards to outside of the query.

Probably makes sense for myself to look into this more, now that someone else also wants that. I will only get to that at some point after the 25th April though.

@ghost
Copy link
Author

ghost commented Apr 12, 2022

i was thinking i need a "attach lint for later reporting higher up" facility when selection is successful, since all the the nice error reporting seems to come from returning a SelectionError instead of a Selection, so that's perfect to hear that would be a good direction to go!

i wasn't sure if that would be too obtrusive a change, but it sounds like my hacky don't query change is going the opposite direction of what we want, based on what you're saying

i'll start taking a look at this and see if i can make any progress on it (zulip)

@ghost
Copy link
Author

ghost commented Apr 15, 2022

@lcnr, @estebank, i've made some progress on the obligation linting, which affects the "implement deprecated_safe for fn() pointer closure coercions" commit in this PR

assuming we go the route of putting a new linting system in place that this PR can then use, the commit i mentioned would change from:

to something like:

the rest of the commits in this PR are unaffected by this

@bors
Copy link
Contributor

bors commented Apr 15, 2022

☔ The latest upstream changes (presumably #96087) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimon
Copy link
Member

Ping from triage:
@skippy10110 - can you please address the conflicts and build failures and post your status?

FYI: when a PR is ready for review, send a message containing
@rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

@wesleywiser
Copy link
Member

wesleywiser commented May 12, 2022

Visited during compiler team triage meeting. Looks like this is blocked on #96092. Marking as such for now. (If that is incorrect, please let me know and we can adjust the labels again)

@wesleywiser wesleywiser added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 12, 2022
Repository owner closed this by deleting the head repository Aug 25, 2022
@jhpratt
Copy link
Member

jhpratt commented Aug 28, 2022

As this PR's author has deleted their account, I have backed up the state of this pull request on my fork. It is located here. This should make it easier to use existing code if anyone would like to take it over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.