]> git.lizzy.rs Git - rust.git/log
rust.git
5 years agoFix `useless_format` suggestions
Michael Wright [Sun, 24 Feb 2019 05:30:08 +0000 (07:30 +0200)]
Fix `useless_format` suggestions

5 years agoAuto merge of #3801 - Wilfred:patch-1, r=Manishearth
bors [Sat, 23 Feb 2019 00:23:56 +0000 (00:23 +0000)]
Auto merge of #3801 - Wilfred:patch-1, r=Manishearth

Fix broken markdown in README.md

5 years agoFix broken markdown in README.md
Wilfred Hughes [Sat, 23 Feb 2019 00:20:57 +0000 (00:20 +0000)]
Fix broken markdown in README.md

5 years agoAuto merge of #3796 - rust-lang:clarify-readme, r=oli-obk
bors [Fri, 22 Feb 2019 09:18:21 +0000 (09:18 +0000)]
Auto merge of #3796 - rust-lang:clarify-readme, r=oli-obk

Clarify lint groups in readme

I'm explicitly avoiding mention of the deprecated/restriction lint groups, those exist more for testing purposes and are not really something people should be using.

r? @oli-obk @phansch

fixes #2964

5 years agoClarify lint groups in readme
Manish Goregaokar [Fri, 22 Feb 2019 07:56:49 +0000 (13:26 +0530)]
Clarify lint groups in readme

5 years agoAuto merge of #3795 - mikerite:test-rustfmt, r=phansch
bors [Fri, 22 Feb 2019 06:54:25 +0000 (06:54 +0000)]
Auto merge of #3795 - mikerite:test-rustfmt, r=phansch

Allow rustfmt to run on more tests

5 years agorustfmt tests/ui/methods.rs
Michael Wright [Fri, 22 Feb 2019 06:05:21 +0000 (08:05 +0200)]
rustfmt tests/ui/methods.rs

5 years agoAdd `#[rustfmt::skip]` to methods tests
Michael Wright [Fri, 22 Feb 2019 05:49:17 +0000 (07:49 +0200)]
Add `#[rustfmt::skip]` to methods tests

Many people run rustfmt automatically on save. Format-dependent tests
should be marked with `#[rustfmt::skip]` to prevent accidental
reformatting from this. As a bonus the rest of the code can the formatted.

5 years agoAuto merge of #3789 - bzzzzzz:needless_range_loop_bugfix, r=oli-obk
bors [Thu, 21 Feb 2019 09:36:13 +0000 (09:36 +0000)]
Auto merge of #3789 - bzzzzzz:needless_range_loop_bugfix, r=oli-obk

Make needless_range_loop not applicable to structures without iter method

Fixes https://github.com/rust-lang/rust-clippy/issues/3788

Now we will start lint indexed structure only if it has known iter or iter_mut method implemented.

5 years agoFixed formatting and typo
bzzzz [Wed, 20 Feb 2019 18:12:24 +0000 (10:12 -0800)]
Fixed formatting and typo

5 years agoAuto merge of #3781 - uniphil:write_with_newline_false_positive, r=oli-obk
bors [Wed, 20 Feb 2019 16:37:32 +0000 (16:37 +0000)]
Auto merge of #3781 - uniphil:write_with_newline_false_positive, r=oli-obk

Don't check [print/write]_with_newline on raw strings

Some tests for #3778 and some maybe-not-the-greatest code that passes those tests!

I didn't run `fmt` because a) it doesn't seem to install on nightly for me, and b) on stable it wanted to apply formatting to over 90 files. Happy to make any tweaks though!

I suspect this contribution may require more than just tweaks. I'm still sort of new to rust so it may not be idiomatic, and the specific approach I took feels a little heavy-handed and brittle. I'm happy to make changes with some guidance, or equally happy if this gives a starting place for someone else to do it better :)

5 years agoAuto merge of #3779 - mikerite:fix-3704, r=phansch
bors [Wed, 20 Feb 2019 09:21:18 +0000 (09:21 +0000)]
Auto merge of #3779 - mikerite:fix-3704, r=phansch

Improve `iter_cloned_collect` suggestions

Fixes #3704

5 years agoMake needless_range_loop not applicable to structures without iter method
bzzzz [Wed, 20 Feb 2019 08:10:25 +0000 (00:10 -0800)]
Make needless_range_loop not applicable to structures without iter method

5 years agoFormat again
Michael Wright [Wed, 20 Feb 2019 04:06:00 +0000 (06:06 +0200)]
Format again

5 years agoAuto merge of #3776 - notriddle:drop-bounds, r=oli-obk
bors [Tue, 19 Feb 2019 09:46:29 +0000 (09:46 +0000)]
Auto merge of #3776 - notriddle:drop-bounds, r=oli-obk

Add a lint to warn on `T: Drop` bounds

**What it does:** Checks for generics with `std::ops::Drop` as bounds.

**Why is this bad?** `Drop` bounds do not really accomplish anything.
A type may have compiler-generated drop glue without implementing the
`Drop` trait itself. The `Drop` trait also only has one method,
`Drop::drop`, and that function is by fiat not callable in user code.
So there is really no use case for using `Drop` in trait bounds.

**Known problems:** None.

**Example:**
```rust
fn foo<T: Drop>() {}
```

Fixes #3773

5 years agoAuto merge of #3786 - rust-lang:rustup, r=Manishearth
bors [Tue, 19 Feb 2019 07:35:44 +0000 (07:35 +0000)]
Auto merge of #3786 - rust-lang:rustup, r=Manishearth

Rustup to rustc master (32471f7ea 2019-02-19)

None

5 years agoRustup to rustc 1.34.0-nightly (32471f7ea 2019-02-19)
Manish Goregaokar [Tue, 19 Feb 2019 07:34:43 +0000 (13:04 +0530)]
Rustup to rustc 1.34.0-nightly (32471f7ea 2019-02-19)

5 years agoFormat again
Michael Wright [Tue, 19 Feb 2019 04:39:22 +0000 (06:39 +0200)]
Format again

5 years agoAdd more descriptive details
Michael Howell [Tue, 19 Feb 2019 02:37:08 +0000 (19:37 -0700)]
Add more descriptive details

5 years agoFix formatting
Michael Howell [Tue, 19 Feb 2019 02:36:58 +0000 (19:36 -0700)]
Fix formatting

5 years agoCheck {print,write}_with_newline for literal newline
phil [Mon, 18 Feb 2019 16:39:23 +0000 (11:39 -0500)]
Check {print,write}_with_newline for literal newline

Both regular strings and raw strings can contain literal newlines. This commit
extends the lint to also warn about terminating strings with these.

Behaviour handling for raw strings is also moved into `check_newlines` by
passing in the `is_raw` boolean from `check_tts` as
[suggested](https://github.com/rust-lang/rust-clippy/pull/3781#pullrequestreview-204663732)

5 years agoAuto merge of #3729 - illicitonion:match_enum_wildcard, r=flip1995
bors [Mon, 18 Feb 2019 23:59:32 +0000 (23:59 +0000)]
Auto merge of #3729 - illicitonion:match_enum_wildcard, r=flip1995

wildcard_enum_match_arm gives suggestions

And is also more robust

5 years agoFix Binding for rustc update
Daniel Wagner-Hall [Mon, 18 Feb 2019 23:16:53 +0000 (23:16 +0000)]
Fix Binding for rustc update

5 years agoRestore tests
Daniel Wagner-Hall [Mon, 18 Feb 2019 22:55:16 +0000 (22:55 +0000)]
Restore tests

Also, fix existing test

5 years agowildcard_enum_match_arm gives suggestions
Daniel Wagner-Hall [Thu, 31 Jan 2019 22:01:23 +0000 (22:01 +0000)]
wildcard_enum_match_arm gives suggestions

And is also more robust

5 years agoAuto merge of #3783 - Enet4:patch-1, r=Manishearth
bors [Mon, 18 Feb 2019 20:05:54 +0000 (20:05 +0000)]
Auto merge of #3783 - Enet4:patch-1, r=Manishearth

Update why transmute_int_to_float is bad

As suggested in #3550, this PR changes the reason why using `transmute` from an integer to a float is not recommended. Effectively, `from_bits` uses `transmute` underneath, but the former is preferred.

5 years agoDon't fail for raw string ending in \n
phil [Mon, 18 Feb 2019 05:53:30 +0000 (00:53 -0500)]
Don't fail for raw string ending in \n

Pass tests for #3778, {print,write}_with_newline false positive

This change guards the lint from checking newlines with a sort of complicated
check to see if it's a raw string. Raw strings shouldn't be newline-checked,
since r"\n" is literally \-n, not a newline. I think it's ok not to check for
_literal_ newlines at the end of raw strings, but maybe that's debatable.

I... don't think this code is that great. I wanted to write the check after
`check_tts`, but that was too late -- raw string type info is lost (or I
couldn't find it). Putting it inside `check_tts` feels heavy-duty and the check
itself feels like a brittle reach possibly into places it shouldn't.

Maybe someone can fix this up :)

5 years agoAdd failing test for #3778 write_with_newline
phil [Mon, 18 Feb 2019 03:32:58 +0000 (22:32 -0500)]
Add failing test for #3778 write_with_newline

Literal `\n` characters (not a newline) in a `r"raw"` string should not
fail the lint.

This affects both write_with_newline and print_with_newline, so it is added in
both places.

I also copied a missing test case from write_with_newline over to
print_with_newline and added a note that one of those tests is supposed to
fail.

5 years agoFormat `transmute_from_int_to_float` docs
Eduardo Pinho [Mon, 18 Feb 2019 15:09:34 +0000 (15:09 +0000)]
Format `transmute_from_int_to_float` docs

5 years agoUpdate why transmute_int_to_float is bad
Eduardo Pinho [Mon, 18 Feb 2019 14:14:54 +0000 (14:14 +0000)]
Update why transmute_int_to_float is bad

Fix #3550

5 years agoAuto merge of #3777 - timotree3:patch-1, r=Manishearth
bors [Mon, 18 Feb 2019 11:40:29 +0000 (11:40 +0000)]
Auto merge of #3777 - timotree3:patch-1, r=Manishearth

Fix typo in documentation for float_cmp_const lint

5 years agoFormat
Michael Wright [Mon, 18 Feb 2019 06:32:53 +0000 (08:32 +0200)]
Format

5 years agoUpdate README and CHANGELOG
Michael Howell [Sun, 17 Feb 2019 20:32:24 +0000 (13:32 -0700)]
Update README and CHANGELOG

5 years agoAdd a lint to warn on `T: Drop` bounds
Michael Howell [Sun, 17 Feb 2019 04:28:16 +0000 (21:28 -0700)]
Add a lint to warn on `T: Drop` bounds

**What it does:** Checks for generics with `std::ops::Drop` as bounds.

**Why is this bad?** `Drop` bounds do not really accomplish anything.
A type may have compiler-generated drop glue without implementing the
`Drop` trait itself. The `Drop` trait also only has one method,
`Drop::drop`, and that function is by fiat not callable in user code.
So there is really no use case for using `Drop` in trait bounds.

**Known problems:** None.

**Example:**
```rust
fn foo<T: Drop>() {}
```

5 years agoImprove `iter_cloned_collect` suggestions
Michael Wright [Mon, 18 Feb 2019 05:30:50 +0000 (07:30 +0200)]
Improve `iter_cloned_collect` suggestions

Fixes #3704

5 years agoAdd failing test for #3778 write_with_newline
phil [Mon, 18 Feb 2019 03:32:58 +0000 (22:32 -0500)]
Add failing test for #3778 write_with_newline

Literal `\n` characters (not a newline) in a `r"raw"` string should not
fail the lint.

5 years agoAdd a semicolon as suggested
Timo [Mon, 18 Feb 2019 03:14:38 +0000 (22:14 -0500)]
Add a semicolon as suggested

5 years agoFix typo in documentation for float_cmp_const lint
Timo [Mon, 18 Feb 2019 02:06:29 +0000 (21:06 -0500)]
Fix typo in documentation for float_cmp_const lint

5 years agoAuto merge of #3775 - flip1995:ice-3717, r=phansch
bors [Sun, 17 Feb 2019 07:03:15 +0000 (07:03 +0000)]
Auto merge of #3775 - flip1995:ice-3717, r=phansch

Fix ICE #3717 in lint implicit_hasher

Fixes #3717

This fixes the ICE. We lose some information in a very specific case though. But less information if better than an ICE. For an example see the test file.

Does anyone know, if there's another way to get the `ty::Ty` of a `hir::Expr`?

5 years agoAdd test for ICE #3717 fix
flip1995 [Sat, 16 Feb 2019 21:41:06 +0000 (22:41 +0100)]
Add test for ICE #3717 fix

5 years agoFix ICE #3717
flip1995 [Sat, 16 Feb 2019 21:40:44 +0000 (22:40 +0100)]
Fix ICE #3717

Restore the old `TypeckTables` in visit_body after walking the body

5 years agoAuto merge of #3774 - notriddle:patch-1, r=flip1995
bors [Sat, 16 Feb 2019 22:01:48 +0000 (22:01 +0000)]
Auto merge of #3774 - notriddle:patch-1, r=flip1995

Use normal HTML label semantics for filter

The improvement is that you can click on the label and it'll select the form field.

5 years agoUse normal HTML label semantics for filter
Michael Howell [Sat, 16 Feb 2019 20:16:50 +0000 (13:16 -0700)]
Use normal HTML label semantics for filter

I legitimately don't understand why you did it with ARIA instead.

5 years agoAuto merge of #3762 - mikerite:fix-build-20190214, r=flip1995
bors [Thu, 14 Feb 2019 13:17:48 +0000 (13:17 +0000)]
Auto merge of #3762 - mikerite:fix-build-20190214, r=flip1995

Fix breakage due to rust-lang/rust#58167

5 years agoFix breakage from rust-lang/rust#58296
flip1995 [Thu, 14 Feb 2019 13:01:43 +0000 (14:01 +0100)]
Fix breakage from rust-lang/rust#58296

5 years agoFix breakage due to rust-lang/rust#58167
Michael Wright [Thu, 14 Feb 2019 06:55:50 +0000 (08:55 +0200)]
Fix breakage due to rust-lang/rust#58167

5 years agoAuto merge of #3760 - rust-lang:rustup, r=flip1995
bors [Wed, 13 Feb 2019 21:10:06 +0000 (21:10 +0000)]
Auto merge of #3760 - rust-lang:rustup, r=flip1995

Rustup

cc rust-lang/rust#58137

5 years agoRustup
flip1995 [Wed, 13 Feb 2019 21:06:19 +0000 (22:06 +0100)]
Rustup

cc rust-lang/rust#58137

5 years agoAuto merge of #3756 - g-bartoszek:redundant-closure-for-methods, r=oli-obk
bors [Tue, 12 Feb 2019 13:31:44 +0000 (13:31 +0000)]
Auto merge of #3756 - g-bartoszek:redundant-closure-for-methods, r=oli-obk

Redundant closure for methods

fixes  #3469

5 years agoAuto merge of #3757 - mikerite:fix-2542, r=oli-obk
bors [Tue, 12 Feb 2019 10:27:18 +0000 (10:27 +0000)]
Auto merge of #3757 - mikerite:fix-2542, r=oli-obk

Fix `needless_range_loop` bad suggestion

Detect if the index variable is used inside a closure.

Fixes #2542

5 years agoAuto merge of #3758 - phansch:document_macro, r=flip1995
bors [Mon, 11 Feb 2019 23:52:52 +0000 (23:52 +0000)]
Auto merge of #3758 - phansch:document_macro, r=flip1995

Document `declare_clippy_lint` macro

Split up from my work on updating CONTRIBUTING.md, which is slowly
making progress.

cc #2666

5 years agoUpdate comment regarding crate level cfg_attr
Philipp Hansch [Mon, 11 Feb 2019 21:32:54 +0000 (22:32 +0100)]
Update comment regarding crate level cfg_attr

5 years agoDocument some more core functions
Philipp Hansch [Mon, 11 Feb 2019 06:59:57 +0000 (07:59 +0100)]
Document some more core functions

5 years agoDocument `declare_clippy_lint` macro
Philipp Hansch [Mon, 11 Feb 2019 06:35:28 +0000 (07:35 +0100)]
Document `declare_clippy_lint` macro

Split up from my work on updating CONTRIBUTING.md, which is slowly
making progress.

cc #2666

5 years agoFix `needless_range_loop` bad suggestion
Michael Wright [Mon, 11 Feb 2019 05:03:12 +0000 (07:03 +0200)]
Fix `needless_range_loop` bad suggestion

Detect if the index variable is used inside a closure.

Fixes #2542

5 years agotest formatting
Grzegorz [Sun, 10 Feb 2019 20:23:04 +0000 (21:23 +0100)]
test formatting

5 years agoAuto merge of #3754 - phansch:uicleanup, r=oli-obk
bors [Sun, 10 Feb 2019 14:06:20 +0000 (14:06 +0000)]
Auto merge of #3754 - phansch:uicleanup, r=oli-obk

UI test cleanup: Extract similar_names tests

cc #2038

5 years agoAuto merge of #3744 - phansch:fix3144, r=oli-obk
bors [Sun, 10 Feb 2019 13:39:46 +0000 (13:39 +0000)]
Auto merge of #3744 - phansch:fix3144, r=oli-obk

Fix ICE in needless_pass_by_value lint

If I understand it correctly, we were first creating a type with a
`RegionKind::ReErased` region and then deleted it again in
`util::implements_trait` with:

    cx.tcx.erase_regions(&ty);

causing the type query to fail.

It looks like using `ReEmpty` works around that deletion.

Fixes #3144

5 years agoAuto merge of #3740 - flip1995:const_assert_macro, r=oli-obk
bors [Sun, 10 Feb 2019 12:47:16 +0000 (12:47 +0000)]
Auto merge of #3740 - flip1995:const_assert_macro, r=oli-obk

Macro check for assertion_on_constants lint

The `assertion_on_constants` lint currently has following output for this code [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6f2c9df6fc50baf847212d3b5136ee97):
```rust
macro_rules! assert_const {
    ($len:expr) => {
        assert!($len > 0);
    }
}

fn main() {
    assert_const!(3);
    assert_const!(-1);
}
```
```
warning: assert!(const: true) will be optimized out by the compiler
 --> src/main.rs:3:9
  |
3 |         assert!($len > 0);
  |         ^^^^^^^^^^^^^^^^^^
...
8 |     assert_const!(3);
  |     ---------------- in this macro invocation
  |
  = note: #[warn(clippy::assertions_on_constants)] on by default
  = help: remove it
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants

warning: assert!(const: false) should probably be replaced
 --> src/main.rs:3:9
  |
3 |         assert!($len > 0);
  |         ^^^^^^^^^^^^^^^^^^
...
9 |     assert_const!(-1);
  |     ----------------- in this macro invocation
  |
  = help: use panic!() or unreachable!()
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
```

This is contradictory. This lint should not trigger if the `assert!` is in a macro itself.

5 years agoremoving redundant closures in the whole project
Grzegorz [Sun, 10 Feb 2019 12:35:44 +0000 (13:35 +0100)]
removing redundant closures in the whole project

5 years agoAuto merge of #3755 - phansch:uicleanup2, r=oli-obk
bors [Sun, 10 Feb 2019 12:25:44 +0000 (12:25 +0000)]
Auto merge of #3755 - phansch:uicleanup2, r=oli-obk

UI test cleanup: Extract match_same_arms tests

cc #2038

5 years agoredundant closure implemented for closures containing method calls
Grzegorz [Sun, 10 Feb 2019 11:58:51 +0000 (12:58 +0100)]
redundant closure implemented for closures containing method calls

5 years agorustfmt
Philipp Hansch [Sun, 10 Feb 2019 09:48:24 +0000 (10:48 +0100)]
rustfmt

5 years agoUI test cleanup: Rename copies.rs to match_same_arms.rs
Philipp Hansch [Sun, 10 Feb 2019 09:20:28 +0000 (10:20 +0100)]
UI test cleanup: Rename copies.rs to match_same_arms.rs

5 years agoUI test cleanup: Extract match_same_arms tests
Philipp Hansch [Sun, 10 Feb 2019 09:19:24 +0000 (10:19 +0100)]
UI test cleanup: Extract match_same_arms tests

5 years agoUI test cleanup: Extract similar_names tests
Philipp Hansch [Sun, 10 Feb 2019 08:44:49 +0000 (09:44 +0100)]
UI test cleanup: Extract similar_names tests

5 years agoAuto merge of #3751 - h-michael:opt-def-id, r=phansch
bors [Sat, 9 Feb 2019 12:01:45 +0000 (12:01 +0000)]
Auto merge of #3751 - h-michael:opt-def-id, r=phansch

Use Hir::Def opt_def_id

related with: https://github.com/rust-lang/rust-clippy/pull/3750#issuecomment-462010225

Using `def.opt_def_id` in `opt_def_id` before replacing all all at once.

5 years agoUse Hir::Def opt_def_id
Hirokazu Hata [Sat, 9 Feb 2019 04:28:21 +0000 (13:28 +0900)]
Use Hir::Def opt_def_id

5 years agoAuto merge of #3748 - phansch:uitest, r=oli-obk
bors [Sat, 9 Feb 2019 04:09:25 +0000 (04:09 +0000)]
Auto merge of #3748 - phansch:uitest, r=oli-obk

Add a uitest subcommand to simplify UI test invocation

This makes running single tests a lot easier.

It's now

`TESTNAME=xxx cargo uitest`

instead of

`TESTNAME=xxx cargo test --test compile-test`

5 years agoAuto merge of #3750 - h-michael:const-params, r=phansch
bors [Sat, 9 Feb 2019 03:41:50 +0000 (03:41 +0000)]
Auto merge of #3750 - h-michael:const-params, r=phansch

Fix failing build  (adding new Hir::Def type ConstParam)

solves: #3749

related with:
- https://travis-ci.com/rust-lang/rust-clippy/jobs/176480646
- https://github.com/rust-lang/rust/pull/58191
- https://github.com/rust-lang/rust/commit/29f72063667187f2d281e940209a924730e165b2#diff-c1e317a81486d937bbfc6edca1dee92aR55

5 years agoAdd new Def type ConstParam
Hirokazu Hata [Sat, 9 Feb 2019 02:42:13 +0000 (11:42 +0900)]
Add new Def type ConstParam

5 years agoAdd a uitest subcommand to simplify UI test invocation
Philipp Hansch [Fri, 8 Feb 2019 07:05:52 +0000 (08:05 +0100)]
Add a uitest subcommand to simplify UI test invocation

This allows to run

`TESTNAME=xxx cargo uitest`

instead of

`TESTNAME=xxx cargo test --test-compile-test`

5 years agoAuto merge of #3665 - jsgf:master, r=oli-obk
bors [Wed, 6 Feb 2019 15:43:07 +0000 (15:43 +0000)]
Auto merge of #3665 - jsgf:master, r=oli-obk

Start making clippy easier to invoke in non-cargo contexts

Clippy (clippy-driver) currently has a couple of strong but unnecessary couplings with cargo. This series:
1. makes detection of check builds more robust, and
2. make clippy-driver use the --sysroot specified on the command line as its internal sysroot.

5 years agoAuto merge of #3743 - phansch:you_shall_not_pass, r=flip1995
bors [Wed, 6 Feb 2019 08:59:55 +0000 (08:59 +0000)]
Auto merge of #3743 - phansch:you_shall_not_pass, r=flip1995

Move run-pass tests to UI tests

This should give us more UI coverage for free.
It also removes the `run-pass` suite, so we now only have the `ui` suite.

5 years agoFix ICE in needless_pass_by_value lint
Philipp Hansch [Wed, 6 Feb 2019 07:09:56 +0000 (08:09 +0100)]
Fix ICE in needless_pass_by_value lint

If I understand it correctly, we were first creating a type with a
`RegionKind::ReErased` region and then deleted it again in
`util::implements_trait` with:

    cx.tcx.erase_regions(&ty);

causing the type query to fail.

It looks like using `ReEmpty` works around that deletion.

5 years agoMove run-pass tests to UI tests
Philipp Hansch [Wed, 6 Feb 2019 06:45:57 +0000 (07:45 +0100)]
Move run-pass tests to UI tests

This should give us more UI coverage for free.
It also removes the `run-pass` suite, so we now only have the `ui` suite.

5 years agoAdd tests for assertion_on_constants macro check
flip1995 [Tue, 5 Feb 2019 18:06:08 +0000 (19:06 +0100)]
Add tests for assertion_on_constants macro check

5 years agoDon't warn about const assertions when assert is in a macro itself
flip1995 [Tue, 5 Feb 2019 18:05:42 +0000 (19:05 +0100)]
Don't warn about const assertions when assert is in a macro itself

5 years agoAuto merge of #3725 - mikerite:fix-2728, r=phansch
bors [Mon, 4 Feb 2019 05:52:44 +0000 (05:52 +0000)]
Auto merge of #3725 - mikerite:fix-2728, r=phansch

Fix `cast_sign_loss` false positive

This checks if the value is a non-negative constant before linting about
losing the sign.

Because the `constant` function doesn't handle const functions, we check if
the value is from a call to a `max_value` function directly. A utility method
called `get_def_path` was added to make checking for the function paths
easier.

Fixes #2728

5 years agoDocument `get_def_path`
Michael Wright [Mon, 4 Feb 2019 05:29:19 +0000 (07:29 +0200)]
Document `get_def_path`

5 years agoMerge pull request #3735 from jsgf/setup-toolchain
Manish Goregaokar [Mon, 4 Feb 2019 05:14:07 +0000 (21:14 -0800)]
Merge pull request #3735 from jsgf/setup-toolchain

Add setup-toolchain.sh script to configure the master version of rustc,

5 years agoAdd setup-toolchain.sh script to configure the master version of rustc,
Jeremy Fitzhardinge [Sat, 2 Feb 2019 19:54:18 +0000 (11:54 -0800)]
Add setup-toolchain.sh script to configure the master version of rustc,
and update CONTRIBUTING.md accordingly.

5 years agoAuto merge of #3737 - phansch:2018, r=phansch
bors [Sun, 3 Feb 2019 15:24:54 +0000 (15:24 +0000)]
Auto merge of #3737 - phansch:2018, r=phansch

Transition leftover test libs to Rust 2018

To tick off some checkboxes in https://github.com/rust-lang/rust/issues/58099 =)

5 years agoTransition leftover test libs to Rust 2018
Philipp Hansch [Sun, 3 Feb 2019 13:47:03 +0000 (14:47 +0100)]
Transition leftover test libs to Rust 2018

5 years agoAuto merge of #3723 - rhysd:issue3721, r=oli-obk
bors [Sun, 3 Feb 2019 13:03:41 +0000 (13:03 +0000)]
Auto merge of #3723 - rhysd:issue3721, r=oli-obk

Implement dbg_macro rule

Fixes  #3721

This patch adds new `dbg_macro` rule to check `dbg!` macro use.

Since this is my first patch to clippy, I'm not confident about following points:

- ~~Currently only checks `dbg!` span. Is it possible to check if the `dbg!` macro is provided by standard library or user-defined? If it's possible, I can make the check more strict.~~ Resolved as https://github.com/rust-lang/rust-clippy/pull/3723#discussion_r252417934
- ~~Is category `style` correct for this rule?~~'restriction' is used instead
- ~~Should I use `span_lint_and_sugg` instead of `span_lint`? Currently entire message is put as `msg`.  But later part `ensure to avoid having uses of it in version control` may be put as suggestion.~~ Done
- I'm not native English speaker. The message and doc may not be natural as English.

5 years agorun `util/dev update_lints` and `cargo fmt --all`
rhysd [Sun, 3 Feb 2019 12:28:43 +0000 (21:28 +0900)]
run `util/dev update_lints` and `cargo fmt --all`

5 years agoMerge branch 'master' into issue3721
rhysd [Sun, 3 Feb 2019 12:27:23 +0000 (21:27 +0900)]
Merge branch 'master' into issue3721

5 years agoprefer `if` to `match`
rhysd [Sun, 3 Feb 2019 09:50:00 +0000 (18:50 +0900)]
prefer `if` to `match`

5 years agouse snippet for making a suggestion if possible
rhysd [Sun, 3 Feb 2019 09:28:42 +0000 (18:28 +0900)]
use snippet for making a suggestion if possible

5 years agoAuto merge of #3736 - mikerite:fix-build-20190203, r=phansch
bors [Sun, 3 Feb 2019 08:42:14 +0000 (08:42 +0000)]
Auto merge of #3736 - mikerite:fix-build-20190203, r=phansch

Fix breakage due to rust-lang/rust#58079

The rustc change added HirId to a few nodes. As I understand it, the plan is
to remove the NodeId from these nodes eventually. Where the NodeId was
not being matched, I used `..` to try and avoid further breakage. Where it
was, I used `_` to make the fix easier when NodeId is removed.

5 years agoFix breakage due to rust-lang/rust#58079
Michael Wright [Sun, 3 Feb 2019 07:12:07 +0000 (09:12 +0200)]
Fix breakage due to rust-lang/rust#58079

The rustc change added HirId to a few nodes. As I understand it, the plan is
to remove the NodeId from these nodes eventually. Where the NodeId was
not being matched, I used `..` to try and avoid further breakage. Where it
was, I used `_` to make the fix easier when NodeId is removed.

5 years agoAdd a CI test for cargoless use of clippy-driver
Jeremy Fitzhardinge [Sun, 27 Jan 2019 02:24:45 +0000 (18:24 -0800)]
Add a CI test for cargoless use of clippy-driver

5 years agobase-tests: use subshells to manage current directory
Jeremy Fitzhardinge [Sun, 27 Jan 2019 01:49:29 +0000 (17:49 -0800)]
base-tests: use subshells to manage current directory

It saves on having to pair `cd <path> && think && cd ..`.

5 years agoDrive-by cleanups to cargo-clippy. No functional change.
Jeremy Fitzhardinge [Sun, 27 Jan 2019 00:44:52 +0000 (16:44 -0800)]
Drive-by cleanups to cargo-clippy. No functional change.

5 years agoLet CLIPPY_CONF_DIR be used to start search for config, and fall back to
Jeremy Fitzhardinge [Sun, 27 Jan 2019 00:11:30 +0000 (16:11 -0800)]
Let CLIPPY_CONF_DIR be used to start search for config, and fall back to
CARGO_MANIFEST_DIR if it isn't set. If CARGO_MANIFEST_DIR isn't set, fall back
"." rather than panicing.

Issue #3663

5 years agoclippy-driver: if --sysroot is specified on the command line, use that
Jeremy Fitzhardinge [Tue, 15 Jan 2019 19:39:23 +0000 (11:39 -0800)]
clippy-driver: if --sysroot is specified on the command line, use that

If the user explicitly sets sysroot on the command line, then use that
value.

Issue #3663

5 years agoclippy-driver: more robust test to see if we're clippy-enabled
Jeremy Fitzhardinge [Tue, 15 Jan 2019 18:56:09 +0000 (10:56 -0800)]
clippy-driver: more robust test to see if we're clippy-enabled

Rather than looking for a fixed --emit arg set, just check to see
if we're emitting metadata at all. This makes it more robust to
being invoked by tools other than cargo (or if cargo changes its
invocation).

Issue #3663

5 years agoAuto merge of #2857 - avborhanian:master, r=phansch
bors [Sat, 2 Feb 2019 08:32:27 +0000 (08:32 +0000)]
Auto merge of #2857 - avborhanian:master, r=phansch

Adding lint test for excessive LOC.

This is a WIP for #2377. Just wanted to pull in because I had a few questions:

1. Is it okay that I'm approaching this via counting by looking at each line in the snippet instead of looking at the AST tree? If there's another way to do it, I want to make sure I'm doing the correct way, but I wasn't sure since the output AST JSON doesn't seem to contain whitespace.

2. My function is definitely going to trigger the lint, so also wanted to see if there was something obvious I could do to reduce it.

3. Are the two tests fine, or is there something obvious I'm missing?

4. Obviously bigger question - am I approaching the line count correctly. Current strategy is count a line if it contains some code, so skip if it's just comments or empty.

5 years agoAuto merge of #3731 - phansch:travis, r=phansch
bors [Sat, 2 Feb 2019 00:12:32 +0000 (00:12 +0000)]
Auto merge of #3731 - phansch:travis, r=phansch

Travis: Don't run integration tests on every PR commit

This does not save Clippy any time but it makes sure that the concurrent
build limit is not reached as quickly for the `rust-lang` Travis
account.

I can't create a permalink to the discussion somehow, so here's an
excerpt from the Infra channel:

```
[11:57 PM] pietroalbini: there is a clippy build (20 jobs) and a packed_simd one (42 builders)  and a rustc one which isn't scheduling atm
[11:58 PM] pietroalbini: I don't think there is a way to prioritize rustc builds in the queue on travis, right?
[12:22 AM] alexcrichton: pietro: I don't think so no
[12:22 AM] alexcrichton: If it's a problem we should cull builds on other projects
[12:22 AM] alexcrichton: The rust repo is the #1 priority
```

Since the integration tests are rarely failing these days, I think it's
fine to not run them on every commit.

If needed, it's also still possible to do a complete test run with `@bors try`.

5 years agoAuto merge of #3732 - phansch:fix_ice_3720, r=oli-obk
bors [Fri, 1 Feb 2019 23:49:46 +0000 (23:49 +0000)]
Auto merge of #3732 - phansch:fix_ice_3720, r=oli-obk

Fix ICE in vec_box lint and add run-rustfix

Includes https://github.com/rust-lang/rust-clippy/pull/3726

`hir::Ty` doesn't seem to know anything about type bounds and
`cx.tcx.type_of(def_id)` caused an ICE when it was passed a generic type
with a bound:

```
src/librustc_typeck/collect.rs:1311: unexpected non-type Node::GenericParam: Type { default: None, synthetic: None }
```

Converting it to a proper `Ty` fixes the ICE and catches a few more places
where the lint applies.

Fixes #3720