-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustdoc: Remove AttributesExt
trait magic that added needless complexity
#135428
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
Conversation
It's never overridden, so it shouldn't be on the trait.
The two implementations were identical, so there's no need to use a trait method.
rustbot has assigned @GuillaumeGomez. Use |
The new code is more explicit and avoids trait magic that added needless complexity to this part of rustdoc.
.flat_map(|attr| attr.meta_item_list().unwrap_or_default()) | ||
let mut cfg = if doc_cfg_active || doc_auto_cfg_active { | ||
let mut doc_cfg = attrs | ||
.clone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before it didn't need to clone, is there a reason it needs to now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really cloning the attributes. Before attrs was the attributes themselves, and we used the extension trait to make an iterator from them. Now, the iterator is created by the caller of this function and attrs is the iterator. So this is just cloning the iterator, which is a very cheap operation and equivalent to creating a new one using .iter()
like before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, thanks for the explanation!
Thanks! @bors r+ rollup |
…omez rustdoc: Remove `AttributesExt` trait magic that added needless complexity The new code is more explicit and avoids trait magic that added needless complexity to this part of rustdoc.
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#131806 (Treat other items as functions for the purpose of type-based search) - rust-lang#132654 (std: lazily allocate the main thread handle) - rust-lang#135003 (deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead) - rust-lang#135428 (rustdoc: Remove `AttributesExt` trait magic that added needless complexity) - rust-lang#135498 (Prefer lower `TraitUpcasting` candidates in selection) - rust-lang#135529 (remove outdated FIXME) r? `@ghost` `@rustbot` modify labels: rollup
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#132654 (std: lazily allocate the main thread handle) - rust-lang#135003 (deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead) - rust-lang#135428 (rustdoc: Remove `AttributesExt` trait magic that added needless complexity) - rust-lang#135498 (Prefer lower `TraitUpcasting` candidates in selection) - rust-lang#135507 (TRPL: incorporate all backward-compatible Edition changes) - rust-lang#135529 (remove outdated FIXME) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#135428 - camelid:attr-cleanup, r=GuillaumeGomez rustdoc: Remove `AttributesExt` trait magic that added needless complexity The new code is more explicit and avoids trait magic that added needless complexity to this part of rustdoc.
The new code is more explicit and avoids trait magic that added needless
complexity to this part of rustdoc.