Commit graph

158061 commits

Author SHA1 Message Date
Josh Triplett
e35b7bbdf8 Stabilize -Z strip as -C strip
Leave -Z strip available temporarily as an alias, to avoid breaking
cargo until cargo transitions to using -C strip. (If the user passes
both, the -C version wins.)
2021-11-15 10:21:02 +01:00
Josh Triplett
c4884bbec7 Support having -Z and -C options with the same name
Tweak the `options!` macro to allow for -Z and -C options with the same
name without generating conflicting internal parsing functions.

Split out of the commit stabilizing -Z strip as -C strip.
2021-11-15 10:18:30 +01:00
bors
4205481110 Auto merge of #90684 - jyn514:dist-aliases, r=Mark-Simulacrum
Change paths for `dist` command to match the components they generate

Before, you could have the confusing situation where the command to
generate a component had no relation to the name of that component (e.g.
the `rustc` component was generated with `src/librustc`). This changes
the name to make them match up.
2021-11-15 03:19:01 +00:00
bors
ad44239975 Auto merge of #88282 - Neutron3529:patch-4, r=Mark-Simulacrum
Optimize BinaryHeap::extend from Vec

This improves the performance of extending `BinaryHeap`s from vectors directly. Future work may involve extending this optimization to other, similar, cases where the length of the added elements is well-known, but this is not yet done in this PR.
2021-11-14 18:47:42 +00:00
bors
c8e94975a6 Auto merge of #90596 - the8472:path-hash-opt, r=Mark-Simulacrum
Optimize Eq and Hash for Path/PathBuf

```
# new

test path::tests::bench_hash_path_long                            ... bench:          86 ns/iter (+/- 1)
test path::tests::bench_hash_path_short                           ... bench:          13 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:         197 ns/iter (+/- 6)
test path::tests::bench_path_hashset_miss                         ... bench:          94 ns/iter (+/- 4)

# old

test path::tests::bench_hash_path_long                            ... bench:         192 ns/iter (+/- 2)
test path::tests::bench_hash_path_short                           ... bench:          33 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:       1,121 ns/iter (+/- 24)
test path::tests::bench_path_hashset_miss                         ... bench:         273 ns/iter (+/- 6)
```
2021-11-14 15:18:26 +00:00
bors
3b2c45441d Auto merge of #90839 - pierwill:docs-rustc-newtype-index, r=jackh726
Generate documentation in rustc `rustc_index::newtype_index` macro

The macro now documents all generated items. Documentation notes possible panics and unsafety.
2021-11-14 12:17:32 +00:00
bors
6d387431e5 Auto merge of #90757 - GuillaumeGomez:search-index-performance, r=camelid
Remove unneeded FIXMEs comments in search index generation

Original comment:

> Instead of recreating a new `vec` for each arguments, we re-use the same. The impact on performance should be minor but worth a try.

After testing it, we reached the conclusion that the code readability drop wasn't worth the almost unnoticeable performance improvement.

r? `@camelid`
2021-11-14 08:57:27 +00:00
bors
f820d9d4e5 Auto merge of #90867 - hi-rustin:rustin-patch-rustdoc, r=CraftSpider
Delete rustdoc::doctree

close https://github.com/rust-lang/rust/issues/90864
2021-11-14 05:50:54 +00:00
bors
589ad6a5b7 Auto merge of #90883 - matthiaskrgr:rollup-iu9k5pe, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #90771 (Fix trait object error code)
 - #90840 (relate lifetime in `TypeOutlives` bounds on drop impls)
 - #90853 (rustdoc: Use an empty Vec instead of Option<Vec>)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-14 01:06:05 +00:00
pierwill
845c25d1b4 Generate documentation in rustc rustc_index::newtype_index macro
The macro now documents all generated items. Documentation notes
possible panics and unsafety.
2021-11-13 18:50:29 -06:00
Matthias Krüger
c677a8da86
Rollup merge of #90853 - notriddle:notriddle/option-vec, r=GuillaumeGomez
rustdoc: Use an empty Vec instead of Option<Vec>
2021-11-13 22:35:05 +01:00
Matthias Krüger
e273fab434
Rollup merge of #90840 - BoxyUwU:lolripme, r=jackh726
relate lifetime in `TypeOutlives` bounds on drop impls

Fixes #90838
2021-11-13 22:35:04 +01:00
Matthias Krüger
b35af0d04d
Rollup merge of #90771 - asterycs:fix/trait-object-error-code, r=michaelwoerister
Fix trait object error code

closes #90768

I `grep`:d and changed the occurrences that seemed relevant. Please let me know what you think and if anything is missing!
2021-11-13 22:35:03 +01:00
bors
b416e3892d Auto merge of #90385 - mfrw:mfrw/librustdoc, r=GuillaumeGomez
rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()

For: #90187

r? `@jyn514`
2021-11-13 20:11:58 +00:00
bors
d212d902ae Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk
Stabilize `const_raw_ptr_deref` for `*const T`

This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is behind the
same feature gate as mutable references.

closes https://github.com/rust-lang/rust/issues/51911
2021-11-13 17:10:15 +00:00
bors
1b12d01903 Auto merge of #90542 - the8472:privatize-the-means-of-rawvec-production, r=joshtriplett
Make RawVec private to alloc

RawVec was previously exposed for compiler-internal use (libarena specifically) in 1acbb0a935

Since it is unstable, doc-hidden and has no associated tracking issue it was never meant for public use. And since
it is no longer used outside alloc itself it can be made private again.

Also remove some functions that are dead due to lack of internal users.
2021-11-13 13:57:00 +00:00
hi-rustin
e7a20c96b1 Delete rustdoc::doctree
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-11-13 21:50:13 +08:00
Joshua Nelson
d42a391333 Change paths for dist command to match the components they generate
Before, you could have the confusing situation where the command to
generate a component had no relation to the name of that component (e.g.
the `rustc` component was generated with `src/librustc`). This changes
the name to make them match up.
2021-11-13 07:28:37 -06:00
bors
3e018ce194 Auto merge of #87264 - mystor:expand_literal, r=petrochenkov
proc_macro: Add an expand_expr method to TokenStream

This feature is aimed at giving proc macros access to powers similar to those used by builtin macros such as `format_args!` or `concat!`. These macros are able to accept macros in place of string literal parameters, such as the format string, as they perform recursive macro expansion while being expanded.

This can be especially useful in many cases thanks to helper macros like `concat!`, `stringify!` and `include_str!` which are often used to construct string literals at compile-time in user code.

For now, this method only allows expanding macros which produce literals, although more expressions will be supported before the method is stabilized.

In earlier versions of this PR, this method exclusively returned `Literal`, and spans on returned literals were stripped of expansion context before being returned to be as conservative as possible about permission leakage. The method's naming has been generalized to eventually support arbitrary expressions, and the context stripping has been removed (https://github.com/rust-lang/rust/pull/87264#discussion_r674863279), which should allow for more general APIs like "format_args_implicits" (https://github.com/rust-lang/rust/issues/67984) to be supported as well.

## API Surface

```rust
impl TokenStream {
    pub fn expand_expr(&self) -> Result<TokenStream, ExpandError>;
}

#[non_exhaustive]
pub struct ExpandError;

impl Debug for ExpandError { ... }
impl Display for ExpandError { ... }
impl Error for ExpandError {}
impl !Send for ExpandError {}
impl !Sync for ExpandError {}
```
2021-11-13 08:22:52 +00:00
Michael Howell
688ed0a019 Use an empty Vec instead of Option<Vec> 2021-11-12 22:25:31 -07:00
bors
7594067b69 Auto merge of #90041 - jfrimmel:rt_copy_checks, r=Mark-Simulacrum
Re-enable `copy[_nonoverlapping]()` debug-checks

This commit re-enables the debug checks for valid usages of the two functions `copy()` and `copy_nonoverlapping()`. Those checks were commented out in #79684 in order to make the functions const. All that's been left was a FIXME, that could not be resolved until there is was way to only do the checks at runtime.
Since #89247 there is such a way: `const_eval_select()`. This commit uses that new intrinsic in order to either do nothing (at compile time) or to do the old checks (at runtime).

The change itself is rather small: in order to make the checks usable with `const_eval_select`, they are moved into a local function (one for `copy` and one for `copy_nonoverlapping` to keep symmetry).

The change does not break referential transparency, as there is nothing you can do at compile time, which you cannot do on runtime without getting undefined behavior. The CTFE-engine won't allow missuses. The other way round is also fine.

I've refactored the code to use `#[cfg(debug_assertions)]` on the new items. If that is not desired, the second commit can be dropped.
I haven't added any checks, as I currently don't know, how to test this properly.

Closes #90012.

cc `@rust-lang/lang,` `@rust-lang/libs` and `@rust-lang/wg-const-eval` (as those teams are linked in the issue above).
2021-11-13 05:19:39 +00:00
bors
032dfe4360 Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrum
pub use core::simd;

A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust, `std::arch` offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completely `unsafe` to use.  `core::simd` offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available.

`core::simd` is enabled by the `#![portable_simd]` nightly feature tracked in https://github.com/rust-lang/rust/issues/86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests **are** introduced via the documentation, but these use deterministic asserts.

There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out.

The major types are
- `core::simd::Simd<T, N>`
- `core::simd::Mask<T, N>`

There is also the `LaneCount` struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.
2021-11-13 02:17:20 +00:00
Jubilee Young
7c3d72d069 Test core::simd works
These tests just verify some basic APIs of core::simd function, and
guarantees that attempting to access the wrong things doesn't work.
The majority of tests are stochastic, and so remain upstream, but
a few deterministic tests arrive in the subtree as doc tests.
2021-11-12 16:58:47 -08:00
Jubilee Young
39cb863253 Expose portable-simd as core::simd
This enables programmers to use a safe alternative to the current
`extern "platform-intrinsics"` API for writing portable SIMD code.
This is `#![feature(portable_simd)]` as tracked in #86656
2021-11-12 16:58:39 -08:00
Jubilee Young
fdee059c90 Add 'library/portable-simd/' from commit '1ce1c645cf27c4acdefe6ec8a11d1f0491954a99'
git-subtree-dir: library/portable-simd
git-subtree-mainline: efd0483949
git-subtree-split: 1ce1c645cf
2021-11-12 16:58:25 -08:00
Jubilee Young
1ce1c645cf Rewrite Arm transmutes, reading std::arch closer 2021-11-12 16:56:14 -08:00
Ellen
875024ca6b oops... 2021-11-12 20:50:25 +00:00
Nika Layzell
3e4d3d2a29 proc_macro: Add an expand_expr method to TokenStream
This feature is aimed at giving proc macros access to powers similar to
those used by builtin macros such as `format_args!` or `concat!`. These
macros are able to accept macros in place of string literal parameters,
such as the format string, as they perform recursive macro expansion
while being expanded.

This can be especially useful in many cases thanks to helper macros like
`concat!`, `stringify!` and `include_str!` which are often used to
construct string literals at compile-time in user code.

For now, this method only allows expanding macros which produce
literals, although more expresisons will be supported before the method
is stabilized.
2021-11-12 15:41:40 -05:00
bors
e90c5fbbc5 Auto merge of #90836 - matthiaskrgr:rollup-ou6yrlw, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90589 (rustc_llvm: update PassWrapper for recent LLVM)
 - #90644 (Extend the const swap feature)
 - #90704 (Unix ExitStatus comments and a tiny docs fix)
 - #90761 (Shorten Span of unused macro lints)
 - #90795 (Add more comments to explain the code to generate the search index)
 - #90798 (Document `unreachable!` custom panic message)
 - #90826 (rustc_feature: Convert `BuiltinAttribute` from tuple to a struct)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-12 19:28:04 +00:00
Matthias Krüger
5e7c031397
Rollup merge of #90826 - petrochenkov:binattr, r=cjgillot
rustc_feature: Convert `BuiltinAttribute` from tuple to a struct

The tuple starts having too many fields.
Noticed while reviewing https://github.com/rust-lang/rust/pull/88681.
2021-11-12 19:17:34 +01:00
Matthias Krüger
5b3cb68d97
Rollup merge of #90798 - edmorley:doc-unreachable-custom-message, r=dtolnay
Document `unreachable!` custom panic message

The `unreachable!` docs previously did not mention that there was a second form, `unreachable!("message")` that could be used to specify a custom panic message,

The docs now mention this feature in the same wording as currently used for `unimplemented!`:
https://doc.rust-lang.org/core/macro.unimplemented.html#panics
2021-11-12 19:17:33 +01:00
Matthias Krüger
f522f26867
Rollup merge of #90795 - GuillaumeGomez:more-search-index-comments, r=notriddle
Add more comments to explain the code to generate the search index

Fixes #90766.

I tried to put comments when the code wasn't easy to understand at first sight and added more documentation on the recursive function. Please tell me if I misused the terminology or if comments can be improved or added into other places.

r? `@notriddle`
2021-11-12 19:17:32 +01:00
Matthias Krüger
640f365bff
Rollup merge of #90761 - hellow554:macro_span, r=estebank
Shorten Span of unused macro lints

The span has been reduced to the actual ident of the macro, instead of linting the
*whole* macro.

Closes #90745

r? ``@estebank``
2021-11-12 19:17:31 +01:00
Matthias Krüger
160602b485
Rollup merge of #90704 - ijackson:exitstatus-comments, r=joshtriplett
Unix ExitStatus comments and a tiny docs fix

Some nits left over from #88300
2021-11-12 19:17:31 +01:00
Matthias Krüger
70532c4503
Rollup merge of #90644 - est31:const_swap, r=Mark-Simulacrum
Extend the const swap feature

Adds the `const_swap` feature gate to three more swap functions. cc tracking issue #83163

```Rust
impl<T> [T] {
    pub const fn swap(&mut self, a: usize, b: usize);
    pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize);
}
impl<T: ?Sized> *mut T {
    pub const unsafe fn swap(self, with: *mut T);
}
2021-11-12 19:17:30 +01:00
Matthias Krüger
1fe15be34c
Rollup merge of #90589 - durin42:llvm-14-ASO-now-struct, r=nikic
rustc_llvm: update PassWrapper for recent LLVM

Now AddressSanitizerOptions is a struct, but at least the change was
tiny.

r? `@nikic`
2021-11-12 19:17:28 +01:00
bors
220ed09b26 Auto merge of #89316 - asquared31415:multiple-clobber-abi, r=Amanieu
Add support for specifying multiple clobber_abi in `asm!`

r? `@Amanieu`
cc #72016
`@rustbot` label: +A-inline-assembly +F-asm
2021-11-12 16:29:25 +00:00
asquared31415
e80f3008e0 fix aarch test error annotations 2021-11-12 10:30:20 -05:00
Guillaume Gomez
9c05335a0f Add more comments to explain the code to generate the search index 2021-11-12 15:33:10 +01:00
Guillaume Gomez
6b3695d480 Remove unneeded FIXME: after testing the suggested changes, we reached the conclusion that the code readibility wasn't worth the almost unnoticeable perf improvement 2021-11-12 15:25:13 +01:00
Vadim Petrochenkov
6655727041 rustc_feature: Convert BuiltinAttribute from tuple to a struct 2021-11-12 20:15:14 +08:00
bors
f31622a50b Auto merge of #90813 - notriddle:notriddle/vec-extend, r=GuillaumeGomez
Use Vec extend and collect instead of repeatedly calling push
2021-11-12 12:13:32 +00:00
Neutron3529
2feee3659e provide a SpecExtend trait for Vec<T>
The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3)
2021-11-12 15:45:25 +08:00
bors
e4c23daeb4 Auto merge of #90731 - pierwill:fix-90658, r=michaelwoerister
Remove `rustc_incremental::persist::fs::dep_graph_path_from`

Closes https://github.com/rust-lang/rust/issues/90658.

r? `@michaelwoerister`
2021-11-12 04:26:28 +00:00
Michael Howell
a82692d613 Use Iterator::collect instead of calling Vec::push in a loop 2021-11-11 16:11:38 -07:00
bors
14a2fd640e Auto merge of #90489 - jyn514:load-all-extern-crates, r=petrochenkov
rustdoc: Go back to loading all external crates unconditionally

This *continues* to cause regressions. This code will be unnecessary
once access to the resolver happens fully before creating the tyctxt
(#83761), so load all crates unconditionally for now. To minimize churn, this leaves in the code for loading crates selectively.

"Fixes" https://github.com/rust-lang/rust/issues/84738. Previously: https://github.com/rust-lang/rust/pull/83738, https://github.com/rust-lang/rust/pull/85749, https://github.com/rust-lang/rust/pull/88215

r? `@petrochenkov` cc `@camelid` (this should fix the "index out of bounds" error you had while looking up `crate_name`).
2021-11-11 22:00:53 +00:00
Michael Howell
b0fd642de6 Use Vec::extend, instead of calling Vec::push in a loop 2021-11-11 13:56:32 -07:00
The8472
c1ea7bdc87 Prefix can be case-insensitive, delegate to its Hash impl instead of trying to hash the raw bytes
This should have 0 performance overhead on unix since Prefix is always None.
2021-11-11 21:44:12 +01:00
Jubilee Young
6ddf7ad8e1 Restrict Arm types to Arm v7+
This mostly mirrors the restrictions in std::arch.
It can be loosened slightly with later refactoring.
2021-11-11 11:40:18 -08:00
bors
936238a92b Auto merge of #90746 - nnethercote:opt-pattern-matching, r=Nadrieril
Optimize pattern matching

These commits speed up the `match-stress-enum` benchmark, which is very artificial, but the changes are simple enough that it's probably worth doing.

r? `@Nadrieril`
2021-11-11 18:26:49 +00:00