]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agouse static strs
mark [Sun, 22 Mar 2020 02:32:35 +0000 (21:32 -0500)]
use static strs

4 years agoconvert a couple more errors
mark [Sun, 22 Mar 2020 00:47:23 +0000 (19:47 -0500)]
convert a couple more errors

4 years agoreplace some adhoc logic with article_and_descr
Mark Mansi [Mon, 16 Mar 2020 02:48:09 +0000 (21:48 -0500)]
replace some adhoc logic with article_and_descr

4 years agoAuto merge of #69729 - RalfJung:backtrace, r=Mark-Simulacrum
bors [Sat, 21 Mar 2020 16:41:39 +0000 (16:41 +0000)]
Auto merge of #69729 - RalfJung:backtrace, r=Mark-Simulacrum

update backtrace crate

In particular this release includes https://github.com/rust-lang/backtrace-rs/pull/297 and https://github.com/rust-lang/backtrace-rs/pull/300.

4 years agoAuto merge of #70222 - Dylan-DPC:rollup-cwkv5ez, r=Dylan-DPC
bors [Sat, 21 Mar 2020 13:26:44 +0000 (13:26 +0000)]
Auto merge of #70222 - Dylan-DPC:rollup-cwkv5ez, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #69497 (Don't unwind when hitting the macro expansion recursion limit)
 - #69901 (add #[rustc_layout(debug)])
 - #69910 (Avoid query type in generics)
 - #69955 (Fix abort-on-eprintln during process shutdown)
 - #70032 (put type params in front of const params in generics_of)
 - #70119 (rustc: use LocalDefId instead of DefId in TypeckTables.)

Failed merges:

r? @ghost

4 years agoRollup merge of #70119 - eddyb:typeck-tables-local-def-id, r=petrochenkov
Dylan DPC [Sat, 21 Mar 2020 12:06:42 +0000 (13:06 +0100)]
Rollup merge of #70119 - eddyb:typeck-tables-local-def-id, r=petrochenkov

rustc: use LocalDefId instead of DefId in TypeckTables.

The logic in `TypeckTables`' implementation of `HashStable`, which created `DefId`s by combining a `CrateNum` from a `DefId` and a `DefIndex` from a `LocalDefId`, bothered me a bit.

I don't know how much this matters, but it works so might as well submit it.

4 years agoRollup merge of #70032 - lcnr:issue69970, r=varkor
Dylan DPC [Sat, 21 Mar 2020 12:06:40 +0000 (13:06 +0100)]
Rollup merge of #70032 - lcnr:issue69970, r=varkor

put type params in front of const params in generics_of

fixes #69970

r? @varkor

4 years agoRollup merge of #69955 - alexcrichton:stderr-infallible, r=sfackler
Dylan DPC [Sat, 21 Mar 2020 12:06:38 +0000 (13:06 +0100)]
Rollup merge of #69955 - alexcrichton:stderr-infallible, r=sfackler

Fix abort-on-eprintln during process shutdown

This commit fixes an issue where if `eprintln!` is used in a TLS
destructor it can accidentally cause the process to abort. TLS
destructors are executed after `main` returns on the main thread, and at
this point we've also deinitialized global `Lazy` values like those
which store the `Stderr` and `Stdout` internals. This means that despite
handling TLS not being accessible in `eprintln!`, we will fail due to
not being able to call `stderr()`. This means that we'll double-panic
quickly because panicking also attempt to write to stderr.

The fix here is to reimplement the global stderr handle to avoid the
need for destruction. This avoids the need for `Lazy` as well as the
hidden panic inside of the `stderr` function.

Overall this should improve the robustness of printing errors and/or
panics in weird situations, since the `stderr` accessor should be
infallible in more situations.

4 years agoRollup merge of #69910 - cjgillot:polym, r=Zoxc
Dylan DPC [Sat, 21 Mar 2020 12:06:36 +0000 (13:06 +0100)]
Rollup merge of #69910 - cjgillot:polym, r=Zoxc

Avoid query type in generics

There are at the moment roughly 170 queries in librustc.
The way ty::query is structured, a lot of code is duplicated for each query.
I suspect this to be responsible for a part of librustc'c compile time.

This PR reduces the amount of code generic on the query,
replacing it by code generic on the key-value types.

This is split out of #69808,
and should not contain the perf regression.

cc #65031

4 years agoRollup merge of #69901 - RalfJung:rustc_layout, r=eddyb
Dylan DPC [Sat, 21 Mar 2020 12:06:35 +0000 (13:06 +0100)]
Rollup merge of #69901 - RalfJung:rustc_layout, r=eddyb

add #[rustc_layout(debug)]

@eddyb recently told me about the `#[rustc_layout]` attribute, and I think it would be very useful if it could be used to print all the layout information Rust has about a type. When working with layouts (e.g. in Miri), it is often not clear how certain surface language features get represented internally. I have some awful hacks locally to be able to dump this debug information; with this attribute I could get it on the playground which is so much better. :)

4 years agoRollup merge of #69497 - Zoxc:ast-fragment-error, r=petrochenkov
Dylan DPC [Sat, 21 Mar 2020 12:06:33 +0000 (13:06 +0100)]
Rollup merge of #69497 - Zoxc:ast-fragment-error, r=petrochenkov

Don't unwind when hitting the macro expansion recursion limit

This removes one use of `FatalError.raise()`.

r? @petrochenkov

4 years agonormalize away preferred alignment
Ralf Jung [Sat, 21 Mar 2020 09:07:44 +0000 (10:07 +0100)]
normalize away preferred alignment

4 years agoAuto merge of #70211 - Centril:rollup-fusltgc, r=Centril
bors [Sat, 21 Mar 2020 07:53:12 +0000 (07:53 +0000)]
Auto merge of #70211 - Centril:rollup-fusltgc, r=Centril

Rollup of 8 pull requests

Successful merges:

 - #67888 (Prefetch some queries used by the metadata encoder)
 - #69934 (Update the mir inline costs)
 - #69965 (Refactorings to get rid of rustc_codegen_utils)
 - #70054 (Build dist-android with --enable-profiler)
 - #70089 (rustc_infer: remove InferCtxt::closure_sig as the FnSig is always shallowly known.)
 - #70092 (hir: replace "items" terminology with "nodes" where appropriate.)
 - #70138 (do not 'return' in 'throw_' macros)
 - #70151 (Update stdarch submodule)

Failed merges:

 - #70074 (Expand: nix all fatal errors)

r? @ghost

4 years agoRollup merge of #70151 - Amanieu:stdarch, r=sfackler
Mazdak Farrokhzad [Sat, 21 Mar 2020 07:51:23 +0000 (08:51 +0100)]
Rollup merge of #70151 - Amanieu:stdarch, r=sfackler

Update stdarch submodule

This only includes one commit:
- https://github.com/rust-lang/stdarch/commit/abe96ca3b87fcca6aa1dfcefd40d8c8d92d2e673 (https://github.com/rust-lang/stdarch/pull/842)

Fixes #68905

4 years agoRollup merge of #70138 - RalfJung:throw-not-return, r=oli-obk
Mazdak Farrokhzad [Sat, 21 Mar 2020 07:51:21 +0000 (08:51 +0100)]
Rollup merge of #70138 - RalfJung:throw-not-return, r=oli-obk

do not 'return' in 'throw_' macros

In https://github.com/rust-lang/rust/pull/69839 we turned a closure into a `try` block, but it turns out that does not work with our `throw_` macros, which `return` so they skip the `try`.

Here we fix that. For some reason that means we also have to remove some `;`.

r? @oli-obk

4 years agoRollup merge of #70092 - eddyb:hir-items-are-just-nodes, r=Zoxc
Mazdak Farrokhzad [Sat, 21 Mar 2020 07:51:19 +0000 (08:51 +0100)]
Rollup merge of #70092 - eddyb:hir-items-are-just-nodes, r=Zoxc

hir: replace "items" terminology with "nodes" where appropriate.

The newly added `HirOwnerItems` confused me before I realized that "items" there actually referred to HIR nodes, not `hir:Item` or "item-like" (which we should IMO replace with "owner").

I suspect the naming had something to do with `ItemLocalId`'s use of "item".
That is, `ItemLocalId` could be interpreted to mean one of two things:
* `IntraItemNodeId` i.e. `IntraOwnerNodeId`
  * this is IMO correct, and I'd even like to rename it, but I didn't want to throw that into this PR
* `IntraOwnerItemId`
  * this is what `HirOwnerItems` would seem to imply

r? @Zoxc cc @michaelwoerister @nikomatsakis

4 years agoRollup merge of #70089 - eddyb:closure-sig-infer, r=nikomatsakis
Mazdak Farrokhzad [Sat, 21 Mar 2020 07:51:18 +0000 (08:51 +0100)]
Rollup merge of #70089 - eddyb:closure-sig-infer, r=nikomatsakis

rustc_infer: remove InferCtxt::closure_sig as the FnSig is always shallowly known.

That is, `ClosureSubsts` is always created (in `rustc_typeck::check::closure`) with a `FnSig`, as the number of inputs is known, even if they might all have inference types.
The only useful thing `InferCtxt::closure_sig` was doing is resolving an inference variable used just to get the `ty::FnPtr` containing that `FnSig` into `ClosureSubsts`.

The ideal way to solve this would be to add a constructor for `ClosureSubsts`, that combines the parent `Substs`, the closure kind, the signature, and capture types together, but for now I've went with resolving the inference types just after unifying them with the real types.

r? @nikomatsakis

4 years agoRollup merge of #70054 - rojamd:android-pgo, r=michaelwoerister
Mazdak Farrokhzad [Sat, 21 Mar 2020 07:51:15 +0000 (08:51 +0100)]
Rollup merge of #70054 - rojamd:android-pgo, r=michaelwoerister

Build dist-android with --enable-profiler

This will make the runtime available to enable PGO for Rust code in Firefox on Android.

r? @michaelwoerister

4 years agoRollup merge of #69965 - mark-i-m:codegen-utils, r=eddyb
Mazdak Farrokhzad [Sat, 21 Mar 2020 07:51:14 +0000 (08:51 +0100)]
Rollup merge of #69965 - mark-i-m:codegen-utils, r=eddyb

Refactorings to get rid of rustc_codegen_utils

r? @eddyb

cc #45276

After this, the only modules left in `rustc_codegen_utils` are
- `link`: a bunch of linking-related functions (many dealing with file names). These are mostly consumed by save analysis, rustc_driver, rustc_interface, and of course codegen. I assume they live here because we don't want a dependency of save analysis on codegen... Perhaps they can be moved to librustc?
- ~`symbol_names` and `symbol_names_test`: honestly it seems odd that `symbol_names_test` is not a submodule of `symbol_names`. It seems like these could honestly live in their own crate or move to librustc. Already name mangling is exported as the `symbol_name` query.~ (move it to its own crate)

I don't mind doing either of the above as part of this PR or a followup if you want.

4 years agoRollup merge of #69934 - andjo403:inlinecost, r=wesleywiser
Mazdak Farrokhzad [Sat, 21 Mar 2020 07:51:12 +0000 (08:51 +0100)]
Rollup merge of #69934 - andjo403:inlinecost, r=wesleywiser

Update the mir inline costs

handle that when mir is lowered to llvm-ir more code is generated.
Landingpads generates 10 llvm-ir instructions
and resume 9 llvm-ir instructions.

r? @wesleywiser

4 years agoRollup merge of #67888 - Zoxc:metadata-prefetch, r=matthewjasper
Mazdak Farrokhzad [Sat, 21 Mar 2020 07:51:10 +0000 (08:51 +0100)]
Rollup merge of #67888 - Zoxc:metadata-prefetch, r=matthewjasper

Prefetch some queries used by the metadata encoder

This brings the time for `metadata encoding and writing` for `syntex_syntax` from 1.338s to 0.997s with 6 threads in non-incremental debug mode.

r? @Mark-Simulacrum

4 years agoAuto merge of #70205 - Centril:rollup-0jq9k4s, r=Centril
bors [Sat, 21 Mar 2020 04:34:04 +0000 (04:34 +0000)]
Auto merge of #70205 - Centril:rollup-0jq9k4s, r=Centril

Rollup of 16 pull requests

Successful merges:

 - #65097 (Make std::sync::Arc compatible with ThreadSanitizer)
 - #69033 (Use generator resume arguments in the async/await lowering)
 - #69997 (add `Option::{zip,zip_with}` methods under "option_zip" gate)
 - #70038 (Remove the call that makes miri fail)
 - #70058 (can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.)
 - #70111 (BTreeMap: remove shared root)
 - #70139 (add delay_span_bug to TransmuteSizeDiff, just to be sure)
 - #70165 (Remove the erase regions MIR transform)
 - #70166 (Derive PartialEq, Eq and Hash for RangeInclusive)
 - #70176 (Add tests for #58319 and #65131)
 - #70177 (Fix oudated comment for NamedRegionMap)
 - #70184 (expand_include: set `.directory` to dir of included file.)
 - #70187 (more clippy fixes)
 - #70188 (Clean up E0439 explanation)
 - #70189 (Abi::is_signed: assert that we are a Scalar)
 - #70194 (#[must_use] on split_off())

Failed merges:

r? @ghost

4 years agoRollup merge of #70194 - kornelski:must_split, r=joshtriplett
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:36 +0000 (05:33 +0100)]
Rollup merge of #70194 - kornelski:must_split, r=joshtriplett

#[must_use] on split_off()

I've noticed this function used for truncation in the wild. `must_use` will clear that up.

4 years agoRollup merge of #70189 - RalfJung:is_signed, r=eddyb
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:35 +0000 (05:33 +0100)]
Rollup merge of #70189 - RalfJung:is_signed, r=eddyb

Abi::is_signed: assert that we are a Scalar

A bit more sanity checking, suggested by @eddyb. This makes this method actually "safer" than `TyS::is_signed`, so I made sure Miri consistently uses the `Abi` version.

Though I am not sure if this would have caught the mistake where the layout of a zero-sized enum was asked for its sign.

r? @eddyb

4 years agoRollup merge of #70188 - GuillaumeGomez:cleanup-e0439, r=Dylan-DPC
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:33 +0000 (05:33 +0100)]
Rollup merge of #70188 - GuillaumeGomez:cleanup-e0439, r=Dylan-DPC

Clean up E0439 explanation

r? @Dylan-DPC

4 years agoRollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-Simulacrum
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:31 +0000 (05:33 +0100)]
Rollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-Simulacrum

more clippy fixes

    * remove redundant returns (clippy::needless_return)
    * remove redundant import (clippy::single_component_path_imports)
    * remove redundant format!() call (clippy::useless_format)
    * don't use ok() before calling expect() (clippy::ok_expect)

4 years agoRollup merge of #70184 - Centril:include-mod-relativism, r=petrochenkov
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:30 +0000 (05:33 +0100)]
Rollup merge of #70184 - Centril:include-mod-relativism, r=petrochenkov

expand_include: set `.directory` to dir of included file.

Resolves the regression noted in https://github.com/rust-lang/rust/pull/69838/#discussion_r395217057.

r? @petrochenkov
cc @eddyb @Mark-Simulacrum

4 years agoRollup merge of #70177 - bjorn3:patch-2, r=Dylan-DPC
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:28 +0000 (05:33 +0100)]
Rollup merge of #70177 - bjorn3:patch-2, r=Dylan-DPC

Fix oudated comment for NamedRegionMap

`ResolveLifetimes` uses a `LocalDefId` since #66131.

4 years agoRollup merge of #70176 - rylev:ice-tests, r=Centril
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:27 +0000 (05:33 +0100)]
Rollup merge of #70176 - rylev:ice-tests, r=Centril

Add tests for #58319 and #65131

Fixes #58319 and fixes #65131

4 years agoRollup merge of #70166 - CDirkx:range-inclusive-derives, r=cramertj
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:26 +0000 (05:33 +0100)]
Rollup merge of #70166 - CDirkx:range-inclusive-derives, r=cramertj

Derive PartialEq, Eq and Hash for RangeInclusive

The manual implementation of `PartialEq`, `Eq` and `Hash` for `RangeInclusive` was functionally equivalent to a derived implementation.

This change removes the manual implementation and adds the respective derives.
A side effect of this change is that the derives also add implementations for `StructuralPartialEq` and `StructuralEq`, which enables `RangeInclusive` to be used in const generics, closing #70155.

This change is enabled by #68835, which changed the field `is_empty: Option<bool>` to `exhausted: bool` removing the need for *semantic* equality instead of *structural* equality.

## PartialEq
original [`PartialEq`](https://github.com/rust-lang/rust/blob/f4c675c476c18b1a11041193f2f59d695b126bc8/src/libcore/ops/range.rs#L353-L359) implementation:
```rust
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: PartialEq> PartialEq for RangeInclusive<Idx> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.start == other.start && self.end == other.end && self.exhausted == other.exhausted
    }
}
```
expanded derive implementation (using `cargo expand ops::range`):
```rust
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx> crate::marker::StructuralPartialEq for RangeInclusive<Idx> {}

#[automatically_derived]
#[allow(unused_qualifications)]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: crate::cmp::PartialEq> crate::cmp::PartialEq for RangeInclusive<Idx> {
    #[inline]
    fn eq(&self, other: &RangeInclusive<Idx>) -> bool {
        match *other {
            RangeInclusive { start: ref __self_1_0,end: ref __self_1_1, exhausted: ref __self_1_2 } => match *self {
                RangeInclusive { start: ref __self_0_0, end: ref __self_0_1, exhausted: ref __self_0_2 } => {
                    (*__self_0_0) == (*__self_1_0) && (*__self_0_1) == (*__self_1_1) && (*__self_0_2) == (*__self_1_2)
                }
            },
        }
    }
    #[inline]
    fn ne(&self, other: &RangeInclusive<Idx>) -> bool {
        match *other {
            RangeInclusive { start: ref __self_1_0, end: ref __self_1_1, exhausted: ref __self_1_2 } => match *self {
                RangeInclusive { start: ref __self_0_0, end: ref __self_0_1exhausted: ref __self_0_2 } => {
                    (*__self_0_0) != (*__self_1_0) || (*__self_0_1) != (*__self_1_1) || (*__self_0_2) != (*__self_1_2)
                }
            },
        }
    }
}
```

These implementations both test for *structural* equality, with the same order of field comparisons, and the bound `Idx: PartialEq` is the same.
## Eq
original [`Eq`](https://github.com/rust-lang/rust/blob/f4c675c476c18b1a11041193f2f59d695b126bc8/src/libcore/ops/range.rs#L361-L362) implementation:
```rust
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: Eq> Eq for RangeInclusive<Idx> {}
```
expanded derive implementation (using `cargo expand ops::range`):
```rust
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx> crate::marker::StructuralEq for RangeInclusive<Idx> {}

#[automatically_derived]
#[allow(unused_qualifications)]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: crate::cmp::Eq> crate::cmp::Eq for RangeInclusive<Idx> {
    #[inline]
    #[doc(hidden)]
    fn assert_receiver_is_total_eq(&self) -> () {
        {
            let _: crate::cmp::AssertParamIsEq<Idx>;
            let _: crate::cmp::AssertParamIsEq<Idx>;
            let _: crate::cmp::AssertParamIsEq<bool>;
        }
    }
}
```
These implementations are equivalent since `Eq` is just a marker trait and the bound `Idx: Eq` is the same.

## Hash
original [`Hash`](https://github.com/rust-lang/rust/blob/f4c675c476c18b1a11041193f2f59d695b126bc8/src/libcore/ops/range.rs#L364-L371) implementation:
```rust
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: Hash> Hash for RangeInclusive<Idx> {
    fn hash<H: Hasher>(&self, state: &mut H) {
        self.start.hash(state);
        self.end.hash(state);
        self.exhausted.hash(state);
    }
}
```
expanded derive implementation (using `cargo expand ops::range`):
```rust
#[automatically_derived]
#[allow(unused_qualifications)]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: crate::hash::Hash> crate::hash::Hash for RangeInclusive<Idx> {
    fn hash<__H: crate::hash::Hasher>(&self, state: &mut __H) -> () {
        match *self { RangeInclusive { start: ref __self_0_0, end: ref __self_0_1, exhausted: ref __self_0_2 } => {
                crate::hash::Hash::hash(&(*__self_0_0), state);
                crate::hash::Hash::hash(&(*__self_0_1), state);
                crate::hash::Hash::hash(&(*__self_0_2), state)
            }
        }
    }
}
```
These implementations are functionally equivalent, with the same order of field hashing, and the bound `Idx: Hash` is the same.

4 years agoRollup merge of #70165 - matthewjasper:erase-more, r=nikomatsakis
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:24 +0000 (05:33 +0100)]
Rollup merge of #70165 - matthewjasper:erase-more, r=nikomatsakis

Remove the erase regions MIR transform

We now ensure that MIR never contains unerased regions in the first place.

4 years agoRollup merge of #70139 - RalfJung:delay, r=eddyb
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:23 +0000 (05:33 +0100)]
Rollup merge of #70139 - RalfJung:delay, r=eddyb

add delay_span_bug to TransmuteSizeDiff, just to be sure

See https://github.com/rust-lang/rust/pull/69839#discussion_r394858464.

r? @eddyb

4 years agoRollup merge of #70111 - Mark-Simulacrum:btree-no-shared, r=cuviper
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:21 +0000 (05:33 +0100)]
Rollup merge of #70111 - Mark-Simulacrum:btree-no-shared, r=cuviper

BTreeMap: remove shared root

This replaces the shared root with `Option`s in the BTreeMap code, and then slightly cleans up the node manipulation code taking advantage of the removal of the shared root. I expect that further simplification is possible, but wanted to get this posted for initial review.

Note that `BTreeMap::new()` continues to not allocate.

Benchmarks seem within the margin of error/unaffected, as expected for an entirely predictable branch.

```
 name                                 alloc-bench-a ns/iter  alloc-bench-b ns/iter  diff ns/iter  diff %  speedup
 btree::map::iter_mut_20              20                     21                                1   5.00%   x 0.95
 btree::set::clone_100                1,360                  1,439                            79   5.81%   x 0.95
 btree::set::clone_100_and_into_iter  1,319                  1,434                           115   8.72%   x 0.92
 btree::set::clone_10k                143,515                150,991                       7,476   5.21%   x 0.95
 btree::set::clone_10k_and_clear      142,792                152,916                      10,124   7.09%   x 0.93
 btree::set::clone_10k_and_into_iter  146,019                154,561                       8,542   5.85%   x 0.94
```

4 years agoRollup merge of #70058 - Centril:fix-70050, r=petrochenkov
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:20 +0000 (05:33 +0100)]
Rollup merge of #70058 - Centril:fix-70050, r=petrochenkov

can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.

Make `can_begin_literal_or_bool` (renamed to `can_begin_literal_maybe_minus`) accept `NtLiteral(e) | NtExpr(e)` where `e` is either a literal or a negated literal.

Fixes https://github.com/rust-lang/rust/issues/70050.

r? @petrochenkov

4 years agoRollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:18 +0000 (05:33 +0100)]
Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung

Remove the call that makes miri fail

Fixes the concern raised in https://github.com/rust-lang/rust/pull/69645/files#r392884274

cc @RalfJung

4 years agoRollup merge of #69997 - WaffleLapkin:option_zip, r=LukasKalbertodt
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:16 +0000 (05:33 +0100)]
Rollup merge of #69997 - WaffleLapkin:option_zip, r=LukasKalbertodt

add `Option::{zip,zip_with}` methods under "option_zip" gate

This PR introduces 2 methods - `Option::zip` and `Option::zip_with` with
respective signatures:
- zip: `(Option<T>, Option<U>) -> Option<(T, U)>`
- zip_with: `(Option<T>, Option<U>, (T, U) -> R) -> Option<R>`
Both are under the feature gate "option_zip".

I'm not sure about the name "zip", maybe we can find a better name for this.
(I would prefer `union` for example, but this is a keyword :( )

--------------------------------------------------------------------------------

Recently in a russian rust begginers telegram chat a newbie asked (translated):
> Are there any methods for these conversions:
>
> 1. `(Option<A>, Option<B>) -> Option<(A, B)>`
> 2. `Vec<Option<T>> -> Option<Vec<T>>`
>
> ?

While second (2.) is clearly `vec.into_iter().collect::<Option<Vec<_>>()`, the
first one isn't that clear.

I couldn't find anything similar in the `core` and I've come to this solution:
```rust
let tuple: (Option<A>, Option<B>) = ...;
let res: Option<(A, B)> = tuple.0.and_then(|a| tuple.1.map(|b| (a, b)));
```

However this solution isn't "nice" (same for just `match`/`if let`), so I thought
that this functionality should be in `core`.

4 years agoRollup merge of #69033 - jonas-schievink:resume-with-context, r=tmandry
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:15 +0000 (05:33 +0100)]
Rollup merge of #69033 - jonas-schievink:resume-with-context, r=tmandry

Use generator resume arguments in the async/await lowering

This removes the TLS requirement from async/await and enables it in `#![no_std]` crates.

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

I'm not confident the HIR lowering is completely correct, there seem to be quite a few undocumented invariants in there. The `async-std` and tokio test suites are passing with these changes though.

4 years agoRollup merge of #65097 - tmiasko:arc, r=Amanieu
Mazdak Farrokhzad [Sat, 21 Mar 2020 04:33:13 +0000 (05:33 +0100)]
Rollup merge of #65097 - tmiasko:arc, r=Amanieu

Make std::sync::Arc compatible with ThreadSanitizer

The memory fences used previously in Arc implementation are not properly
understood by thread sanitizer as synchronization primitives. This had
unfortunate effect where running any non-trivial program compiled with
`-Z sanitizer=thread` would result in numerous false positives.

Replace acquire fences with acquire loads to address the issue.

Fixes #39608.

4 years agomore type annotations to help inference
Ralf Jung [Fri, 20 Mar 2020 22:28:01 +0000 (23:28 +0100)]
more type annotations to help inference

4 years agofmt
Ralf Jung [Fri, 20 Mar 2020 22:22:36 +0000 (23:22 +0100)]
fmt

4 years agoremove redundant returns (clippy::needless_return)
Matthias Krüger [Fri, 20 Mar 2020 14:03:11 +0000 (15:03 +0100)]
remove redundant returns (clippy::needless_return)

4 years agoremove redundant import (clippy::single_component_path_imports)
Matthias Krüger [Thu, 19 Mar 2020 21:09:26 +0000 (22:09 +0100)]
remove redundant import (clippy::single_component_path_imports)
remove redundant format!() call (clippy::useless_format)
don't use ok() before calling expect() (clippy::ok_expect)

4 years agoAuto merge of #69509 - RalfJung:debug-assert-write, r=eddyb
bors [Fri, 20 Mar 2020 19:02:32 +0000 (19:02 +0000)]
Auto merge of #69509 - RalfJung:debug-assert-write, r=eddyb

debug-assert ptr sanity in ptr::write

This is a re-submission of the parts that we removed from https://github.com/rust-lang/rust/pull/69208 due to ["interesting" test failures](https://github.com/rust-lang/rust/pull/69208#issuecomment-591310437).

Fixes https://github.com/rust-lang/rust/issues/53871
r? @Mark-Simulacrum @eddyb

4 years agomake rustc_layout also work for type definitions
Ralf Jung [Fri, 20 Mar 2020 16:48:03 +0000 (17:48 +0100)]
make rustc_layout also work for type definitions

4 years agoexpand_include: set `.directory` to dir of included file.
Mazdak Farrokhzad [Fri, 20 Mar 2020 15:02:46 +0000 (16:02 +0100)]
expand_include: set `.directory` to dir of included file.

4 years agoadd a test for rustc_layout(debug)
Ralf Jung [Tue, 10 Mar 2020 21:31:27 +0000 (22:31 +0100)]
add a test for rustc_layout(debug)

4 years agoadd debug option to #[rustc_layout]
Ralf Jung [Tue, 10 Mar 2020 21:25:53 +0000 (22:25 +0100)]
add debug option to #[rustc_layout]

4 years agofix layout_test visitor name
Ralf Jung [Tue, 10 Mar 2020 20:53:22 +0000 (21:53 +0100)]
fix layout_test visitor name

4 years agoAbi::is_signed: assert that we are a Scalar
Ralf Jung [Fri, 20 Mar 2020 16:05:00 +0000 (17:05 +0100)]
Abi::is_signed: assert that we are a Scalar

4 years agoClean up E0439 explanation
Guillaume Gomez [Fri, 20 Mar 2020 16:03:04 +0000 (17:03 +0100)]
Clean up E0439 explanation

4 years agoFix debugger pretty printing of BTrees
Mark Rousskov [Wed, 18 Mar 2020 19:29:05 +0000 (15:29 -0400)]
Fix debugger pretty printing of BTrees

4 years agoAuto merge of #70174 - JohnTitor:rollup-0lum0jh, r=JohnTitor
bors [Fri, 20 Mar 2020 15:58:34 +0000 (15:58 +0000)]
Auto merge of #70174 - JohnTitor:rollup-0lum0jh, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #69618 (Clarify the relationship between `forget()` and `ManuallyDrop`.)
 - #69768 (Compute the correct layout for variants of uninhabited enums)
 - #69935 (codegen/mir: support polymorphic `InstanceDef`s)
 - #70103 (Clean up E0437 explanation)
 - #70131 (Add regression test for TAIT lifetime inference (issue #55099))
 - #70133 (remove unused imports)
 - #70145 (doc: Add quote to .init_array)
 - #70146 (Clean up e0438 explanation)
 - #70150 (triagebot.toml: accept cleanup-crew)

Failed merges:

r? @ghost

4 years agocan_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.
Mazdak Farrokhzad [Mon, 16 Mar 2020 22:36:14 +0000 (23:36 +0100)]
can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.

4 years agomust_use on split_off
Kornel [Fri, 20 Mar 2020 14:40:35 +0000 (14:40 +0000)]
must_use on split_off

4 years agoFix abort-on-eprintln during process shutdown
Alex Crichton [Thu, 12 Mar 2020 18:39:30 +0000 (11:39 -0700)]
Fix abort-on-eprintln during process shutdown

This commit fixes an issue where if `eprintln!` is used in a TLS
destructor it can accidentally cause the process to abort. TLS
destructors are executed after `main` returns on the main thread, and at
this point we've also deinitialized global `Lazy` values like those
which store the `Stderr` and `Stdout` internals. This means that despite
handling TLS not being accessible in `eprintln!`, we will fail due to
not being able to call `stderr()`. This means that we'll double-panic
quickly because panicking also attempt to write to stderr.

The fix here is to reimplement the global stderr handle to avoid the
need for destruction. This avoids the need for `Lazy` as well as the
hidden panic inside of the `stderr` function.

Overall this should improve the robustness of printing errors and/or
panics in weird situations, since the `stderr` accessor should be
infallible in more situations.

4 years agoUpdate test commentary for shared root removal
Mark Rousskov [Fri, 20 Mar 2020 13:40:57 +0000 (09:40 -0400)]
Update test commentary for shared root removal

4 years agoSimplify ensure_root_is_owned callers
Mark Rousskov [Wed, 18 Mar 2020 23:00:15 +0000 (19:00 -0400)]
Simplify ensure_root_is_owned callers

This makes ensure_root_is_owned return a reference to the (now guaranteed to
exist) root, allowing callers to operate on it without going through another
unwrap.

Unfortunately this is only rarely useful as it's frequently the case that both
the length and the root need to be accessed and field-level borrows in methods
don't yet exist.

4 years agoDrop NodeHeader type from BTree code
Mark Rousskov [Wed, 18 Mar 2020 15:10:21 +0000 (11:10 -0400)]
Drop NodeHeader type from BTree code

We no longer have a separate header because the shared root is gone; all code
can work solely with leafs now.

4 years agoMake functions dependent only on shared root avoidance safe
Mark Rousskov [Wed, 18 Mar 2020 14:45:35 +0000 (10:45 -0400)]
Make functions dependent only on shared root avoidance safe

4 years agoRemove shared root code and assertions from BTree nodes
Mark Rousskov [Wed, 18 Mar 2020 14:28:33 +0000 (10:28 -0400)]
Remove shared root code and assertions from BTree nodes

4 years agoReplace shared root with optional root
Mark Rousskov [Wed, 18 Mar 2020 14:25:46 +0000 (10:25 -0400)]
Replace shared root with optional root

This simplifies the node manipulation, as we can (in later commits) always know
when traversing nodes that we are not in a shared root.

4 years agoAdd tests for #58319 and #65131
Ryan Levick [Fri, 20 Mar 2020 12:24:35 +0000 (13:24 +0100)]
Add tests for #58319 and #65131

4 years agoFix oudated comment for NamedRegionMap
bjorn3 [Fri, 20 Mar 2020 12:23:24 +0000 (13:23 +0100)]
Fix oudated comment for NamedRegionMap

4 years agoUpdate const_forget.rs
DutchGhost [Fri, 20 Mar 2020 09:36:40 +0000 (10:36 +0100)]
Update const_forget.rs

4 years agoRollup merge of #70150 - rust-lang:accept-felixes-typo, r=Mark-Simulacrum
Yuki Okushi [Fri, 20 Mar 2020 08:02:14 +0000 (17:02 +0900)]
Rollup merge of #70150 - rust-lang:accept-felixes-typo, r=Mark-Simulacrum

triagebot.toml: accept cleanup-crew

r? @Mark-Simulacrum

4 years agoRollup merge of #70146 - GuillaumeGomez:cleanup-e0438, r=Dylan-DPC
Yuki Okushi [Fri, 20 Mar 2020 08:02:12 +0000 (17:02 +0900)]
Rollup merge of #70146 - GuillaumeGomez:cleanup-e0438, r=Dylan-DPC

Clean up e0438 explanation

r? @Dylan-DPC

4 years agoRollup merge of #70145 - lzutao:patch-1, r=Dylan-DPC
Yuki Okushi [Fri, 20 Mar 2020 08:02:11 +0000 (17:02 +0900)]
Rollup merge of #70145 - lzutao:patch-1, r=Dylan-DPC

doc: Add quote to .init_array

The current formatting is not good without quotes:
![without-quote](https://i.imgur.com/RkIm4cr.png)

4 years agoRollup merge of #70133 - hermitcore:libpanic_unwind, r=nikomatsakis
Yuki Okushi [Fri, 20 Mar 2020 08:02:09 +0000 (17:02 +0900)]
Rollup merge of #70133 - hermitcore:libpanic_unwind, r=nikomatsakis

remove unused imports

patch is required to avoid compiler errors by building src/libpanic_unwind/hermit.rs

4 years agoRollup merge of #70131 - Aaron1011:fix/issue-55099-test, r=nikomatsakis
Yuki Okushi [Fri, 20 Mar 2020 08:02:08 +0000 (17:02 +0900)]
Rollup merge of #70131 - Aaron1011:fix/issue-55099-test, r=nikomatsakis

Add regression test for TAIT lifetime inference (issue #55099)

Fixes #55099

The minimized reproducer in issue #55099 now compiles successfully.
This commit adds a regression test for it.

4 years agoRollup merge of #70103 - GuillaumeGomez:cleanup-e0437, r=Dylan-DPC
Yuki Okushi [Fri, 20 Mar 2020 08:02:06 +0000 (17:02 +0900)]
Rollup merge of #70103 - GuillaumeGomez:cleanup-e0437, r=Dylan-DPC

Clean up E0437 explanation

r? @Dylan-DPC

4 years agoRollup merge of #69935 - davidtwco:issue-69925, r=eddyb
Yuki Okushi [Fri, 20 Mar 2020 08:02:05 +0000 (17:02 +0900)]
Rollup merge of #69935 - davidtwco:issue-69925, r=eddyb

codegen/mir: support polymorphic `InstanceDef`s

cc #69925

This PR modifies the use of `subst_and_normalize_erasing_regions` on parts of the MIR bodies returned from `instance_mir`, so that `InstanceDef::CloneShim` and `InstanceDef::DropGlue` (where there is a type) do not perform substitutions. This avoids double substitutions and enables polymorphic `InstanceDef`s.

r? @eddyb
cc @nikomatsakis

4 years agoRollup merge of #69768 - oli-obk:union_field_ice, r=eddyb,RalfJung
Yuki Okushi [Fri, 20 Mar 2020 08:02:03 +0000 (17:02 +0900)]
Rollup merge of #69768 - oli-obk:union_field_ice, r=eddyb,RalfJung

Compute the correct layout for variants of uninhabited enums

r? @eddyb
cc @RalfJung

fixes #69191
cc #69763

4 years agoRollup merge of #69618 - hniksic:mem-forget-doc-fix, r=RalfJung
Yuki Okushi [Fri, 20 Mar 2020 08:02:01 +0000 (17:02 +0900)]
Rollup merge of #69618 - hniksic:mem-forget-doc-fix, r=RalfJung

Clarify the relationship between `forget()` and `ManuallyDrop`.

As discussed on reddit, this commit addresses two issues with the
documentation of `mem::forget()`:

* The documentation of `mem::forget()` can confuse the reader because of the
  discrepancy between usage examples that show correct usage and the
  accompanying text which speaks of the possibility of double-free.  The
  text that says "if the panic occurs before `mem::forget` was called"
  refers to a variant of the second example that was never shown, modified
  to use `mem::forget` instead of `ManuallyDrop`.  Ideally the documentation
  should show both variants, so it's clear what it's talking about.

  Also, the double free could be fixed just by placing `mem::forget(v)`
  before the construction of `s`.  Since the lifetimes of `s` and `v`
  wouldn't overlap, there would be no point where panic could cause a double
  free.  This could be mentioned, and contrasted against the more robust fix
  of using `ManuallyDrop`.

* This sentence seems unjustified: "For some types, operations such as
  passing ownership (to a funcion like `mem::forget`) requires them to
  actually be fully owned right now [...]".  Unlike C++, Rust has no move
  constructors, its moves are (possibly elided) bitwise copies.  Even if you
  pass an invalid object to `mem::forget`, no harm should come to pass
  because `mem::forget` consumes the object and exists solely to prevent
  drop, so there no one left to observe the invalid state state.

4 years agoRefactorings to begin getting rid of rustc_codegen_utils
Mark Mansi [Thu, 12 Mar 2020 23:07:58 +0000 (18:07 -0500)]
Refactorings to begin getting rid of rustc_codegen_utils

4 years agofix FIXME comment
Bastian Kauschke [Thu, 19 Mar 2020 23:28:49 +0000 (00:28 +0100)]
fix FIXME comment

Co-Authored-By: varkor <github@varkor.com>
4 years agoMake std::sync::Arc compatible with ThreadSanitizer
Tomasz Miąsko [Fri, 20 Mar 2020 00:00:00 +0000 (00:00 +0000)]
Make std::sync::Arc compatible with ThreadSanitizer

The memory fences used previously in Arc implementation are not properly
understood by ThreadSanitizer as synchronization primitives. This had
unfortunate effect where running any non-trivial program compiled with
`-Z sanitizer=thread` would result in numerous false positives.

Replace acquire fences with acquire loads when using ThreadSanitizer to
address the issue.

4 years agoRemoved unused `Hasher` import.
CDirkx [Thu, 19 Mar 2020 20:58:11 +0000 (21:58 +0100)]
Removed unused `Hasher` import.

4 years agoUse erased regions in MIR
Matthew Jasper [Thu, 19 Mar 2020 11:40:38 +0000 (11:40 +0000)]
Use erased regions in MIR

4 years agoDerive PartialEq, Eq and Hash for RangeInclusive
CDirkx [Thu, 19 Mar 2020 19:45:47 +0000 (20:45 +0100)]
Derive PartialEq, Eq and Hash for RangeInclusive

The manual implementation of PartialEq, Eq and Hash for RangeInclusive was functionally equivalent to a derived implementation.

This change removes the manual implementation and adds the respective derives.
A side effect of this change is that the derives also add implementations for StructuralPartialEq and StructuralEq, which enables RangeInclusive to be used in const generics.

4 years agosort generic param order in generics_of
Bastian Kauschke [Thu, 19 Mar 2020 19:20:09 +0000 (20:20 +0100)]
sort generic param order in generics_of

4 years agomake "other" in docs of `Option::{zip,zip_with}` monofont
Waffle [Thu, 19 Mar 2020 19:19:37 +0000 (22:19 +0300)]
make "other" in docs of `Option::{zip,zip_with}` monofont

4 years agorustc/query: tweak comments on hir_owner{,_nodes}.
Eduard-Mihai Burtescu [Wed, 18 Mar 2020 20:46:57 +0000 (22:46 +0200)]
rustc/query: tweak comments on hir_owner{,_nodes}.

4 years agoAuto merge of #69402 - GuillaumeGomez:extend-search, r=kinnison
bors [Thu, 19 Mar 2020 16:07:59 +0000 (16:07 +0000)]
Auto merge of #69402 - GuillaumeGomez:extend-search, r=kinnison

Extend search

I realized that when looking for "struct:String" in the rustdoc search for example, the "in arguments" and "returned" tabs were always empty. After some investigation, I realized it was because we only provided the name, and not the type, making it impossible to pass the "type filtering" check.

To resolve this, I added the type alongside the name. Note for the future: we could improve this by instead only registering the path id and use the path dictionary directly. The only problem with that solution (which I already tested) is that it becomes complicated for types in other crates. It'd force us to handle both case with an id and a case with `(name, type)`. I found the current PR big enough to not want to provide it directly. However, I think this is definitely worth it to make it work this way in the future.

About the two tests I added: they don't have much interest except checking that we actually have something returned in the search in the cases of a type filtering with and without literal search.

I also had to update a bit the test script to add the new locally global (haha) variable I created (`NO_TYPE_FILTER`). I added this variable to make the code easier to read than just "-1".

r? @kinnison

cc @ollie27

4 years agotriagebot.toml: accept typo due to pnkfelix
Mazdak Farrokhzad [Thu, 19 Mar 2020 14:38:31 +0000 (15:38 +0100)]
triagebot.toml: accept typo due to pnkfelix

4 years agoUpdate stdarch submodule
Amanieu d'Antras [Thu, 19 Mar 2020 14:38:09 +0000 (14:38 +0000)]
Update stdarch submodule

4 years agoUse `assert_ignored` when encoding metadata
John Kåre Alsaker [Sat, 14 Mar 2020 12:41:38 +0000 (13:41 +0100)]
Use `assert_ignored` when encoding metadata

4 years agoAdd some comments
John Kåre Alsaker [Sat, 14 Mar 2020 12:39:33 +0000 (13:39 +0100)]
Add some comments

4 years agoMake metadata prefetching more accurate
John Kåre Alsaker [Mon, 13 Jan 2020 15:23:42 +0000 (16:23 +0100)]
Make metadata prefetching more accurate

4 years agoMake the timer more verbose
John Kåre Alsaker [Sat, 11 Jan 2020 03:47:20 +0000 (04:47 +0100)]
Make the timer more verbose

4 years agoPrefetch exported symbols
John Kåre Alsaker [Sat, 11 Jan 2020 03:02:22 +0000 (04:02 +0100)]
Prefetch exported symbols

4 years agoEncode exported symbols last
John Kåre Alsaker [Sat, 11 Jan 2020 02:42:40 +0000 (03:42 +0100)]
Encode exported symbols last

4 years agoPrefetch queries used by the metadata encoder
John Kåre Alsaker [Sat, 4 Jan 2020 20:42:28 +0000 (21:42 +0100)]
Prefetch queries used by the metadata encoder

4 years agoUpdate test
John Kåre Alsaker [Sat, 29 Feb 2020 03:23:58 +0000 (04:23 +0100)]
Update test

4 years agoDon't unwind when hitting the macro expansion recursion limit
John Kåre Alsaker [Wed, 26 Feb 2020 22:43:49 +0000 (23:43 +0100)]
Don't unwind when hitting the macro expansion recursion limit

4 years agoDon't hard-code the vector length in the examples.
Hrvoje Nikšić [Thu, 19 Mar 2020 12:56:48 +0000 (13:56 +0100)]
Don't hard-code the vector length in the examples.

Co-Authored-By: lzutao <taolzu@gmail.com>
4 years agoMinor re-wordings and typo fixes.
Hrvoje Nikšić [Wed, 18 Mar 2020 10:30:39 +0000 (11:30 +0100)]
Minor re-wordings and typo fixes.

Co-Authored-By: Ralf Jung <post@ralfj.de>
4 years agoRestore (and reword) the warning against passing invalid values to mem::forget.
Hrvoje Niksic [Wed, 4 Mar 2020 21:12:53 +0000 (22:12 +0100)]
Restore (and reword) the warning against passing invalid values to mem::forget.

As pointed out by Ralf Jung, dangling references and boxes are
undefined behavior as per
https://doc.rust-lang.org/reference/behavior-considered-undefined.html
and the Miri checker.

4 years agoClarify the relationship between `forget()` and `ManuallyDrop`.
Hrvoje Niksic [Sun, 1 Mar 2020 20:31:08 +0000 (21:31 +0100)]
Clarify the relationship between `forget()` and `ManuallyDrop`.

As discussed on reddit, this commit addresses two issues with the
documentation of `mem::forget()`:

* The documentation of `mem::forget()` can confuse the reader because of the
  discrepancy between usage examples that show correct usage and the
  accompanying text which speaks of the possibility of double-free.  The
  text that says "if the panic occurs before `mem::forget` was called"
  refers to a variant of the second example that was never shown, modified
  to use `mem::forget` instead of `ManuallyDrop`.  Ideally the documentation
  should show both variants, so it's clear what it's talking about.

  Also, the double free could be fixed just by placing `mem::forget(v)`
  before the construction of `s`.  Since the lifetimes of `s` and `v`
  wouldn't overlap, there would be no point where panic could cause a double
  free.  This could be mentioned, and contrasted against the more robust fix
  of using `ManuallyDrop`.

* This sentence seems unjustified: "For some types, operations such as
  passing ownership (to a funcion like `mem::forget`) requires them to
  actually be fully owned right now [...]".  Unlike C++, Rust has no move
  constructors, its moves are (possibly elided) bitwise copies.  Even if you
  pass an invalid object to `mem::forget`, no harm should come to pass
  because `mem::forget` consumes the object and exists solely to prevent
  drop, so there no one left to observe the invalid state state.

4 years agoClean up e0438 explanation
Guillaume Gomez [Thu, 19 Mar 2020 13:11:27 +0000 (14:11 +0100)]
Clean up e0438 explanation

4 years agoClean up E0437 explanation
Guillaume Gomez [Wed, 18 Mar 2020 13:13:48 +0000 (14:13 +0100)]
Clean up E0437 explanation