The current structure makes it hard to tell that there are just four
distinct code paths, depending on how many items there are in `bb_items`
and `next_items`. This commit introduces a `match` that clarifies
things.
Dylan DPC [Thu, 10 Mar 2022 22:12:59 +0000 (23:12 +0100)]
Rollup merge of #94719 - jonhoo:enable-static-lld, r=Mark-Simulacrum
Statically compile libstdc++ everywhere if asked
PR #93918 made it so that `-static-libstdc++` was only set in one place,
and was only set during linking, but accidentally also made it so that
it is no longer passed when building LLD, only when building LLVM
itself. This moves the logic for setting `-static-libstdc++` in the
linker flags to `configure_cmake` so that it takes effect for all CMake
invocations in `native.rs`.
As a side-effect, this also causes libstdc++ to be statically compiled
into sanitizers, whereas previously the `llvm-static-stdcpp` flag had no
effect on sanitizers. It also makes it so that LLD will be compiled
statically if `llvm-tools-enabled` is set, even though previously it was
only linked statically if `llvm-static-stdcpp` was set explicitly. Both
of these seem like they match expected behavior than what was there
prior to #93918.
Dylan DPC [Thu, 10 Mar 2022 22:12:57 +0000 (23:12 +0100)]
Rollup merge of #94274 - djkoloski:unknown_unstable_lints, r=tmandry
Treat unstable lints as unknown
This change causes unstable lints to be ignored if the `unknown_lints`
lint is allowed. To achieve this, it also changes lints to apply as soon
as they are processed. Previously, lints in the same set were processed
as a batch and then all simultaneously applied.
Implementation of https://github.com/rust-lang/compiler-team/issues/469
Dylan DPC [Thu, 10 Mar 2022 22:12:57 +0000 (23:12 +0100)]
Rollup merge of #93950 - T-O-R-U-S:use-modern-formatting-for-format!-macros, r=Mark-Simulacrum
Use modern formatting for format! macros
This updates the standard library's documentation to use the new format_args syntax.
The documentation is worthwhile to update as it should be more idiomatic
(particularly for features like this, which are nice for users to get acquainted
with). The general codebase is likely more hassle than benefit to update: it'll
hurt git blame, and generally updates can be done by folks updating the code if
(and when) that makes things more readable with the new format.
A few places in the compiler and library code are updated (mostly just due to
already having been done when this commit was first authored).
`eprintln!("{}", e)` becomes `eprintln!("{e}")`, but `eprintln!("{}", e.kind())` remains untouched.
bors [Thu, 10 Mar 2022 18:28:45 +0000 (18:28 +0000)]
Auto merge of #94814 - matthiaskrgr:rollup-a5sk366, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #94440 (Better error for normalization errors from parent crates that use `#![feature(generic_const_exprs)]`)
- #94587 (Document new recommended use of `FromIterator::from_iter`)
- #94644 (Fix soundness issue in scoped threads.)
- #94740 (Unify impl blocks by wrapping them into a div)
- #94753 (Improve rustdoc book)
- #94796 (Allow `cargo run` instead of `cargo run -p bootstrap`)
- #94805 (Revert accidental stabilization)
- #94809 (RustWrapper: add missing include)
Matthias Krüger [Thu, 10 Mar 2022 18:00:10 +0000 (19:00 +0100)]
Rollup merge of #94796 - jyn514:cargo-run-bootstrap, r=Mark-Simulacrum
Allow `cargo run` instead of `cargo run -p bootstrap`
This was part of `@Mark-Simulacrum` 's original PR in https://github.com/rust-lang/rust/commit/ecb424f12992a4aebace8a153d5efea040327a01,
but I missed it when writing #92260.
This also has the side effect of allowing `cargo build --bins` instead of `cargo build -p bootstrap --bins`. I'm not sure when you would want to run cargo build/check/test without going through bootstrap, but this still allows you to do so as long as you pass `-p` for all the crates you want to build.
Matthias Krüger [Thu, 10 Mar 2022 18:00:09 +0000 (19:00 +0100)]
Rollup merge of #94753 - Urgau:rustdoc-book-improvements, r=GuillaumeGomez
Improve rustdoc book
This pull-request improves the `rustdoc` book by doing some (light) cleanup, by merging some stuff, by adding some missing stuff (like tracking issues links, for those who had one) and also by moving some chapter's into sub-chapter's to improve the flow of the book.
~~Note that I locally tested with `mdbook-lintcheck` that no links became accidentally broken.~~ (Not enough, ;-))
Matthias Krüger [Thu, 10 Mar 2022 18:00:08 +0000 (19:00 +0100)]
Rollup merge of #94740 - GuillaumeGomez:unify-impl-blocks, r=notriddle
Unify impl blocks by wrapping them into a div
The blanket and "auto traits" sections are wrapped into a `div` with an ID. This PR fixes this incoherence by wrapping each impl section (the "deref impl" and the "inherent impl" sections were missing it). It'll also make some tests simpler to write.
Matthias Krüger [Thu, 10 Mar 2022 18:00:07 +0000 (19:00 +0100)]
Rollup merge of #94644 - m-ou-se:scoped-threads-drop-soundness, r=joshtriplett
Fix soundness issue in scoped threads.
This was discovered in https://github.com/rust-lang/rust/pull/94559#discussion_r820116323
The `scope()` function returns when all threads are finished, but I accidentally considered a thread 'finished' before dropping their panic payload or ignored return value.
So if a thread returned (or panics with) something that in its `Drop` implementation still uses borrowed stuff, it goes wrong.
Matthias Krüger [Thu, 10 Mar 2022 18:00:06 +0000 (19:00 +0100)]
Rollup merge of #94587 - JKAnderson409:issue-90107-fix, r=scottmcm
Document new recommended use of `FromIterator::from_iter`
#90107
Most of the added prose was paraphrased from the links provided in the issue. The suggested `VecDeque` example seemed to make the point well enough so I just used that.
Matthias Krüger [Thu, 10 Mar 2022 18:00:05 +0000 (19:00 +0100)]
Rollup merge of #94440 - compiler-errors:issue-94282, r=lcnr
Better error for normalization errors from parent crates that use `#![feature(generic_const_exprs)]`
This PR implements a somewhat rudimentary heuristic to suggest using `#![feature(generic_const_exprs)]` in a child crate when a function from a foreign crate (that may have used `#![feature(generic_const_exprs)]`) fails to normalize during codegen.
T-O-R-U-S [Sat, 12 Feb 2022 19:16:17 +0000 (23:16 +0400)]
Use implicit capture syntax in format_args
This updates the standard library's documentation to use the new syntax. The
documentation is worthwhile to update as it should be more idiomatic
(particularly for features like this, which are nice for users to get acquainted
with). The general codebase is likely more hassle than benefit to update: it'll
hurt git blame, and generally updates can be done by folks updating the code if
(and when) that makes things more readable with the new format.
A few places in the compiler and library code are updated (mostly just due to
already having been done when this commit was first authored).
bors [Thu, 10 Mar 2022 12:32:01 +0000 (12:32 +0000)]
Auto merge of #94802 - matthiaskrgr:rollup-4plu0fi, r=matthiaskrgr
Rollup of 5 pull requests
Successful merges:
- #92150 (Improve suggestion when casting usize to (possibly) wide pointer)
- #94635 (Merge `#[deprecated]` and `#[rustc_deprecated]`)
- #94657 (Constify `Index{,Mut}` for `[T]`, `str`, and `[T; N]`)
- #94746 (diagnostics: use rustc_on_unimplemented to recommend `[].iter()`)
- #94788 (Account for suggestions for complete removal of lines)
Matthias Krüger [Thu, 10 Mar 2022 11:20:51 +0000 (12:20 +0100)]
Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwco
Merge `#[deprecated]` and `#[rustc_deprecated]`
The first commit makes "reason" an alias for "note" in `#[rustc_deprecated]`, while still prohibiting it in `#[deprecated]`.
The second commit changes "suggestion" to not just be a feature of `#[rustc_deprecated]`. This is placed behind the new `deprecated_suggestion` feature. This needs a tracking issue; let me know if this PR will be approved and I can create one.
The third commit is what permits `#[deprecated]` to be used when `#![feature(staged_api)]` is enabled. This isn't yet used in stdlib (only tests), as it would require duplicating all deprecation attributes until a bootstrap occurs. I intend to submit a follow-up PR that replaces all uses and removes the remaining `#[rustc_deprecated]` code after the next bootstrap.
Matthias Krüger [Thu, 10 Mar 2022 11:20:50 +0000 (12:20 +0100)]
Rollup merge of #92150 - compiler-errors:better_usize_to_wide_ptr_cast, r=petrochenkov
Improve suggestion when casting usize to (possibly) wide pointer
I thought #92125 was a wonderful idea, so I went ahead and took a stab at it. Not sure if my approach is the best going forward, but I'm happy with the improvement in the error message.
Iwill definitely address any changes if people are more opinionated with the wordings or want more features.
bors [Thu, 10 Mar 2022 05:53:59 +0000 (05:53 +0000)]
Auto merge of #94059 - b-naber:constantkind-val-transformation, r=lcnr
Treat constant values as mir::ConstantKind::Val
Another step that is necessary for the introduction of Valtrees: we don't want to treat `ty::Const` instances of kind `ty::ConstKind::Value` as `mir::ConstantKind::Ty` anymore.
bors [Thu, 10 Mar 2022 02:38:43 +0000 (02:38 +0000)]
Auto merge of #94787 - matthiaskrgr:rollup-yyou15f, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #91804 (Make some `Clone` impls `const`)
- #92541 (Mention intent of `From` trait in its docs)
- #93057 (Add Iterator::collect_into)
- #94739 (Suggest `if let`/`let_else` for refutable pat in `let`)
- #94754 (Warn users about `||` in let chain expressions)
- #94763 (Add documentation about lifetimes to thread::scope.)
- #94768 (Ignore `close_read_wakes_up` test on SGX platform)
- #94772 (Add miri to the well known conditional compilation names and values)
bors [Thu, 10 Mar 2022 00:15:39 +0000 (00:15 +0000)]
Auto merge of #94737 - lcnr:pass-stuff-by-value, r=davidtwco
add `#[rustc_pass_by_value]` to more types
the only interesting changes here should be to `TransitiveRelation`, but I believe to be highly unlikely that we will ever use a non `Copy` type with this type.
Matthias Krüger [Wed, 9 Mar 2022 22:14:16 +0000 (23:14 +0100)]
Rollup merge of #94772 - Urgau:check-cfg-miri, r=petrochenkov
Add miri to the well known conditional compilation names and values
This pull request adds `miri` to the list of well known names and values of the conditional compilation checking (`--check-cfg`).
This was brought up in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/RFC.203013.3A.20Checking.20conditional.20compilation.20at.20compile.20time/near/274513827) when discussing about the future of `--check-cfg`.
Matthias Krüger [Wed, 9 Mar 2022 22:14:11 +0000 (23:14 +0100)]
Rollup merge of #93057 - frengor:iter_collect_into, r=m-ou-se
Add Iterator::collect_into
This PR adds `Iterator::collect_into` as proposed by ``@cormacrelf`` in #48597 (see https://github.com/rust-lang/rust/pull/48597#issuecomment-842083688).
Followup of #92982.
This adds the following method to the Iterator trait:
Matthias Krüger [Wed, 9 Mar 2022 22:14:10 +0000 (23:14 +0100)]
Rollup merge of #92541 - asquared31415:from-docs, r=m-ou-se
Mention intent of `From` trait in its docs
This pr is a docs modification to add to the documentation of the `From` trait a note about its intent as a perfect conversion. This is already stated in the `TryFrom` docs so this is simply adding that information in a more visible way.
Matthias Krüger [Wed, 9 Mar 2022 22:14:09 +0000 (23:14 +0100)]
Rollup merge of #91804 - woppopo:const_clone, r=oli-obk
Make some `Clone` impls `const`
Tracking issue: #91805
`Clone::clone_from` and some impls (Option, Result) bounded on `~const Drop`.
```rust
// core::clone
impl const Clone for INTEGER
impl const Clone for FLOAT
impl const Clone for bool
impl const Clone for char
impl const Clone for !
impl<T: ?Sized> const Clone for *const T
impl<T: ?Sized> const Clone for *mut T
impl<T: ?Sized> const Clone for &T
// core::option
impl<T> const Clone for Option<T>
where
T: ~const Clone + ~const Drop
bors [Wed, 9 Mar 2022 06:30:19 +0000 (06:30 +0000)]
Auto merge of #94761 - Dylan-DPC:rollup-v4emqsy, r=Dylan-DPC
Rollup of 6 pull requests
Successful merges:
- #94312 (Edit `rustc_trait_selection::infer::lattice` docs)
- #94583 (Add a team for '`@rustbot` ping fuchsia')
- #94686 (Do not allow `#[rustc_legacy_const_generics]` on methods)
- #94699 (BTree: remove dead data needlessly complicating insert)
- #94756 (Use `unreachable!` for an unreachable code path)
- #94759 (Update cargo)
Dylan DPC [Wed, 9 Mar 2022 05:38:53 +0000 (06:38 +0100)]
Rollup merge of #94759 - ehuss:update-cargo, r=ehuss
Update cargo
11 commits in 3d6970d50e30e797b8e26b2b9b1bdf92dc381f34..65c82664263feddc5fe2d424be0993c28d46377a
2022-02-28 19:29:07 +0000 to 2022-03-09 02:32:56 +0000
- Remove remaining 2 warn(clippy::*) instances (rust-lang/cargo#10438)
- Use `available_parallelism` instead of `num_cpus` (rust-lang/cargo#10427)
- Wait up to one second while waiting for curl (rust-lang/cargo#10456)
- Improve code coverage (rust-lang/cargo#10460)
- Don't recommend leaking tokens into the console history (rust-lang/cargo#10458)
- fix some typos (rust-lang/cargo#10454)
- Use `extend` instead of `push`ing in a loop (rust-lang/cargo#10453)
- Use locked_version more (rust-lang/cargo#10449)
- Disable dependabot (rust-lang/cargo#10443)
- Update git2 dependencies (rust-lang/cargo#10442)
- Stop gating stable features (rust-lang/cargo#10434)
bors [Wed, 9 Mar 2022 02:17:58 +0000 (02:17 +0000)]
Auto merge of #94750 - cuviper:dirent64_min, r=joshtriplett
unix: reduce the size of DirEntry
On platforms where we call `readdir` instead of `readdir_r`, we store
the name as an allocated `CString` for variable length. There's no point
carrying around a full `dirent64` with its fixed-length `d_name` too.
Dylan DPC [Tue, 8 Mar 2022 21:44:00 +0000 (22:44 +0100)]
Rollup merge of #94724 - cuviper:rmdirall-cstr, r=Dylan-DPC
unix: Avoid name conversions in `remove_dir_all_recursive`
Each recursive call was creating an `OsString` for a `&Path`, only for
it to be turned into a `CString` right away. Instead we can directly
pass `.name_cstr()`, saving two allocations each time.
Dylan DPC [Tue, 8 Mar 2022 21:43:59 +0000 (22:43 +0100)]
Rollup merge of #94723 - dtolnay:mustuse, r=Mark-Simulacrum
Add core::hint::must_use
The example code in this documentation is minimized from a real-world situation in the `anyhow` crate where this function would have been valuable.
Having this provided by the standard library is especially useful for proc macros, even more than for macro_rules. That's because proc macro crates aren't allowed to export anything other than macros, so they couldn't make their own `must_use` function for their macro-generated code to call.
<br>
## Rendered documentation
> An identity function that causes an `unused_must_use` warning to be triggered if the given value is not used (returned, stored in a variable, etc) by the caller.
>
> This is primarily intended for use in macro-generated code, in which a [`#[must_use]` attribute][must_use] either on a type or a function would not be convenient.
>
> [must_use]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute
>
> ### Example
>
> ```rust
> #![feature(hint_must_use)]
>
> use core::fmt;
>
> pub struct Error(/* ... */);
>
> #[macro_export]
> macro_rules! make_error {
> ($($args:expr),*) => {
> core::hint::must_use({
> let error = $crate::make_error(core::format_args!($($args),*));
> error
> })
> };
> }
>
> // Implementation detail of make_error! macro.
> #[doc(hidden)]
> pub fn make_error(args: fmt::Arguments<'_>) -> Error {
> Error(/* ... */)
> }
>
> fn demo() -> Option<Error> {
> if true {
> // Oops, meant to write `return Some(make_error!("..."));`
> Some(make_error!("..."));
> }
> None
> }
> ```
>
> In the above example, we'd like an `unused_must_use` lint to apply to the value created by `make_error!`. However, neither `#[must_use]` on a struct nor `#[must_use]` on a function is appropriate here, so the macro expands using `core::hint::must_use` instead.
>
> - We wouldn't want `#[must_use]` on the `struct Error` because that would make the following unproblematic code trigger a warning:
>
> ```rust
> fn f(arg: &str) -> Result<(), Error>
>
> #[test]
> fn t() {
> // Assert that `f` returns error if passed an empty string.
> // A value of type `Error` is unused here but that's not a problem.
> f("").unwrap_err();
> }
> ```
>
> - Using `#[must_use]` on `fn make_error` can't help because the return value *is* used, as the right-hand side of a `let` statement. The `let` statement looks useless but is in fact necessary for ensuring that temporaries within the `format_args` expansion are not kept alive past the creation of the `Error`, as keeping them alive past that point can cause autotrait issues in async code:
>
> ```rust
> async fn f() {
> // Using `let` inside the make_error expansion causes temporaries like
> // `unsync()` to drop at the semicolon of that `let` statement, which
> // is prior to the await point. They would otherwise stay around until
> // the semicolon on *this* statement, which is after the await point,
> // and the enclosing Future would not implement Send.
> log(make_error!("look: {:p}", unsync())).await;
> }
>
> async fn log(error: Error) {/* ... */}
>
> // Returns something without a Sync impl.
> fn unsync() -> *const () {
> 0 as *const ()
> }
> ```
Dylan DPC [Tue, 8 Mar 2022 21:43:57 +0000 (22:43 +0100)]
Rollup merge of #94714 - ChrisDenton:win-close_read_wakes_up, r=Mark-Simulacrum
Enable `close_read_wakes_up` test on Windows
I wonder if we could/should try enabling this again? It was closed by #38867 due to #31657. I've tried running this test (along with other tests) on my machine a number of times and haven't seen this fail yet,
Caveat: the worst that can happen is this succeeds initially but then causes random hangs in CI. This is not a great failure mode and would be a reason not to do this.
Dylan DPC [Tue, 8 Mar 2022 21:43:56 +0000 (22:43 +0100)]
Rollup merge of #94689 - compiler-errors:on-unimplemented-substs, r=petrochenkov
Use impl substs in `#[rustc_on_unimplemented]`
We were using the trait-ref substs instead of impl substs in `rustc_on_unimplemented`, even when computing the `rustc_on_unimplemented` attached to an impl block. Let's not do that.
This PR also untangles impl and trait def-ids in the logic in `on_unimplemented` a bit.
Josh Stone [Tue, 8 Mar 2022 21:36:01 +0000 (13:36 -0800)]
unix: reduce the size of DirEntry
On platforms where we call `readdir` instead of `readdir_r`, we store
the name as an allocated `CString` for variable length. There's no point
carrying around a full `dirent64` with its fixed-length `d_name` too.
bors [Tue, 8 Mar 2022 19:25:19 +0000 (19:25 +0000)]
Auto merge of #94702 - b-naber:static-refs-mir, r=lcnr
Reinstate #93800
https://github.com/rust-lang/rust/pull/93800 caused a regression in an alt builder with parallel enabled. https://github.com/rust-lang/rust/pull/94205 reverted that PR because of the regression. For an unknown reason the regression has disappeared, so we reinstate the changes in https://github.com/rust-lang/rust/pull/93800 here.
David Koloski [Mon, 28 Feb 2022 20:29:06 +0000 (20:29 +0000)]
Switch the primary diagnostic to `unknown_lints`
This also affects the `non_exhaustive_omitted_patterns` and
`must_not_suspend` lints as they are not stable. This also changes the
diagnostic level to pull from `unknown_lints` instead of always being
allow or deny.
David Koloski [Wed, 23 Feb 2022 04:53:17 +0000 (04:53 +0000)]
Treat unstable lints as unknown
This change causes unstable lints to be ignored if the `unknown_lints`
lint is allowed. To achieve this, it also changes lints to apply as soon
as they are processed. Previously, lints in the same set were processed
as a batch and then all simultaneously applied.
Implementation of https://github.com/rust-lang/compiler-team/issues/469