Skip to content

Implement push_mut #135975

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Implement push_mut #135975

wants to merge 7 commits into from

Conversation

balt-dev
Copy link

@balt-dev balt-dev commented Jan 24, 2025

Implementation of #135974.

@rustbot
Copy link
Collaborator

rustbot commented Jan 24, 2025

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ibraheemdev (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 24, 2025
@balt-dev
Copy link
Author

Sorry if I did this wrong, it's my first time!

@rust-log-analyzer

This comment has been minimized.

@balt-dev
Copy link
Author

A single trailing whitespace. Oops.

@rust-log-analyzer

This comment has been minimized.

@ibraheemdev
Copy link
Member

I'm not sure we should be touching Vec::push here.. maybe just duplicate the implementation?

@balt-dev
Copy link
Author

Alright, I'll do that soon.

@ibraheemdev ibraheemdev 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 Jan 31, 2025
@balt-dev
Copy link
Author

I finally got around to duplicating the implementation. College has been eating my time like a child with Halloween candy, sorry.

@balt-dev
Copy link
Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 22, 2025
///
/// let mut vec = vec![];
/// // Due to current borrow checker limitations (see -Zpolonius), this is the only way to spell this right now.
/// let last = if let Some(v) = vec.last_mut() { v } else { vec.push_mut(0) };
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand the point of this.

Copy link
Author

Choose a reason for hiding this comment

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

There should probably be a better example, yeah. Will update soon!

@rustbot rustbot 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 Feb 23, 2025
@alex-semenyuk
Copy link
Member

@balt-dev
Thanks for your contribution
From wg-triage. Any updates on this PR?

@balt-dev
Copy link
Author

balt-dev commented Apr 7, 2025

I'm sorry, college has been quite a time sink for me and I haven't had the time to follow up as of recent - I will when I can, promise!

@balt-dev
Copy link
Author

It's been a rough few months. ._.

@rustbot

This comment has been minimized.

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label May 31, 2025
@balt-dev
Copy link
Author

hm.

@balt-dev
Copy link
Author

balt-dev commented May 31, 2025

I think I messed up my fork so bad I'll have to reset it and put my code in from scratch in order to get rid of the merge commit. At least it's copy/pasteable?

@ibraheemdev ibraheemdev 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 Jun 8, 2025
@rustbot

This comment has been minimized.

@balt-dev
Copy link
Author

balt-dev commented Jun 9, 2025

...again?

@balt-dev
Copy link
Author

balt-dev commented Jun 9, 2025

Sigh....

@balt-dev
Copy link
Author

balt-dev commented Jun 9, 2025

@traviscross How'd you fix the submodules?

@balt-dev
Copy link
Author

balt-dev commented Jun 9, 2025

image
Hm. I can't access anything here.

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor

tgross35 commented Jun 9, 2025

@traviscross How'd you fix the submodules?

The easiest way is something like:

# Make sure you have rust-lang's `master` available
git remote add upstream https://github.com/rust-lang/rust.git
git fetch upstream master

# Do a soft reset to the point where you forked off from master.
# Mild warning: this will keep the diff but get rid of the new
# commits (the files will show up as having unstaged changes)
git reset "$(git merge-base HEAD upstream/master)"

# Just reset submodules
git submodule deinit --all --force

# Add the changes you actually want and create a new commit
git add library
git commit

# Update this PR, which will replace the three commits here with
# the one new commit
git push --force-with-lease

git rebase -i "$(git merge-base HEAD upstream/master)" will work in the future then , if you need to squash at some point.

For future reference, it's usually better practice to always work on branches rather than your fork's master so you can do git branch --set-upstream-to=upstream/master on your local master, then it will always track rust-lang/rust without needing to continually update your fork. But since this PR is from your master, don't do this until it merges :)

@bors
Copy link
Collaborator

bors commented Jun 10, 2025

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

@balt-dev
Copy link
Author

That probably fixed the merge conflict.

@balt-dev
Copy link
Author

@tgross35 Thank you so much!

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@balt-dev
Copy link
Author

Hm.

@balt-dev
Copy link
Author

balt-dev commented Jun 14, 2025

---- library/alloc/src/vec/mod.rs - vec::Vec<T,A>::push_mut (line 2572) stdout ----
error[E0614]: type `()` cannot be dereferenced
  --> library/alloc/src/vec/mod.rs:2579:1
   |
10 | *last = 4;
   | ^^^^^ can't be dereferenced

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0614`.

Ah. @ibraheemdev The test you provided in the review was broken - it used push instead of push_mut.

@rust-log-analyzer

This comment has been minimized.

@balt-dev
Copy link
Author

@ibraheemdev ...did you even test that suggested test before suggesting it?

@tgross35
Copy link
Contributor

@ibraheemdev ...did you even test that suggested test before suggesting it?

Please keep in mind that reviews are thoughtful and often suggest a general shape, but it's really up to the PR author to make sure they work and tweak them as needed. Reviewers won't be checking out and building your branch.

It's reasonably easy to run tests locally, ./x t library/alloc from the repo root should test what you need (note this may take a while to build the first time). Otherwise relying on CI is fine, that just means a slightly slower feedback loop.

@balt-dev
Copy link
Author

balt-dev commented Jun 15, 2025

Yeah, @ibraheemdev sorry for lashing out.
The problem is, tests take at least 10 minutes on my old laptop even when narrowing down as much as I can (./x.py test --doc --keep-stage 1 --stage 0 library/alloc), and CI is worse on that front, so it's tough to go back and forth on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants