about summary refs log tree commit diff
path: root/src/librustdoc/clean
AgeCommit message (Collapse)AuthorLines
2022-03-01Rollup merge of #93385 - CraftSpider:rustdoc-ty-fixes, r=camelidDylan DPC-42/+40
Rustdoc ty consistency fixes Changes to make rustdoc cleaning of ty more consistent with hir, and hopefully use it in more places. r? `@camelid`
2022-02-25Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillotMatthias Krüger-2/+2
Remove in band lifetimes As discussed in t-lang backlog bonanza, the `in_band_lifetimes` FCP closed in favor for the feature not being stabilized. This PR removes `#![feature(in_band_lifetimes)]` in its entirety. Let me know if this PR is too hasty, and if we should instead do something intermediate for deprecate the feature first. r? `@scottmcm` (or feel free to reassign, just saw your last comment on #44524) Closes #44524
2022-02-24Remove LifetimeDefOriginMichael Goulet-2/+2
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-4/+2
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-1/+1
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-24Auto merge of #94129 - cjgillot:rmeta-table, r=petrochenkovbors-2/+2
Back more metadata using per-query tables r? `@ghost`
2022-02-23rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.Eduard-Mihai Burtescu-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-2/+2
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-19Stop interning stability.Camille GILLOT-2/+2
2022-02-19Don't render Const computed values in hexadecimal for DisplayGuillaume Gomez-1/+5
2022-02-18Auto merge of #94088 - oli-obk:revert, r=jackh726bors-6/+1
Revert #91403 fixes #94004 r? `@pnkfelix` `@cjgillot`
2022-02-17Rollup merge of #94011 - est31:let_else, r=lcnrMatthias Krüger-3/+1
Even more let_else adoptions Continuation of #89933, #91018, #91481, #93046, #93590.
2022-02-17Revert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk"Oli Scherer-6/+1
This reverts commit 3cfa4def7c87d571bd46d92fed608edf8fad236e, reversing changes made to 5d8767cb229b097fedb1dd4bd9420d463c37774f.
2022-02-16Adopt let_else in even more placesest31-3/+1
2022-02-15Overhaul `Const`.Nicholas Nethercote-6/+6
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-6/+6
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-15Overhaul `TyS` and `Ty`.Nicholas Nethercote-1/+1
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
2022-02-14Auto merge of #93938 - BoxyUwU:fix_res_self_ty, r=lcnrbors-7/+7
Make `Res::SelfTy` a struct variant and update docs I found pattern matching on a `(Option<DefId>, Option<(DefId, bool)>)` to not be super readable, additionally the doc comments on the types in a tuple variant aren't visible anywhere at use sites as far as I can tell (using rust analyzer + vscode) The docs incorrectly assumed that the `DefId` in `Option<(DefId, bool)>` would only ever be for an impl item and I also found the code examples to be somewhat unclear about which `DefId` was being talked about. r? `@lcnr` since you reviewed the last PR changing these docs
2022-02-14update two rustdoc commentsEllen-3/+3
2022-02-12change to a struct variantEllen-5/+5
2022-02-12Filter out anonymous generics in rustdoc.Camille GILLOT-1/+6
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-1/+0
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-1/+1
2022-02-09Rollup merge of #93746 - cjgillot:nodefii, r=nikomatsakisYuki Okushi-1/+2
Remove defaultness from ImplItem. This information is not really used anywhere, except HIR pretty-printing. This makes ImplItem and TraitItem more similar.
2022-02-07Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakisbors-0/+1
Lazy type-alias-impl-trait Previously opaque types were processed by 1. replacing all mentions of them with inference variables 2. memorizing these inference variables in a side-table 3. at the end of typeck, resolve the inference variables in the side table and use the resolved type as the hidden type of the opaque type This worked okayish for `impl Trait` in return position, but required lots of roundabout type inference hacks and processing. This PR instead stops this process of replacing opaque types with inference variables, and just keeps the opaque types around. Whenever an opaque type `O` is compared with another type `T`, we make the comparison succeed and record `T` as the hidden type. If `O` is compared to `U` while there is a recorded hidden type for it, we grab the recorded type (`T`) and compare that against `U`. This makes implementing * https://github.com/rust-lang/rfcs/pull/2515 much simpler (previous attempts on the inference based scheme were very prone to ICEs and general misbehaviour that was not explainable except by random implementation defined oddities). r? `@nikomatsakis` fixes #93411 fixes #88236
2022-02-04Rollup merge of #93638 - notriddle:notriddle/unused-hash, r=GuillaumeGomezMatthias Krüger-1/+1
rustdoc: remove unused Hash impl
2022-02-03rustdoc: remove unused Hash implMichael Howell-1/+1
2022-02-03rustdoc: clippy::complexity fixesMatthias Krüger-5/+2
clippy::map_flatten clippy::clone_on_copy clippy::useless_conversion clippy::needless_arbitrary_self_type
2022-02-03Remove defaultness from ImplItem.Camille GILLOT-1/+2
2022-02-02Rollup merge of #93542 - GuillaumeGomez:lifetime-elision, r=oli-obkMatthias Krüger-3/+13
Prevent lifetime elision in type alias Fixes #93401. Apparently, the problem has been fixed in the compiler. r? `@oli-obk`
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-0/+1
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-01Fix lifetime elision in type aliasesGuillaume Gomez-3/+13
2022-01-30Auto merge of #92711 - zredb:issue-90187-fix, r=notriddlebors-13/+1
rustdoc: Remove `def_id_no_primitives` Fixes #90187.
2022-01-30Rollup merge of #92908 - dtolnay:rustdoc, r=GuillaumeGomezEric Huss-53/+242
Render more readable macro matcher tokens in rustdoc Follow-up to #92334. This PR lifts some of the token rendering logic from https://github.com/dtolnay/prettyplease into rustdoc so that even the matchers for which a source code snippet is not available (because they are macro-generated, or any other reason) follow some baseline good assumptions about where the tokens in the macro matcher are appropriate to space. The below screenshots show an example of the difference using one of the gnarliest macros I could find. Some things to notice: - In the **before**, notice how a couple places break in between `$(....)`↵`*`, which is just about the worst possible place that it could break. - In the **before**, the lines that wrapped are weirdly indented by 1 space of indentation relative to column 0. In the **after**, we use the typical way of block indenting in Rust syntax which is put the open/close delimiters on their own line and indent their contents by 4 spaces relative to the previous line (so 8 spaces relative to column 0, because the matcher itself is indented by 4 relative to the `macro_rules` header). - In the **after**, macro_rules metavariables like `$tokens:tt` are kept together, which is how just about everybody writing Rust today writes them. ## Before ![Screenshot from 2022-01-14 13-05-53](https://user-images.githubusercontent.com/1940490/149585105-1f182b78-751f-421f-a234-9dbc04fa3bbd.png) ## After ![Screenshot from 2022-01-14 13-06-04](https://user-images.githubusercontent.com/1940490/149585118-d4b52ea7-3e67-4b6e-a12b-31dfb8172f86.png) r? `@camelid`
2022-01-28Same code for ty and hir impl itemsRune Tynan-16/+16
2022-01-28Remove now-unnecessary blanket impl HIR checkRune Tynan-22/+5
2022-01-28Set visibility to inherited in trait impls to match HIRRune Tynan-1/+10
2022-01-28Remove extra empty doc lineGuillaume Gomez-1/+0
2022-01-26Convert empty tuple to DefaultReturn in ty pathRune Tynan-1/+8
2022-01-26Don't use is_local to determine function cleaning method call intentRune Tynan-6/+5
2022-01-25Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillotbors-6/+5
Store a `Symbol` instead of an `Ident` in `AssocItem` This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-25Auto merge of #92353 - Kobzol:doc-attr-lists-gat, r=GuillaumeGomezbors-46/+17
Rustdoc: remove ListAttributesIter and use impl Iterator instead This is a continuation of https://github.com/rust-lang/rust/pull/92227. I found that `ListAttributesIter` did not optimize well and replacing it with a simple `impl Iterator` resulted in 1-3 % instruction count wins locally. Because I needed to use `impl Iterator` on a slice of AST attributes, I had to implement it using GAT + impl trait. I also have a version without GAT [here](https://github.com/Kobzol/rust/commit/5470e2a65cbd3086d19f0847f44ca9cbbc049689), if GATs are not welcome in rustdoc :D Locally it resulted in equal performance numbers. Can I ask for a perf. run? Thanks. r? rust-lang/rustdoc
2022-01-25Rollup merge of #93169 - CraftSpider:rustdoc-clean-inconsistency, ↵Matthias Krüger-6/+22
r=GuillaumeGomez Fix inconsistency of local blanket impls When a blanket impl is local, go through HIR instead of middle. This fixes inconsistencies with data detected during JSON generation. Expected this change to take longer. I also tried doing the whole item through existing clean architecture, but it didn't work out trivially, and felt like it would have added more complexity than it removed. Properly fixes #83718
2022-01-21rustdoc: Make some `pub` items crate-privateNoah Lev-10/+10
They don't need to be `pub`. Making them crate-private improves code clarity and `dead_code` linting.
2022-01-21Remove FIXME and fix inconsistency of local blanket impls by using HIR for themRune Tynan-6/+22
2022-01-20Rollup merge of #93038 - GuillaumeGomez:block-doc-comments, r=notriddleMatthias Krüger-2/+2
Fix star handling in block doc comments Fixes #92872. Some extra explanation about this PR and why https://github.com/rust-lang/rust/pull/92357 created this regression: when we merge doc comment kinds for example in: ```rust /// he /** * hello */ #[doc = "boom"] ``` We don't want to remove the empty lines between them. However, to correctly compute the "horizontal trim", we still need it, so instead, I put back a part of the "vertical trim" directly in the "horizontal trim" computation so it doesn't impact the output buffer but allows us to correctly handle the stars. r? ``@camelid``
2022-01-20More clean upGuillaume Gomez-8/+4