summary refs log tree commit diff
path: root/src/librustdoc/clean/utils.rs
AgeCommit message (Collapse)AuthorLines
2022-09-17Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnrbors-4/+3
Use only ty::Unevaluated<'tcx, ()> in type system r? `@lcnr`
2022-09-15Streamline `register_res`.Nicholas Nethercote-21/+5
Turns out it's only ever passed a `Res::Def`.
2022-09-13rebaseb-naber-1/+1
2022-09-13use ty::Unevaluated<'tcx, ()> in type systemb-naber-3/+2
2022-09-09RPITIT placeholder itemsMichael Goulet-2/+2
2022-09-03Rustdoc-Json: Add enum discriminantNixon Enraght-Moony-9/+25
2022-08-29Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.Nicholas Nethercote-4/+4
`rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations.
2022-08-09remove Clean trait implementation for ast::ModuleGuillaume Gomez-4/+4
2022-08-03remove Clean trait implementation for ty::RegionGuillaume Gomez-4/+4
2022-07-29Change maybe_body_owned_by to take local def idMiguel Guarniz-2/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-24Remove Clean trait implementation for ConstantGuillaume Gomez-4/+4
2022-07-23Remove Clean trait implementation for hir::Ty and middle::TyGuillaume Gomez-4/+5
2022-07-21Remove unused field in ItemKind::KeywordItemGuillaume Gomez-1/+1
2022-07-04Rollup merge of #98814 - fmease:minimal-fix-for-issue-97933, r=GuillaumeGomezMatthias Krüger-6/+87
rustdoc: Censor certain complex unevaluated const exprs Fixes #97933. This is more of a hotfix for the aforementioned issue. By that, I mean that my proposed patch is not the best solution but one that does not change as much existing code. It treats symptoms rather than the root cause. This PR “censors” certain complex unevaluated constant expressions like `match`es, blocks, function calls, struct literals etc. by pretty-printing them as `_` / `{ _ }` (number and string literals, paths and `()` are still printed as one would expect). Resorting to this placeholder is preferable to printing the full expression verbatim since they can be quite large and verbose resulting in an unreadable mess in the generated documentation. Further, mindlessly printing the const would leak private and `doc(hidden)` struct fields (#97933), at least in the current stable & nightly implementations which rely on `span_to_snippet` (!) and `rustc_hir_pretty::id_to_string`. The censoring of _verbose_ expressions is probably going to stay longer term. However, in regards to private and `doc(hidden)` struct fields, I have a more proper fix in mind which I have already partially implemented locally and for which I am going to open a separate PR sometime soon. For that, I was already in contact with `@GuillaumeGomez.` The proper fix involves rustdoc not falling back on pretty-printing unevaluated consts so easily (what this PR is concerned about) and instead preferring to print evaluated consts which contain more information allowing it to selectively hide private and `doc(hidden)` fields, create hyperlinks etc. generally making the output more granular and precise (compared to the brutal `_` placeholder). Unfortunately, I was a bit too late and the issue just hit stable (1.62). Should this be backported to beta or even a potential 1.62.1? r? `@GuillaumeGomez`
2022-07-04rustdoc: censor certain complex unevaluated const exprsLeón Orell Valerian Liehr-6/+87
2022-06-21Rustdoc fallout.Camille GILLOT-6/+3
2022-06-14address reviewb-naber-9/+10
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-7/+6
2022-06-14Rename the `ConstS::val` field as `kind`.Nicholas Nethercote-2/+2
And likewise for the `Const::val` method. Because its type is called `ConstKind`. Also `val` is a confusing name because `ConstKind` is an enum with seven variants, one of which is called `Value`. Also, this gives consistency with `TyS` and `PredicateS` which have `kind` fields. The commit also renames a few `Const` variables from `val` to `c`, to avoid confusion with the `ConstKind::Value` variant.
2022-05-25Auto merge of #97365 - klensy:rustdoc-vs-clippy, r=notriddlebors-1/+1
rustdoc: fix few clippy lints Fix few clippy lints: second commit - perf ones, first - other ones.
2022-05-24fix simple clippy lintsklensy-1/+1
2022-05-24Rollup merge of #97288 - compiler-errors:tcxify-rustdoc, r=Dylan-DPCDylan DPC-11/+11
Lifetime variance fixes for rustdoc #97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be unified by shortening both to some common lifetime. This is doable, since everything is already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`. Split out from #97287 so the rustdoc team can review independently.
2022-05-22Lifetime variance fixes for rustdocMichael Goulet-11/+11
2022-05-21Extend `substs_to_args` into a perfectly-sized Vec almost every timeMichael Howell-16/+16
2022-05-21Shrink GenericArgs/PathSegment with boxed slicesMichael Howell-4/+4
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-18/+22
2022-05-10update rustdoclcnr-4/+3
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-1/+1
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-04-16Rename `def_id` into `item_id` when the type is `ItemId` for readabilityGuillaume Gomez-2/+2
2022-04-12rustdoc: discr. required+provided assoc consts+tysLeón Orell Valerian Liehr-1/+1
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-1/+1
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30fix rustdoclcnr-1/+1
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-1/+1
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-14Auto merge of #94139 - est31:let_else_rustdoc, r=notriddlebors-4/+2
librustdoc: adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This PR handles librustdoc.
2022-03-06Fix rustdoc for GATs with with anonymous bound regionsMichael Goulet-20/+25
2022-03-04librustdoc: adopt let else in more placesest31-4/+2
2022-02-21Auto merge of #94225 - matthiaskrgr:rollup-0728x8n, r=matthiaskrgrbors-5/+1
Rollup of 10 pull requests Successful merges: - #91192 (Some improvements to the async docs) - #94143 (rustc_const_eval: adopt let else in more places) - #94156 (Gracefully handle non-UTF-8 string slices when pretty printing) - #94186 (Update pin_static_ref stabilization version.) - #94189 (Implement LowerHex on Scalar to clean up their display in rustdoc) - #94190 (Use Metadata::modified instead of FileTime::from_last_modification_ti…) - #94203 (CTFE engine: Scalar: expose size-generic to_(u)int methods) - #94211 (Better error if the user tries to do assignment ... else) - #94215 (trait system: comments and small nonfunctional changes) - #94220 (Correctly handle miniz_oxide extern crate declaration) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-21update rustdoclcnr-1/+1
2022-02-20Implement LowerHex on Scalar to clean up their display in rustdocGuillaume Gomez-5/+1
2022-02-20Rollup merge of #94091 - GuillaumeGomez:rustdoc-const-computed-value, r=oli-obkMatthias Krüger-1/+5
Fix rustdoc const computed value Fixes #85088. It looks like this now (instead of hexadecimal): ![Screenshot from 2022-02-17 17-55-39](https://user-images.githubusercontent.com/3050060/154532115-0f9861a0-406f-4c9c-957f-32bedd8aca7d.png) r? ````@oli-obk````
2022-02-19Don't render Const computed values in hexadecimal for DisplayGuillaume Gomez-1/+5
2022-02-15Overhaul `Const`.Nicholas Nethercote-5/+5
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-15Overhaul `RegionKind` and `Region`.Nicholas Nethercote-1/+1
Specifically, change `Region` from this: ``` pub type Region<'tcx> = &'tcx RegionKind; ``` to this: ``` pub struct Region<'tcx>(&'tcx Interned<RegionKind>); ``` This now matches `Ty` and `Predicate` more closely. Things to note - Regions have always been interned, but we haven't been using pointer-based `Eq` and `Hash`. This is now happening. - I chose to impl `Deref` for `Region` because it makes pattern matching a lot nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`. - Various methods are moved from `RegionKind` to `Region`. - There is a lot of tedious sigil changes. - A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`. - A couple of test outputs change slightly, I'm not sure why, but the new outputs are a little better.
2022-02-14update two rustdoc commentsEllen-3/+3
2022-02-12change to a struct variantEllen-4/+4
2022-01-18Move render_macro_matcher to own moduleDavid Tolnay-189/+2
2022-01-18Render more readable macro matchers in rustdocDavid Tolnay-4/+139
2022-01-15initial revertEllen-1/+1
2022-01-13Rollup merge of #92334 - dtolnay:rustdocmatcher, r=camelid,GuillaumeGomezMatthias Krüger-6/+55
rustdoc: Preserve rendering of macro_rules matchers when possible Fixes #92331. This approach restores the behavior prior to #86282 **if** the matcher token held by the compiler **and** the matcher token found in the source code are identical TokenTrees. Thus #86208 remains fixed, but without regressing formatting for the vast majority of macros which are not macro-generated.
2022-01-07rustdoc: Introduce a resolver cache for sharing data between early doc link ↵Vadim Petrochenkov-0/+1
resolution and later passes