]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agointroduce newtype'd `Predicate<'tcx>`
Bastian Kauschke [Mon, 11 May 2020 20:06:41 +0000 (22:06 +0200)]
introduce newtype'd `Predicate<'tcx>`

4 years agorename `Predicate` to `PredicateKind`, introduce alias
Bastian Kauschke [Mon, 11 May 2020 19:09:57 +0000 (21:09 +0200)]
rename `Predicate` to `PredicateKind`, introduce alias

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 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 agoHandle InlineAsm in clippy
Amanieu d'Antras [Wed, 6 May 2020 14:03:53 +0000 (15:03 +0100)]
Handle InlineAsm in clippy

4 years agoMerge commit 'e214ea82ad0a751563acf67e1cd9279cf302db3a' into clippyup
flip1995 [Sun, 17 May 2020 15:36:26 +0000 (17:36 +0200)]
Merge commit 'e214ea82ad0a751563acf67e1cd9279cf302db3a' into clippyup

4 years agoRollup merge of #72047 - Julian-Wollersberger:literal_error_reporting_cleanup, r...
Ralf Jung [Sat, 16 May 2020 17:46:31 +0000 (19:46 +0200)]
Rollup merge of #72047 - Julian-Wollersberger:literal_error_reporting_cleanup, r=petrochenkov

Literal error reporting cleanup

While doing some performance work, I noticed some code duplication in `librustc_parser/lexer/mod.rs`, so I cleaned it up.

This PR is probably best reviewed commit by commit.

I'm not sure what the API stability practices for `librustc_lexer` are. Four public methods in `unescape.rs` can be removed, but two are used by clippy, so I left them in for now.
I could open a PR for Rust-Analyzer when this one lands.

But how do I open a PR for clippy? (Git submodules are frustrating to work with)

4 years agoRollup merge of #72090 - RalfJung:rustc_driver-exit-code, r=oli-obk
Dylan DPC [Sat, 16 May 2020 00:37:23 +0000 (02:37 +0200)]
Rollup merge of #72090 - RalfJung:rustc_driver-exit-code, r=oli-obk

rustc_driver: factor out computing the exit code

In a recent Miri PR I [added a convenience wrapper](https://github.com/rust-lang/miri/pull/1405/files#diff-c3d602c5c8035a16699ce9c015bfeceaR125) around `catch_fatal_errors` and `run_compiler` that @oli-obk suggested I could upstream. However, after seeing what could be shared between `rustc_driver::main`, clippy and Miri, really the only thing I found is computing the exit code -- so that's what this PR does.

What prevents using the Miri convenience function in `rustc_driver::main` and clippy is that they do extra work inside `catch_fatal_errors`, and while I could abstract that away, clippy actually *computes the callbacks* inside there, and I fond no good way to abstract that and thus gave up. Maybe the clippy thing could be moved out, I am not sure if it ever can actually raise a `FatalErrorMarker` -- someone more knowledgeable in clippy would have to do that.

4 years agoRollup merge of #71948 - csmoe:issue-61076, r=oli-obk
Dylan DPC [Sat, 16 May 2020 00:37:21 +0000 (02:37 +0200)]
Rollup merge of #71948 - csmoe:issue-61076, r=oli-obk

Suggest to await future before ? operator

Closes https://github.com/rust-lang/rust/issues/71811
cc #61076

4 years agoimplement type_implments_trait query
csmoe [Thu, 14 May 2020 15:07:46 +0000 (23:07 +0800)]
implement type_implments_trait query

4 years agoReplace some usages of the old `unescape_` functions in AST, clippy and tests.
Julian Wollersberger [Wed, 13 May 2020 08:03:49 +0000 (10:03 +0200)]
Replace some usages of the old `unescape_` functions in AST, clippy and tests.

4 years agoMerge commit '43a1777b89cf6791f9e20878b4e5e3ae907867a5' into clippyup
flip1995 [Mon, 11 May 2020 18:23:47 +0000 (20:23 +0200)]
Merge commit '43a1777b89cf6791f9e20878b4e5e3ae907867a5' into clippyup

4 years agorustc_driver: factor out computing the exit code
Ralf Jung [Sun, 10 May 2020 21:36:41 +0000 (23:36 +0200)]
rustc_driver: factor out computing the exit code

4 years agoRollup merge of #71555 - cjgillot:nameless, r=matthewjasper
Ralf Jung [Sat, 9 May 2020 11:36:39 +0000 (13:36 +0200)]
Rollup merge of #71555 - cjgillot:nameless, r=matthewjasper

Remove ast::{Ident, Name} reexports.

The reexport of `Symbol` into `Name` confused me.

4 years agoFix clippy.
Camille GILLOT [Fri, 8 May 2020 11:57:01 +0000 (13:57 +0200)]
Fix clippy.

4 years agoFix nit and cargo.lock
Jack Huey [Thu, 7 May 2020 21:46:31 +0000 (17:46 -0400)]
Fix nit and cargo.lock

4 years agoUpdate clippy lint
Dylan MacKenzie [Sun, 3 May 2020 18:41:03 +0000 (11:41 -0700)]
Update clippy lint

4 years agoStabilize fn-like proc macros in expression, pattern and statement positions
Vadim Petrochenkov [Fri, 31 Jan 2020 22:02:31 +0000 (01:02 +0300)]
Stabilize fn-like proc macros in expression, pattern and statement positions

4 years agoAuto merge of #5548 - matthiaskrgr:traget_os, r=flip1995
bors [Fri, 1 May 2020 16:33:14 +0000 (16:33 +0000)]
Auto merge of #5548 - matthiaskrgr:traget_os, r=flip1995

mismatched_target_os: link to respective section in rust reference

changelog: none

4 years agomismatched_target_os: link to respective section in rust reference
Matthias Krüger [Thu, 30 Apr 2020 23:21:24 +0000 (01:21 +0200)]
mismatched_target_os: link to respective section in rust reference

4 years agoAuto merge of #5547 - CrazyRoka:fix-clone-double-ref-suggestion, r=flip1995
bors [Wed, 29 Apr 2020 20:05:18 +0000 (20:05 +0000)]
Auto merge of #5547 - CrazyRoka:fix-clone-double-ref-suggestion, r=flip1995

Fixed incorrect suggestion of `clone_double_ref` lint

- Added `<_>` to suggestion
- Changed help message
- Added new tests
Closes #5494

changelog: Improve suggestion of [`clone_double_ref`]

4 years agoFixed incorrect suggestion of `clone_double_ref` lint
CrazyRoka [Wed, 29 Apr 2020 19:40:57 +0000 (22:40 +0300)]
Fixed incorrect suggestion of `clone_double_ref` lint

- Added `<_>` to suggestion
- Changed help message

4 years agoAuto merge of #5545 - flip1995:rustup, r=flip1995
bors [Wed, 29 Apr 2020 13:59:30 +0000 (13:59 +0000)]
Auto merge of #5545 - flip1995:rustup, r=flip1995

Rustup to rust-lang/rust#71518

changelog: none

4 years agoRustup to rust-lang/rust#71518
flip1995 [Wed, 29 Apr 2020 13:48:43 +0000 (15:48 +0200)]
Rustup to rust-lang/rust#71518

4 years agoAuto merge of #5543 - matthiaskrgr:rustup_45, r=flip1995
bors [Tue, 28 Apr 2020 18:30:01 +0000 (18:30 +0000)]
Auto merge of #5543 - matthiaskrgr:rustup_45, r=flip1995

rustup https://github.com/rust-lang/rust/pull/71292/

cc https://github.com/rust-lang/rust/issues/71608

---

changelog: none

4 years agorustup https://github.com/rust-lang/rust/pull/71292/
Matthias Krüger [Tue, 28 Apr 2020 13:05:56 +0000 (15:05 +0200)]
rustup https://github.com/rust-lang/rust/pull/71292/

4 years agoAuto merge of #5535 - ebroto:issue_5360, r=phansch
bors [Tue, 28 Apr 2020 05:36:30 +0000 (05:36 +0000)]
Auto merge of #5535 - ebroto:issue_5360, r=phansch

used_underscore_binding: do not lint on `await` desugaring

changelog: used_underscore_binding: do not lint on `await` desugaring

Fixes #5360

4 years agoTest that we lint the awaited expression
Eduardo Broto [Mon, 27 Apr 2020 19:12:39 +0000 (21:12 +0200)]
Test that we lint the awaited expression

4 years agoused_underscore_binding: do not lint on `await` desugaring
Eduardo Broto [Sun, 26 Apr 2020 22:12:51 +0000 (00:12 +0200)]
used_underscore_binding: do not lint on `await` desugaring

4 years agoAuto merge of #5538 - csmoe:rustup, r=phansch
bors [Mon, 27 Apr 2020 16:58:24 +0000 (16:58 +0000)]
Auto merge of #5538 - csmoe:rustup, r=phansch

rustup: rust-lang/rust#71628

cc https://github.com/rust-lang/rust/issues/71608

changelog: none

4 years agorustup: rust-lang/rust#71628
csmoe [Mon, 27 Apr 2020 13:56:20 +0000 (21:56 +0800)]
rustup: rust-lang/rust#71628

4 years agoAuto merge of #5522 - CrazyRoka:match_vec_item, r=phansch
bors [Mon, 27 Apr 2020 06:02:05 +0000 (06:02 +0000)]
Auto merge of #5522 - CrazyRoka:match_vec_item, r=phansch

New  lint `match_vec_item`

Added new lint to warn a match on index item which can panic. It's always better to use `get(..)` instead.
Closes #5500
changelog: New lint `match_on_vec_items`

4 years agoAuto merge of #5506 - ebroto:mismatched_target_os, r=flip1995
bors [Mon, 27 Apr 2020 02:29:49 +0000 (02:29 +0000)]
Auto merge of #5506 - ebroto:mismatched_target_os, r=flip1995

Implement mismatched_target_os lint

I've extended the check suggested in the issue to all the currently supported operating systems instead of limiting it to `linux` and `macos`, let me know if we want to do this.

Also, I've restored the text `There are over XXX lints ...` in the README as it was matched against by `cargo dev new_lint`.

changelog: Added `mismatched_target_os` lint to warn when an operating system is used in target family position in a #[cfg] attribute

Closes #3949

4 years agoSplit tests in unix/non-unix
Eduardo Broto [Sun, 26 Apr 2020 19:26:19 +0000 (21:26 +0200)]
Split tests in unix/non-unix

4 years agoRemove some OSes from the test to comply with stderr line limit
Eduardo Broto [Sat, 25 Apr 2020 22:00:30 +0000 (00:00 +0200)]
Remove some OSes from the test to comply with stderr line limit

4 years agoUse the span of the attribute for the error message
Eduardo Broto [Sat, 25 Apr 2020 21:52:36 +0000 (23:52 +0200)]
Use the span of the attribute for the error message

4 years agoApply suggestions from PR review
Eduardo Broto [Sat, 25 Apr 2020 18:55:46 +0000 (20:55 +0200)]
Apply suggestions from PR review

- Show just one error message with multiple suggestions in case of
  using multiple times an OS in target family position
- Only suggest #[cfg(unix)] when the OS is in the Unix family
- Test all the operating systems

4 years agoImplement mismatched_target_os lint
Eduardo Broto [Wed, 22 Apr 2020 21:01:25 +0000 (23:01 +0200)]
Implement mismatched_target_os lint

4 years agoUpdated lint info in lib.rs
CrazyRoka [Sun, 26 Apr 2020 15:11:21 +0000 (18:11 +0300)]
Updated lint info in lib.rs

4 years agoSmall lint update
CrazyRoka [Sun, 26 Apr 2020 14:57:19 +0000 (17:57 +0300)]
Small lint update

- Changed lint category to `correctness`
- Moved main function to bottom in test file
- Added `FIXME` comment to `span_lint_and_sugg` to improve later

4 years agoAuto merge of #5534 - phansch:remove-util-dev, r=flip1995
bors [Sun, 26 Apr 2020 14:44:08 +0000 (14:44 +0000)]
Auto merge of #5534 - phansch:remove-util-dev, r=flip1995

Remove util/dev script

`cargo dev` has been the replacement for a while, so I think we can
remove it now.

cc #5394

changelog: none

4 years agoAuto merge of #5509 - phansch:more-diagnostic-items2, r=matthiaskrgr
bors [Sun, 26 Apr 2020 12:30:52 +0000 (12:30 +0000)]
Auto merge of #5509 - phansch:more-diagnostic-items2, r=matthiaskrgr

Use more diagnostic items

In particular for:

* `VecDeque`
* `String`
* `Mutex`
* `HashMap`
* `HashSet`

cc rust-lang/rust#71414 #5393

---

changelog: none

4 years agoFix cargo crash
Philipp Hansch [Sun, 26 Apr 2020 11:45:47 +0000 (13:45 +0200)]
Fix cargo crash

4 years agoRemove util/dev script
Philipp Hansch [Sun, 26 Apr 2020 12:00:03 +0000 (14:00 +0200)]
Remove util/dev script

`cargo dev` has been the replacement for a while, so I think we can
remove it now.

cc #5394

4 years agocargo dev fmt
Philipp Hansch [Thu, 23 Apr 2020 06:12:03 +0000 (08:12 +0200)]
cargo dev fmt

4 years agoMore diagnostic items
Philipp Hansch [Thu, 23 Apr 2020 06:09:42 +0000 (08:09 +0200)]
More diagnostic items

In particular for:

* `VecDeque`
* `String`
* `Mutex`
* `HashMap`
* `HashSet`

cc https://github.com/rust-lang/rust/pull/71414 https://github.com/rust-lang/rust-clippy/issues/5393

4 years agoAuto merge of #5533 - phansch:rustup001, r=matthiaskrgr
bors [Sun, 26 Apr 2020 11:26:15 +0000 (11:26 +0000)]
Auto merge of #5533 - phansch:rustup001, r=matthiaskrgr

rustup to https://github.com/rust-lang/rust/pull/70043

changelog: none

4 years agorustup to https://github.com/rust-lang/rust/pull/70043
Philipp Hansch [Sun, 26 Apr 2020 08:12:14 +0000 (10:12 +0200)]
rustup to https://github.com/rust-lang/rust/pull/70043

4 years agoAuto merge of #5511 - alex-700:fix-redundant-pattern-matching, r=flip1995
bors [Sat, 25 Apr 2020 21:41:56 +0000 (21:41 +0000)]
Auto merge of #5511 - alex-700:fix-redundant-pattern-matching, r=flip1995

Fix redundant_pattern_matching lint

fixes #5504

changelog: Fix suggestion in `redundant_pattern_matching` for macros.

4 years agoAuto merge of #5525 - flip1995:issue_1654, r=phansch
bors [Sat, 25 Apr 2020 21:29:03 +0000 (21:29 +0000)]
Auto merge of #5525 - flip1995:issue_1654, r=phansch

 Don't trigger while_let_on_iterator when the iterator is recreated every iteration

r? @phansch

Fixes #1654

changelog: Fix false positive in [`while_let_on_iterator`]

4 years agoAuto merge of #5530 - ebroto:issue_5524, r=flip1995
bors [Sat, 25 Apr 2020 21:16:06 +0000 (21:16 +0000)]
Auto merge of #5530 - ebroto:issue_5524, r=flip1995

map_clone: avoid suggesting `copied()` for &mut

changelog: map_clone: avoid suggesting `copied()` for &mut

Fixes #5524

4 years agomap_clone: avoid suggesting `copied()` for &mut
Eduardo Broto [Sat, 25 Apr 2020 20:49:06 +0000 (22:49 +0200)]
map_clone: avoid suggesting `copied()` for &mut

4 years agofix redundant_pattern_matching lint
Aleksei Latyshev [Thu, 23 Apr 2020 08:40:16 +0000 (11:40 +0300)]
fix redundant_pattern_matching lint

- now it gives correct suggestion in case of macros
- better tests
- remove a couple of non-relevant tests

4 years agoAuto merge of #5527 - flip1995:rollup-pr2htfd, r=flip1995
bors [Sat, 25 Apr 2020 19:38:04 +0000 (19:38 +0000)]
Auto merge of #5527 - flip1995:rollup-pr2htfd, r=flip1995

Rollup of 5 pull requests

Successful merges:

 - #5408 (Downgrade match_bool to pedantic)
 - #5505 (Avoid running cargo+internal lints when not enabled)
 - #5516 (Add a note to the beta sections of release.md)
 - #5517 (Deploy time travel)
 - #5523 (Add lifetime test case for `new_ret_no_self`)

Failed merges:

r? @ghost

changelog: rollup

4 years agoRollup merge of #5523 - phansch:add-new-ret-no-self-testcase, r=flip1995
Philipp Krones [Sat, 25 Apr 2020 19:06:31 +0000 (21:06 +0200)]
Rollup merge of #5523 - phansch:add-new-ret-no-self-testcase, r=flip1995

Add lifetime test case for `new_ret_no_self`

cc https://github.com/rust-lang/rust-clippy/issues/734#issuecomment-619344352

changelog: none

4 years agoRollup merge of #5517 - flip1995:deploy_time_travel, r=Manishearth
Philipp Krones [Sat, 25 Apr 2020 19:06:30 +0000 (21:06 +0200)]
Rollup merge of #5517 - flip1995:deploy_time_travel, r=Manishearth

Deploy time travel

Since not only commits to the master branch, but also tags and the beta branch are deployed, we have to be cautious which version of the deploy script is used. GHA always runs the workflow that is commited on the `ref`, that gets tested. For tagged commits. this is 6 weeks outdated workflows/scripts. To prevent this, this workflow first checks out the deploy.sh script, the website templates and all python scripts generating files for the website.

changelog: none

4 years agoRollup merge of #5516 - flip1995:doc_release, r=phansch
Philipp Krones [Sat, 25 Apr 2020 19:06:28 +0000 (21:06 +0200)]
Rollup merge of #5516 - flip1995:doc_release, r=phansch

Add a note to the beta sections of release.md

changelog: none

4 years agoRollup merge of #5505 - flip1995:avoid_running_lints, r=matthiaskrgr
Philipp Krones [Sat, 25 Apr 2020 19:06:27 +0000 (21:06 +0200)]
Rollup merge of #5505 - flip1995:avoid_running_lints, r=matthiaskrgr

Avoid running cargo+internal lints when not enabled

r? @matthiaskrgr

changelog: none

4 years agoRollup merge of #5408 - dtolnay:matchbool, r=flip1995
Philipp Krones [Sat, 25 Apr 2020 19:06:26 +0000 (21:06 +0200)]
Rollup merge of #5408 - dtolnay:matchbool, r=flip1995

Downgrade match_bool to pedantic

I don't quite buy the justification in https://rust-lang.github.io/rust-clippy/. The justification is:

> It makes the code less readable.

In the Rust codebases I've worked in, I have found people were comfortable using `match bool` (selectively) to make code more readable. For example, initializing struct fields is a place where the indentation of `match` can work better than the indentation of `if`:

```rust
let _ = Struct {
    v: {
        ...
    },
    w: match doing_w {
        true => ...,
        false => ...,
    },
    x: Nested {
        c: ...,
        b: ...,
        a: ...,
    },
    y: if doing_y {
        ...
    } else { // :(
        ...
    },
    z: ...,
};
```

Or sometimes people prefer something a bit less pithy than `if` when the meaning of the bool doesn't read off clearly from the condition:

```rust
if set.insert(...) {
    ... // ???
} else {
    ...
}

match set.insert(...) {
    // set.insert returns false if already present
    false => ...,
    true => ...,
}
```

Or `match` can be a better fit when the bool is playing the role more of a value than a branch condition:

```rust
impl ErrorCodes {
    pub fn from(b: bool) -> Self {
        match b {
            true => ErrorCodes::Yes,
            false => ErrorCodes::No,
        }
    }
}
```

And then there's plain old it's-1-line-shorter, which means we get 25% more content on a screen when stacking a sequence of conditions:

```rust
let old_noun = match old_binding.is_import() {
    true => "import",
    false => "definition",
};
let new_participle = match new_binding.is_import() {
    true => "imported",
    false => "defined",
};
```

Bottom line is I think this lint fits the bill better as a pedantic lint; I don't think linting on this by default is justified.

changelog: Remove match_bool from default set of enabled lints

4 years agoAdd tests for #1654
flip1995 [Sat, 25 Apr 2020 18:51:23 +0000 (20:51 +0200)]
Add tests for #1654

4 years agoDon't trigger while_let_on_iterator when the iterator is recreated every iteration
flip1995 [Sat, 25 Apr 2020 18:51:02 +0000 (20:51 +0200)]
Don't trigger while_let_on_iterator when the iterator is recreated every iteration

4 years agoAuto merge of #5520 - matthiaskrgr:rustup_44, r=flip1995,phansch
bors [Sat, 25 Apr 2020 18:18:32 +0000 (18:18 +0000)]
Auto merge of #5520 - matthiaskrgr:rustup_44, r=flip1995,phansch

rustup https://github.com/rust-lang/rust/pull/71215/

There's currently an crash in `ui/new_without_default.rs` that I need to figure out how to avoid.

changelog: none

4 years agoUpdate issue_2356.stderr reference file
flip1995 [Sat, 25 Apr 2020 18:07:55 +0000 (20:07 +0200)]
Update issue_2356.stderr reference file

4 years agoUpdate while_let_on_iterator tests
flip1995 [Sat, 25 Apr 2020 18:01:22 +0000 (20:01 +0200)]
Update while_let_on_iterator tests

4 years agoFix while_let_on_iterator suggestion and make it MachineApplicable
flip1995 [Sat, 25 Apr 2020 18:00:00 +0000 (20:00 +0200)]
Fix while_let_on_iterator suggestion and make it MachineApplicable

4 years agoAdd lifetime test case for `new_ret_no_self`
Philipp Hansch [Sat, 25 Apr 2020 08:43:41 +0000 (10:43 +0200)]
Add lifetime test case for `new_ret_no_self`

4 years agoRenamed lint to `match_on_vec_items`
CrazyRoka [Sat, 25 Apr 2020 08:33:40 +0000 (11:33 +0300)]
Renamed lint to `match_on_vec_items`

4 years agoRemoved unnecessary code, added support for vector references
CrazyRoka [Fri, 24 Apr 2020 21:52:02 +0000 (00:52 +0300)]
Removed unnecessary code, added support for vector references

4 years agoAdded lint `match_vec_item`
CrazyRoka [Thu, 23 Apr 2020 21:28:18 +0000 (00:28 +0300)]
Added  lint `match_vec_item`

4 years agorustup https://github.com/rust-lang/rust/pull/71215/
Matthias Krüger [Fri, 24 Apr 2020 09:57:34 +0000 (11:57 +0200)]
rustup https://github.com/rust-lang/rust/pull/71215/

4 years agoDowngrade match_bool to pedantic
David Tolnay [Fri, 3 Apr 2020 00:36:49 +0000 (17:36 -0700)]
Downgrade match_bool to pedantic

4 years agoRun fetch before testing if master contains beta
flip1995 [Thu, 23 Apr 2020 21:24:58 +0000 (23:24 +0200)]
Run fetch before testing if master contains beta

4 years agoThe beta branch update should not require a force push
flip1995 [Thu, 23 Apr 2020 18:34:30 +0000 (20:34 +0200)]
The beta branch update should not require a force push

4 years agoAdd a note to the beta sections of release.md
flip1995 [Thu, 23 Apr 2020 18:14:06 +0000 (20:14 +0200)]
Add a note to the beta sections of release.md

4 years agoAuto merge of #5513 - matthiaskrgr:reg, r=phansch
bors [Thu, 23 Apr 2020 20:56:15 +0000 (20:56 +0000)]
Auto merge of #5513 - matthiaskrgr:reg, r=phansch

fix clippy_dev exit status and make regex match again

changelog: none

Fixes #5510

r? @phansch

4 years agoRemove apt-get upgrade again
flip1995 [Thu, 23 Apr 2020 18:45:39 +0000 (20:45 +0200)]
Remove apt-get upgrade again

4 years agoAlways use the deploy script and templates of the master branch
flip1995 [Thu, 23 Apr 2020 18:44:18 +0000 (20:44 +0200)]
Always use the deploy script and templates of the master branch

4 years agoAuto merge of #5498 - phansch:update_changelog, r=flip1995
bors [Thu, 23 Apr 2020 18:35:22 +0000 (18:35 +0000)]
Auto merge of #5498 - phansch:update_changelog, r=flip1995

Update CHANGELOG.md for Rust 1.43 and 1.44

[Rendered](https://github.com/phansch/rust-clippy/blob/update_changelog/CHANGELOG.md)

changelog: none

4 years agoREADME: fix lit count line
Matthias Krüger [Thu, 23 Apr 2020 14:08:40 +0000 (16:08 +0200)]
README: fix lit count line

It looks like after changing to "there are more than 120 lints", an older PR was merged
and resolving merge conflicts this was changed back to "there are 123 lints" causing the update-script to silently fail.

Changed back the README.md back to the new format fixes the problem.

4 years agoclippy_dev: make it fatal when the regex for updating lint count does not match
Matthias Krüger [Thu, 23 Apr 2020 13:51:03 +0000 (15:51 +0200)]
clippy_dev: make it fatal when the regex for updating lint count does not match

Fixes #5510

4 years agoAuto merge of #5508 - lzutao:rustup-71044, r=phansch
bors [Thu, 23 Apr 2020 05:08:29 +0000 (05:08 +0000)]
Auto merge of #5508 - lzutao:rustup-71044, r=phansch

Rustup "Remove `BodyAndCache`"

cc https://github.com/rust-lang/rust/pull/71044
changelog: none

4 years ago`predecessors_for` will be removed soon
lzutao [Thu, 23 Apr 2020 02:02:26 +0000 (09:02 +0700)]
`predecessors_for` will be removed soon

Co-Authored-By: ecstatic-morse <ecstaticmorse@gmail.com>
4 years agoRustup "Remove `BodyAndCache`"
Lzu Tao [Thu, 23 Apr 2020 01:39:35 +0000 (08:39 +0700)]
Rustup "Remove `BodyAndCache`"

4 years agoOnly run (late) internal lints, when they are warn/deny/forbid
flip1995 [Wed, 22 Apr 2020 18:51:58 +0000 (20:51 +0200)]
Only run (late) internal lints, when they are warn/deny/forbid

4 years agoOnly run cargo lints, when they are warn/deny/forbid
flip1995 [Tue, 21 Apr 2020 20:53:18 +0000 (22:53 +0200)]
Only run cargo lints, when they are warn/deny/forbid

4 years agoAuto merge of #5439 - rokob:lock-await, r=Manishearth
bors [Wed, 22 Apr 2020 15:50:32 +0000 (15:50 +0000)]
Auto merge of #5439 - rokob:lock-await, r=Manishearth

Lint for holding locks across await points

Fixes #4226

This introduces the lint await_holding_lock. For async functions, we iterate
over all types in generator_interior_types and look for types named MutexGuard,
RwLockReadGuard, or RwLockWriteGuard. If we find one then we emit a lint.

changelog: introduce the await_holding_lock lint

4 years agospan_lint_and_note now takes an Option<Span> for the note_span instead of just a...
Andy Weiss [Wed, 22 Apr 2020 04:28:23 +0000 (21:28 -0700)]
span_lint_and_note now takes an Option<Span> for the note_span instead of just a span

4 years agoMake lint also capture blocks and closures, adjust language to mention other mutex...
Andy Weiss [Fri, 17 Apr 2020 06:21:49 +0000 (23:21 -0700)]
Make lint also capture blocks and closures, adjust language to mention other mutex types

4 years agodon't test the code in the lint docs
Andy Weiss [Fri, 10 Apr 2020 05:12:34 +0000 (22:12 -0700)]
don't test the code in the lint docs

4 years agoSwitch to matching against full paths instead of just the last element of the path
Andy Weiss [Fri, 10 Apr 2020 04:50:23 +0000 (21:50 -0700)]
Switch to matching against full paths instead of just the last element of the path

4 years agoLint for holding locks across await points
Andy Weiss [Wed, 8 Apr 2020 04:20:37 +0000 (21:20 -0700)]
Lint for holding locks across await points

Fixes #4226

This introduces the lint await_holding_lock. For async functions, we iterate
over all types in generator_interior_types and look for types named MutexGuard,
RwLockReadGuard, or RwLockWriteGuard. If we find one then we emit a lint.

4 years agoAlso mention `--fix` for nightly users
Philipp Hansch [Tue, 21 Apr 2020 05:06:44 +0000 (07:06 +0200)]
Also mention `--fix` for nightly users

4 years agoAuto merge of #5499 - matthiaskrgr:crash_5497, r=flip1995
bors [Mon, 20 Apr 2020 23:54:15 +0000 (23:54 +0000)]
Auto merge of #5499 - matthiaskrgr:crash_5497, r=flip1995

fix crash on issue-69020-assoc-const-arith-overflow.rs

Fixes #5497

changelog: fix crash on rustc test issue-69020-assoc-const-arith-overflow.rs

4 years agofix crash on issue-69020-assoc-const-arith-overflow.rs
Matthias Krüger [Mon, 20 Apr 2020 21:00:01 +0000 (23:00 +0200)]
fix crash on issue-69020-assoc-const-arith-overflow.rs

Fixes #5497

4 years agoAuto merge of #5496 - phansch:markdown-link, r=flip1995
bors [Mon, 20 Apr 2020 21:00:25 +0000 (21:00 +0000)]
Auto merge of #5496 - phansch:markdown-link, r=flip1995

util/fetch_prs_between.sh: Add Markdown formatted link

This can then be easily copy/pasted into the changelog :blue_heart:

changelog: none

4 years agoAddress review comments
Philipp Hansch [Mon, 20 Apr 2020 20:53:00 +0000 (22:53 +0200)]
Address review comments

4 years agoAuto merge of #5495 - phansch:update_changelog_docs, r=flip1995
bors [Mon, 20 Apr 2020 20:40:45 +0000 (20:40 +0000)]
Auto merge of #5495 - phansch:update_changelog_docs, r=flip1995

Update the changelog update documentation

I just started working on updating the changelog. Hopefully the docs are a bit clearer now?

r? @flip1995

changelog: none

4 years agoremark fixes
Philipp Hansch [Mon, 20 Apr 2020 20:29:27 +0000 (22:29 +0200)]
remark fixes

4 years agoUpdate CHANGELOG.md for Rust 1.43 and 1.44
Philipp Hansch [Mon, 20 Apr 2020 20:22:05 +0000 (22:22 +0200)]
Update CHANGELOG.md for Rust 1.43 and 1.44

4 years agoAuto merge of #5332 - DevinR528:if-let-else-mutex, r=flip1995
bors [Mon, 20 Apr 2020 20:21:33 +0000 (20:21 +0000)]
Auto merge of #5332 - DevinR528:if-let-else-mutex, r=flip1995

If let else mutex

changelog: Adds lint to catch incorrect use of `Mutex::lock` in `if let` expressions with lock calls in any of the blocks.

closes: #5219