Commit Graph

158046 Commits

Author SHA1 Message Date
Andreas Jonson
50ec47aa06 Remove workaround for the forward progress handling in LLVM 2021-11-14 16:35:09 +01: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
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
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
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
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
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
Ian Jackson
fe39fb3149 process::ExitStatus: Discuss exit vs _exit in a comment.
As discussed here
 https://github.com/rust-lang/rust/pull/88300#issuecomment-936097710

I felt this was the best place to put this (rather than next to
ExitStatusExt).  After all, it's a property of the ExitStatus type on
Unix.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11 17:48:51 +00:00
Ian Jackson
d1df4715ec unix::ExitStatus: Add comment saying that it's a wait status
With cross-reference.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11 17:48:51 +00:00
Ian Jackson
79e52b3f1e unix::ExitStatusExt: Correct reference to _exit system call
As discussed here
 https://github.com/rust-lang/rust/pull/88300#issuecomment-936085371

exit is (conventionally) a library function, with _exit being the
actual system call.

I have checked the other references and they say "if the process
terminated by calling `exti`".  I think despite the slight
imprecision (strictly, it should read iff ... `_exit`), this is
clearer.  Anyone who knows about the distinction between `exit` and
`_exit` will not be confused.

`_exit` is the correct traditional name for the system call, despite
Linux calling it `exit_group` or `exit`:
  https://www.freebsd.org/cgi/man.cgi?query=_exit&sektion=2&n=1

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11 17:48:03 +00:00
bors
3d29b68077 Auto merge of #90648 - matthewjasper:assoc-item-cleanup, r=cjgillot
Assoc item cleanup

This removes some fields from ObligationCauseCode

Split out of #90639
2021-11-11 15:15:15 +00:00
Krasimir Georgiev
d9f2d5f0e9 PassWrapper: additional sanitizer update to match clang
This happened later in the stream than the other changes, but the fix is
overlapping. Fix taken from a55c4ec1cee7683d9095327d9d33e7137ec25292 in
LLVM.
2021-11-11 09:05:21 -05:00
Ed Morley
b41b2e5a5c
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 in the same style as currently used for `unimplemented!`:
https://doc.rust-lang.org/core/macro.unimplemented.html#panics
2021-11-11 13:41:21 +00:00
Muhammad Falak R Wani
5cfc7ce337
librustdoc: revert use of def_id for one of the edge case
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-11-11 18:32:31 +05:30
bors
d71ba74f0d Auto merge of #88798 - sunfishcode:sunfishcode/windows-null-handles, r=joshtriplett
Fix assertion failures in `OwnedHandle` with `windows_subsystem`.

As discussed in #88576, raw handle values in Windows can be null, such
as in `windows_subsystem` mode, or when consoles are detached from a
process. So, don't use `NonNull` to hold them, don't assert that they're
not null, and remove `OwnedHandle`'s `repr(transparent)`. Introduce a
new `HandleOrNull` type, similar to `HandleOrInvalid`, to cover the FFI
use case.

r? `@joshtriplett`
2021-11-11 12:07:53 +00:00
bors
62efba8a05 Auto merge of #90755 - scottmcm:spec-array-clone, r=jackh726
Specialize array cloning for Copy types

Because after PR 86041, the optimizer no longer load-merges at the LLVM IR level, which might be part of the perf loss.  (I'll run perf and see if this makes a difference.)

Also I added a codegen test so this hopefully won't regress in future -- it passes on stable and with my change here, but not on the 2021-11-09 nightly.

Example on current nightly: <https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=1f52d46fb8fc3ca3ac9f097390085ffa>
```rust
type T = u8;
const N: usize = 3;

pub fn demo_clone(x: &[T; N]) -> [T; N] {
    x.clone()
}

pub fn demo_copy(x: &[T; N]) -> [T; N] {
    *x
}
```
```llvm-ir
; playground::demo_clone
; Function Attrs: mustprogress nofree nosync nounwind nonlazybind uwtable willreturn
define i24 `@_ZN10playground10demo_clone17h98a4f11453d1a753E([3` x i8]* noalias nocapture readonly align 1 dereferenceable(3) %x) unnamed_addr #0 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* `@rust_eh_personality` {
start:
  %0 = getelementptr [3 x i8], [3 x i8]* %x, i64 0, i64 0
  %1 = getelementptr inbounds [3 x i8], [3 x i8]* %x, i64 0, i64 1
  %.val.i.i.i.i.i.i.i.i.i = load i8, i8* %0, align 1, !alias.scope !2, !noalias !9
  %2 = getelementptr inbounds [3 x i8], [3 x i8]* %x, i64 0, i64 2
  %.val.i.i.i.i.i.1.i.i.i.i = load i8, i8* %1, align 1, !alias.scope !2, !noalias !20
  %.val.i.i.i.i.i.2.i.i.i.i = load i8, i8* %2, align 1, !alias.scope !2, !noalias !23
  %array.sroa.6.0.insert.ext.i.i.i.i = zext i8 %.val.i.i.i.i.i.2.i.i.i.i to i32
  %array.sroa.6.0.insert.shift.i.i.i.i = shl nuw nsw i32 %array.sroa.6.0.insert.ext.i.i.i.i, 16
  %array.sroa.5.0.insert.ext.i.i.i.i = zext i8 %.val.i.i.i.i.i.1.i.i.i.i to i32
  %array.sroa.5.0.insert.shift.i.i.i.i = shl nuw nsw i32 %array.sroa.5.0.insert.ext.i.i.i.i, 8
  %array.sroa.0.0.insert.ext.i.i.i.i = zext i8 %.val.i.i.i.i.i.i.i.i.i to i32
  %array.sroa.5.0.insert.insert.i.i.i.i = or i32 %array.sroa.5.0.insert.shift.i.i.i.i, %array.sroa.0.0.insert.ext.i.i.i.i
  %array.sroa.0.0.insert.insert.i.i.i.i = or i32 %array.sroa.5.0.insert.insert.i.i.i.i, %array.sroa.6.0.insert.shift.i.i.i.i
  %.sroa.4.0.extract.trunc.i.i.i.i = trunc i32 %array.sroa.0.0.insert.insert.i.i.i.i to i24
  ret i24 %.sroa.4.0.extract.trunc.i.i.i.i
}

; playground::demo_copy
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind readonly uwtable willreturn
define i24 `@_ZN10playground9demo_copy17h7817453f9291d746E([3` x i8]* noalias nocapture readonly align 1 dereferenceable(3) %x) unnamed_addr #1 {
start:
  %.sroa.0.0..sroa_cast = bitcast [3 x i8]* %x to i24*
  %.sroa.0.0.copyload = load i24, i24* %.sroa.0.0..sroa_cast, align 1
  ret i24 %.sroa.0.0.copyload
}
```
2021-11-11 09:13:22 +00:00
Marcel Hellwig
9f6ca7482c Shorten Span of unused macro lints
The span has been recuded to the actual ident, instead of linting the
*whole* macro.
2021-11-11 08:04:02 +01:00
bors
1d34cb4efc Auto merge of #89550 - lcnr:coherence-specialization, r=nikomatsakis
do not emit overlap errors for impls failing the orphan check

this should finally allow us to merge #86986, see https://github.com/rust-lang/rust/pull/86986#discussion_r716059345 for more details.

r? `@nikomatsakis` cc `@eddyb`
2021-11-11 05:47:37 +00:00