Skip to content

Conversation

@strmfos
Copy link

@strmfos strmfos commented Jul 28, 2025

Replace two-step operation to get the first map entry (keys().next() + swap_remove()) with a more idiomatic and efficient single drain().next() call

@rustbot
Copy link
Collaborator

rustbot commented Jul 28, 2025

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 28, 2025
@rust-log-analyzer
Copy link
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] askama test:false 0.174
error[E0061]: this method takes 1 argument but 0 arguments were supplied
   --> src/librustdoc/clean/auto_trait.rs:283:34
    |
283 |         let (target, deps) = map.drain().next().unwrap();
    |                                  ^^^^^-- argument #1 is missing
    |
note: method defined here
   --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/indexmap-2.10.0/src/map.rs:300:12
    |
300 |     pub fn drain<R>(&mut self, range: R) -> Drain<'_, K, V>
    |            ^^^^^
help: provide the argument
    |
283 |         let (target, deps) = map.drain(/* range */).next().unwrap();
    |                                        +++++++++++

For more information about this error, try `rustc --explain E0061`.
[RUSTC-TIMING] rustdoc test:false 3.330
error: could not compile `rustdoc` (lib) due to 1 previous error

@bjorn3
Copy link
Member

bjorn3 commented Jul 28, 2025

Using drain will clear out the entire Vec. As per the docs:

If the iterator is dropped before being fully consumed, it drops the remaining removed elements.

@fmease fmease 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 Jul 28, 2025
@Dylan-DPC
Copy link
Member

@strmfos any updates on this? thanks

@fmease
Copy link
Member

fmease commented Oct 8, 2025

Since the current change is incorrect, I'll close this one. I've been meaning to fully rewrite auto trait impl synthesis for ages now (and with the next solver coming closer to the finish line, I need to act very soon) which would likely make this obsolete anyway.

@fmease fmease closed this Oct 8, 2025
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants