-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rustdoc: various cross-crate reexport fixes #103885
rustdoc: various cross-crate reexport fixes #103885
Conversation
Some changes occurred in src/librustdoc/clean/types.rs cc @camelid |
5040540
to
3e4c6ad
Compare
Looks good to me, thanks for working on this. Let's wait for @cjgillot's approval too. Also I'd like to have @notriddle's confirmation too. |
3e4c6ad
to
eda9cd7
Compare
eda9cd7
to
3b9ed4a
Compare
@@ -1677,6 +1701,9 @@ pub(crate) fn clean_middle_ty<'tcx>( | |||
|
|||
inline::record_extern_fqn(cx, did, ItemType::Trait); | |||
|
|||
// FIXME(fmease): Hide the trait-object lifetime bound if it coincides with its default | |||
// to partially address #44306. Follow the rules outlined at | |||
// https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes |
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.
There is an object lifetime default query, so you can just test equality.
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.
Yep, I am aware of the existence of tcx.object_lifetime_default
but it's not the whole solution to the problem, it's only part of it.
The query doesn't take a Region
, it takes the DefId
of a type parameter of an item, e.g. the T
of Box
. Anyways, that's all fine and good and explained in the linked Zulip topic. I'd really prefer to implement that in a follow-up PR to avoid bitrotting, to make reviewing easier and since that logic will be a little bit more complicated.
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.
Right, so regarding trait-object-type lifetime-bound defaults, my local work-in-progress patch is currently +168/-43 in size and it's not as straightforward as this PR meaning I won't add it to it.
3b9ed4a
to
52f6ba6
Compare
☔ The latest upstream changes (presumably #103962) made this pull request unmergeable. Please resolve the merge conflicts. |
…ss-crate functions and methods
…ions & function pointers for consistency with the way we display local definitions (cleaned from HIR, not from rustc_middle).
… where-clause to param declaration site I've overlooked this in rust-lang#103190.
…ds in trait-object types
as well as some FIXMEs
52f6ba6
to
5ccaed2
Compare
@GuillaumeGomez LGTM on the use of rustc data structures. |
Thanks to both of you! @bors r=cjgillot,GuillaumeGomez rollup |
…-reexport-fixes, r=cjgillot,GuillaumeGomez rustdoc: various cross-crate reexport fixes Fixes for various smaller cross-crate reexport issues. The PR is split into several commits for easier review. Will be squashed after approval. Most notable changes: * We finally render late-bound lifetimes in the generic parameter list of cross-crate functions & methods. Previously, we would display the re-export of `pub fn f<'s>(x: &'s str) {}` as `pub fn f(x: &'s str)` * We now render unnamed parameters of cross-crate functions and function pointers as underscores since that's exactly what we do for local definitions, too. Mentioned as a bug in rust-lang#44306. * From now on, the rendering of cross-crate trait-object types is more correct: * `for<>` parameter lists (for higher-ranked lifetimes) are now shown * the return type of `Fn{,Mut,Once}` trait bounds is now displayed Regarding the last list item, here is a diff for visualization (before vs. after): ```patch - dyn FnOnce(&'any str) + 'static + dyn for<'any> FnOnce(&'any str) -> bool + 'static ``` The redundant `+ 'static` will be removed in a follow-up PR that will hide trait-object lifetime-bounds if they coincide with [their default](https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes) (see [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/clean_middle_ty.3A.20I.20need.20to.20add.20a.20parameter/near/307143097)). `FIXME(fmease)`s were added. `@rustbot` label A-cross-crate-reexports r? `@GuillaumeGomez`
Rollup of 9 pull requests Successful merges: - rust-lang#103885 (rustdoc: various cross-crate reexport fixes) - rust-lang#103914 (Make underscore_literal_suffix a hard error.) - rust-lang#104045 (Add type_array to BaseTypeMethods) - rust-lang#104056 (Vec: IntoIterator signature consistency) - rust-lang#104059 (Fix typo in `rustc_middle/lint.rs`) - rust-lang#104062 (rustdoc: remove unused CSS `#sidebar-filler`) - rust-lang#104065 (Migrate rust logo filter to CSS variables) - rust-lang#104066 (LLVM 16: Update RISCV data layout) - rust-lang#104074 (rustdoc: Add an example for round that is different from truncate) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…r-obj-lt-bnds, r=notriddle,cgillot,GuillaumeGomez rustdoc: re-elide cross-crate default trait-object lifetime bounds Hide trait-object lifetime bounds (re-exported from an external crate) if they coincide with [their default](https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes). Partially addresses rust-lang#44306. Follow-up to rust-lang#103885. [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/clean_middle_ty.3A.20I.20need.20to.20add.20a.20parameter/near/307143097). Most notably, if `std` exported something from `core` containing a type like `Box<dyn Fn()>`, then it would now be rendered as `Box<dyn Fn(), Global>` instead of `Box<dyn Fn() + 'static, Global>` (hiding `+ 'static` as it is the default in this case). Showing `Global` here is a separate issue, rust-lang#80379, which is on my agenda. Note that I am not really fond of the fact that I had to add a parameter to such a widely used function (30+ call sites) to address such a niche bug. CC `@GuillaumeGomez` Requesting a review from a compiler contributor or team member as recommended on Zulip. r? compiler --- `@rustbot` label T-compiler T-rustdoc A-cross-crate-reexports
…-args, r=<try> rustdoc: elide cross-crate default generic arguments Early draft. Requesting perf run. Thx :) CC `@GuillaumeGomez` Elide cross-crate generic arguments if they coincide with their default. TL;DR: Most notably, no more `Box<…, Global>` in `std`'s docs, just `Box<…>` from now on. Fixes rust-lang#80379. Also helps with rust-lang#44306. Follow-up to rust-lang#103885,rust-lang#107637. `@rustbot` label T-rustdoc A-cross-crate-reexports S-experimental r? `@ghost`
…-args, r=<try> rustdoc: elide cross-crate default generic arguments Elide cross-crate generic arguments if they coincide with their default. TL;DR: Most notably, no more `Box<…, Global>` in `std`'s docs, just `Box<…>` from now on. Fixes rust-lang#80379. Also helps with rust-lang#44306. Follow-up to rust-lang#103885, rust-lang#107637. r? `@ghost`
…-args, r=<try> rustdoc: elide cross-crate default generic arguments Elide cross-crate generic arguments if they coincide with their default. TL;DR: Most notably, no more `Box<…, Global>` in `std`'s docs, just `Box<…>` from now on. Fixes rust-lang#80379. Also helps with rust-lang#44306. Follow-up to rust-lang#103885, rust-lang#107637. r? `@ghost`
…en-args, r=GuillaumeGomez rustdoc: elide cross-crate default generic arguments Elide cross-crate generic arguments if they coincide with their default. TL;DR: Most notably, no more `Box<…, Global>` in `std`'s docs, just `Box<…>` from now on. Fixes rust-lang#80379. Also helps with rust-lang#44306. Follow-up to rust-lang#103885, rust-lang#107637. r? `@ghost`
…en-args, r=GuillaumeGomez rustdoc: elide cross-crate default generic arguments Elide cross-crate generic arguments if they coincide with their default. TL;DR: Most notably, no more `Box<…, Global>` in `std`'s docs, just `Box<…>` from now on. Fixes rust-lang#80379. Also helps with rust-lang#44306. Follow-up to rust-lang#103885, rust-lang#107637. r? ``@ghost``
Rollup merge of rust-lang#112463 - fmease:rustdoc-elide-x-crate-def-gen-args, r=GuillaumeGomez rustdoc: elide cross-crate default generic arguments Elide cross-crate generic arguments if they coincide with their default. TL;DR: Most notably, no more `Box<…, Global>` in `std`'s docs, just `Box<…>` from now on. Fixes rust-lang#80379. Also helps with rust-lang#44306. Follow-up to rust-lang#103885, rust-lang#107637. r? ``@ghost``
Fixes for various smaller cross-crate reexport issues.
The PR is split into several commits for easier review. Will be squashed after approval.
Most notable changes:
Previously, we would display the re-export of
pub fn f<'s>(x: &'s str) {}
aspub fn f(x: &'s str)
since that's exactly what we do for local definitions, too. Mentioned as a bug in Re-exported types have confusingly different documentation #44306.
for<>
parameter lists (for higher-ranked lifetimes) are now shownFn{,Mut,Once}
trait bounds is now displayedRegarding the last list item, here is a diff for visualization (before vs. after):
The redundant
+ 'static
will be removed in a follow-up PR that will hide trait-object lifetime-bounds if they coincide with their default (see Zulip discussion).FIXME(fmease)
s were added.@rustbot label A-cross-crate-reexports
r? @GuillaumeGomez