Skip to content

Remove an unnecessary .move_iter().collect() #14139

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

Closed
wants to merge 1 commit into from

Conversation

SimonSapin
Copy link
Contributor

Well, at least it looks unnecessary. This is completely untested. I’m leaving that job to bors, if that’s ok.

@lilyball
Copy link
Contributor

This is almost certainly left over from to_utf16() returning ~[T]. Since it now returns Vec<u16>, the conversion has become unnecessary.

@SimonSapin
Copy link
Contributor Author

Ah, I see. I suppose this was added when ~[T].push was removed.

flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 20, 2025
)

In the case where `iter` is a `DoubleEndedIterator`, replacing a call to
`iter.last()` (which consumes `iter`) by `iter.next_back()` (which
requires a mutable reference to `iter`) cannot be done when `iter` is a
non-mutable binding which is not a mutable reference. When possible, a
local immutable binding is made into a mutable one.

Also, the applicability is switched to `MaybeIncorrect` and a note is
added to the output when the element types have a significant drop,
because the drop order will potentially be modified because
`.next_back()` does not consume the iterator nor the elements before the
last one.

Fix rust-lang#14139

changelog: [`double_ended_iterator_last`]: do not trigger on
non-reference immutable receiver, and warn about possible drop order
change
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.

3 participants