Add suggestions to deprecation lints
Clippy used to do this suggestion, but the clippy lints happen after the deprecation lints so we ended up never seeing the structured suggestions.
Implement Weak::{strong_count, weak_count}
The counters are also useful on `Weak`, not just on strong references (`Rc` or `Arc`).
In situations where there are still strong references around, you can also get these counts by temporarily upgrading and adjusting the values accordingly. Using the methods introduced here is simpler to do, less error-prone (since you can't forget to adjust the counts), can also be used when no strong references are around anymore, and might be more efficient due to not having to temporarily create an `Rc`.
This is mainly useful in assertions or tests of complex data structures. Data structures might have internal invariants that make them the sole owner of a `Weak` pointer, and an assertion on the weak count could be used to ensure that this indeed happens as expected. Due to the presence of `Weak::upgrade`, the `strong_count` becomes less useful, but it still seems worthwhile to mirror the API of `Rc`.
TODO:
* [X] Tracking issue - https://github.com/rust-lang/rust/issues/57977
Closes https://github.com/rust-lang/rust/issues/50158
Use LLVM intrinsics for saturating add/sub
Use the `[su](add|sub).sat` LLVM intrinsics, if we're compiling against LLVM 8, as they should optimize and codegen better than IR based on `[su](add|sub).with.overlow`.
For the fallback for LLVM < 8 I'm using the same expansion that target lowering in LLVM uses, which is not the same as Rust currently uses (in particular due to the use of selects rather than branches).
Fixes#55286.
Fixes#52203.
Fixes#44500.
r? @nagisa
compiletest: Support opt-in Clang-based run-make tests and use them for testing xLTO.
Some cross-language run-make tests need a Clang compiler that matches the LLVM version of `rustc`. Since such a compiler usually isn't available these tests (marked with the `needs-matching-clang`
directive) are ignored by default.
For some CI jobs we do need these tests to run unconditionally though. In order to support this a `--force-clang-based-tests` flag is added to compiletest. If this flag is specified, `compiletest` will fail if it can't detect an appropriate version of Clang.
@rust-lang/infra The PR doesn't yet enable the tests yet. Do you have any recommendation for which jobs to enable them?
cc #57438
r? @alexcrichton
This commit adds a suggestion when a import is duplicated (ie. the same name
is used twice trying to import the same thing) to remove the second
import.
Rollup of 12 pull requests
Successful merges:
- #57008 (suggest `|` when `,` founds in invalid match value)
- #57106 (Mark str::trim.* functions as #[must_use].)
- #57920 (use `SOURCE_DATE_EPOCH` for man page time if set)
- #57934 (Introduce into_raw_non_null on Rc and Arc)
- #57971 (SGX target: improve panic & exit handling)
- #57980 (Add the edition guide to the bookshelf)
- #57984 (Improve bug message in check_ty)
- #57999 (Add MOVBE x86 CPU feature)
- #58000 (Fixes and cleanups)
- #58005 (update docs for fix_start/end_matches)
- #58007 (Don't panic when accessing enum variant ctor using `Self` in match)
- #58008 (Pass correct arguments to places_conflict)
Failed merges:
r? @ghost
Add MOVBE x86 CPU feature
I have no idea if this is correct. I basically copied the ADX feature. I verified the feature is also called `movbe` in LLVM.
I marked this to become stable immediately, as part of the RFC 2045.
r? @alexcrichton
Improve bug message in check_ty
This branch was hit in Clippy and I think it would be nice to
show the thing that was unexpected in the bug message.
It's also in line with the other `bug!` messages in `check_ty`.
SGX target: improve panic & exit handling
Implement this part of the spec:
> The enclave must not rely on userspace to terminate other threads still running. Similarly, the enclave must not trust that it will no longer be entered by userspace, and it must safeguard against that in the entrypoints.
Also use `UserRef` to access panic buffer
r? @alexcrichton
cc @VardhanThigle
Mark str::trim.* functions as #[must_use].
The functions return a reference to a new object and do not modify in-place
as the following code shows:
````
let s = String::from(" hello ");
s.trim();
assert_eq!(s, " hello ");
````
The new reference should be bound to a variable as now indicated by #[must_use].
This branch was hit in Clippy and I think it would be nice to
show the thing that was unexpected in the bug message.
It's also in line with the other `bug!` messages in `check_ty`.