about summary refs log tree commit diff
path: root/src/librustdoc/clean
AgeCommit message (Collapse)AuthorLines
2025-02-08Rustfmtbjorn3-49/+61
2025-02-06Auto merge of #136265 - notriddle:notriddle/clean-up, r=fmeasebors-14/+12
rustdoc: use ThinVec for generic arg parts This reduces the size of both these args, and of path segments, so should measurably help with memory use.
2025-02-05Auto merge of #136244 - yotamofek:pr/rustdoc-join-iter, r=GuillaumeGomezbors-19/+40
librustdoc: create a helper for separating elements of an iterator instead of implementing it multiple times This implements something similar to [`Itertools::format`](https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.format), but on `Fn`s returning iterators instead of directly on iterators, to allow implementing `Display` without the use of a `Cell` (to handle the possibility of `fmt` being called multiple times while receiving `&self`). ~This is WIP, I just want to get a perf run first to see if the regression I saw in #135494 is fixed~ This was originally part of #135494 , but originally caused a perf regression that was since fixed: https://github.com/rust-lang/rust/blob/7d5ae1863aa66847a4edf8d2ef9420717df65c5d/src/librustdoc/html/format.rs#L507
2025-02-04librustdoc: create a helper for separating elements of an iterator instead ↵Yotam Ofek-19/+40
of implementing it multiple times
2025-02-04Auto merge of #136525 - matthiaskrgr:rollup-m8kqlek, r=matthiaskrgrbors-4/+4
Rollup of 6 pull requests Successful merges: - #134807 (fix(rustdoc): always use a channel when linking to doc.rust-lang.org) - #134814 (Add `kl` and `widekl` target features, and the feature gate) - #135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL) - #136022 (Port ui/simd tests to use the intrinsic macro) - #136309 (set rustc dylib on manually constructed rustc command) - #136462 (mir_build: Simplify `lower_pattern_range_endpoint`) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-04Rollup merge of #134807 - poliorcetics:ab/push-skpynvsmwkll, r=camelidMatthias Krüger-4/+4
fix(rustdoc): always use a channel when linking to doc.rust-lang.org Closes #131971 I manually checked the resulting links One issue is that this will create `nightly/...` links in places that formerly linked to stable, is that ok ? (the `slice` and `array` links in the search help notably)
2025-02-03Rollup merge of #136411 - dtolnay:fnptr, r=notriddleMatthias Krüger-5/+17
Omit argument names from function pointers that do not have argument names This matches the style used for the vast majority of function pointer types in real-world code, in my experience. Prefixing `_: ` to every argument does not improve clarity. **Before:** <img src="https://github.com/user-attachments/assets/f07efa8b-d57e-4897-aa97-40db7d207862"> **After:** <img src="https://github.com/user-attachments/assets/8405e08b-d6d2-4904-bcc3-a3eb866cecf0">
2025-02-02rustc_allowed_through_unstable_modules: require deprecation messageRalf Jung-10/+2
2025-02-01Omit argument names from function pointers that do not have argument namesDavid Tolnay-5/+17
2025-01-30fix(rustdoc): always use a channel when linking to doc.rust-lang.orgAlexis (Poliorcetics) Bourget-4/+4
2025-01-30introduce `ty::Value`Lukas Markeffsky-4/+2
Co-authored-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
2025-01-29Collect directly into ThinVecMichael Howell-9/+7
2025-01-29rustdoc: use ThinVec for generic arg partsMichael Howell-5/+5
This reduces the size of both these args, and of path segments, so should measurably help with memory use.
2025-01-29Eliminate PatKind::PathOli Scherer-1/+2
2025-01-24Auto merge of #135272 - BoxyUwU:generic_arg_infer_reliability_2, ↵bors-9/+14
r=compiler-errors Forbid usage of `hir` `Infer` const/ty variants in ambiguous contexts The feature `generic_arg_infer` allows providing `_` as an argument to const generics in order to infer them. This introduces a syntactic ambiguity as to whether generic arguments are type or const arguments. In order to get around this we introduced a fourth `GenericArg` variant, `Infer` used to represent `_` as an argument to generic parameters when we don't know if its a type or a const argument. This made hir visitors that care about `TyKind::Infer` or `ConstArgKind::Infer` very error prone as checking for `TyKind::Infer`s in `visit_ty` would find *some* type infer arguments but not *all* of them as they would sometimes be lowered to `GenericArg::Infer` instead. Additionally the `visit_infer` method would previously only visit `GenericArg::Infer` not *all* infers (e.g. `TyKind::Infer`), this made it very easy to override `visit_infer` and expect it to visit all infers when in reality it would only visit *some* infers. --- This PR aims to fix those issues by making the `TyKind` and `ConstArgKind` types generic over whether the infer types/consts are represented by `Ty/ConstArgKind::Infer` or out of line (e.g. by a `GenericArg::Infer` or accessible by overiding `visit_infer`). We then make HIR Visitors convert all const args and types to the versions where infer vars are stored out of line and call `visit_infer` in cases where a `Ty`/`Const` would previously have had a `Ty/ConstArgKind::Infer` variant: API Summary ```rust enum AmbigArg {} enum Ty/ConstArgKind<Unambig = ()> { ... Infer(Unambig), } impl Ty/ConstArg { fn try_as_ambig_ty/ct(self) -> Option<Ty/ConstArg<AmbigArg>>; } impl Ty/ConstArg<AmbigArg> { fn as_unambig_ty/ct(self) -> Ty/ConstArg; } enum InferKind { Ty(Ty), Const(ConstArg), Ambig(InferArg), } trait Visitor { ... fn visit_ty/const_arg(&mut self, Ty/ConstArg<AmbigArg>) -> Self::Result; fn visit_infer(&mut self, id: HirId, sp: Span, kind: InferKind) -> Self::Result; } // blanket impl'd, not meant to be overriden trait VisitorExt { fn visit_ty/const_arg_unambig(&mut self, Ty/ConstArg) -> Self::Result; } fn walk_unambig_ty/const_arg(&mut V, Ty/ConstArg) -> Self::Result; fn walk_ty/const_arg(&mut V, Ty/ConstArg<AmbigArg>) -> Self::Result; ``` The end result is that `visit_infer` visits *all* infer args and is also the *only* way to visit an infer arg, `visit_ty` and `visit_const_arg` can now no longer encounter a `Ty/ConstArgKind::Infer`. Representing this in the type system means that it is now very difficult to mess things up, either accessing `TyKind::Infer` "just works" and you won't miss *some* type infers- or it doesn't work and you have to look at `visit_infer` or some `GenericArg::Infer` which forces you to think about the full complexity involved. Unfortunately there is no lint right now about explicitly matching on uninhabited variants, I can't find the context for why this is the case :woman_shrugging: I'm not convinced the framing of un/ambig ty/consts is necessarily the right one but I'm not sure what would be better. I somewhat like calling them full/partial types based on the fact that `Ty<Partial>`/`Ty<Full>` directly specifies how many of the type kinds are actually represented compared to `Ty<Ambig>` which which leaves that to the reader to figure out based on the logical consequences of it the type being in an ambiguous position. --- tool changes have been modified in their own commits for easier reviewing by anyone getting cc'd from subtree changes. I also attempted to split out "bug fixes arising from the refactoring" into their own commit so they arent lumped in with a big general refactor commit Fixes #112110
2025-01-23Rustdog :3cBoxy-8/+13
2025-01-23Make `hir::TyKind::TraitObject` use tagged ptrBoxy-2/+2
2025-01-22rustdoc: extract duplicated code into methodYotam Ofek-72/+45
2025-01-15Rollup merge of #135428 - camelid:attr-cleanup, r=GuillaumeGomezGuillaume Gomez-142/+112
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.
2025-01-15Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable, ↵Guillaume Gomez-5/+11
r=davidtwco deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead The `rustc_allowed_through_unstable_modules` attribute lets users call `std::mem::transmute` as `std::intrinsics::transmute`. The former is a reexport of the latter, and for a long time we didn't properly check stability for reexports, so making this a hard error now would be a breaking change for little gain. But at the same time, `std::intrinsics::transmute` is not the intended path for this function, so I think it is a good idea to show a deprecation warning when that path is used. This PR implements that, for all the functions in `std::intrinsics` that carry the attribute. I assume this will need ``@rust-lang/libs-api`` FCP.
2025-01-15Auto merge of #134353 - oli-obk:safe-target-feature-unsafe-by-default, ↵bors-5/+16
r=wesleywiser Treat safe target_feature functions as unsafe by default [less invasive variant] This unblocks * #134090 As I stated in https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 I think the previous impl was too easy to get wrong, as by default it treated safe target feature functions as safe and had to add additional checks for when they weren't. Now the logic is inverted. By default they are unsafe and you have to explicitly handle safe target feature functions. This is the less (imo) invasive variant of #134317, as it doesn't require changing the Safety enum, so it only affects FnDefs and nothing else, as it should.
2025-01-15Treat safe target_feature functions as unsafe by defaultOli Scherer-2/+13
2025-01-15show deprecation message in rustdoc, tooRalf Jung-5/+11
2025-01-15allowed_through_unstable_modules: support showing a deprecation message when ↵Ralf Jung-1/+1
the unstable module name is used
2025-01-14Fix clippy lintsGuillaume Gomez-4/+4
2025-01-14Add hir::HeaderSafety to make follow up commits simplerOli Scherer-4/+4
2025-01-13rustdoc: Eliminate `AttributesExt`Noah Lev-45/+20
The new code is more explicit and avoids trait magic that added needless complexity to this part of rustdoc.
2025-01-12rustdoc: Extract `AttributesExt::lists` trait method as functionNoah Lev-32/+21
The two implementations were identical, so there's no need to use a trait method.
2025-01-12rustdoc: Extract `AttributesExt::cfg` trait method as functionNoah Lev-80/+86
It's never overridden, so it shouldn't be on the trait.
2025-01-08Rename PatKind::Lit to ExprOli Scherer-2/+2
2025-01-07Rollup merge of #134989 - max-niederman:guard-patterns-hir, r=oli-obkMatthias Krüger-0/+1
Lower Guard Patterns to HIR. Implements lowering of [guard patterns](https://rust-lang.github.io/rfcs/3637-guard-patterns.html) (see the [tracking issue](#129967)) to HIR.
2025-01-04Auto merge of #135031 - RalfJung:intrinsics-without-body, r=oli-obkbors-1/+1
rustc_intrinsic: support functions without body We synthesize a HIR body `loop {}` but such bodyless intrinsics. Most of the diff is due to turning `ItemKind::Fn` into a brace (named-field) enum variant, because it carries a `bool`-typed field now. This is to remember whether the function has a body. MIR building panics to avoid ever translating the fake `loop {}` body, and the intrinsic logic uses the lack of a body to implicitly mark that intrinsic as must-be-overridden. I first tried actually having no body rather than generating the fake body, but there's a *lot* of code that assumes that all function items have HIR and MIR, so this didn't work very well. Then I noticed that even `rustc_intrinsic_must_be_overridden` intrinsics have MIR generated (they are filled with an `Unreachable` terminator) so I guess I am not the first to discover this. ;) r? `@oli-obk`
2025-01-04turn hir::ItemKind::Fn into a named-field variantRalf Jung-1/+1
2025-01-02rustdoc: treat `allowed_through_unstable_modules` as deprecationMichael Howell-1/+21
This ensures `std::intrinsics::transmute` is deemphasized in the search engine and other UI, by cleaning it into a deprecation without propagating it through reexports when the parent module is stable.
2024-12-31add guard patterns to HIR and implement loweringMax Niederman-0/+1
2024-12-31Unsafe binder support in rustdocMichael Goulet-5/+32
2024-12-28nits: librustdoc::cleanAlexis (Poliorcetics) Bourget-12/+10
- librustdoc::clean::clean_lifetime doesn't need a mut doc context - librustdoc::clean::normalize doesn't need a mut doc context - move Some() wrapping up into `clean_predicate()` - simplify nested if in librustdoc::clean::record_extern_fqn()
2024-12-25Improve rustdoc codeGuillaume Gomez-3/+3
2024-12-25Auto merge of #134703 - poliorcetics:ab/push-ovsylkzsoxku, r=GuillaumeGomezbors-12/+10
nits: Cleanup of `librustdoc::clean::Cfg::simplify_with` r? `@GuillaumeGomez`
2024-12-24nit: cleanups in `Cfg::simplify_with`Alexis (Poliorcetics) Bourget-12/+10
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-0/+2
2024-12-20Rollup merge of #134321 - dtolnay:docassocconst, r=fmeaseJacob Pratt-38/+55
Hide `= _` as associated constant value inside impl blocks Closes #134320. ### Before: <img src="https://github.com/user-attachments/assets/19d28811-45d2-4563-9726-f40c6af411c6" width="300">&nbsp;<img src="https://github.com/user-attachments/assets/1ecf8764-97ce-47f0-87fa-3b174d2fc578" width="300"> ### After: <img src="https://github.com/user-attachments/assets/6408c4ca-b1c4-42e4-884b-248833a4865f" width="300">&nbsp;<img src="https://github.com/user-attachments/assets/df2f6981-16f6-409f-8abb-73c0a4a71d6b" width="300"> r? `@fmease`
2024-12-19Rename TyMethodItem -> RequiredMethodItemDavid Tolnay-7/+9
2024-12-19Rename TyAssocTypeItem -> RequiredAssocTypeItemDavid Tolnay-7/+7
2024-12-19Split AssocConstItem into ProvidedAssocConstItem and ImplAssocConstItemDavid Tolnay-21/+32
2024-12-19Rename TyAssocConstItem -> RequiredAssocConstItemDavid Tolnay-8/+12
2024-12-18Rollup merge of #134161 - nnethercote:overhaul-token-cursors, r=spastorino许杰友 Jieyou Xu (Joe)-2/+2
Overhaul token cursors Some nice cleanups here. r? `````@davidtwco`````
2024-12-18Rename `RefTokenTreeCursor`.Nicholas Nethercote-2/+2
Because `TokenStreamIter` is a much better name for a `TokenStream` iterator. Also rename the `TokenStream::trees` method as `TokenStream::iter`, and some local variables.
2024-12-17Auto merge of #134376 - jdonszelmann:fix-rustdoc-perf, r=jieyouxubors-1/+1
Try to fix perf regression in rustdoc after hir attributes Slight performance regression introduced in #131808 r? `@jieyouxu`
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-1/+1