bors [Mon, 7 Mar 2022 21:20:05 +0000 (21:20 +0000)]
Auto merge of #94709 - martingms:link-to-chunked-opt-pr, r=nnethercote
Add link to closed PR for future optimizers of ChunkedBitSet relations
While optimizing these operations proved unfruitful w.r.t. improving compiler performance right now, faster versions might be needed at a later time. This PR adds a link in the FIXME to save any future optimizers some time, as requested by `@nnethercote` in https://github.com/rust-lang/rust/pull/94625.
bors [Mon, 7 Mar 2022 18:06:31 +0000 (18:06 +0000)]
Auto merge of #94706 - matthiaskrgr:rollup-l5erynr, r=matthiaskrgr
Rollup of 4 pull requests
Successful merges:
- #93350 (libunwind: readd link attrs to _Unwind_Backtrace)
- #93827 (Stabilize const_fn_fn_ptr_basics, const_fn_trait_bound, and const_impl_trait)
- #94696 (Remove whitespaces and use CSS to align line numbers to the right instead)
- #94700 (rustdoc: Update minifier version)
Matthias Krüger [Mon, 7 Mar 2022 17:39:03 +0000 (18:39 +0100)]
Rollup merge of #94696 - GuillaumeGomez:align-line-numbers-right, r=notriddle
Remove whitespaces and use CSS to align line numbers to the right instead
Instead of generating whitespaces to create padding, we simply use the CSS rule: `text-align: right`.
Nice side-effect: it reduces the generated HTML size from **75.004** to **74.828** (MegaBytes) on the std source pages (it's not much but it's always a nice plus :laughing: ).
Previously only `Sized` was allowed as a trait bound.
There is no way to call methods from the trait because trait methods cannot currently be marked as const. Allowing trait bounds in const functions does allow the const function to use the trait's associated types and constants.
This feature also allowes `dyn Trait` types. These work equivalently to non-const code. Similar to other pointers in const code, the value of a `dyn Trait` pointer cannot be observed.
Note that due to https://github.com/rust-lang/rust/issues/90912, it was already possible to do the example above as follows:
The following tests include code that exercises `const_fn_trait_bound`:
- `src/test/ui/consts/const-fn.rs`
- `src/test/ui/consts/issue-88071.rs`
- `src/test/ui/consts/min_const_fn/min_const_fn.rs`
- `src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs`
- `src/test/ui/nll/issue-55825-const-fn.rs`
- Many of the tests in `src/test/ui/rfc-2632-const-trait-impl/` also exercise this feature.
## `const_impl_trait`
Allows argument and return position `impl Trait` in a `const fn`, such as in the following example:
Similar to generic parameters and function pointers, this allows the creation of such opaque types, but not doing anything with them beyond accessing associated types and constants.
These features are documented along with the other const evaluation features in the Rust Reference at https://doc.rust-lang.org/stable/reference/const_eval.html.
There is a PR that updates this documentation to reflect the capabilities enabled by these features at https://github.com/rust-lang/reference/pull/1166.
bors [Mon, 7 Mar 2022 15:25:42 +0000 (15:25 +0000)]
Auto merge of #94690 - nnethercote:clarify-Layout-interning, r=fee1-dead
Clarify `Layout` interning.
`Layout` is another type that is sometimes interned, sometimes not, and
we always use references to refer to it so we can't take any advantage
of the uniqueness properties for hashing or equality checks.
This commit renames `Layout` as `LayoutS`, and then introduces a new
`Layout` that is a newtype around an `Interned<LayoutS>`. It also
interns more layouts than before. Previously layouts within layouts
(via the `variants` field) were never interned, but now they are. Hence
the lifetime on the new `Layout` type.
Unlike other interned types, these ones are in `rustc_target` instead of
`rustc_middle`. This reflects the existing structure of the code, which
does layout-specific stuff in `rustc_target` while `TyAndLayout` is
generic over the `Ty`, allowing the type-specific stuff to occur in
`rustc_middle`.
The commit also adds a `HashStable` impl for `Interned`, which was
needed. It hashes the contents, unlike the `Hash` impl which hashes the
pointer.
bors [Mon, 7 Mar 2022 07:29:08 +0000 (07:29 +0000)]
Auto merge of #94692 - matthiaskrgr:rollup-64p7ya7, r=matthiaskrgr
Rollup of 4 pull requests
Successful merges:
- #94636 (Check extra function arg exprs even if the fn is not C-variadic)
- #94676 (Remove unnecessary `..` patterns)
- #94681 (CTFE engine: expose misc_cast to Miri)
- #94684 (Fix rustdoc for GATs with with anonymous bound regions)
Matthias Krüger [Mon, 7 Mar 2022 05:44:02 +0000 (06:44 +0100)]
Rollup merge of #94636 - compiler-errors:issue-94599, r=davidtwco
Check extra function arg exprs even if the fn is not C-variadic
We should still call check_expr on the args that exceed the formal input ty count, so that we have expr types to emit during writeback.
Not sure where this regressed, but it wasn't due to the same root cause as #94334 I think. I thought this might've regressed in #92360, but I think that is in stable, ad the test I provided (which minimizes #94599) passes on stable in playground. Maybe it regressed in #93118.
bors [Mon, 7 Mar 2022 04:48:23 +0000 (04:48 +0000)]
Auto merge of #94272 - tavianator:readdir-reclen-for-real, r=cuviper
fs: Don't dereference a pointer to a too-small allocation
ptr::addr_of!((*ptr).field) still requires ptr to point to an
appropriate allocation for its type. Since the pointer returned by
readdir() can be smaller than sizeof(struct dirent), we need to entirely
avoid dereferencing it as that type.
`Layout` is another type that is sometimes interned, sometimes not, and
we always use references to refer to it so we can't take any advantage
of the uniqueness properties for hashing or equality checks.
This commit renames `Layout` as `LayoutS`, and then introduces a new
`Layout` that is a newtype around an `Interned<LayoutS>`. It also
interns more layouts than before. Previously layouts within layouts
(via the `variants` field) were never interned, but now they are. Hence
the lifetime on the new `Layout` type.
Unlike other interned types, these ones are in `rustc_target` instead of
`rustc_middle`. This reflects the existing structure of the code, which
does layout-specific stuff in `rustc_target` while `TyAndLayout` is
generic over the `Ty`, allowing the type-specific stuff to occur in
`rustc_middle`.
The commit also adds a `HashStable` impl for `Interned`, which was
needed. It hashes the contents, unlike the `Hash` impl which hashes the
pointer.
bors [Sun, 6 Mar 2022 22:37:54 +0000 (22:37 +0000)]
Auto merge of #94597 - nnethercote:ConstAllocation, r=fee1-dead
Introduce `ConstAllocation`.
Currently some `Allocation`s are interned, some are not, and it's very
hard to tell at a use point which is which.
This commit introduces `ConstAllocation` for the known-interned ones,
which makes the division much clearer. `ConstAllocation::inner()` is
used to get the underlying `Allocation`.
In some places it's natural to use an `Allocation`, in some it's natural
to use a `ConstAllocation`, and in some places there's no clear choice.
I've tried to make things look as nice as possible, while generally
favouring `ConstAllocation`, which is the type that embodies more
information. This does require quite a few calls to `inner()`.
The commit also tweaks how `PartialOrd` works for `Interned`. The
previous code was too clever by half, building on `T: Ord` to make the
code shorter. That caused problems with deriving `PartialOrd` and `Ord`
for `ConstAllocation`, so I changed it to build on `T: PartialOrd`,
which is slightly more verbose but much more standard and avoided the
problems.
Currently some `Allocation`s are interned, some are not, and it's very
hard to tell at a use point which is which.
This commit introduces `ConstAllocation` for the known-interned ones,
which makes the division much clearer. `ConstAllocation::inner()` is
used to get the underlying `Allocation`.
In some places it's natural to use an `Allocation`, in some it's natural
to use a `ConstAllocation`, and in some places there's no clear choice.
I've tried to make things look as nice as possible, while generally
favouring `ConstAllocation`, which is the type that embodies more
information. This does require quite a few calls to `inner()`.
The commit also tweaks how `PartialOrd` works for `Interned`. The
previous code was too clever by half, building on `T: Ord` to make the
code shorter. That caused problems with deriving `PartialOrd` and `Ord`
for `ConstAllocation`, so I changed it to build on `T: PartialOrd`,
which is slightly more verbose but much more standard and avoided the
problems.
bors [Sun, 6 Mar 2022 20:21:35 +0000 (20:21 +0000)]
Auto merge of #94679 - matthiaskrgr:rollup-9vd7w6a, r=matthiaskrgr
Rollup of 3 pull requests
Successful merges:
- #94659 (explain why shift with signed offset works the way it does)
- #94671 (fix pin doc typo)
- #94672 (Improved error message for failed bitcode load)
bors [Sun, 6 Mar 2022 18:07:11 +0000 (18:07 +0000)]
Auto merge of #94579 - tmiasko:target-features, r=nagisa
Always include global target features in function attributes
This ensures that information about target features configured with
`-C target-feature=...` or detected with `-C target-cpu=native` is
retained for subsequent consumers of LLVM bitcode.
This is crucial for linker plugin LTO, since this information is not
conveyed to the plugin otherwise.
<details><summary>Additional test case demonstrating the issue</summary>
```rust
extern crate core;
#[inline]
#[target_feature(enable = "aes")]
unsafe fn f(a: u128, b: u128) -> u128 {
use core::arch::x86_64::*;
use core::mem::transmute;
transmute(_mm_aesenc_si128(transmute(a), transmute(b)))
}
Matthias Krüger [Sun, 6 Mar 2022 14:41:26 +0000 (15:41 +0100)]
Rollup merge of #93412 - fee1-dead:improve-rustdoc-const-bounds, r=GuillaumeGomez
Improve rustdoc const bounds
- Rustdoc no longer displays `~const` in trait bounds, because it currently means nothing for stable users, and because we still haven't decided on the final syntax yet.
- Rustdoc will hide trait bounds where the trait is `Drop` AND it is `~const`, i.e. `~const Drop` bounds because it has no effect on stable users as well.
- Because of additional logic that hides the whole `where` statement where it consists of `~const Drop` bounds (so it doesn't display `struct Foo<T>() where ;` like that), bounds that have no trait e.g. `where [T; N+1]: ;` are also hidden.
bors [Sun, 6 Mar 2022 12:57:32 +0000 (12:57 +0000)]
Auto merge of #94668 - fee1-dead:rollup-8e92bht, r=fee1-dead
Rollup of 3 pull requests
Successful merges:
- #92509 (doc: `Iterator::partition` use partial type hints)
- #94621 (rustbuild: support RelWithDebInfo for lld)
- #94649 (Unix path::absolute: Fix leading "." component)
fee1-dead [Sun, 6 Mar 2022 11:35:30 +0000 (22:35 +1100)]
Rollup merge of #94621 - ridwanabdillahi:lld-rel-dbg, r=Mark-Simulacrum
rustbuild: support RelWithDebInfo for lld
r? ``@alexcrichton``
LLVM has flags that control the level of debuginfo generated when building via rustbuild. Since LLD is built separately, it currently has no way of generating any debuginfo. This change re-uses the same flags as LLVM for LLD to ensure it has the same level of debuginfo generated as LLVM.
bors [Sat, 5 Mar 2022 22:52:08 +0000 (22:52 +0000)]
Auto merge of #94601 - csmoe:android-asan, r=nagisa
add address sanitizer fo android
We have been being using asan to debug the rust/cpp/c mixed android application in production for months: recompile the rust library with a patched rustc, everything just works fine. The patch is really small thanks to `@nagisa` 's refactoring in https://github.com/rust-lang/rust/pull/81866
bors [Sat, 5 Mar 2022 19:53:45 +0000 (19:53 +0000)]
Auto merge of #94648 - RalfJung:rollup-4iorcrd, r=RalfJung
Rollup of 4 pull requests
Successful merges:
- #94630 (Update note about tier 2 docs.)
- #94633 (Suggest removing a semicolon after derive attributes)
- #94642 (Fix source code pages scroll)
- #94645 (do not attempt to open cgroup files under Miri)
Ralf Jung [Sat, 5 Mar 2022 17:53:17 +0000 (12:53 -0500)]
Rollup merge of #94645 - RalfJung:available-parallelism-miri, r=the8472
do not attempt to open cgroup files under Miri
Since https://github.com/rust-lang/rust/pull/92697, `cargo miri test` always fails under default flags, and one would have to use `MIRIFLAGS=-Zmiri-disable-isolation cargo miri test` instead. This PR fixes that problem.
Ralf Jung [Sat, 5 Mar 2022 17:53:17 +0000 (12:53 -0500)]
Rollup merge of #94642 - GuillaumeGomez:source-code-scroll, r=Urgau
Fix source code pages scroll
To reproduce the bug, go to https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_ast/ast.rs.html#537-541 and click on the `Path` link. The page won't scroll to the content.
bors [Sat, 5 Mar 2022 17:13:03 +0000 (17:13 +0000)]
Auto merge of #92123 - m-ou-se:thread-local-cell-methods, r=joshtriplett
Implement RFC 3184 - thread local cell methods
This implements [RFC 3184](https://github.com/rust-lang/rfcs/pull/3184), with `@danielhenrymantilla's` [suggestion](https://github.com/rust-lang/rfcs/pull/3184#issuecomment-965773616) for the `with_` method names.
bors [Sat, 5 Mar 2022 14:32:25 +0000 (14:32 +0000)]
Auto merge of #94480 - bjorn3:no_build_helper, r=Mark-Simulacrum
Remove build_helper
The majority of the code is only used by either rustbuild or
rustc_llvm's build script. Rust_build is compiled once for rustbuild and
once for every stage. This means that the majority of the code in this
crate is needlessly compiled multiple times. By moving only the code
actually used by the respective crates to rustbuild and rustc_llvm's
build script, this needless duplicate compilation is avoided.
bjorn3 [Thu, 24 Feb 2022 12:30:50 +0000 (13:30 +0100)]
Remove build_helper
The majority of the code is only used by either rustbuild or
rustc_llvm's build script. Rust_build is compiled once for rustbuild and
once for every stage. This means that the majority of the code in this
crate is needlessly compiled multiple times. By moving only the code
actually used by the respective crates to rustbuild and rustc_llvm's
build script, this needless duplicate compilation is avoided.
bors [Sat, 5 Mar 2022 11:29:59 +0000 (11:29 +0000)]
Auto merge of #94561 - Urgau:check-cfg-lint-help-remove, r=petrochenkov
Improve unexpected_cfgs lint when their is no value expected
This pull-request improve the `unexpected_cfgs` when their is no value expected by suggesting to remove the value.
I also took the liberty to special case it for `feature` as it seems wrong to suggest to remove the value when the problem is most probably the absence of value(s) and also the fact that it doesn't make sense to only have `feature` without a value.
bors [Sat, 5 Mar 2022 04:56:35 +0000 (04:56 +0000)]
Auto merge of #94634 - Dylan-DPC:rollup-8wx1yrj, r=Dylan-DPC
Rollup of 6 pull requests
Successful merges:
- #94446 (UNIX `remove_dir_all()`: Try recursing first on the slow path)
- #94460 (Reenable generator drop tracking tests and fix mutation handling)
- #94620 (Edit docs on consistency of `PartialOrd` and `PartialEq`)
- #94624 (Downgrade `#[test]` on macro call to warning)
- #94626 (Add known-bug directive to issue #47511 test case)
- #94631 (Fix typo in c-variadic)