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

refactor: removing library/alloc/src/vec/mod.rs ignore-tidy-filelength #78934

Merged
merged 22 commits into from
Dec 31, 2020
Merged

refactor: removing library/alloc/src/vec/mod.rs ignore-tidy-filelength #78934

merged 22 commits into from
Dec 31, 2020

Conversation

DeveloperC286
Copy link
Contributor

This PR removes the need for ignore-tidy-filelength for library/alloc/src/vec/mod.rs which is part of the issue #60302

It is probably easiest to review this PR by looking at it commit by commit rather than looking at the overall diff.

@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 @joshtriplett (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

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 Nov 11, 2020
@bors
Copy link
Contributor

bors commented Nov 11, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 16, 2020
@m-ou-se m-ou-se assigned m-ou-se and unassigned joshtriplett Nov 16, 2020
Copy link
Member

@m-ou-se m-ou-se left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

I have verified everything up to 643b7d8 just moves things unmodified, except for a few pubs and some formatting changes.

I have a few comments:

Comment on lines 2528 to 2520
macro_rules! __impl_slice_eq1 {
([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, #[$stability:meta]) => {
#[$stability]
impl<A, B, $($vars)*> PartialEq<$rhs> for $lhs
where
A: PartialEq<B>,
$($ty: $bound)?
{
#[inline]
fn eq(&self, other: &$rhs) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &$rhs) -> bool { self[..] != other[..] }
}
}
}

__impl_slice_eq1! { [] Vec<A>, Vec<B>, #[stable(feature = "rust1", since = "1.0.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 think it'd be good to keep macros like this and their list of invocations together.

Maybe instead of a macros.rs, there could be a slice_eq.rs or something like that.

where
F: FnMut(&mut T) -> bool,
{
pub(crate) vec: &'a mut Vec<T>,
Copy link
Member

Choose a reason for hiding this comment

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

@KodrAus said on zulip:

Hmm, I feel like PRs that are splitting up large modules into smaller child ones that use mostly pub(super) or pub(crate) internals could be missing an opportunity to define better privacy boundaries 🤔

It'd be good to see if we can avoid making these all pub(crate). pub(super) would already be a bit better, but it'd be good to check if we can make these private, possibly by adding a pub(super) function or two, depending on what the parent module actually needs.

If that's a lot of work, it would be okay to just merge this with pub(super) to avoid bitrot/merge conflicts, and fix it up in a smaller follow-up PR.

@@ -0,0 +1,34 @@
use crate::borrow::Cow;
Copy link
Member

Choose a reason for hiding this comment

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

It might be good to just name this file cow.rs. I think the word Cow is more recognizable in Rust than clone_on_write.

@TimDiekmann
Copy link
Member

It would be good if we could wait to merge the PR until #78461 has landed, as many things of Vec has changed there.

@DeveloperC286
Copy link
Contributor Author

Hi @m-ou-se thanks for your review and the comments 👍 I will take your comments onboard and fix up my PR. I will just wait until @TimDiekmann 's #78461 has been merged. @TimDiekmann any idea on the timeline or other PR's I should wait on?

@TimDiekmann
Copy link
Member

TimDiekmann commented Nov 16, 2020

Thanks for your consideration!
My pull request is still waiting for a review but the crater run was successful so this shouldn't take too long as soon as @Amanieu has time to look into it.

I don't think you have to be considerate of other PRs. Most likely AllocRef and Vec::alloc_ref will be renamed to Allocator and Vec::allocator respectively, but these are only small changes that I can easily rebase later.

@bors
Copy link
Contributor

bors commented Nov 22, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@m-ou-se m-ou-se 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 Nov 28, 2020
@DeveloperC286
Copy link
Contributor Author

@m-ou-se Hey! Sorry it took me a while to get this PR updated.

I followed your suggestion and used cow.rs instead of clone_on_write.rs
I removed the marcos.rs and instead the macros now live with the structs/traits that use them.
Also used pub (super) everywhere I could instead of pub (crate), making it private seemed to require a decent amount of changes so maybe that might need to be a separate issue/PR?

Thanks,

@bors
Copy link
Contributor

bors commented Dec 15, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@DeveloperC286
Copy link
Contributor Author

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@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 Dec 18, 2020
@bors
Copy link
Contributor

bors commented Dec 29, 2020

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

Copy link
Member

@m-ou-se m-ou-se left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this! And sorry for the delay.

This looks great! I have one tiny nit:

Comment on lines 13 to 14
/// This `struct` is created by the `into_iter` method on [`super::Vec`] (provided
/// by the [`IntoIterator`] trait).
Copy link
Member

Choose a reason for hiding this comment

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

This link used to be [`Vec`]. Let's keep the visible text the same:

Suggested change
/// This `struct` is created by the `into_iter` method on [`super::Vec`] (provided
/// by the [`IntoIterator`] trait).
/// This `struct` is created by the `into_iter` method on [`Vec`](super::Vec)
/// (provided by the [`IntoIterator`] trait).

@m-ou-se
Copy link
Member

m-ou-se commented Dec 30, 2020

I'll just commit my suggestion and approve your PR, to not delay it any further. Hope you don't mind. :)

@bors r+

@bors
Copy link
Contributor

bors commented Dec 30, 2020

📌 Commit 16834a8 has been approved by m-ou-se

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2020
@DeveloperC286
Copy link
Contributor Author

I'll just commit my suggestion and approve your PR, to not delay it any further. Hope you don't mind. :)

@bors r+

Thank you for your review and for fixing the documentation link for me! 👍

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 30, 2020
Rollup of 9 pull requests

Successful merges:

 - rust-lang#78934 (refactor: removing library/alloc/src/vec/mod.rs ignore-tidy-filelength)
 - rust-lang#79479 (Add `Iterator::intersperse`)
 - rust-lang#80128 (Edit rustc_ast::ast::FieldPat docs)
 - rust-lang#80424 (Don't give an error when creating a file for the first time)
 - rust-lang#80458 (Some Promotion Refactoring)
 - rust-lang#80488 (Do not create dangling &T in Weak<T>::drop)
 - rust-lang#80491 (Miri: make size/align_of_val work for dangling raw ptrs)
 - rust-lang#80495 (Rename kw::Invalid -> kw::Empty)
 - rust-lang#80513 (Add regression test for rust-lang#80062)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 242a252 into rust-lang:master Dec 31, 2020
@rustbot rustbot added this to the 1.51.0 milestone Dec 31, 2020
@DeveloperC286 DeveloperC286 deleted the issue_60302_vec branch December 31, 2020 00:37
rylev added a commit to rylev/rust that referenced this pull request Jan 8, 2021
…ec, r=m-ou-se"

This reverts commit 242a252, reversing
changes made to 507bff9.
@rylev
Copy link
Member

rylev commented Jan 8, 2021

@DeveloperC286 @m-ou-se this seems to be the cause of a slight perf regression as you can see in #80814

I assume this is likely a change in inlining which often happens when moving things around. We should look into if we can gain some of that perf lost back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

9 participants