self-profiling: Add events for metadata loading (plus a small dep-tracking optimization)
This PR
- adds self-profiling events related to loading things from crate metadata
- makes the compiler cache the `DepNodeIndex` of upstream crates, so that they don't have to be looked up over and over.
The commits are best reviewed in isolation.
Self-profiling tracking issue: https://github.com/rust-lang/rust/issues/58967
r? @Mark-Simulacrum
cc @wesleywiser
Rollup of 10 pull requests
Successful merges:
- #65214 (Split non-CAS atomic support off into target_has_atomic_load_store)
- #65246 (vxWorks: implement get_path() and get_mode() for File fmt::Debug)
- #65312 (improve performance of signed saturating_mul)
- #65336 (Fix typo in task::Waker)
- #65346 (nounwind tests and cleanup)
- #65347 (Fix #[unwind(abort)] with Rust ABI)
- #65366 (Implement Error::source on IntoStringError + Remove superfluous cause impls)
- #65369 (Don't discard value names when using address or memory sanitizer)
- #65370 (Add `dyn` to `Any` documentation)
- #65373 (Fix typo in docs for `Rc`)
Failed merges:
r? @ghost
Add `dyn` to `Any` documentation
I noticed that in documentation to `Any` trait the old trait object syntax is used, which could be confusing for newcomers, since we generally recommend using `dyn Trait` instead of just `Trait`. This PR changes the documentation comment, so that it uses `&dyn Any`, `&mut dyn Any` and `Box<dyn Any>`, correspondingly.
Don't discard value names when using address or memory sanitizer
The value names are used when reporting issues found by address
sanitizer or memory sanitizer. Avoid discarding names when those
sanitizers are enabled, unless explicitly requested to do otherwise.
Implement Error::source on IntoStringError + Remove superfluous cause impls
IntoStringError only implemented `Error::cause`, which is deprecated. This implemements `Error::source` instead.
`Error::cause` will still work as before, thanks to the default implementation.
I think this was the only/last `Error` impl in the standard library to have a cause, but not a source.
nounwind tests and cleanup
This is a follow-up to @pnkfelix' https://github.com/rust-lang/rust/pull/65020. In particular it adds some tests as @nagisa asked. It also does a cleanup that the original PR omitted to reduce backporting risks.
I hope I finally managed to write an uncontroversial PR in this area. ;) This should not change any behavior, just test it better.
Split non-CAS atomic support off into target_has_atomic_load_store
This PR implements my proposed changes in https://github.com/rust-lang/rust/issues/32976#issuecomment-518542029 by removing `target_has_atomic = "cas"` and splitting `target_has_atomic` into two separate `cfg`s:
* `target_has_atomic = 8/16/32/64/128`: This indicates the largest width that the target can atomically CAS (which implies support for all atomic operations).
* ` target_has_atomic_load_store = 8/16/32/64/128`: This indicates the largest width that the target can support loading or storing atomically (but may not support CAS).
cc #32976
r? @alexcrichton
I noticed that in documentation to `Any` trait the old trait object syntax is used, which could be confusing for newcomers, since we generally recommend using `dyn Trait` instead of just `Trait`. This PR changes the documentation comment, so that it uses `&dyn Any`, `&mut dyn Any` and `Box<dyn Any>`, correspondingly.
resolve: fix error title regarding private constructors
One reason is that constructors can be private while their types can be
public.
Idea credit to @petrochenkov, discussed at #65153
Improve docs on some char boolean methods
simple revival of #61794
(also rustfmt on rest of file :)
Documentation for `is_xid_start()` and `is_xid_continue()` couldn't be improved since both methods got remove from this repository
r? @dtolnay
cc @JohnCSimon
Implement Clone::clone_from for VecDeque
See #28481. For simple data types with the target much longer than the source, this implementation can be significantly slower than the default (probably due to the use of truncate). However, it should be substantially faster when cloning from nested data structures with similar shapes or when cloning from VecDeques with similar lengths, hopefully more common use cases for clone_from.
The value names are used when reporting issues found by address
sanitizer or memory sanitizer. Avoid discarding names when those
sanitizers are enabled, unless explicitly requested to do otherwise.
IntoStringError only implemented Error::cause, which is
deprecated. This implemements Error::source instead.
Error::cause will still work as before, thanks to the default
implementation.
Enhance report-time option
## Short overview
This PR is a follow-up to a previously closed#64714 PR.
## Changes introduced by this PR
* `libtest` now retrieves the type of the test within `TestDesc` (available types are: `UnitTest`, `IntegrationTest`, `DocTest`, `Unknown`).
* `--report-time` subcommand of the `libtest` now supports colored output (disabled by default).
* Colorized output depends on the threshold values. Default values (proposed by @wesleywiser):
- For unit-tests: 50ms warn/100ms critical,
- For integration-tests: 500ms warn/1000ms critical,
- For doctests: same as for integration tests,
- For unknown tests: `TEST_WARN_TIMEOUT_S` warn/ `TEST_WARN_TIMEOUT_S * 2` critical (it will only applied single-threaded mode, because otherwise test will be interrupted after reaching `TEST_WARN_TIMEOUT_S`).
- These values can be overrided by setting environment variables (since those thresholds are somewhat constant for every project, it's more flexible to use environment variables than command line arguments).
* New optional flag `--ensure-test-time` for `libtest`. With this flag applied, exectuion time limit excesss will cause test failure.
## What have not been done
There was a comment that it would be nice to have an entry in the Cargo book about it.
However, changes introduced by this PR (and #64663 in which `report-time` flag was added) aren't related directly to `cargo`, it's more about `libtest` itself.
I'm considering that [The Unstable Book](https://doc.rust-lang.org/unstable-book/) is more appropriate place, but not sure if I'm right (and if so, how exactly it should be described).
As one possible option, this PR may be merged without denoting it in the documentation, and in the next PR adding support of this feature to the `cargo` itself, I'll add a note in the Cargo book.
## Scope of this PR
Logical scope of this PR is `libtest` only. However, to get test types, I had to modify also `libsyntax_ext` and `librustdoc` for them to provide information about test type.
## Rationale
Rationale for colored output was submitted in #64714
Providing the information about kind of test was also proposed in #64714, and as an additional benefit this information may be useful for the tools using `libtest` (e.g. `cargo`).
Adding flag to treat time limits excess seems logical to me, so projects that do care about test execution time won't have to invent a wheel.
## Backward compatibility
All the changes are completely backward compatible.
## Demo
![rustc_enhanced_time](https://user-images.githubusercontent.com/12111581/65818381-c04f6800-e219-11e9-9875-322463abe24f.gif)
r? @wesleywiser