]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #71854 - eduardosm:assoc-char-funcs-and-consts, r=Amanieu
Ralf Jung [Thu, 21 May 2020 11:12:13 +0000 (13:12 +0200)]
Rollup merge of #71854 - eduardosm:assoc-char-funcs-and-consts, r=Amanieu

Make `std::char` functions and constants associated to `char`.

First step to fix https://github.com/rust-lang/rust/issues/71763.

4 years agoAuto merge of #72205 - ecstatic-morse:nrvo, r=oli-obk
bors [Thu, 21 May 2020 07:16:44 +0000 (07:16 +0000)]
Auto merge of #72205 - ecstatic-morse:nrvo, r=oli-obk

Dumb NRVO

This is a very simple version of an NRVO pass, which scans backwards from the `return` terminator to see if there is an an assignment like `_0 = _1`. If a basic block with two or more predecessors is encountered during this scan without first seeing an assignment to the return place, we bail out. This avoids running a full "reaching definitions" dataflow analysis.

I wanted to see how much `rustc` would benefit from even a very limited version of this optimization. We should be able to use this as a point of comparison for more advanced versions that are based on live ranges.

r? @ghost

4 years agoBail out if new return place has different type than old
Dylan MacKenzie [Thu, 21 May 2020 05:44:57 +0000 (22:44 -0700)]
Bail out if new return place has different type than old

4 years agoAuto merge of #70705 - lcnr:generic_discriminant, r=nikomatsakis
bors [Thu, 21 May 2020 03:48:47 +0000 (03:48 +0000)]
Auto merge of #70705 - lcnr:generic_discriminant, r=nikomatsakis

Use `T`'s discriminant type in `mem::Discriminant<T>` instead of `u64`.

fixes #70509

Adds the lang-item `discriminant_kind`.
Updates the function signature of `intrinsics::discriminant_value`.
Adds the *probably permanently unstable* trait `DiscriminantKind`.
`mem::Discriminant` should now be smaller in some cases.

r? @ghost

4 years agoAuto merge of #67759 - nikic:llvm-10, r=Mark-Simulacrum
bors [Wed, 20 May 2020 22:49:57 +0000 (22:49 +0000)]
Auto merge of #67759 - nikic:llvm-10, r=Mark-Simulacrum

Update to LLVM 10

LLVM 10 is going to be branched soon, so it's a good time to start finding all those tasty new miscompiles and performance regressions ;)

Status:

 * Preparation split off into #67900.
 * Optimization regressions:
   * [x] https://bugs.llvm.org/show_bug.cgi?id=44419 => https://reviews.llvm.org/D72048 has landed.
   * [x] https://bugs.llvm.org/show_bug.cgi?id=44423 => https://reviews.llvm.org/D72060 has landed.
   * [x] https://reviews.llvm.org/D72169 submitted.
   * [ ] https://bugs.llvm.org/show_bug.cgi?id=44461 reported. https://reviews.llvm.org/D72420 submitted, but unlikely eligible for LLVM 10.
 * Compile-time regressions:
   * [x] GlobalOpt regression identified. ~~fhahn proposed https://reviews.llvm.org/D72214.~~ fhahn has [reverted](https://github.com/llvm/llvm-project/commit/192cce10f67e4f22be6d9b8c0975f78ad246d1bd) the patch.
   * [ ] Even with the revert, there are [large regressions](https://perf.rust-lang.org/compare.html?start=760ce94c69ca510d44087291c311296f6d9ccdf5&end=4e84f97d76e694bb9f59039f5bdeb6d8bca46d14).
 * Assertion failures / infinite loops:
   * [x] https://bugs.llvm.org/show_bug.cgi?id=44600 => https://reviews.llvm.org/D73135, https://reviews.llvm.org/D73854 and https://reviews.llvm.org/D73908 have landed and been cherry-picked to the 10.x branch.
   * [x] https://bugs.llvm.org/show_bug.cgi?id=44835 => https://reviews.llvm.org/D74278 has landed and been cherry-picked.

4 years agoAuto merge of #72378 - Dylan-DPC:rollup-m87bp2d, r=Dylan-DPC
bors [Wed, 20 May 2020 19:29:01 +0000 (19:29 +0000)]
Auto merge of #72378 - Dylan-DPC:rollup-m87bp2d, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #71863 (Suggest fixes and add error recovery for `use foo::self`)
 - #72139 (Make `fold` standalone.)
 - #72275 (Continue lowering for unsupported async generator instead of returning an error.)
 - #72361 (split_inclusive: add tracking issue number (72360))
 - #72364 (Remove unused dependencies)
 - #72366 (Adjust the zero check in `RawVec::grow`.)

Failed merges:

r? @ghost

4 years agoSet CMAKE_CXX_STANDARD when compiling LLD
Nikita Popov [Tue, 19 May 2020 16:05:56 +0000 (18:05 +0200)]
Set CMAKE_CXX_STANDARD when compiling LLD

4 years agoUpdate LLVM submodule
Nikita Popov [Tue, 31 Dec 2019 14:46:46 +0000 (15:46 +0100)]
Update LLVM submodule

4 years agoAuto merge of #72384 - mati865:ci-fix, r=pietroalbini
bors [Wed, 20 May 2020 15:55:59 +0000 (15:55 +0000)]
Auto merge of #72384 - mati865:ci-fix, r=pietroalbini

Workaround MSYS2/chocolatey issue again

4 years agoWorkaround MSYS2/chocolatey issue again
Mateusz Mikuła [Wed, 20 May 2020 14:56:05 +0000 (16:56 +0200)]
Workaround MSYS2/chocolatey issue again

4 years agoRollup merge of #72366 - nnethercote:tiny-vecs-are-dumb-followup, r=Amanieu
Dylan DPC [Wed, 20 May 2020 12:21:13 +0000 (14:21 +0200)]
Rollup merge of #72366 - nnethercote:tiny-vecs-are-dumb-followup, r=Amanieu

Adjust the zero check in `RawVec::grow`.

This was supposed to land as part of #72227. (I wish `git push` would
abort when you have uncommited changes.)

r? @Amanieu

4 years agoRollup merge of #72364 - jsgf:remove-unused-deps, r=Mark-Simulacrum
Dylan DPC [Wed, 20 May 2020 12:21:11 +0000 (14:21 +0200)]
Rollup merge of #72364 - jsgf:remove-unused-deps, r=Mark-Simulacrum

Remove unused dependencies

Remove some unused dependencies found while while working on https://github.com/rust-lang/rust/pull/72342.

4 years agoRollup merge of #72361 - golddranks:split_inclusive_add_tracking_issue, r=shepmaster
Dylan DPC [Wed, 20 May 2020 12:21:09 +0000 (14:21 +0200)]
Rollup merge of #72361 - golddranks:split_inclusive_add_tracking_issue, r=shepmaster

split_inclusive: add tracking issue number (72360)

Adds tracking issue number ( https://github.com/rust-lang/rust/issues/72360 ) to the unstable feature attributes.

4 years agoRollup merge of #72275 - marmeladema:fix-issue-71104-2, r=ecstatic-morse
Dylan DPC [Wed, 20 May 2020 12:21:07 +0000 (14:21 +0200)]
Rollup merge of #72275 - marmeladema:fix-issue-71104-2, r=ecstatic-morse

Continue lowering for unsupported async generator instead of returning an error.

This way the hir is "valid" and we can remove one more call to
`opt_node_id_to_hir_id` but an error is still emitted.

This is another partial fix for #71104

r? @eddyb

4 years agoRollup merge of #72139 - nnethercote:standalone-fold, r=cuviper
Dylan DPC [Wed, 20 May 2020 12:21:06 +0000 (14:21 +0200)]
Rollup merge of #72139 - nnethercote:standalone-fold, r=cuviper

Make `fold` standalone.

`fold` is currently implemented via `try_fold`, but implementing it
directly results in slightly less LLVM IR being generated, speeding up
compilation of some benchmarks.

r? @cuviper

4 years agoRollup merge of #71863 - mibac138:self-import, r=estebank
Dylan DPC [Wed, 20 May 2020 12:21:00 +0000 (14:21 +0200)]
Rollup merge of #71863 - mibac138:self-import, r=estebank

Suggest fixes and add error recovery for `use foo::self`

Fixes #63741.
I have implemented 2 suggestions on how to fix a `use foo::self` import, however I feel like showing them both might be too verbose.

Additionally, I have also implemented error recovery as [menitoned](https://github.com/rust-lang/rust/issues/63741#issuecomment-602391091) by @comex.

I believe r? @estebank deals with diagnostics.

4 years agoAuto merge of #71923 - csmoe:issue-70818, r=tmandry
bors [Wed, 20 May 2020 09:28:25 +0000 (09:28 +0000)]
Auto merge of #71923 - csmoe:issue-70818, r=tmandry

Check non-Send/Sync upvars captured by generator

Closes #70818
r? @tmandry

4 years agoAuto merge of #71769 - petrochenkov:crto, r=cuviper
bors [Wed, 20 May 2020 05:47:10 +0000 (05:47 +0000)]
Auto merge of #71769 - petrochenkov:crto, r=cuviper

linker: More systematic handling of CRT objects

Document which kinds of `crt0.o`-like objects we link and in which cases, discovering bugs in process.
`src/librustc_target/spec/crt_objects.rs` is the place to start reading from.

This PR also automatically contains half of the `-static-pie` support (https://github.com/rust-lang/rust/pull/70740), because that's one of the six cases that we need to consider when linking CRT objects.

This is a breaking change for custom target specifications that specify CRT objects.

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

4 years agoAuto merge of #72339 - ehuss:update-cargo, r=ehuss
bors [Wed, 20 May 2020 02:22:44 +0000 (02:22 +0000)]
Auto merge of #72339 - ehuss:update-cargo, r=ehuss

Update cargo

9 commits in cb06cb2696df2567ce06d1a39b1b40612a29f853..500b2bd01c958f5a33b6aa3f080bea015877b83c
2020-05-08 21:57:44 +0000 to 2020-05-18 17:12:54 +0000
- Handle LTO with an rlib/cdylib crate type (rust-lang/cargo#8254)
- Gracefully handle errors during a build. (rust-lang/cargo#8247)
- Update `im-rc` to 15.0.0 (rust-lang/cargo#8255)
- Fix `cargo update` with unused patch. (rust-lang/cargo#8243)
- Rephrased error message for disallowed sections in virtual workspace (rust-lang/cargo#8200)
- Ignore broken console output in some situations. (rust-lang/cargo#8236)
- Expand error message to explain that a string was found (rust-lang/cargo#8235)
- Add context to some fs errors. (rust-lang/cargo#8232)
- Move SipHasher to an isolated module. (rust-lang/cargo#8233)

4 years agoAdjust the zero check in `RawVec::grow`.
Nicholas Nethercote [Tue, 19 May 2020 23:47:21 +0000 (09:47 +1000)]
Adjust the zero check in `RawVec::grow`.

This was supposed to land as part of #72227. (I wish `git push` would
abort when you have uncommited changes.)

4 years agoRemove unused dependencies
Jeremy Fitzhardinge [Sun, 17 May 2020 23:03:43 +0000 (16:03 -0700)]
Remove unused dependencies

4 years agoAlter wording for `use foo::self` help
mibac138 [Tue, 19 May 2020 20:12:41 +0000 (22:12 +0200)]
Alter wording for `use foo::self` help

4 years agosplit_inclusive: add tracking issue number (72360)
Pyry Kontio [Tue, 19 May 2020 19:22:37 +0000 (04:22 +0900)]
split_inclusive: add tracking issue number (72360)

4 years agoAdd error recovery for `use foo::self`
mibac138 [Sun, 3 May 2020 16:56:52 +0000 (18:56 +0200)]
Add error recovery for `use foo::self`

4 years agoSuggest fixes for `use foo::self`
mibac138 [Sun, 3 May 2020 16:54:21 +0000 (18:54 +0200)]
Suggest fixes for `use foo::self`

4 years agoAuto merge of #69171 - Amanieu:new-asm, r=nagisa,nikomatsakis
bors [Tue, 19 May 2020 18:32:40 +0000 (18:32 +0000)]
Auto merge of #69171 - Amanieu:new-asm, r=nagisa,nikomatsakis

Implement new asm! syntax from RFC 2850

This PR implements the new `asm!` syntax proposed in https://github.com/rust-lang/rfcs/pull/2850.

# Design

A large part of this PR revolves around taking an `asm!` macro invocation and plumbing it through all of the compiler layers down to LLVM codegen. Throughout the various stages, an `InlineAsm` generally consists of 3 components:

- The template string, which is stored as an array of `InlineAsmTemplatePiece`. Each piece represents either a literal or a placeholder for an operand (just like format strings).
```rust
pub enum InlineAsmTemplatePiece {
    String(String),
    Placeholder { operand_idx: usize, modifier: Option<char>, span: Span },
}
```

- The list of operands to the `asm!` (`in`, `[late]out`, `in[late]out`, `sym`, `const`). These are represented differently at each stage of lowering, but follow a common pattern:
  - `in`, `out` and `inout` all have an associated register class (`reg`) or explicit register (`"eax"`).
  - `inout` has 2 forms: one with a single expression that is both read from and written to, and one with two separate expressions for the input and output parts.
  - `out` and `inout` have a `late` flag (`lateout` / `inlateout`) to indicate that the register allocator is allowed to reuse an input register for this output.
  - `out` and the split variant of `inout` allow `_` to be specified for an output, which means that the output is discarded. This is used to allocate scratch registers for assembly code.
  - `sym` is a bit special since it only accepts a path expression, which must point to a `static` or a `fn`.

- The options set at the end of the `asm!` macro. The only one that is particularly of interest to rustc is `NORETURN` which makes `asm!` return `!` instead of `()`.
```rust
bitflags::bitflags! {
    pub struct InlineAsmOptions: u8 {
        const PURE = 1 << 0;
        const NOMEM = 1 << 1;
        const READONLY = 1 << 2;
        const PRESERVES_FLAGS = 1 << 3;
        const NORETURN = 1 << 4;
        const NOSTACK = 1 << 5;
    }
}
```

## AST

`InlineAsm` is represented as an expression in the AST:

```rust
pub struct InlineAsm {
    pub template: Vec<InlineAsmTemplatePiece>,
    pub operands: Vec<(InlineAsmOperand, Span)>,
    pub options: InlineAsmOptions,
}

pub enum InlineAsmRegOrRegClass {
    Reg(Symbol),
    RegClass(Symbol),
}

pub enum InlineAsmOperand {
    In {
        reg: InlineAsmRegOrRegClass,
        expr: P<Expr>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: Option<P<Expr>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: P<Expr>,
    },
    SplitInOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_expr: P<Expr>,
        out_expr: Option<P<Expr>>,
    },
    Const {
        expr: P<Expr>,
    },
    Sym {
        expr: P<Expr>,
    },
}
```

The `asm!` macro is implemented in librustc_builtin_macros and outputs an `InlineAsm` AST node. The template string is parsed using libfmt_macros, positional and named operands are resolved to explicit operand indicies. Since target information is not available to macro invocations, validation of the registers and register classes is deferred to AST lowering.

## HIR

`InlineAsm` is represented as an expression in the HIR:

```rust
pub struct InlineAsm<'hir> {
    pub template: &'hir [InlineAsmTemplatePiece],
    pub operands: &'hir [InlineAsmOperand<'hir>],
    pub options: InlineAsmOptions,
}

pub enum InlineAsmRegOrRegClass {
    Reg(InlineAsmReg),
    RegClass(InlineAsmRegClass),
}

pub enum InlineAsmOperand<'hir> {
    In {
        reg: InlineAsmRegOrRegClass,
        expr: Expr<'hir>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: Option<Expr<'hir>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: Expr<'hir>,
    },
    SplitInOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_expr: Expr<'hir>,
        out_expr: Option<Expr<'hir>>,
    },
    Const {
        expr: Expr<'hir>,
    },
    Sym {
        expr: Expr<'hir>,
    },
}
```

AST lowering is where `InlineAsmRegOrRegClass` is converted from `Symbol`s to an actual register or register class. If any modifiers are specified for a template string placeholder, these are validated against the set allowed for that operand type. Finally, explicit registers for inputs and outputs are checked for conflicts (same register used for different operands).

## Type checking

Each register class has a whitelist of types that it may be used with. After the types of all operands have been determined, the `intrinsicck` pass will check that these types are in the whitelist. It also checks that split `inout` operands have compatible types and that `const` operands are integers or floats. Suggestions are emitted where needed if a template modifier should be used for an operand based on the type that was passed into it.

## HAIR

`InlineAsm` is represented as an expression in the HAIR:

```rust
crate enum ExprKind<'tcx> {
    // [..]
    InlineAsm {
        template: &'tcx [InlineAsmTemplatePiece],
        operands: Vec<InlineAsmOperand<'tcx>>,
        options: InlineAsmOptions,
    },
}
crate enum InlineAsmOperand<'tcx> {
    In {
        reg: InlineAsmRegOrRegClass,
        expr: ExprRef<'tcx>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: Option<ExprRef<'tcx>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        expr: ExprRef<'tcx>,
    },
    SplitInOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_expr: ExprRef<'tcx>,
        out_expr: Option<ExprRef<'tcx>>,
    },
    Const {
        expr: ExprRef<'tcx>,
    },
    SymFn {
        expr: ExprRef<'tcx>,
    },
    SymStatic {
        expr: ExprRef<'tcx>,
    },
}
```

The only significant change compared to HIR is that `Sym` has been lowered to either a `SymFn` whose `expr` is a `Literal` ZST of the `fn`, or a `SymStatic` whose `expr` is a `StaticRef`.

## MIR

`InlineAsm` is represented as a `Terminator` in the MIR:

```rust
pub enum TerminatorKind<'tcx> {
    // [..]

    /// Block ends with an inline assembly block. This is a terminator since
    /// inline assembly is allowed to diverge.
    InlineAsm {
        /// The template for the inline assembly, with placeholders.
        template: &'tcx [InlineAsmTemplatePiece],

        /// The operands for the inline assembly, as `Operand`s or `Place`s.
        operands: Vec<InlineAsmOperand<'tcx>>,

        /// Miscellaneous options for the inline assembly.
        options: InlineAsmOptions,

        /// Destination block after the inline assembly returns, unless it is
        /// diverging (InlineAsmOptions::NORETURN).
        destination: Option<BasicBlock>,
    },
}

pub enum InlineAsmOperand<'tcx> {
    In {
        reg: InlineAsmRegOrRegClass,
        value: Operand<'tcx>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        place: Option<Place<'tcx>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_value: Operand<'tcx>,
        out_place: Option<Place<'tcx>>,
    },
    Const {
        value: Operand<'tcx>,
    },
    SymFn {
        value: Box<Constant<'tcx>>,
    },
    SymStatic {
        value: Box<Constant<'tcx>>,
    },
}
```

As part of HAIR lowering, `InOut` and `SplitInOut` operands are lowered to a split form with a separate `in_value` and `out_place`.

Semantically, the `InlineAsm` terminator is similar to the `Call` terminator except that it has multiple output places where a `Call` only has a single return place output.

The constant promotion pass is used to ensure that `const` operands are actually constants (using the same logic as `#[rustc_args_required_const]`).

## Codegen

Operands are lowered one more time before being passed to LLVM codegen:

```rust
pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> {
    In {
        reg: InlineAsmRegOrRegClass,
        value: OperandRef<'tcx, B::Value>,
    },
    Out {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        place: Option<PlaceRef<'tcx, B::Value>>,
    },
    InOut {
        reg: InlineAsmRegOrRegClass,
        late: bool,
        in_value: OperandRef<'tcx, B::Value>,
        out_place: Option<PlaceRef<'tcx, B::Value>>,
    },
    Const {
        string: String,
    },
    SymFn {
        instance: Instance<'tcx>,
    },
    SymStatic {
        def_id: DefId,
    },
}
```

The operands are lowered to LLVM operands and constraint codes as follow:
- `out` and the output part of `inout` operands are added first, as required by LLVM. Late output operands have a `=` prefix added to their constraint code, non-late output operands have a `=&` prefix added to their constraint code.
- `in` operands are added normally.
- `inout` operands are tied to the matching output operand.
- `sym` operands are passed as function pointers or pointers, using the `"s"` constraint.
- `const` operands are formatted to a string and directly inserted in the template string.

The template string is converted to LLVM form:
- `$` characters are escaped as `$$`.
- `const` operands are converted to strings and inserted directly.
- Placeholders are formatted as `${X:M}` where `X` is the operand index and `M` is the modifier character. Modifiers are converted from the Rust form to the LLVM form.

The various options are converted to clobber constraints or LLVM attributes, refer to the [RFC](https://github.com/Amanieu/rfcs/blob/inline-asm/text/0000-inline-asm.md#mapping-to-llvm-ir) for more details.

Note that LLVM is sometimes rather picky about what types it accepts for certain constraint codes so we sometimes need to insert conversions to/from a supported type. See the target-specific ISelLowering.cpp files in LLVM for details.

# Adding support for new architectures

Adding inline assembly support to an architecture is mostly a matter of defining the registers and register classes for that architecture. All the definitions for register classes are located in `src/librustc_target/asm/`.

Additionally you will need to implement lowering of these register classes to LLVM constraint codes in `src/librustc_codegen_llvm/asm.rs`.

4 years agoUpdate dlmalloc dependency to 0.1.4
Amanieu d'Antras [Tue, 19 May 2020 17:25:41 +0000 (18:25 +0100)]
Update dlmalloc dependency to 0.1.4

4 years agoAuto merge of #72227 - nnethercote:tiny-vecs-are-dumb, r=Amanieu
bors [Tue, 19 May 2020 15:12:12 +0000 (15:12 +0000)]
Auto merge of #72227 - nnethercote:tiny-vecs-are-dumb, r=Amanieu

Tiny Vecs are dumb.

Currently, if you repeatedly push to an empty vector, the capacity
growth sequence is 0, 1, 2, 4, 8, 16, etc. This commit changes the
relevant code (the "amortized" growth strategy) to skip 1 and 2, instead
using 0, 4, 8, 16, etc. (You can still get a capacity of 1 or 2 using
the "exact" growth strategy, e.g. via `reserve_exact()`.)

This idea (along with the phrase "tiny Vecs are dumb") comes from the
"doubling" growth strategy that was removed from `RawVec` in #72013.
That strategy was barely ever used -- only when a `VecDeque` was grown,
oddly enough -- which is why it was removed in #72013.

(Fun fact: until just a few days ago, I thought the "doubling" strategy
was used for repeated push case. In other words, this commit makes
`Vec`s behave the way I always thought they behaved.)

This change reduces the number of allocations done by rustc itself by
10% or more. It speeds up rustc, and will also speed up any other Rust
program that uses `Vec`s a lot.

In theory, the change could increase memory usage, but in practice it
doesn't. It would be an unusual program where very small `Vec`s having a
capacity of 4 rather than 1 or 2 would make a difference. You'd need a
*lot* of very small `Vec`s, and/or some very small `Vec`s with very
large elements.

r? @Amanieu

4 years agoAuto merge of #72346 - Dylan-DPC:rollup-vp418xs, r=Dylan-DPC
bors [Tue, 19 May 2020 11:54:40 +0000 (11:54 +0000)]
Auto merge of #72346 - Dylan-DPC:rollup-vp418xs, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #71886 (Stabilize saturating_abs and saturating_neg)
 - #72066 (correctly handle uninferred consts)
 - #72068 (Ignore arguments when looking for `IndexMut` for subsequent `mut` obligation)
 - #72338 (Fix ICE in -Zsave-analysis)
 - #72344 (Assert doc wording)

Failed merges:

r? @ghost

4 years agoRollup merge of #72344 - kornelski:assertdoc, r=Mark-Simulacrum
Dylan DPC [Tue, 19 May 2020 11:53:47 +0000 (13:53 +0200)]
Rollup merge of #72344 - kornelski:assertdoc, r=Mark-Simulacrum

Assert doc wording

The current wording implies unsafe code is dependent on assert:

https://users.rust-lang.org/t/are-assert-statements-included-in-unsafe-blocks/42865

4 years agoRollup merge of #72338 - doctorn:trait-object-ice, r=ecstatic-morse
Dylan DPC [Tue, 19 May 2020 11:53:45 +0000 (13:53 +0200)]
Rollup merge of #72338 - doctorn:trait-object-ice, r=ecstatic-morse

Fix ICE in -Zsave-analysis

Puts a short-circuit in to avoid an ICE in `-Zsave-analysis`.

r? @ecstatic-morse

Resolves #72267

4 years agoRollup merge of #72068 - estebank:mut-deref-hack, r=oli-obk
Dylan DPC [Tue, 19 May 2020 11:53:43 +0000 (13:53 +0200)]
Rollup merge of #72068 - estebank:mut-deref-hack, r=oli-obk

Ignore arguments when looking for `IndexMut` for subsequent `mut` obligation

Given code like `v[&field].boo();` where `field: String` and
`.boo(&mut self)`, typeck will have decided that `v` is accessed using
`Index`, but when `boo` adds a new `mut` obligation,
`convert_place_op_to_mutable` is called. When this happens, for *some
reason* the arguments' dereference adjustments are completely ignored
causing an error saying that `IndexMut` is not satisfied:

```
error[E0596]: cannot borrow data in an index of `Indexable` as mutable
  --> src/main.rs:30:5
   |
30 |     v[&field].boo();
   |     ^^^^^^^^^ cannot borrow as mutable
   |
   = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Indexable`
```

This is not true, but by changing `try_overloaded_place_op` to retry
when given `Needs::MutPlace` without passing the argument types, the
example successfully compiles.

I believe there might be more appropriate ways to deal with this.

Fix #72002.

4 years agoRollup merge of #72066 - lcnr:const-type-info-err, r=varkor
Dylan DPC [Tue, 19 May 2020 11:53:41 +0000 (13:53 +0200)]
Rollup merge of #72066 - lcnr:const-type-info-err, r=varkor

correctly handle uninferred consts

fixes the ICE mentioned in https://github.com/rust-lang/rust/issues/70507#issuecomment-615268893

I originally tried to generalize `need_type_info_err` to also work with consts which was not as much fun as I hoped :sweat_smile:

It might be easier to have some duplication here and handle consts separately.

r? @varkor

4 years agoRollup merge of #71886 - t-rapp:tr-saturating-funcs, r=dtolnay
Dylan DPC [Tue, 19 May 2020 11:53:36 +0000 (13:53 +0200)]
Rollup merge of #71886 - t-rapp:tr-saturating-funcs, r=dtolnay

Stabilize saturating_abs and saturating_neg

Stabilizes the following signed integer functions with saturation mechanics:
 * saturating_abs()
 * saturating_neg()

Closes #59983

4 years agoAssert doc wording
Kornel [Tue, 19 May 2020 10:19:09 +0000 (11:19 +0100)]
Assert doc wording

4 years agoadd test for repr(128) enum derives
Bastian Kauschke [Tue, 28 Apr 2020 15:07:05 +0000 (17:07 +0200)]
add test for repr(128) enum derives

4 years agoadd tests for enum discriminants
Bastian Kauschke [Sun, 5 Apr 2020 20:20:38 +0000 (22:20 +0200)]
add tests for enum discriminants

4 years agoupdate `discriminant_value` usage in tests
Bastian Kauschke [Sun, 5 Apr 2020 18:37:10 +0000 (20:37 +0200)]
update `discriminant_value` usage in tests

4 years agoupdate `discriminant_value` usage in the compiler
Bastian Kauschke [Sun, 5 Apr 2020 18:36:39 +0000 (20:36 +0200)]
update `discriminant_value` usage in the compiler

4 years agoupdate codegen of `discriminant_value`
Bastian Kauschke [Sun, 5 Apr 2020 18:02:55 +0000 (20:02 +0200)]
update codegen of `discriminant_value`

4 years agoauto impl`DiscriminantKind` for every type
Bastian Kauschke [Sun, 5 Apr 2020 17:57:32 +0000 (19:57 +0200)]
auto impl`DiscriminantKind` for every type

4 years agoupdate libcore, add `discriminant_kind` lang-item
Bastian Kauschke [Sun, 5 Apr 2020 17:30:03 +0000 (19:30 +0200)]
update libcore, add `discriminant_kind` lang-item

4 years agoupdate select docs
Bastian Kauschke [Thu, 2 Apr 2020 12:05:04 +0000 (14:05 +0200)]
update select docs

4 years agoAuto merge of #71447 - cuviper:unsized_cow, r=dtolnay
bors [Tue, 19 May 2020 08:08:48 +0000 (08:08 +0000)]
Auto merge of #71447 - cuviper:unsized_cow, r=dtolnay

impl From<Cow> for Box, Rc, and Arc

These forward `Borrowed`/`Owned` values to existing `From` impls.

- `Box<T>` is a fundamental type, so it would be a breaking change to add a blanket impl. Therefore, `From<Cow>` is only implemented for `[T]`, `str`, `CStr`, `OsStr`, and `Path`.
- For `Rc<T>` and `Arc<T>`, `From<Cow>` is implemented for everything that implements `From` the borrowed and owned types separately.

4 years agoAuto merge of #68717 - petrochenkov:stabexpat, r=varkor
bors [Tue, 19 May 2020 03:11:32 +0000 (03:11 +0000)]
Auto merge of #68717 - petrochenkov:stabexpat, r=varkor

Stabilize fn-like proc macros in expression, pattern and statement positions

I.e. all the positions in which stable `macro_rules` macros are supported.

Depends on https://github.com/rust-lang/rust/pull/68716 ("Stabilize `Span::mixed_site`").

cc https://github.com/rust-lang/rust/issues/54727
cc https://github.com/rust-lang/rust/issues/54727#issuecomment-580647446

Stabilization report: https://github.com/rust-lang/rust/pull/68717#issuecomment-623197503.

4 years agoAuto merge of #72330 - Dylan-DPC:rollup-yuxadv8, r=Dylan-DPC
bors [Mon, 18 May 2020 22:50:40 +0000 (22:50 +0000)]
Auto merge of #72330 - Dylan-DPC:rollup-yuxadv8, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #71599 (Support coercion between (FnDef | Closure) and (FnDef | Closure))
 - #71973 (Lazy normalization of constants (Reprise))
 - #72283 (Drop Elaboration Elaboration)
 - #72290 (Add newer rust versions to linker-plugin-lto.md)
 - #72318 (Add help text for remote-test-client)

Failed merges:

r? @ghost

4 years agoUpdate cargo
Eric Huss [Mon, 18 May 2020 22:41:57 +0000 (15:41 -0700)]
Update cargo

4 years agoFix ICE in -Zsave-analysis
Nathan Corbyn [Mon, 18 May 2020 21:48:06 +0000 (22:48 +0100)]
Fix ICE in -Zsave-analysis

4 years agoAuto merge of #72332 - mati865:ci-fix, r=pietroalbini
bors [Mon, 18 May 2020 18:40:07 +0000 (18:40 +0000)]
Auto merge of #72332 - mati865:ci-fix, r=pietroalbini

CI: Workaround MSYS2 issue

4 years agoUpdate pacman first
Mateusz Mikuła [Mon, 18 May 2020 17:57:18 +0000 (19:57 +0200)]
Update pacman first

4 years agocorrectly handle uninferred consts
Bastian Kauschke [Sat, 9 May 2020 22:01:23 +0000 (00:01 +0200)]
correctly handle uninferred consts

4 years agoRollup merge of #72318 - tblah:remote-test-client-doc, r=nikomatsakis
Dylan DPC [Mon, 18 May 2020 17:04:08 +0000 (19:04 +0200)]
Rollup merge of #72318 - tblah:remote-test-client-doc, r=nikomatsakis

Add help text for remote-test-client

Add help text describing the usage of remote-test-client

4 years agoRollup merge of #72290 - elichai:2020-doc-lto, r=wesleywiser
Dylan DPC [Mon, 18 May 2020 17:04:06 +0000 (19:04 +0200)]
Rollup merge of #72290 - elichai:2020-doc-lto, r=wesleywiser

Add newer rust versions to linker-plugin-lto.md

Hi,
This doc got a bit out of date,
it's hosted here: https://doc.rust-lang.org/rustc/linker-plugin-lto.html
you can check the versions I've added via:
```bash
$ rustup install 1.38.0
$ rustc +1.38.0 -vV
rustc 1.38.0 (625451e37 2019-09-23)
binary: rustc
commit-hash: 625451e376bb2e5283fc4741caa0a3e8a2ca4d54
commit-date: 2019-09-23
host: x86_64-unknown-linux-gnu
release: 1.38.0
LLVM version: 9.0

$ rustup install 1.43.1
$ rustc +1.43.1 -vV
rustc 1.43.1 (8d69840ab 2020-05-04)
binary: rustc
commit-hash: 8d69840ab92ea7f4d323420088dd8c9775f180cd
commit-date: 2020-05-04
host: x86_64-unknown-linux-gnu
release: 1.43.1
LLVM version: 9.0
```

4 years agoRollup merge of #72283 - jonas-schievink:elaborate-drop-elaboration, r=cramertj
Dylan DPC [Mon, 18 May 2020 17:04:04 +0000 (19:04 +0200)]
Rollup merge of #72283 - jonas-schievink:elaborate-drop-elaboration, r=cramertj

Drop Elaboration Elaboration

As in, adding more documentation to it.

4 years agoRollup merge of #71973 - lcnr:lazy-norm, r=nikomatsakis
Dylan DPC [Mon, 18 May 2020 17:04:03 +0000 (19:04 +0200)]
Rollup merge of #71973 - lcnr:lazy-norm, r=nikomatsakis

Lazy normalization of constants (Reprise)

Continuation of #67890 by @skinny121.

Initial implementation of #60471 for constants.

Perform normalization/evaluation of constants lazily, which is known as lazy normalization. Lazy normalization is only enabled when using `#![feature(lazy_normalization_consts)]`, by default constants are still evaluated eagerly as there are currently.

Lazy normalization of constants is achieved with a new ConstEquate predicate which type inferences uses to delay checking whether constants are equal to each other until later, avoiding cycle errors.

Note this doesn't allow the use of generics within repeat count expressions as that is still evaluated during conversion to mir. There are also quite a few other known problems with lazy normalization which will be fixed in future PRs.

r? @nikomatsakis

fixes #71922, fixes #71986

4 years agoRollup merge of #71599 - ldm0:fnclo, r=nikomatsakis
Dylan DPC [Mon, 18 May 2020 17:04:01 +0000 (19:04 +0200)]
Rollup merge of #71599 - ldm0:fnclo, r=nikomatsakis

Support coercion between (FnDef | Closure) and (FnDef | Closure)

Fixes #46742, fixes #48109
Inject `Closure` into the `FnDef x FnDef` coercion special case, which makes coercion of `(FnDef | Closure) x (FnDef | Closure)` possible, where closures should be **non-capturing**.

4 years agoUpdate unstable book documentation with the latest RFC text
Amanieu d'Antras [Mon, 18 May 2020 13:39:07 +0000 (14:39 +0100)]
Update unstable book documentation with the latest RFC text

4 years agoUpdate LLVM submodule
Amanieu d'Antras [Mon, 18 May 2020 13:35:40 +0000 (14:35 +0100)]
Update LLVM submodule

4 years agoSimplify register name output for x86
Amanieu d'Antras [Thu, 14 May 2020 21:09:32 +0000 (22:09 +0100)]
Simplify register name output for x86

4 years agoUpdate compiler_builtins to 0.1.28
Amanieu d'Antras [Tue, 12 May 2020 14:24:24 +0000 (15:24 +0100)]
Update compiler_builtins to 0.1.28

4 years agoMark asm unstable book doctests as allow_fail since they don't work with system LLVM
Amanieu d'Antras [Mon, 11 May 2020 20:48:21 +0000 (21:48 +0100)]
Mark asm unstable book doctests as allow_fail since they don't work with system LLVM

4 years agoFix const handling and add tests for const operands
Amanieu d'Antras [Mon, 11 May 2020 16:53:32 +0000 (17:53 +0100)]
Fix const handling and add tests for const operands

4 years agoFix docs
Amanieu d'Antras [Fri, 8 May 2020 20:05:22 +0000 (21:05 +0100)]
Fix docs

4 years agoFix handling on InlineAsm for the unconditional recursion lint.
Amanieu d'Antras [Fri, 8 May 2020 20:00:33 +0000 (21:00 +0100)]
Fix handling on InlineAsm for the unconditional recursion lint.

4 years agoFix tests
Amanieu d'Antras [Fri, 8 May 2020 17:14:06 +0000 (18:14 +0100)]
Fix tests

4 years agoFix feature gate tests
Amanieu d'Antras [Fri, 8 May 2020 15:37:57 +0000 (16:37 +0100)]
Fix feature gate tests

4 years agoAdd documentation for asm!
Amanieu d'Antras [Fri, 8 May 2020 14:36:34 +0000 (15:36 +0100)]
Add documentation for asm!

4 years agoAdd borrow-check test
Amanieu d'Antras [Fri, 8 May 2020 00:15:56 +0000 (01:15 +0100)]
Add borrow-check test

4 years agoMinor fixes
Amanieu d'Antras [Thu, 7 May 2020 23:57:22 +0000 (00:57 +0100)]
Minor fixes

4 years agoHandle InlineAsm in clippy
Amanieu d'Antras [Wed, 6 May 2020 14:03:53 +0000 (15:03 +0100)]
Handle InlineAsm in clippy

4 years agoMove InlineAsmTemplatePiece and InlineAsmOptions to librustc_ast
Amanieu d'Antras [Wed, 6 May 2020 13:46:01 +0000 (14:46 +0100)]
Move InlineAsmTemplatePiece and InlineAsmOptions to librustc_ast

4 years agoDisable asm tests on system llvm
Amanieu d'Antras [Wed, 6 May 2020 11:04:22 +0000 (12:04 +0100)]
Disable asm tests on system llvm

4 years agoThe h modifier is only supported by reg_abcd
Amanieu d'Antras [Wed, 6 May 2020 10:41:37 +0000 (11:41 +0100)]
The h modifier is only supported by reg_abcd

4 years agoUpdate llvm-project submodule
Amanieu d'Antras [Fri, 1 May 2020 23:28:51 +0000 (00:28 +0100)]
Update llvm-project submodule

4 years agoImplement att_syntax option
Amanieu d'Antras [Fri, 1 May 2020 22:59:15 +0000 (23:59 +0100)]
Implement att_syntax option

4 years agoWork around more LLVM limitations
Amanieu d'Antras [Fri, 1 May 2020 22:23:55 +0000 (23:23 +0100)]
Work around more LLVM limitations

4 years agoAdd notes about functions that are not currently used
Amanieu d'Antras [Fri, 1 May 2020 19:51:54 +0000 (20:51 +0100)]
Add notes about functions that are not currently used

4 years agoAdd support for high byte registers on x86
Amanieu d'Antras [Tue, 28 Apr 2020 23:45:58 +0000 (00:45 +0100)]
Add support for high byte registers on x86

4 years agoUn-deprecate asm! macro
Amanieu d'Antras [Fri, 24 Apr 2020 20:16:00 +0000 (21:16 +0100)]
Un-deprecate asm! macro

4 years agoApply review feedback
Amanieu d'Antras [Thu, 19 Mar 2020 07:41:43 +0000 (07:41 +0000)]
Apply review feedback

4 years agoAdd tests for asm!
Amanieu d'Antras [Thu, 20 Feb 2020 09:19:48 +0000 (09:19 +0000)]
Add tests for asm!

4 years agoImplement asm! codegen
Amanieu d'Antras [Mon, 17 Feb 2020 21:36:01 +0000 (21:36 +0000)]
Implement asm! codegen

4 years agoCheck that asm const operands are actually constants
Amanieu d'Antras [Mon, 17 Feb 2020 22:20:59 +0000 (22:20 +0000)]
Check that asm const operands are actually constants

4 years agoAdd asm! to MIR
Amanieu d'Antras [Fri, 14 Feb 2020 18:17:50 +0000 (18:17 +0000)]
Add asm! to MIR

4 years agoHIR passes for asm!
Amanieu d'Antras [Thu, 13 Feb 2020 11:00:55 +0000 (11:00 +0000)]
HIR passes for asm!

4 years agoImplement AST lowering for asm!
Amanieu d'Antras [Wed, 12 Feb 2020 15:48:03 +0000 (15:48 +0000)]
Implement AST lowering for asm!

4 years agoAdd asm! to HIR
Amanieu d'Antras [Wed, 12 Feb 2020 17:32:41 +0000 (17:32 +0000)]
Add asm! to HIR

4 years agoImplement asm! in librustc_builtin_macros
Amanieu d'Antras [Wed, 12 Feb 2020 15:47:43 +0000 (15:47 +0000)]
Implement asm! in librustc_builtin_macros

4 years agoAdd asm! to AST
Amanieu d'Antras [Wed, 22 Jan 2020 14:20:27 +0000 (14:20 +0000)]
Add asm! to AST

4 years agoAdd inline asm register definitions to librustc_target
Amanieu d'Antras [Wed, 22 Jan 2020 11:24:31 +0000 (11:24 +0000)]
Add inline asm register definitions to librustc_target

4 years agoAdd RISC-V target features
Amanieu d'Antras [Sun, 1 Mar 2020 09:52:04 +0000 (09:52 +0000)]
Add RISC-V target features

4 years agoAdd remote-test-client help text
Tom Eccles [Mon, 18 May 2020 11:32:58 +0000 (12:32 +0100)]
Add remote-test-client help text

4 years agoAuto merge of #72289 - RalfJung:abort_internal, r=Mark-Simulacrum
bors [Mon, 18 May 2020 11:11:19 +0000 (11:11 +0000)]
Auto merge of #72289 - RalfJung:abort_internal, r=Mark-Simulacrum

abort_internal is safe

`sys::abort_internal` is stably exposed as a safe function. Forward that assumption "inwards" to the `sys` module by making the function itself safe, too.

This corresponds to what https://github.com/rust-lang/rust/pull/72204 did for the intrinsic. We should probably wait until that lands because some of the intrinsic calls in this PR might then need adjustments.

4 years agoAuto merge of #72316 - RalfJung:rollup-70g6bln, r=RalfJung
bors [Mon, 18 May 2020 07:53:03 +0000 (07:53 +0000)]
Auto merge of #72316 - RalfJung:rollup-70g6bln, r=RalfJung

Rollup of 2 pull requests

Successful merges:

 - #72143 (make offset must_use)
 - #72307 (use the new interface to initialize conditional variables)

Failed merges:

r? @ghost

4 years agoAdd some more `rfold` implementations.
Nicholas Nethercote [Sun, 17 May 2020 23:34:34 +0000 (09:34 +1000)]
Add some more `rfold` implementations.

4 years agoRollup merge of #72307 - hermitcore:condvar, r=Mark-Simulacrum
Ralf Jung [Mon, 18 May 2020 06:48:45 +0000 (08:48 +0200)]
Rollup merge of #72307 - hermitcore:condvar, r=Mark-Simulacrum

use the new interface to initialize conditional variables

HermitCore introduce a new interface to intialize conditional variables.
Consequently, minor changes are required to support this interface.

4 years agoRollup merge of #72143 - rust-lang:steveklabnik-must-use, r=sfackler
Ralf Jung [Mon, 18 May 2020 06:48:43 +0000 (08:48 +0200)]
Rollup merge of #72143 - rust-lang:steveklabnik-must-use, r=sfackler

make offset must_use

https://djugei.github.io/bad-at-unsafe/ describes an error a user had when trying to use offset:

> At first I just assumed that the .add() and .offset() methods on pointers would mutate the pointer. They do not. Instead they return a new pointer, which gets dropped silently if you don't use it. Unlike for example Result, which is must_use annotated.

This PR only adds `offset`, because I wanted to float the idea; I'm imagining that there's more than just `add` and `offset` that could use this. I am also very open to re-wording the warning.

r? @rust-lang/libs

4 years agoTiny Vecs are dumb.
Nicholas Nethercote [Sun, 17 May 2020 19:28:14 +0000 (05:28 +1000)]
Tiny Vecs are dumb.

Currently, if you repeatedly push to an empty vector, the capacity
growth sequence is 0, 1, 2, 4, 8, 16, etc. This commit changes the
relevant code (the "amortized" growth strategy) to skip 1 and 2 in most
cases, instead using 0, 4, 8, 16, etc. (You can still get a capacity of
1 or 2 using the "exact" growth strategy, e.g. via `reserve_exact()`.)

This idea (along with the phrase "tiny Vecs are dumb") comes from the
"doubling" growth strategy that was removed from `RawVec` in #72013.
That strategy was barely ever used -- only when a `VecDeque` was grown,
oddly enough -- which is why it was removed in #72013.

(Fun fact: until just a few days ago, I thought the "doubling" strategy
was used for repeated push case. In other words, this commit makes
`Vec`s behave the way I always thought they behaved.)

This change reduces the number of allocations done by rustc itself by
10% or more. It speeds up rustc, and will also speed up any other Rust
program that uses `Vec`s a lot.

4 years agoAuto merge of #72300 - flip1995:clippyup, r=Mark-Simulacrum
bors [Mon, 18 May 2020 04:10:01 +0000 (04:10 +0000)]
Auto merge of #72300 - flip1995:clippyup, r=Mark-Simulacrum

Sync Clippy

cc rust-lang/rust-clippy#5608

Included changes:

- renames/merges of some lints
- ICE fix
- Downgrade useless_let_if_seq to nursery
- FP fixes
- formatting

r? @oli-obk

4 years agoAuto merge of #72269 - RalfJung:unsafe-borrow-of-packed, r=Mark-Simulacrum
bors [Mon, 18 May 2020 00:54:42 +0000 (00:54 +0000)]
Auto merge of #72269 - RalfJung:unsafe-borrow-of-packed, r=Mark-Simulacrum

move borrow-of-packed-field unsafety check out of loop

Looks like during the place refactoring, this code somehow got into this loop even though it does not actually depend on the loop variables.