]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #5637 - montrivo:feature/vec_resize_to_zero, r=yaahc,flip1995
Philipp Krones [Sun, 31 May 2020 12:57:32 +0000 (14:57 +0200)]
Rollup merge of #5637 - montrivo:feature/vec_resize_to_zero, r=yaahc,flip1995

new lint: vec_resize_to_zero

implements #5444

changelog: new lint vec_resize_to_zero

4 years agoAuto merge of #5655 - matthiaskrgr:source_mod, r=flip1995
bors [Sun, 31 May 2020 12:55:26 +0000 (12:55 +0000)]
Auto merge of #5655 - matthiaskrgr:source_mod, r=flip1995

cargo_dev: add ra-setup

It takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: cargo dev ra-setup /absolute/path/to/rust/

cc https://github.com/rust-analyzer/rust-analyzer/issues/3517
cc https://github.com/rust-lang/rust-clippy/issues/5514

changelog: none

4 years agoAuto merge of #5665 - flip1995:rustup, r=matthiaskrgr
bors [Sun, 31 May 2020 12:23:08 +0000 (12:23 +0000)]
Auto merge of #5665 - flip1995:rustup, r=matthiaskrgr

Rustup

r? @matthiaskrgr

I finally got to doing the rustup. Sorry for taking so long, I was busy the last few days.

@ebroto FYI: I had to add b6c58f0 to make Clippy pass the rustc test suite.

changelog: none

4 years agoFix sync fallout
flip1995 [Sun, 31 May 2020 12:05:57 +0000 (14:05 +0200)]
Fix sync fallout

4 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Sun, 31 May 2020 11:40:23 +0000 (13:40 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

4 years agonew lint: vec_resize_to_zero
Tim Nielens [Fri, 22 May 2020 22:07:09 +0000 (00:07 +0200)]
new lint: vec_resize_to_zero

4 years agoReturn early to avoid ICE
Yuki Okushi [Sat, 30 May 2020 09:48:54 +0000 (18:48 +0900)]
Return early to avoid ICE

4 years agoadd testcase that no longer ICEs
Matthias Krüger [Fri, 29 May 2020 20:46:05 +0000 (22:46 +0200)]
add testcase that no longer ICEs

Fixes #3969

4 years agoAuto merge of #72671 - flip1995:clippyup, r=Xanewok
bors [Fri, 29 May 2020 11:16:45 +0000 (11:16 +0000)]
Auto merge of #72671 - flip1995:clippyup, r=Xanewok

Update Clippy, RLS, and rustfmt

r? @Dylan-DPC

This makes Clippy test-pass again: 3089c3b

Otherwise this includes bugfixes and a few new lints.

Fixes #72231
Fixes #72232

4 years agoRollup merge of #72466 - lzutao:stabilize_str-strip, r=dtolnay
Dylan DPC [Fri, 29 May 2020 00:33:11 +0000 (02:33 +0200)]
Rollup merge of #72466 - lzutao:stabilize_str-strip, r=dtolnay

Stabilize str_strip feature

This PR stabilizes these APIs:

```rust
impl str {
    /// Returns a string slice with the prefix removed.
    ///
    /// If the string starts with the pattern `prefix`, `Some` is returned with the substring where
    /// the prefix is removed. Unlike `trim_start_matches`, this method removes the prefix exactly
    /// once.
    pub fn strip_prefix<'a, P: Pattern<'a>>(&'a self, prefix: P) -> Option<&'a str>;

    /// Returns a string slice with the suffix removed.
    ///
    /// If the string ends with the pattern `suffix`, `Some` is returned with the substring where
    /// the suffix is removed. Unlike `trim_end_matches`, this method removes the suffix exactly
    /// once.
    pub fn strip_suffix<'a, P>(&'a self, suffix: P) -> Option<&'a str>
    where
        P: Pattern<'a>,
        <P as Pattern<'a>>::Searcher: ReverseSearcher<'a>;
}
```

Closes  #67302

4 years agoTemp fix: don't run cargo lint tests in rustc test suite
flip1995 [Thu, 28 May 2020 15:19:30 +0000 (17:19 +0200)]
Temp fix: don't run cargo lint tests in rustc test suite

4 years agoMerge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2
flip1995 [Thu, 28 May 2020 13:45:24 +0000 (15:45 +0200)]
Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2

4 years agoclippy_dev: add ra_setup
Matthias Krüger [Wed, 27 May 2020 12:08:31 +0000 (14:08 +0200)]
clippy_dev: add ra_setup

This takes an absolute path to a rustc repo and adds path-dependencies
that point towards the respective rustc subcrates into the Cargo.tomls of
the clippy and clippy_lints crate.

This allows rustc-analyzer to show proper type annotations etc on rustc-internals inside the clippy repo.

Usage: cargo dev ra-setup /absolute/path/to/rust/

cc https://github.com/rust-analyzer/rust-analyzer/issues/3517
cc https://github.com/rust-lang/rust-clippy/issues/5514

4 years agolen_zero: skip ranges if feature `range_is_empty` is not enabled
Eduardo Broto [Wed, 27 May 2020 22:36:15 +0000 (00:36 +0200)]
len_zero: skip ranges if feature `range_is_empty` is not enabled

4 years agoAuto merge of #5652 - rust-lang:flip1995-patch-1, r=yaahc
bors [Wed, 27 May 2020 18:55:57 +0000 (18:55 +0000)]
Auto merge of #5652 - rust-lang:flip1995-patch-1, r=yaahc

Fail bors on missing changelog

Bors stopped failed if the changelog was missing. Instead it waited 2h (?) and then timed out.

changelog: none

4 years agoAuto merge of #5631 - ThibsG:ExtendUselessConversion, r=matthiaskrgr
bors [Wed, 27 May 2020 13:06:59 +0000 (13:06 +0000)]
Auto merge of #5631 - ThibsG:ExtendUselessConversion, r=matthiaskrgr

Extend useless conversion

This PR extends `useless_conversion` lint with `TryFrom` and `TryInto`

fixes: #5344

changelog: Extend `useless_conversion` with `TryFrom` and `TryInto`

4 years agoAuto merge of #5653 - matthiaskrgr:rustup_47, r=flip1995
bors [Wed, 27 May 2020 12:30:32 +0000 (12:30 +0000)]
Auto merge of #5653 - matthiaskrgr:rustup_47, r=flip1995

rustup https://github.com/rust-lang/rust/pull/72342, allow unused_crate_dependencies

changelog: none

4 years agorustup https://github.com/rust-lang/rust/pull/72342, allow unused_crate_dependencies
Matthias Krüger [Wed, 27 May 2020 11:55:57 +0000 (13:55 +0200)]
rustup https://github.com/rust-lang/rust/pull/72342, allow unused_crate_dependencies

4 years agoAuto merge of #5651 - ebroto:names_as_early_passes, r=flip1995
bors [Tue, 26 May 2020 23:12:16 +0000 (23:12 +0000)]
Auto merge of #5651 - ebroto:names_as_early_passes, r=flip1995

Register redundant_field_names and non_expressive_names as early passes

Similar names was moved to a pre-expansion pass to solve #2927, so I'm avoiding linting on code from expansion, which makes the dogfood (mostly, see below) pass.

I had to change new_without_default though, and although I understand why it was not triggering before, TBH I don't see why the binding inside the nested `if_chain` is being linted now. Any ideas? (it seems legit though as the code can be changed by the user)

changelog: Register redundant_field_names and non_expressive_names as early passes

Fixes #5356
Fixes #5521

4 years agoFail bors on missing changelog
Philipp Krones [Tue, 26 May 2020 22:51:08 +0000 (00:51 +0200)]
Fail bors on missing changelog

4 years agoAuto merge of #5650 - imbsky:actions-cache-v2, r=flip1995
bors [Tue, 26 May 2020 22:44:56 +0000 (22:44 +0000)]
Auto merge of #5650 - imbsky:actions-cache-v2, r=flip1995

Bump actions/cache from v1 to v2

We just released v2. That includes a lot of improvements.
https://github.com/actions/cache/releases/tag/v2.0.0

changelog: none

4 years agoAvoid triggering similar names on code from expansion
Eduardo Broto [Tue, 26 May 2020 22:06:50 +0000 (00:06 +0200)]
Avoid triggering similar names on code from expansion

4 years agoBump actions/cache from v1 to v2
Sora Morimoto [Tue, 26 May 2020 21:25:38 +0000 (06:25 +0900)]
Bump actions/cache from v1 to v2

4 years agoFix fallout in similar_names
flip1995 [Tue, 12 May 2020 14:50:00 +0000 (16:50 +0200)]
Fix fallout in similar_names

4 years agoFix fallout in redundant_field_names
flip1995 [Tue, 12 May 2020 14:26:55 +0000 (16:26 +0200)]
Fix fallout in redundant_field_names

4 years agoRegister redundant_field_names and non_expressive_names as early passes
flip1995 [Thu, 23 Apr 2020 22:14:03 +0000 (00:14 +0200)]
Register redundant_field_names and non_expressive_names as early passes

4 years agoAdd test cases for broader coverage
ThibsG [Tue, 26 May 2020 16:40:42 +0000 (18:40 +0200)]
Add test cases for broader coverage

4 years agoAuto merge of #5648 - returntrip:master, r=matthiaskrgr
bors [Tue, 26 May 2020 15:23:50 +0000 (15:23 +0000)]
Auto merge of #5648 - returntrip:master, r=matthiaskrgr

Add license symlink

To make it easier for Linux distributions to ship the licenses text within the rustc_tools_util crate directory.

changelog: none

4 years agoAuto merge of #5609 - phansch:empty-line-after-outer-attr-fix, r=flip1995
bors [Tue, 26 May 2020 15:10:35 +0000 (15:10 +0000)]
Auto merge of #5609 - phansch:empty-line-after-outer-attr-fix, r=flip1995

Make empty_line_after_outer_attr an early lint

Fixes #5567

Unfortunately I couldn't find a way to reproduce the issue without syn/quote. Considering that most real-world macros use syn and/or quote, I think it's okay to pull them in anyway.

changelog: Fix false positive in [`empty_line_after_outer_attr`]

4 years agoBe less specific about quote and syn versions
Philipp Hansch [Tue, 26 May 2020 14:51:04 +0000 (16:51 +0200)]
Be less specific about quote and syn versions

4 years agoUsing dev-dependencies doesn't seem to work w/ compiletest
Philipp Hansch [Sun, 17 May 2020 17:13:33 +0000 (19:13 +0200)]
Using dev-dependencies doesn't seem to work w/ compiletest

4 years agoSpecify quote and syn versions
Philipp Hansch [Sun, 17 May 2020 17:09:07 +0000 (19:09 +0200)]
Specify quote and syn versions

4 years agoMake empty_line_after_outer_attr an early lint
Philipp Hansch [Sun, 17 May 2020 16:14:43 +0000 (18:14 +0200)]
Make empty_line_after_outer_attr an early lint

4 years agoAuto merge of #5638 - ebroto:issue_5628_add_suggestion_for_reversed_empty_ranges...
bors [Tue, 26 May 2020 11:56:16 +0000 (11:56 +0000)]
Auto merge of #5638 - ebroto:issue_5628_add_suggestion_for_reversed_empty_ranges, r=phansch

reversed_empty_ranges: add suggestion for &slice[N..N]

As discussed in the issue thread, the user accepted this solution. Let me know if this is what we want, or if changing the way we lint the N..N case is prefered.

changelog: reversed_empty_ranges: add suggestion for &slice[N..N]

Closes #5628

4 years agoAuto merge of #5562 - flip1995:clippyup_up, r=phansch
bors [Tue, 26 May 2020 11:42:15 +0000 (11:42 +0000)]
Auto merge of #5562 - flip1995:clippyup_up, r=phansch

Update contributing section about syncing Clippy

[Rendered](https://github.com/flip1995/rust-clippy/blob/clippyup_up/CONTRIBUTING.md#fixing-build-failures-caused-by-rust)

r? @oli-obk Did I get the sync process right?

changelog: none

4 years agoAuto merge of #5636 - ebroto:issue_5041, r=phansch
bors [Tue, 26 May 2020 06:23:58 +0000 (06:23 +0000)]
Auto merge of #5636 - ebroto:issue_5041, r=phansch

multiple_crate_versions: skip dev and build deps

changelog: multiple_crate_versions: skip dev and build deps

Closes #5041

4 years agoAuto merge of #5647 - ebroto:5644_allow_ptr_arg_in_arg_position, r=flip1995
bors [Mon, 25 May 2020 21:47:07 +0000 (21:47 +0000)]
Auto merge of #5647 - ebroto:5644_allow_ptr_arg_in_arg_position, r=flip1995

ptr_arg: honor `allow` attribute on arguments

The `intravisit::Visitor` impl for `LateContextAndPass` only takes into account the attributes of a function parameter inside the `check_param` method. `ptr_arg` starts its heuristics at `check_item` / `check_impl_item` / `check_trait_item`, so the `allow` is not taken into account automatically.

changelog: ptr_arg: honor `allow` attribute on arguments

Fixes #5644

4 years agoptr_arg: honor `allow` attr on arguments
Eduardo Broto [Mon, 25 May 2020 21:09:06 +0000 (23:09 +0200)]
ptr_arg: honor `allow` attr on arguments

4 years agoTo make it easier for Linux distributions, ship the licenses text within
returntrip [Mon, 25 May 2020 21:06:08 +0000 (23:06 +0200)]
To make it easier for Linux distributions, ship the licenses text within
each crate directory.

4 years agoAuto merge of #4429 - jeremystucki:or_fun_call, r=flip1995
bors [Mon, 25 May 2020 20:15:34 +0000 (20:15 +0000)]
Auto merge of #4429 - jeremystucki:or_fun_call, r=flip1995

Update 'or_fun_call' to ignore calls to len

Resolves #1653

changelog: Update `or_fun_call`: Allow calls to `len` for Slice, Array & Vec.

4 years agoUpdate ui test
Jeremy Stucki [Mon, 25 May 2020 19:38:46 +0000 (21:38 +0200)]
Update ui test

4 years agoFix build
Jeremy Stucki [Mon, 25 May 2020 19:23:39 +0000 (21:23 +0200)]
Fix build

4 years agoIgnore calls to 'len'
Jeremy Stucki [Wed, 21 Aug 2019 19:19:28 +0000 (21:19 +0200)]
Ignore calls to 'len'

4 years agoAdd tests
Jeremy Stucki [Wed, 21 Aug 2019 19:18:43 +0000 (21:18 +0200)]
Add tests

4 years agoAuto merge of #5641 - ThibsG:DocCommonTools, r=flip1995
bors [Mon, 25 May 2020 19:33:52 +0000 (19:33 +0000)]
Auto merge of #5641 - ThibsG:DocCommonTools, r=flip1995

Add common lint tools doc

This PR starts adding some documentation about linting tools.

`Retrieving all methods of a type` is not covered at this time.

fixes partially: #3843

changelog: none

4 years agoAuto merge of #5635 - montrivo:bugfix/option_option_test_case, r=flip1995
bors [Mon, 25 May 2020 19:22:08 +0000 (19:22 +0000)]
Auto merge of #5635 - montrivo:bugfix/option_option_test_case, r=flip1995

option_option test case #4298

Adds regression test case for #4298.

The bug seems still present although rust Playground said otherwise.

changelog: none

4 years agoreversed_empty_ranges: add suggestion for &slice[N..N]
Eduardo Broto [Sat, 23 May 2020 20:07:03 +0000 (22:07 +0200)]
reversed_empty_ranges: add suggestion for &slice[N..N]

4 years agoAdd common lint tools doc
ThibsG [Sat, 23 May 2020 07:35:56 +0000 (09:35 +0200)]
Add common lint tools doc

4 years agoExtend `useless_conversion` lint with TryInto
ThibsG [Fri, 22 May 2020 09:46:17 +0000 (11:46 +0200)]
Extend `useless_conversion` lint with TryInto

4 years agoExtend `useless_conversion` lint with TryFrom
ThibsG [Sat, 9 May 2020 19:28:31 +0000 (21:28 +0200)]
Extend `useless_conversion` lint with TryFrom

4 years agoUse find_map instead of find() + map()
Eduardo Broto [Sun, 24 May 2020 19:17:54 +0000 (21:17 +0200)]
Use find_map instead of find() + map()

4 years agomultiple_crate_versions: skip dev and build deps
Eduardo Broto [Fri, 22 May 2020 20:39:19 +0000 (22:39 +0200)]
multiple_crate_versions: skip dev and build deps

4 years agoMake the name of the crate available in cargo UI tests
Eduardo Broto [Fri, 22 May 2020 20:30:28 +0000 (22:30 +0200)]
Make the name of the crate available in cargo UI tests

4 years agoAuto merge of #5616 - euclio:no-derive-suggestion, r=phansch,flip1995
bors [Mon, 25 May 2020 17:19:00 +0000 (17:19 +0000)]
Auto merge of #5616 - euclio:no-derive-suggestion, r=phansch,flip1995

new_without_default: do not suggest deriving

---

changelog: do not suggest deriving `Default` in `new_without_default`

This commit changes the behavior of the `new_without_default` lint to not suggest deriving `Default`. This suggestion is misleading if the `new` implementation does something different than what a derived `Default` implementation would do, because then the two methods would not be equivalent.

Instead, the `can_derive_default` check is removed, and we always suggest implementing `Default` in terms of `new()`.

4 years agoAuto merge of #5639 - nickrtorres:unnecessary-mut-passed-doc-cleanup, r=phansch
bors [Mon, 25 May 2020 17:02:12 +0000 (17:02 +0000)]
Auto merge of #5639 - nickrtorres:unnecessary-mut-passed-doc-cleanup, r=phansch

Clarify the documentation of the `unnecessary_mut_passed` lint

fixes #5433 by replacing "giving" with "passing"

changelog: Clarifies documentation for `unnecessary_mut_passed`

4 years agoAuto merge of #5646 - flip1995:rustup, r=matthiaskrgr
bors [Mon, 25 May 2020 16:42:50 +0000 (16:42 +0000)]
Auto merge of #5646 - flip1995:rustup, r=matthiaskrgr

Rustup

r? @phansch

changelog: none

4 years agoAlso fetch origin before merging master into the rustup branch
Philipp Krones [Mon, 25 May 2020 15:11:07 +0000 (17:11 +0200)]
Also fetch origin before merging master into the rustup branch

4 years agoClarify the documentation of the `unnecessary_mut_passed` lint
Nick Torres [Sat, 23 May 2020 23:14:38 +0000 (16:14 -0700)]
Clarify the documentation of the `unnecessary_mut_passed` lint

4 years agoiterate List by value
Bastian Kauschke [Sat, 23 May 2020 09:49:24 +0000 (11:49 +0200)]
iterate List by value

4 years agoUse `OnceCell` instead of `Once`
Dylan MacKenzie [Sat, 16 May 2020 04:44:28 +0000 (21:44 -0700)]
Use `OnceCell` instead of `Once`

4 years agooption_option test case #4298
Tim Nielens [Fri, 22 May 2020 17:09:24 +0000 (19:09 +0200)]
option_option test case #4298

4 years agonew_without_default: do not suggest deriving
Andy Russell [Mon, 18 May 2020 22:35:49 +0000 (18:35 -0400)]
new_without_default: do not suggest deriving

4 years agoStabilize str_strip feature
Lzu Tao [Fri, 22 May 2020 15:29:47 +0000 (15:29 +0000)]
Stabilize str_strip feature

4 years agoAuto merge of #5632 - flip1995:rustup, r=phansch
bors [Fri, 22 May 2020 13:00:38 +0000 (13:00 +0000)]
Auto merge of #5632 - flip1995:rustup, r=phansch

Rustup

changelog: none

4 years agoFix dogfood fallout
flip1995 [Fri, 22 May 2020 12:45:51 +0000 (14:45 +0200)]
Fix dogfood fallout

4 years agoAlso install llvm-tools on toolchain setup
flip1995 [Fri, 22 May 2020 00:40:39 +0000 (02:40 +0200)]
Also install llvm-tools on toolchain setup

4 years agoAuto merge of #5614 - ebroto:test_cargo_lints, r=flip1995
bors [Thu, 21 May 2020 14:43:56 +0000 (14:43 +0000)]
Auto merge of #5614 - ebroto:test_cargo_lints, r=flip1995

Test cargo lints

changelog: Add infrastructure to test cargo lints

Closes #5603

4 years agoRelax fs layout so that multiple pass/fail manifests are possible
Eduardo Broto [Thu, 21 May 2020 13:34:48 +0000 (15:34 +0200)]
Relax fs layout so that multiple pass/fail manifests are possible

4 years agoAvoid triggering match_wildcard_for_single_variants
Eduardo Broto [Thu, 21 May 2020 12:47:13 +0000 (14:47 +0200)]
Avoid triggering match_wildcard_for_single_variants

4 years agoAddress comments from PR review
Eduardo Broto [Thu, 21 May 2020 12:46:04 +0000 (14:46 +0200)]
Address comments from PR review

4 years agoAdd documentation for testing cargo lints
Eduardo Broto [Mon, 18 May 2020 19:39:56 +0000 (21:39 +0200)]
Add documentation for testing cargo lints

4 years agoAdapt `cargo dev new_lint` to create tests for cargo lints
Eduardo Broto [Mon, 18 May 2020 19:03:37 +0000 (21:03 +0200)]
Adapt `cargo dev new_lint` to create tests for cargo lints

4 years agoAdd test for multiple_crate_versions
Eduardo Broto [Mon, 18 May 2020 18:58:02 +0000 (20:58 +0200)]
Add test for multiple_crate_versions

Make the output of the lint deterministic by sorting the versions

4 years agoAdd test for cargo_common_metadata
Eduardo Broto [Mon, 18 May 2020 18:56:33 +0000 (20:56 +0200)]
Add test for cargo_common_metadata

Fix missing `authors` entry in the provided example

4 years agoAdd test for wildcard_dependencies
Eduardo Broto [Mon, 18 May 2020 18:55:12 +0000 (20:55 +0200)]
Add test for wildcard_dependencies

4 years agoAdapt compile-test to run tests for cargo lints
Eduardo Broto [Mon, 18 May 2020 18:54:09 +0000 (20:54 +0200)]
Adapt compile-test to run tests for cargo lints

4 years agoAuto merge of #5611 - rrbutani:master, r=flip1995
bors [Wed, 20 May 2020 14:15:12 +0000 (14:15 +0000)]
Auto merge of #5611 - rrbutani:master, r=flip1995

Add to the list of words clippy::doc_markdown ignores

"TypeScript" is the only one of these I actually ran into organically; I can remove the others if they're too much.

changelog: Add to the list of words `clippy::doc_markdown` ignores

4 years agoAuto merge of #5622 - elichai:2020-05-match_wild_err_arm, r=flip1995
bors [Wed, 20 May 2020 14:02:06 +0000 (14:02 +0000)]
Auto merge of #5622 - elichai:2020-05-match_wild_err_arm, r=flip1995

Downgrade `match_wild_err_arm` to pedantic and update help messages

Hi,
This fixes #3688 and downgrades `match_wild_err_arm` to pedantic.
There are a lot of different reasons in that issue, for me the biggest are:
1. Rust's errors aren't like Java's exceptions because they're type safe and in most cases the type of error can't change by itself.
2. Sometimes matching can be more ergonomic, and before the `track_caller` feature got introduced it was actually easier to track the panic location with explicit `panic!` than with `expect`.

Currently clippy is failing to build because of a breaking change in https://github.com/rust-lang/rust/pull/69171 I tried fixing it but it is too complex for my little knowledge of clippy and rustc so I'll leave that to people who know what they're doing :)

Another thing, if rustc is breaking clippy a lot then maybe it's better to use something like `miri` does, where it's hard codes the latest tested rustc commit and they keep bumping it, that way when you develop locally it should work even if there was a breaking change (https://github.com/rust-lang/miri/blob/master/rustup-toolchain#L23-L29)

changelog: Downgrade `match_wild_err_arm` to pedantic

4 years agoUpdate future-not-send stderr output
Elichai Turkel [Wed, 20 May 2020 13:46:30 +0000 (16:46 +0300)]
Update future-not-send stderr output

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 agoMake match_wild_err_arm pedantic, and update help messages
Elichai Turkel [Wed, 20 May 2020 10:23:51 +0000 (13:23 +0300)]
Make match_wild_err_arm pedantic, and update help messages

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 #5582 - vtmargaryan:match_wildcard_for_single_variants, r=flip1995
bors [Wed, 20 May 2020 12:51:28 +0000 (12:51 +0000)]
Auto merge of #5582 - vtmargaryan:match_wildcard_for_single_variants, r=flip1995

New lint: `match_wildcard_for_single_variants`

changelog: Added a new lint match_wildcard_for_single_variants to warn on enum matches where a wildcard is used to match a single variant

Closes #5556

4 years agoAuto merge of #5621 - flip1995:rustup, r=phansch
bors [Wed, 20 May 2020 12:09:24 +0000 (12:09 +0000)]
Auto merge of #5621 - flip1995:rustup, r=phansch

Rustup

@oli-obk Do you know, how we can enforce (ui-)tests pass in rust-lang/rust for Clippy? I can open a PR for this, if you tell me what would be necessary for this.

changelog: none

4 years agoFix dogfood fallout
flip1995 [Wed, 20 May 2020 11:32:53 +0000 (13:32 +0200)]
Fix dogfood fallout

4 years agoUpdate test after const_ptr functions are must_use now
flip1995 [Tue, 19 May 2020 14:12:03 +0000 (16:12 +0200)]
Update test after const_ptr functions are must_use now

4 years agoMerge remote-tracking branch 'upstream/master' into rustup3
flip1995 [Wed, 20 May 2020 11:25:05 +0000 (13:25 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup3

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 agoAdd note, that a merge commit after push is necessary
flip1995 [Tue, 19 May 2020 14:36:14 +0000 (16:36 +0200)]
Add note, that a merge commit after push is necessary

4 years agoAdd note that a subtree fix and stack limit increase is required
flip1995 [Tue, 19 May 2020 13:18:16 +0000 (15:18 +0200)]
Add note that a subtree fix and stack limit increase is required

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 agoAdd to the list of words clippy::doc_markdown ignores
Rahul Butani [Mon, 18 May 2020 03:21:02 +0000 (22:21 -0500)]
Add to the list of words clippy::doc_markdown ignores

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 agoAuto merge of #5568 - ThibsG:RenameIdentityConversionLint, r=flip1995
bors [Sun, 17 May 2020 11:29:04 +0000 (11:29 +0000)]
Auto merge of #5568 - ThibsG:RenameIdentityConversionLint, r=flip1995

Rename lint `identity_conversion` to `useless_conversion`

Lint name `identity_conversion` was misleading, so this PR renames it to `useless_conversion`.

As decision has not really came up in the issue comments, this PR will probably need discussion.

fixes #3106

changelog: Rename lint `identity_conversion` to `useless_conversion`

4 years agoAuto merge of #5529 - alex-700:improve-option-and-then-some-lint, r=phansch
bors [Sun, 17 May 2020 10:58:56 +0000 (10:58 +0000)]
Auto merge of #5529 - alex-700:improve-option-and-then-some-lint, r=phansch

Improve `option_and_then_some` lint

fixed #5492

changelog: Improve and generalize `option_and_then_some` and rename it to `bind_instead_of_map`.

4 years agoimprove and generalize `option_and_then_some` lint
Aleksei Latyshev [Sat, 25 Apr 2020 20:33:11 +0000 (23:33 +0300)]
improve and generalize `option_and_then_some` lint

- rename it to bind_instead_of_map

4 years agoAuto merge of #5608 - flip1995:rustup, r=phansch
bors [Sun, 17 May 2020 05:41:39 +0000 (05:41 +0000)]
Auto merge of #5608 - flip1995:rustup, r=phansch

Rustup with git subtree

The commits from the last rustup #5587, are again included in this rustup, since I rebased the rustup. Lesson learned: never rebase, only merge when working with git subtree.

changelog: none

4 years agoBetter explain remotes in the sync process.
Philipp Krones [Sat, 16 May 2020 23:38:01 +0000 (01:38 +0200)]
Better explain remotes in the sync process.

4 years agoRun fmt
flip1995 [Sat, 16 May 2020 23:18:43 +0000 (01:18 +0200)]
Run fmt