Skip to content
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

Use computed visibility in rustdoc #88447

Merged
merged 2 commits into from
Nov 10, 2021

Conversation

inquisitivecrystal
Copy link
Contributor

@inquisitivecrystal inquisitivecrystal commented Aug 29, 2021

This PR changes librustdoc to use computed visibility instead of syntactic visibility. It was initially part of #88019, but was separated due to concerns that it might cause a regression somewhere we couldn't predict.

r? @jyn514
cc @cjgillot @petrochenkov

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 29, 2021
@jyn514
Copy link
Member

jyn514 commented Aug 29, 2021

There are a few other places in librustdoc that should be checked to see if they can use computed visibility. However, I don't understand them, so they're best left to someone who knows what they're doing.

Can you open an issue for this so it doesn't get forgotten? Ideally with links to the relevant code :) but no worries if that turns out to be a pain.

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 29, 2021
@jyn514
Copy link
Member

jyn514 commented Aug 29, 2021

This should fix the issue @petrochenkov mentioned in #88019 (comment), right, macro_export macros should now be displayed with the proper visibility? Can you add a test for that?

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 29, 2021
@inquisitivecrystal
Copy link
Contributor Author

inquisitivecrystal commented Aug 29, 2021

There are a few other places in librustdoc that should be checked to see if they can use computed visibility. However, I don't understand them, so they're best left to someone who knows what they're doing.

Can you open an issue for this so it doesn't get forgotten? Ideally with links to the relevant code :) but no worries if that turns out to be a pain.

It turns out I spoke too soon! There are fewer instances than I thought, and I should hopefully be able to fix all of them. The reason I thought they were above my paygrade was that I tried fixing one and it made tests fail, but it looks like I was just doing something wrong? It would still be good to have you check them over, of course.

This should fix the issue @petrochenkov mentioned in #88019 (comment), right, macro_export macros should now be displayed with the proper visibility? Can you add a test for that?

That already works, since I did a workaround in that PR (specifically, I checked for the macro_export directly). Do you still want me to do a test?

Oh, also, I think we need an is_public method on ty::Visibility. It seems to pop up all over the place. Should I add that here, or should that be a seperate PR?

@jyn514
Copy link
Member

jyn514 commented Aug 29, 2021

Do you still want me to do a test?

Yes, please.

Oh, also, I think we need an is_public method on ty::Visibility. It seems to pop up all over the place. Should I add that here, or should that be a seperate PR?

Here is fine.

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 13, 2021
@jyn514
Copy link
Member

jyn514 commented Sep 25, 2021

@inquisitivecrystal do you know when you'll get a chance to look at this?

@inquisitivecrystal
Copy link
Contributor Author

@inquisitivecrystal do you know when you'll get a chance to look at this?

Sorry for dropping off the face of the earth! I've been dealing with a lot of stuff IRL.

I don't know exactly when I'll have a chance to work on this again, but I'm hoping it'll be in the next few weeks. The sooner I can find the time the happier I'll be.

@bors

This comment has been minimized.

@inquisitivecrystal
Copy link
Contributor Author

inquisitivecrystal commented Oct 16, 2021

Okay, first off, I apologize for taking such a long amount of time to get back to this.

Do you still want me to do a test?

Yes, please.

I've gotten myself kind of confused. (I'll also mention that most of this is drawn from notes I wrote up months ago, which probably isn't helping.)

The relevant line, as adjusted by #88019, is here:

let is_pub = item.vis.node.is_pub() || self.cx.tcx.has_attr(def_id, sym::macro_export);

This checks whether an AST item is public by checking its syntactic visibility. After this PR, it would instead use computed visibility. is_pub is then used in a few places:

if is_pub {
self.store_path(item.def_id.to_def_id());
}

_ if self.inlining && !is_pub => {}

if is_pub && self.inside_public_path {
let please_inline = attrs.iter().any(|item| match item.meta_item_list() {
Some(ref list) if item.has_name(sym::doc) => {
list.iter().any(|i| i.has_name(sym::inline))
}
_ => false,
});

The first one seems irrelevant to macros. All store_path does is write to exact_paths, which is only used for creating implementors sections. Implementors sections have nothing to do with macros. The third one also seems irrelevant, since it only concerns use declarations, though I'm less sure in that case.

The second case is applicable to macros. It looks like what it's doing is making sure that only public items are ever inlined, which makes sense, since they're the only items that can be imported via a use statement. This is backed up by the test inline_local/macro_by_example.rs. This effectively tests whether #[macro_export] macros are treated as public for inlining (they are). The test fails if I remove the #[macro_export] special casing from is_pub, though it starts working again once I switch to computed visibility.

I think this test may cover everything, but I'm not certain. Am I missing or misunderstanding anything?

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your writeup is convincing to me, I think the existing test is fine :) just one question and then I think we can merge this.

src/librustdoc/visit_ast.rs Outdated Show resolved Hide resolved
@inquisitivecrystal
Copy link
Contributor Author

inquisitivecrystal commented Nov 8, 2021

For the last few days I've been having a look at expanding this to all of rustdoc, as we discussed above a while ago. I'm sorry I didn't update you on my status. I think I've almost got it working, but there's this one really tricky problem I don't know how to deal with.

let mut denied = !(import.vis.node.is_pub()
|| (cx.render_options.document_private && import.vis.node.is_pub_restricted()))
|| pub_underscore
|| attrs.iter().any(|a| {
a.has_name(sym::doc)
&& match a.meta_item_list() {
Some(l) => {
attr::list_contains_name(&l, sym::no_inline)
|| attr::list_contains_name(&l, sym::hidden)
}
None => false,
}
});

On that second line, it checks whether the syntactic visibility is either public or restricted. In the HIR, there are four VisibilityKinds: Public, Crate, Restricted, and Inherited. At the level of computed visibility, there are only three visibilities: Public, Restricted, and Invisible. My first attempt was to do a direct translation, where a VisibilityKind of public or restricted would be equivalent to a computed visibility of public or restricted. However, that's not accurate.

pub mod foo {
// @!has 'foo/foo/union.Union.html'
use crate::reexports::Union;
}

In the case of this test, the use declaration has a VisibilityKind of Inherited, but a computed visibility of Restricted. Note that the conversion is lossy: in this case, pub(self) use would have had a VisibilityKind of Restricted but the same computed visibility. Thus, in document private items mode, rustdoc currently documents the pub(self) use version but not the version here, despite them being equivalent in meaning. At least, if I'm understanding the situation correctly, which I very well might not be.

How should I handle this?

@jyn514
Copy link
Member

jyn514 commented Nov 8, 2021

Ugh, that logic is painful. It's trying to predict ahead of time whether the item will be stripped, but before the tcx is available and using the AST visibility.

Thus, in document private items mode, rustdoc currently documents the pub(self) use version but not the version here, despite them being equivalent in meaning.

That definitely seems like a bug, it should be consistent between the two. @GuillaumeGomez you added this in #86841 - what was your goal in sometimes not inlining here?

@jyn514
Copy link
Member

jyn514 commented Nov 8, 2021

@inquisitivecrystal I think it makes sense to land your other changes in the meantime if you want to push them :)

@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 8, 2021
@inquisitivecrystal inquisitivecrystal changed the title Use computed visibility in librustdoc::visit_ast Use computed visibility in rustdoc Nov 8, 2021
@GuillaumeGomez
Copy link
Member

#86841 was because we have different macro kinds with different visibility settings. The macro 2.0 can be handled like any items whereas the old macros can't. And because of that, we have this weird handling. If it can be improved, I'm all for it! :D

@inquisitivecrystal
Copy link
Contributor Author

#86841 was because we have different macro kinds with different visibility settings. The macro 2.0 can be handled like any items whereas the old macros can't. And because of that, we have this weird handling. If it can be improved, I'm all for it! :D

I think #88019 means they can be treated the same now. Does that open up any directions for improvement?

@jyn514
Copy link
Member

jyn514 commented Nov 9, 2021

@GuillaumeGomez I don't really understand your response; what was the goal of adding the special casing? What does it have to do with macros?

@GuillaumeGomez
Copy link
Member

The issue fixed in #86841 was for the macro 2.0 and a small cleanup. Unless I missed something? Sorry if my explanations aren't clear... Let me try again:

We weren't rendering macros 2.0 correctly because we handled them like the old macros (their visibility too). So I simply changed how we handled them so it was working as expected.

There wasn't big changes in how we handle visibility as far as I can see but maybe I missed something?

@jyn514
Copy link
Member

jyn514 commented Nov 9, 2021

@GuillaumeGomez I'm asking specifically about this change: https://github.com/rust-lang/rust/pull/86841/files#diff-384affc1b4190940f114f3fcebbf969e7e18657a71ef9001da6b223a036687d9R2057
It seems unrelated to either macros or the rest of the PR.

@GuillaumeGomez
Copy link
Member

Oh I see. Sorry, missed it. So for this one, the goal was to fix the display of reexported items if the "--document-private-items" option is used (it's described as is in the PR description). However in this case it seems like it's impacting all items, not just the reexported ones.

@jyn514
Copy link
Member

jyn514 commented Nov 10, 2021

visibility.is_accessible_from(parent_mod.to_def_id(), cx.tcx) does the same thing

Hmm, are you sure? That makes me worried we'll run into #64762. Can you add a test with a nested import?

@inquisitivecrystal
Copy link
Contributor Author

visibility.is_accessible_from(parent_mod.to_def_id(), cx.tcx) does the same thing

Hmm, are you sure? That makes me worried we'll run into #64762. Can you add a test with a nested import?

Am I sure that visibility.is_accessible_from(parent_mod.to_def_id(), cx.tcx) is equivalent to vis.is_at_least(ty::Visibility::Restricted(parent_mod.to_def_id()), cx.tcx)? Yes, fairly, after reading the definition.

I'll confess I don't grasp how #64762 could affect this. Could you explain what that would look like and what I should be testing for? I'm sorry I keep having so many questions.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rustdoc changes LGTM. @petrochenkov how do you feel about the switch from vis == Visibility::Public to vis.is_pub() in the resolver?

@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 10, 2021
@petrochenkov
Copy link
Contributor

Mostly neutral, vis == Visibility::Public was already short enough, but I guess it's common enough to introduce a slightly shorter method instead.
r? @jyn514

@jyn514
Copy link
Member

jyn514 commented Nov 10, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Nov 10, 2021

📌 Commit 6622376 has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 10, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2021
…askrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#88447 (Use computed visibility in rustdoc)
 - rust-lang#88868 (Allow simd_bitmask to return byte arrays)
 - rust-lang#90727 (Remove potential useless data for search index)
 - rust-lang#90742 (Use AddAssign impl)
 - rust-lang#90758 (Fix collections entry API documentation.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a8dff34 into rust-lang:master Nov 10, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 10, 2021
@jyn514
Copy link
Member

jyn514 commented Nov 10, 2021

@inquisitivecrystal thanks for working on this! :)

@nnethercote
Copy link
Contributor

It was suggested that this may have caused a large regression in doc times for the webrender-wrench benchmark: #90769 (comment). Any thoughts about whether that's true?

@jyn514
Copy link
Member

jyn514 commented Nov 21, 2021

That is ... Quite a large difference, wow.

I wouldn't expect this to be the cause of all the regressions there, this shouldn't have affected get_blanket_impls or evaluate_obligation. I think it's plausible it makes clean_crate slower but that's not where most of the regressions are.

Maybe open a couple PRs reverting changes in the rollup and see which if any fix the regression?

@jyn514
Copy link
Member

jyn514 commented Nov 21, 2021

#88868 affects codegen, rolling that up seems suspicious. That or
#90727 would be my guess (altogether neither of those should have affected evaluate_obligation quite so much ...)

@jyn514
Copy link
Member

jyn514 commented Nov 21, 2021

#90361 also seems plausible.

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 23, 2021
…=jyn514

Avoid documenting top-level private imports

PR rust-lang#88447 aimed to make rustdoc's `--document-private-items` mode only document imports that are visible outside the importing module. Unfortunately, I inadvertently set things up so that imports at the crate top-level are always documented, regardless of their visibility. This behavior was unintended and is [not desirable](rust-lang#90865 (comment)).

This PR treats top-level imports as never being visible outside their parent module. In practice, the only way a top-level import can be visible externally is if it's fully public, and there's a seperate check for that.

It's worth calling attention to the fact that this change means that `pub(crate)` imports will be visible in lower level modules, but not at the top-level. This is because, at the top level of the crate, `pub(crate)` means the same thing as `pub(self)`.

It turned out that there were existing tests checking for the only behavior, which I didn't notice at the time of my previous PR. I have updated them to check for the new behavior and substantially extended them to handle differences between the top-level module and lower level modules. I may have gone overboard, so please tell me if there's anything I should cut.

r? `@jyn514`

Fixes rust-lang#90865.
@camelid
Copy link
Member

camelid commented Nov 23, 2021

Followup: IIUC, the perf regression was caused by the behavior regression in #90865. Then #91094 fixed the behavior regression, which in turn fixed the perf regression.

wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request Jan 22, 2022
Pkgsrc changes:
 * Bump available bootstraps to 1.57.0.
 * For some reason, the vendor/libc checksums don't need fixing.
 * Bump required external LLVM to 12.0, according to upstream change log.
 * Adapt the Darwin linker patch.

(For some reason I've not figured out yet, cargo is a lot more
verbose while building, echoes the rustc invocation.)

Upstream changes:

Version 1.58.1 (2022-01-19)
===========================

* Fix race condition in `std::fs::remove_dir_all` ([CVE-2022-21658])
* [Handle captured arguments in the `useless_format` Clippy lint][clippy/8295]
* [Move `non_send_fields_in_send_ty` Clippy lint to nursery][clippy/8075]
* [Fix wrong error message displayed when some imports are missing][91254]
* [Fix rustfmt not formatting generated files from stdin][92912]

[CVE-2022-21658]: https://www.cve.org/CVERecord?id=CVE-2022-21658]
[91254]: rust-lang/rust#91254
[92912]: rust-lang/rust#92912
[clippy/8075]: rust-lang/rust-clippy#8075
[clippy/8295]: rust-lang/rust-clippy#8295

Version 1.58.0 (2022-01-13)
==========================

Language
--------

- [Format strings can now capture arguments simply by writing
  `{ident}` in the string.][90473] This works in all macros accepting
  format strings. Support for this in `panic!` (`panic!("{ident}")`)
  requires the 2021 edition; panic invocations in previous editions
  that appear to be trying to use this will result in a warning lint
  about not having the intended effect.
- [`*const T` pointers can now be dereferenced in const contexts.][89551]
- [The rules for when a generic struct implements `Unsize` have
  been relaxed.][90417]

Compiler
--------

- [Add LLVM CFI support to the Rust compiler][89652]
- [Stabilize -Z strip as -C strip][90058]. Note that while release
  builds already don't add debug symbols for the code you compile,
  the compiled standard library that ships with Rust includes debug
  symbols, so you may want to use the `strip` option to remove these
  symbols to produce smaller release binaries. Note that this release
  only includes support in rustc, not directly in cargo.
- [Add support for LLVM coverage mapping format versions 5 and 6][91207]
- [Emit LLVM optimization remarks when enabled with `-Cremark`][90833]
- [Update the minimum external LLVM to 12][90175]
- [Add `x86_64-unknown-none` at Tier 3*][89062]
- [Build musl dist artifacts with debuginfo enabled][90733]. When
  building release binaries using musl, you may want to use the newly
  stabilized strip option to remove these debug symbols, reducing
  the size of your binaries.
- [Don't abort compilation after giving a lint error][87337]
- [Error messages point at the source of trait bound obligations
  in more places][89580]

\* Refer to Rust's [platform support page][platform-support-doc] for more
   information on Rust's tiered platform support.

Libraries
---------

- [All remaining functions in the standard library have `#[must_use]`
  annotations where appropriate][89692], producing a warning when
  ignoring their return value. This helps catch mistakes such as
  expecting a function to mutate a value in place rather than return
  a new value.
- [Paths are automatically canonicalized on Windows for operations
  that support it][89174]
- [Re-enable debug checks for `copy` and `copy_nonoverlapping`][90041]
- [Implement `RefUnwindSafe` for `Rc<T>`][87467]
- [Make RSplit<T, P>: Clone not require T: Clone][90117]
- [Implement `Termination` for `Result<Infallible, E>`][88601].
  This allows writing `fn main() -> Result<Infallible, ErrorType>`,
  for a program whose successful exits never involve returning from
  `main` (for instance, a program that calls `exit`, or that uses
  `exec` to run another program).

Stabilized APIs
---------------

- [`Metadata::is_symlink`]
- [`Path::is_symlink`]
- [`{integer}::saturating_div`]
- [`Option::unwrap_unchecked`]
- [`Result::unwrap_unchecked`]
- [`Result::unwrap_err_unchecked`]
- [`NonZero{unsigned}::is_power_of_two`]
- [`File::options`]

These APIs are now usable in const contexts:

- [`Duration::new`]
- [`Duration::checked_add`]
- [`Duration::saturating_add`]
- [`Duration::checked_sub`]
- [`Duration::saturating_sub`]
- [`Duration::checked_mul`]
- [`Duration::saturating_mul`]
- [`Duration::checked_div`]
- [`MaybeUninit::as_ptr`]
- [`MaybeUninit::as_mut_ptr`]
- [`MaybeUninit::assume_init`]
- [`MaybeUninit::assume_init_ref`]

Cargo
-----

- [Add --message-format for install command][cargo/10107]
- [Warn when alias shadows external subcommand][cargo/10082]

Rustdoc
-------

- [Show all Deref implementations recursively in rustdoc][90183]
- [Use computed visibility in rustdoc][88447]

Compatibility Notes
-------------------

- [Try all stable method candidates first before trying unstable
  ones][90329]. This change ensures that adding new nightly-only
  methods to the Rust standard library will not break code invoking
  methods of the same name from traits outside the standard library.
- Windows: [`std::process::Command` will no longer search the
  current directory for executables.][87704]
- [All proc-macro backward-compatibility lints are now deny-by-default.][88041]
- [proc_macro: Append .0 to unsuffixed float if it would otherwise
  become int token][90297]
- [Refactor weak symbols in std::sys::unix][90846]. This optimizes
  accesses to glibc functions, by avoiding the use of dlopen. This
  does not increase the [minimum expected version of
  glibc](https://doc.rust-lang.org/nightly/rustc/platform-support.html).
  However, software distributions that use symbol versions to detect
  library dependencies, and which take weak symbols into account in
  that analysis, may detect rust binaries as requiring newer versions
  of glibc.
- [rustdoc now rejects some unexpected semicolons in doctests][91026]

Internal Changes
----------------

These changes provide no direct user facing benefits, but represent
significant improvements to the internals and overall performance
of rustc and related tools.

- [Implement coherence checks for negative trait impls][90104]
- [Add rustc lint, warning when iterating over hashmaps][89558]
- [Optimize live point computation][90491]
- [Enable verification for 1/32nd of queries loaded from disk][90361]
- [Implement version of normalize_erasing_regions that allows for
  normalization failure][91255]

[87337]: rust-lang/rust#87337
[87467]: rust-lang/rust#87467
[87704]: rust-lang/rust#87704
[88041]: rust-lang/rust#88041
[88300]: rust-lang/rust#88300
[88447]: rust-lang/rust#88447
[88601]: rust-lang/rust#88601
[88624]: rust-lang/rust#88624
[89062]: rust-lang/rust#89062
[89174]: rust-lang/rust#89174
[89542]: rust-lang/rust#89542
[89551]: rust-lang/rust#89551
[89558]: rust-lang/rust#89558
[89580]: rust-lang/rust#89580
[89652]: rust-lang/rust#89652
[89677]: rust-lang/rust#89677
[89951]: rust-lang/rust#89951
[90041]: rust-lang/rust#90041
[90058]: rust-lang/rust#90058
[90104]: rust-lang/rust#90104
[90117]: rust-lang/rust#90117
[90175]: rust-lang/rust#90175
[90183]: rust-lang/rust#90183
[90297]: rust-lang/rust#90297
[90329]: rust-lang/rust#90329
[90361]: rust-lang/rust#90361
[90417]: rust-lang/rust#90417
[90473]: rust-lang/rust#90473
[90491]: rust-lang/rust#90491
[90733]: rust-lang/rust#90733
[90833]: rust-lang/rust#90833
[90846]: rust-lang/rust#90846
[90896]: rust-lang/rust#90896
[91026]: rust-lang/rust#91026
[91207]: rust-lang/rust#91207
[91255]: rust-lang/rust#91255
[91301]: rust-lang/rust#91301
[cargo/10082]: rust-lang/cargo#10082
[cargo/10107]: rust-lang/cargo#10107
[`Metadata::is_symlink`]: https://doc.rust-lang.org/stable/std/fs/struct.Metadata.html#method.is_symlink
[`Path::is_symlink`]: https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.is_symlink
[`{integer}::saturating_div`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.saturating_div
[`Option::unwrap_unchecked`]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.unwrap_unchecked
[`Result::unwrap_unchecked`]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_unchecked
[`Result::unwrap_err_unchecked`]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_err_unchecked
[`NonZero{unsigned}::is_power_of_two`]: https://doc.rust-lang.org/stable/std/num/struct.NonZeroU8.html#method.is_power_of_two
[`File::options`]: https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.options
[`unix::process::ExitStatusExt::core_dumped`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.core_dumped
[`unix::process::ExitStatusExt::stopped_signal`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.stopped_signal
[`unix::process::ExitStatusExt::continued`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.continued
[`unix::process::ExitStatusExt::into_raw`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.into_raw
[`Duration::new`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.new
[`Duration::checked_add`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_add
[`Duration::saturating_add`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_add
[`Duration::checked_sub`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_sub
[`Duration::saturating_sub`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_sub
[`Duration::checked_mul`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_mul
[`Duration::saturating_mul`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_mul
[`Duration::checked_div`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_div
[`Duration::as_secs_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.as_secs_f64
[`Duration::as_secs_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.as_secs_f32
[`Duration::from_secs_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.from_secs_f64
[`Duration::from_secs_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.from_secs_f32
[`Duration::mul_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.mul_f64
[`Duration::mul_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.mul_f32
[`Duration::div_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_f64
[`Duration::div_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_f32
[`Duration::div_duration_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_duration_f64
[`Duration::div_duration_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_duration_f32
[`MaybeUninit::as_ptr`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.as_ptr
[`MaybeUninit::as_mut_ptr`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.as_mut_ptr
[`MaybeUninit::assume_init`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init
[`MaybeUninit::assume_init_ref`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_ref
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Mar 1, 2022
Pkgsrc changes:
 * Bump bootstrap kit version to 1.57.0.
 * Bump require external LLVM to 12.0, according to upstream change log.
 * Adjust patches as needed, adjust line numbers.
 * Update checksum adjustments.  For some reason the vendor/libc checksum
   doesn't need fixing, apparently, it remains as commented out.
 * Add makefile to do all the NetBSD boostrap/cross builds (do-cross.mk).
   Allow passing in additions to CONFIGURE_ARGS via ADD_CONFIGURE_ARGS.

Upstream changes:

Version 1.58.1 (2022-01-19)
===========================

* Fix race condition in `std::fs::remove_dir_all` ([CVE-2022-21658])
* [Handle captured arguments in the `useless_format` Clippy lint][clippy/8295]
* [Move `non_send_fields_in_send_ty` Clippy lint to nursery][clippy/8075]
* [Fix wrong error message displayed when some imports are missing][91254]
* [Fix rustfmt not formatting generated files from stdin][92912]

[CVE-2022-21658]: https://www.cve.org/CVERecord?id=CVE-2022-21658]
[91254]: rust-lang/rust#91254
[92912]: rust-lang/rust#92912
[clippy/8075]: rust-lang/rust-clippy#8075
[clippy/8295]: rust-lang/rust-clippy#8295

Version 1.58.0 (2022-01-13)
==========================

Language
--------

- [Format strings can now capture arguments simply by writing
  `{ident}` in the string.][90473] This works in all macros accepting
  format strings. Support for this in `panic!` (`panic!("{ident}")`)
  requires the 2021 edition; panic invocations in previous editions
  that appear to be trying to use this will result in a warning lint
  about not having the intended effect.
- [`*const T` pointers can now be dereferenced in const contexts.][89551]
- [The rules for when a generic struct implements `Unsize` have
  been relaxed.][90417]

Compiler
--------

- [Add LLVM CFI support to the Rust compiler][89652]
- [Stabilize -Z strip as -C strip][90058]. Note that while release
  builds already don't add debug symbols for the code you compile,
  the compiled standard library that ships with Rust includes debug
  symbols, so you may want to use the `strip` option to remove these
  symbols to produce smaller release binaries. Note that this release
  only includes support in rustc, not directly in cargo.
- [Add support for LLVM coverage mapping format versions 5 and 6][91207]
- [Emit LLVM optimization remarks when enabled with `-Cremark`][90833]
- [Update the minimum external LLVM to 12][90175]
- [Add `x86_64-unknown-none` at Tier 3*][89062]
- [Build musl dist artifacts with debuginfo enabled][90733]. When
  building release binaries using musl, you may want to use the newly
  stabilized strip option to remove these debug symbols, reducing
  the size of your binaries.
- [Don't abort compilation after giving a lint error][87337]
- [Error messages point at the source of trait bound obligations
  in more places][89580]

\* Refer to Rust's [platform support page][platform-support-doc] for more
   information on Rust's tiered platform support.

Libraries
---------

- [All remaining functions in the standard library have `#[must_use]`
  annotations where appropriate][89692], producing a warning when
  ignoring their return value. This helps catch mistakes such as
  expecting a function to mutate a value in place rather than return
  a new value.
- [Paths are automatically canonicalized on Windows for operations
  that support it][89174]
- [Re-enable debug checks for `copy` and `copy_nonoverlapping`][90041]
- [Implement `RefUnwindSafe` for `Rc<T>`][87467]
- [Make RSplit<T, P>: Clone not require T: Clone][90117]
- [Implement `Termination` for `Result<Infallible, E>`][88601].
  This allows writing `fn main() -> Result<Infallible, ErrorType>`,
  for a program whose successful exits never involve returning from
  `main` (for instance, a program that calls `exit`, or that uses
  `exec` to run another program).

Stabilized APIs
---------------

- [`Metadata::is_symlink`]
- [`Path::is_symlink`]
- [`{integer}::saturating_div`]
- [`Option::unwrap_unchecked`]
- [`Result::unwrap_unchecked`]
- [`Result::unwrap_err_unchecked`]
- [`NonZero{unsigned}::is_power_of_two`]
- [`File::options`]

These APIs are now usable in const contexts:

- [`Duration::new`]
- [`Duration::checked_add`]
- [`Duration::saturating_add`]
- [`Duration::checked_sub`]
- [`Duration::saturating_sub`]
- [`Duration::checked_mul`]
- [`Duration::saturating_mul`]
- [`Duration::checked_div`]
- [`MaybeUninit::as_ptr`]
- [`MaybeUninit::as_mut_ptr`]
- [`MaybeUninit::assume_init`]
- [`MaybeUninit::assume_init_ref`]

Cargo
-----

- [Add --message-format for install command][cargo/10107]
- [Warn when alias shadows external subcommand][cargo/10082]

Rustdoc
-------

- [Show all Deref implementations recursively in rustdoc][90183]
- [Use computed visibility in rustdoc][88447]

Compatibility Notes
-------------------

- [Try all stable method candidates first before trying unstable
  ones][90329]. This change ensures that adding new nightly-only
  methods to the Rust standard library will not break code invoking
  methods of the same name from traits outside the standard library.
- Windows: [`std::process::Command` will no longer search the
  current directory for executables.][87704]
- [All proc-macro backward-compatibility lints are now deny-by-default.][88041]
- [proc_macro: Append .0 to unsuffixed float if it would otherwise
  become int token][90297]
- [Refactor weak symbols in std::sys::unix][90846]. This optimizes
  accesses to glibc functions, by avoiding the use of dlopen. This
  does not increase the [minimum expected version of
  glibc](https://doc.rust-lang.org/nightly/rustc/platform-support.html).
  However, software distributions that use symbol versions to detect
  library dependencies, and which take weak symbols into account in
  that analysis, may detect rust binaries as requiring newer versions
  of glibc.
- [rustdoc now rejects some unexpected semicolons in doctests][91026]

Internal Changes
----------------

These changes provide no direct user facing benefits, but represent
significant improvements to the internals and overall performance
of rustc and related tools.

- [Implement coherence checks for negative trait impls][90104]
- [Add rustc lint, warning when iterating over hashmaps][89558]
- [Optimize live point computation][90491]
- [Enable verification for 1/32nd of queries loaded from disk][90361]
- [Implement version of normalize_erasing_regions that allows for
  normalization failure][91255]

[87337]: rust-lang/rust#87337
[87467]: rust-lang/rust#87467
[87704]: rust-lang/rust#87704
[88041]: rust-lang/rust#88041
[88300]: rust-lang/rust#88300
[88447]: rust-lang/rust#88447
[88601]: rust-lang/rust#88601
[88624]: rust-lang/rust#88624
[89062]: rust-lang/rust#89062
[89174]: rust-lang/rust#89174
[89542]: rust-lang/rust#89542
[89551]: rust-lang/rust#89551
[89558]: rust-lang/rust#89558
[89580]: rust-lang/rust#89580
[89652]: rust-lang/rust#89652
[89677]: rust-lang/rust#89677
[89951]: rust-lang/rust#89951
[90041]: rust-lang/rust#90041
[90058]: rust-lang/rust#90058
[90104]: rust-lang/rust#90104
[90117]: rust-lang/rust#90117
[90175]: rust-lang/rust#90175
[90183]: rust-lang/rust#90183
[90297]: rust-lang/rust#90297
[90329]: rust-lang/rust#90329
[90361]: rust-lang/rust#90361
[90417]: rust-lang/rust#90417
[90473]: rust-lang/rust#90473
[90491]: rust-lang/rust#90491
[90733]: rust-lang/rust#90733
[90833]: rust-lang/rust#90833
[90846]: rust-lang/rust#90846
[90896]: rust-lang/rust#90896
[91026]: rust-lang/rust#91026
[91207]: rust-lang/rust#91207
[91255]: rust-lang/rust#91255
[91301]: rust-lang/rust#91301
[cargo/10082]: rust-lang/cargo#10082
[cargo/10107]: rust-lang/cargo#10107
[`Metadata::is_symlink`]: https://doc.rust-lang.org/stable/std/fs/struct.Metadata.html#method.is_symlink
[`Path::is_symlink`]: https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.is_symlink
[`{integer}::saturating_div`]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.saturating_div
[`Option::unwrap_unchecked`]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.unwrap_unchecked
[`Result::unwrap_unchecked`]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_unchecked
[`Result::unwrap_err_unchecked`]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_err_unchecked
[`NonZero{unsigned}::is_power_of_two`]: https://doc.rust-lang.org/stable/std/num/struct.NonZeroU8.html#method.is_power_of_two
[`File::options`]: https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.options
[`unix::process::ExitStatusExt::core_dumped`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.core_dumped
[`unix::process::ExitStatusExt::stopped_signal`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.stopped_signal
[`unix::process::ExitStatusExt::continued`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.continued
[`unix::process::ExitStatusExt::into_raw`]: https://doc.rust-lang.org/stable/std/os/unix/process/trait.ExitStatusExt.html#tymethod.into_raw
[`Duration::new`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.new
[`Duration::checked_add`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_add
[`Duration::saturating_add`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_add
[`Duration::checked_sub`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_sub
[`Duration::saturating_sub`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_sub
[`Duration::checked_mul`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_mul
[`Duration::saturating_mul`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.saturating_mul
[`Duration::checked_div`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.checked_div
[`Duration::as_secs_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.as_secs_f64
[`Duration::as_secs_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.as_secs_f32
[`Duration::from_secs_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.from_secs_f64
[`Duration::from_secs_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.from_secs_f32
[`Duration::mul_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.mul_f64
[`Duration::mul_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.mul_f32
[`Duration::div_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_f64
[`Duration::div_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_f32
[`Duration::div_duration_f64`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_duration_f64
[`Duration::div_duration_f32`]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.div_duration_f32
[`MaybeUninit::as_ptr`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.as_ptr
[`MaybeUninit::as_mut_ptr`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.as_mut_ptr
[`MaybeUninit::assume_init`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init
[`MaybeUninit::assume_init_ref`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_ref
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants