rustdoc: Remove AttributesExt trait magic that added needless complexity#135428
rustdoc: Remove AttributesExt trait magic that added needless complexity#135428bors merged 3 commits intorust-lang:masterfrom
AttributesExt trait magic that added needless complexity#135428Conversation
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.
Before it didn't need to clone, is there a reason it needs to now?
There was a problem hiding this comment.
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.
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.