Commit graph

4078 commits

Author SHA1 Message Date
LeSeulArtichaut
dce2262dae Use ty::{IntTy,UintTy,FloatTy} in rustdoc and clippy 2021-01-18 21:10:36 +01:00
Ashley Mannix
9009f8f031 Rollup merge of #81038 - flip1995:clippyup, r=Manishearth
Update Clippy

Biweekly Clippy update

r? ``@Manishearth``
2021-01-18 21:53:22 +10:00
bors
e477105405 Auto merge of #80679 - jackh726:predicate-kind-take2, r=lcnr
Remove PredicateKind and instead only use Binder<PredicateAtom>

Originally brought up in https://github.com/rust-lang/rust/pull/76814#discussion_r546858171

r? `@lcnr`
2021-01-17 20:49:11 +00:00
Jack Huey
e73b8dcbca Review changes 2021-01-16 18:56:37 -05:00
Jack Huey
82569601f2 Cleanup 2021-01-16 18:50:34 -05:00
Jack Huey
7c3b6a63ad Use pred not binder 2021-01-16 18:40:47 -05:00
Jack Huey
f06eeaf982 Cleanup 2021-01-16 18:40:47 -05:00
Jack Huey
3436e21df5 Remove PredicateKind 2021-01-16 18:40:47 -05:00
Jack Huey
38e293cf5d Remove PredicateKind::Atom 2021-01-16 18:40:47 -05:00
flip1995
7449dc96c0 Deprecate unknown_clippy_lints
This is now handled by unknown_lints
2021-01-16 19:44:46 +01:00
flip1995
488153ff2f Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyup 2021-01-15 10:56:44 +01:00
bors
7b3af4145b Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
Reintroduce hir::ExprKind::If

Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications.

The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome.

- [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051)
- [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d)
- [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5)
- [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691)
- [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95)
- [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-14 14:41:58 +00:00
bors
dcd8c8e739 Auto merge of #77524 - Patryk27:fixes/66228, r=estebank
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924)

This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13 20:35:58 +00:00
Joshua Nelson
dfb41f4797 Separate out a hir::Impl struct
This makes it possible to pass the `Impl` directly to functions, instead
of having to pass each of the many fields one at a time. It also
simplifies matches in many cases.
2021-01-12 20:32:33 -05:00
Patryk Wychowaniec
2c6dc8801f Rework diagnostics for wrong number of generic args 2021-01-10 13:07:40 +01:00
Vadim Petrochenkov
9e45a23ab9 ast: Remove some indirection layers from values in key-value attributes 2021-01-09 21:50:39 +03:00
Caio
7d42172899 Reintroduce hir::ExprKind::If 2021-01-07 18:54:12 -03:00
flip1995
ba4bf4f9c5 Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyup 2021-01-02 16:29:43 +01:00
Julian Knodt
48dec842f2 first pass at default values for const generics
- Adds optional default values to const generic parameters in the AST
  and HIR
- Parses these optional default values
- Adds a `const_generics_defaults` feature gate
2021-01-01 10:55:10 +01:00
Joshua Nelson
5479bbaf72 Rename kw::Invalid -> kw::Empty
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.
2020-12-30 09:50:02 -05:00
flip1995
f03edfd7a1 Merge commit '4911ab124c481430672a3833b37075e6435ec34d' into clippyup 2020-12-20 17:19:49 +01:00
Jack Huey
f00b6ac24e More rebinds 2020-12-19 04:26:35 -05:00
bors
8e9a538ae1 Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakis
Move binder for dyn to each list item

This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`.

This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.`

r? `@nikomatsakis`
2020-12-17 18:21:20 +00:00
Yuki Okushi
286e492343 Rollup merge of #79051 - LeSeulArtichaut:if-let-guard, r=matthewjasper
Implement if-let match guards

Implements rust-lang/rfcs#2294 (tracking issue: #51114).

I probably should do a few more things before this can be merged:
- [x] Add tests (added basic tests, more advanced tests could be done in the future?)
- [x] Add lint for exhaustive if-let guard (comparable to normal if-let statements)
- [x] Fix clippy

However since this is a nightly feature maybe it's fine to land this and do those steps in follow-up PRs.

Thanks a lot `@matthewjasper` ❤️ for helping me with lowering to MIR! Would you be interested in reviewing this?
r? `@ghost` for now
2020-12-17 11:43:55 +09:00
Jack Huey
30ef1770d3 Move binder for dyn to each list item 2020-12-11 15:02:46 -05:00
Tomasz Miąsko
0e527baf77 Retain assembly operands span when lowering AST to HIR 2020-12-06 20:48:08 +01:00
flip1995
8eca423ea1 Merge commit 'c1664c50b27a51f7a78c93ba65558e7c33eabee6' into clippyup 2020-12-06 15:01:03 +01:00
LeSeulArtichaut
93c6135c15 Handle Guard::IfLet in clippy 2020-12-06 13:43:19 +01:00
LeSeulArtichaut
402f55f33f Implement lowering of if-let guards to MIR 2020-12-06 13:42:24 +01:00
Camille GILLOT
d95f11bcd6 Remove ForeignMod struct. 2020-11-26 21:32:27 +01:00
Arlie Davis
f6827839c0 Move lev_distance to rustc_ast, make non-generic
rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST
would not have any dependency its lexer, for minimizing unnecessarily
design-time dependencies. Breaking this dependency would also have practical
benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast.

This commit does not remove the rustc_ast --> rustc_lexer dependency,
but it does remove one of the sources of this dependency, which is the
code that handles fuzzy matching between symbol names for making suggestions
in diagnostics. Since that code depends only on Symbol, it is easy to move
it to rustc_span. It might even be best to move it to a separate crate,
since other tools such as Cargo use the same algorithm, and have simply
contain a duplicate of the code.

This changes the signature of find_best_match_for_name so that it is no
longer generic over its input. I checked the optimized binaries, and this
function was duplicated at nearly every call site, because most call sites
used short-lived iterator chains, generic over Map and such. But there's
no good reason for a function like this to be generic, since all it does
is immediately convert the generic input (the Iterator impl) to a concrete
Vec<Symbol>. This has all of the costs of generics (duplicated method bodies)
with no benefit.

Changing find_best_match_for_name to be non-generic removed about 10KB of
code from the optimized binary. I know it's a drop in the bucket, but we have
to start reducing binary size, and beginning to tame over-use of generics
is part of that.
2020-11-24 16:12:23 -08:00
bors
53ce1dd719 Auto merge of #79228 - flip1995:clippyup, r=oli-obk
Update Clippy

Biweekly Clippy update

r? `@Manishearth`
2020-11-24 06:56:02 +00:00
bors
e5fddb6747 Auto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum
Drop support for all cloudabi targets

`cloudabi` is a tier-3 target, and [it is no longer being maintained upstream][no].

This PR drops supports for cloudabi targets. Those targets are:
* aarch64-unknown-cloudabi
* armv7-unknown-cloudabi
* i686-unknown-cloudabi
* x86_64-unknown-cloudabi

Since this drops supports for a target, I'd like somebody to tag `relnotes` label to this PR.

Some other issues:
* The tidy exception for `cloudabi` crate is still remained because
  * `parking_lot v0.9.0` and `parking_lot v0.10.2` depends on `cloudabi v0.0.3`.
  * `parking_lot v0.11.0` depends on `cloudabi v0.1.0`.

[no]: https://github.com/NuxiNL/cloudabi#note-this-project-is-unmaintained
2020-11-23 19:01:19 +00:00
flip1995
284c359c61 Fix ICE in utils::implements_trait
This only happend when debug_assertions were enabled in rustc
2020-11-23 13:52:27 +01:00
flip1995
d3d2018ead Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup 2020-11-23 13:51:04 +01:00
Lzu Tao
4b698f2069 Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
Jonas Schievink
1464dcedfb Thread Constness through selection 2020-11-22 02:13:53 +01:00
Mara Bos
113c1476c9 Clippy: Match on assert!() expansions without an inner block. 2020-11-19 19:47:25 +01:00
Mara Bos
78faaef8de Remove the clippy::panic-params lint.
Rustc itself now warns for all cases that triggered this lint.
2020-11-19 18:34:40 +01:00
Mara Bos
577ebc8cd6 Rollup merge of #79145 - camelid:clippy-fix-panics, r=flip1995
Fix handling of panic calls

This should make Clippy more resilient and will unblock #78343.

This PR is made against rust-lang/rust to avoid the need for a subtree
sync at ``@flip1995's`` suggestion in rust-lang/rust-clippy#6310.

r? ``@flip1995``
cc ``@m-ou-se``
2020-11-18 15:46:36 +01:00
Camelid
4e4c4fb8aa Fix handling of panic calls
This should make Clippy more resilient and will unblock #78343.

This PR is made against rust-lang/rust to avoid the need for a subtree
sync at @flip1995's suggestion in rust-lang/rust-clippy#6310.
2020-11-17 12:16:15 -08:00
bors
a467c514a3 Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk
Introduce `TypeVisitor::BreakTy`

Implements MCP rust-lang/compiler-team#383.
r? `@ghost`
cc `@lcnr` `@oli-obk`

~~Blocked on FCP in rust-lang/compiler-team#383.~~
2020-11-17 12:24:34 +00:00
Bastian Kauschke
3567ea546f clippy: fold by value 2020-11-16 22:42:09 +01:00
LeSeulArtichaut
1b55cc79cc Set the default BreakTy to ! 2020-11-14 21:46:39 +01:00
LeSeulArtichaut
cbb6b1c338 Introduce TypeVisitor::BreakTy 2020-11-14 20:25:27 +01:00
Fabian Zaiser
864e554b9a Add underscore expressions for destructuring assignments
Co-authored-by: varkor <github@varkor.com>
2020-11-14 13:53:12 +00:00
Mara Bos
3a648ffc02 Rollup merge of #78836 - fanzier:struct-and-slice-destructuring, r=petrochenkov
Implement destructuring assignment for structs and slices

This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the second part of #71156, which was split up to allow for easier review.

Note that the first PR (#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If ``@petrochenkov`` prefers to wait until the first PR is merged, I totally understand, of course.

This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern).

Unfortunately, this PR slightly regresses the diagnostics implemented in #77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR.

Thanks to ``@varkor`` who helped with the implementation, particularly around the struct rest changes.

r? ``@petrochenkov``
2020-11-12 19:46:09 +01:00
bors
92ece84873 Auto merge of #78782 - petrochenkov:nodoctok, r=Aaron1011
Do not collect tokens for doc comments

Doc comment is a single token and AST has all the information to re-create it precisely.
Doc comments are also responsible for majority of calls to `collect_tokens` (with `num_calls == 1` and `num_calls == 0`, cc https://github.com/rust-lang/rust/pull/78736).

(I also moved token collection into `fn parse_attribute` to deduplicate code a bit.)

r? `@Aaron1011`
2020-11-12 00:33:55 +00:00
Fabian Zaiser
5f310d9b83 Implement destructuring assignment for structs and slices
Co-authored-by: varkor <github@varkor.com>
2020-11-11 12:10:52 +00:00
Ikko Ashimine
f92f8d095d Fix typo in comment
occurences -> occurrences
2020-11-11 20:23:08 +09:00
Dylan DPC
6294300b8e Rollup merge of #78710 - petrochenkov:macvisit, r=davidtwco
rustc_ast: Do not panic by default when visiting macro calls

Panicking by default made sense when we didn't have HIR or MIR and everything worked on AST, but now all AST visitors run early and majority of them have to deal with macro calls, often by ignoring them.

The second commit renames `visit_mac` to `visit_mac_call`, the corresponding structures were renamed earlier in https://github.com/rust-lang/rust/pull/69589.
2020-11-09 19:06:55 +01:00
Vadim Petrochenkov
8845f10e94 Do not collect tokens for doc comments 2020-11-09 01:47:11 +03:00
flip1995
34244190d4 Merge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyup 2020-11-05 14:29:48 +01:00
bors
0c1531a5c4 Auto merge of #78662 - sexxi-goose:add_expr_id_to_delegate, r=nikomatsakis
Provide diagnostic suggestion in ExprUseVisitor Delegate

The [Delegate trait](981346fc07/compiler/rustc_typeck/src/expr_use_visitor.rs (L28-L38)) currently use `PlaceWithHirId` which is composed of Hir `Place` and the
corresponding expression id.

Even though this is an accurate way of expressing how a Place is used,
it can cause confusion during diagnostics.

Eg:

```
let arr : [String; 5];

let [a, ...]     =   arr;
 ^^^ E1 ^^^      =  ^^E2^^
 ```

 Here `arr` is moved because of the binding created E1. However, when we
 point to E1 in diagnostics with the message `arr` was moved, it can be
 confusing.  Rather we would like to report E2 to the user.

 Closes: https://github.com/rust-lang/project-rfc-2229/issues/20

r? `@ghost`
2020-11-04 22:45:15 +00:00
oli
83edb2f4e4 s/Scalar::Raw/Scalar::Int 2020-11-04 10:11:31 +00:00
Oliver Scherer
6fdbde5f46 Split the "raw integer bytes" part out of Scalar 2020-11-04 09:58:59 +00:00
Vadim Petrochenkov
c2a769f84c rustc_ast: visit_mac -> visit_mac_call 2020-11-03 23:39:51 +03:00
Vadim Petrochenkov
89fa373059 rustc_ast: Do not panic by default when visiting macro calls 2020-11-03 20:38:20 +03:00
Dhruv Jauhar
5f973264bd Provide diagnostic suggestion in ExprUseVisitor Delegate
The [Delegate
trait](981346fc07/compiler/rustc_typeck/src/expr_use_visitor.rs (L28-L38))
currently use `PlaceWithHirId` which is composed of Hir `Place` and the
corresponding expression id.

Even though this is an accurate way of expressing how a Place is used,
it can cause confusion during diagnostics.

Eg:

```
let arr : [String; 5];

let [a, ...]     =   arr;
 ^^^ E1 ^^^      =  ^^E2^^
 ```

 Here `arr` is moved because of the binding created E1. However, when we
 point to E1 in diagnostics with the message `arr` was moved, it can be
 confusing.  Rather we would like to report E2 to the user.

 Closes: https://github.com/rust-lang/project-rfc-2229/issues/20
2020-11-02 01:31:34 -05:00
bors
8a18963f28 Auto merge of #75534 - Aaron1011:feature/new-future-breakage, r=pnkfelix
Implement rustc side of report-future-incompat

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

This is an alternative to `@pnkfelix's` initial implementation in https://github.com/pnkfelix/rust/commits/prototype-rustc-side-of-report-future-incompat (mainly because I started working before seeing that branch 😄 ).

My approach outputs the entire original `Diagnostic`, in a way that is compatible with incremental compilation. This is not yet integrated with compiletest, but can be used manually by passing `-Z emit-future-incompat-report` to `rustc`.

Several changes are made to support this feature:
* The `librustc_session/lint` module is moved to a new crate `librustc_lint_defs` (name bikesheddable). This allows accessing lint definitions from `librustc_errors`.
* The `Lint` struct is extended with an `Option<FutureBreakage>`. When present, it indicates that we should display a lint in the future-compat report. `FutureBreakage` contains additional information that we may want to display in the report (currently, a `date` field indicating when the crate will stop compiling).
* A new variant `rustc_error::Level::Allow` is added. This is used when constructing a diagnostic for a future-breakage lint that is marked as allowed (via `#[allow]` or `--cap-lints`). This allows us to capture any future-breakage diagnostics in one place, while still discarding them before they are passed to the `Emitter`.
* `DiagnosticId::Lint` is extended with a `has_future_breakage` field, indicating whether or not the `Lint` has future breakage information (and should therefore show up in the report).
* `Session` is given access to the `LintStore` via a new `SessionLintStore` trait (since `librustc_session` cannot directly reference `LintStore` without a cyclic dependency). We use this to turn a string `DiagnosticId::Lint` back into a `Lint`, to retrieve the `FutureBreakage` data.

Currently, `FutureBreakage.date` is always set to `None`. However, this could potentially be interpreted by Cargo in the future.

I've enabled the future-breakage report for the `ARRAY_INTO_ITER` lint, which can be used to test out this PR. The intent is to use the field to allow Cargo to determine the date of future breakage (as described in [RFC 2834](https://github.com/rust-lang/rfcs/blob/master/text/2834-cargo-report-future-incompat.md)) without needing to parse the diagnostic itself.

cc `@pnkfelix`
2020-11-01 16:52:28 +00:00
Aaron Hill
4bbc7712fc Update Clippy path to Lint 2020-10-30 21:41:16 -04:00
LeSeulArtichaut
1c8c3d14ef Remove implicit Continue type 2020-10-30 12:27:47 +01:00
LeSeulArtichaut
4a06145ced Use ControlFlow::is{break,continue} 2020-10-30 12:27:46 +01:00
LeSeulArtichaut
fa79cc4f6f TypeVisitor: use ControlFlow in clippy 2020-10-30 12:27:45 +01:00
Eduardo Broto
50419118b4 Merge commit '645ef505da378b6f810b1567806d1bcc2856395f' into clippyup 2020-10-28 23:36:07 +01:00
Nathan Whitaker
a1bb10e9b8 Remove lint from clippy 2020-10-26 18:19:48 -04:00
Yuki Okushi
df85532112 Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkov
Split out statement attributes changes from #78306

This is the same as PR https://github.com/rust-lang/rust/pull/78306, but `unused_doc_comments` is modified to explicitly ignore statement items (which preserves the current behavior).

This shouldn't have any user-visible effects, so it can be landed without lang team discussion.

---------
When the 'early' and 'late' visitors visit an attribute target, they
activate any lint attributes (e.g. `#[allow]`) that apply to it.
This can affect warnings emitted on sibiling attributes. For example,
the following code does not produce an `unused_attributes` for
`#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed
the warning.

```rust
trait Foo {
    #[allow(unused_attributes)] #[inline] fn first();
    #[inline] #[allow(unused_attributes)] fn second();
}
```

However, we do not do this for statements - instead, the lint attributes
only become active when we visit the struct nested inside `StmtKind`
(e.g. `Item`).

Currently, this is difficult to observe due to another issue - the
`HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`.
As a result, the `unused_doc_comments` lint will never see attributes on
item statements.

This commit makes two interrelated fixes to the handling of inert
(non-proc-macro) attributes on statements:

* The `HasAttr` impl for `StmtKind` now returns attributes for
  `StmtKind::Item`, treating it just like every other `StmtKind`
  variant. The only place relying on the old behavior was macro
  which has been updated to explicitly ignore attributes on item
  statements. This allows the `unused_doc_comments` lint to fire for
  item statements.
* The `early` and `late` lint visitors now activate lint attributes when
  invoking the callback for `Stmt`. This ensures that a lint
  attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to
  sibiling attributes on an item statement.

For now, the `unused_doc_comments` lint is explicitly disabled on item
statements, which preserves the current behavior. The exact locatiosn
where this lint should fire are being discussed in PR #78306
2020-10-25 18:43:49 +09:00
Aaron Hill
33f3cfcadc Fix inconsistencies in handling of inert attributes on statements
When the 'early' and 'late' visitors visit an attribute target, they
activate any lint attributes (e.g. `#[allow]`) that apply to it.
This can affect warnings emitted on sibiling attributes. For example,
the following code does not produce an `unused_attributes` for
`#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed
the warning.

```rust
trait Foo {
    #[allow(unused_attributes)] #[inline] fn first();
    #[inline] #[allow(unused_attributes)] fn second();
}
```

However, we do not do this for statements - instead, the lint attributes
only become active when we visit the struct nested inside `StmtKind`
(e.g. `Item`).

Currently, this is difficult to observe due to another issue - the
`HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`.
As a result, the `unused_doc_comments` lint will never see attributes on
item statements.

This commit makes two interrelated fixes to the handling of inert
(non-proc-macro) attributes on statements:

* The `HasAttr` impl for `StmtKind` now returns attributes for
  `StmtKind::Item`, treating it just like every other `StmtKind`
  variant. The only place relying on the old behavior was macro
  which has been updated to explicitly ignore attributes on item
  statements. This allows the `unused_doc_comments` lint to fire for
  item statements.
* The `early` and `late` lint visitors now activate lint attributes when
  invoking the callback for `Stmt`. This ensures that a lint
  attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to
  sibiling attributes on an item statement.

For now, the `unused_doc_comments` lint is explicitly disabled on item
statements, which preserves the current behavior. The exact locatiosn
where this lint should fire are being discussed in PR #78306
2020-10-24 11:55:48 -04:00
Eduardo Broto
6caeed1bfa Remove duplicate import of Target 2020-10-23 23:45:37 +02:00
Eduardo Broto
cdb555f4fc Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup 2020-10-23 22:16:59 +02:00
Yuki Okushi
82f775d2c4 Rollup merge of #77851 - exrook:split-btreemap, r=dtolnay
BTreeMap: refactor Entry out of map.rs into its own file

btree/map.rs is approaching the 3000 line mark, splitting out the entry
code buys about 500 lines of headroom.

I've created this PR because the changes I've made in #77438 will push `map.rs` over the 3000 line limit and cause tidy to complain.

I picked `Entry` to factor out because it feels less tightly coupled to the rest of `BTreeMap` than the various iterator implementations.

Related: #60302
2020-10-18 04:11:07 +09:00
Jacob Hughes
29392a1728 Appease the almightly lord clippy, hallowed be thy name 2020-10-17 13:48:54 -04:00
Santiago Pastorino
0af467ebf2 Handle ExprKind::ConstBlock on clippy 2020-10-16 17:14:34 -03:00
est31
2c1e8cfc62 Remove rustc_session::config::Config
The wrapper type led to tons of target.target
across the compiler. Its ptr_width field isn't
required any more, as target_pointer_width
is already present in parsed form.
2020-10-15 12:02:24 +02:00
Jonas Schievink
1178777457 Refactor how SwitchInt stores jump targets 2020-10-10 17:46:11 +02:00
flip1995
fbf2430f02 Merge commit '2f6439ae6a6803d030cceb3ee14c9150e91b328b' into clippyup 2020-10-09 12:45:29 +02:00
Matthew Jasper
adb7fc6283 Fix tools 2020-10-06 11:19:30 +01:00
Yuki Okushi
22c5e0c347 Rollup merge of #77560 - rschoon:fix-litkind-rc-bytebuf, r=lcnr
Fix LitKind's byte buffer to use refcounted slice

While working on adding a new lint for clippy (see https://github.com/rust-lang/rust-clippy/pull/6044) for avoiding shared ownership of "mutable buffer" types (such as using `Rc<Vec<T>>` instead of `Rc<[T]>`), I noticed a type exported from rustc_ast and used by clippy gets caught by the lint. This PR fixes the exported type.

This PR includes the actual change to clippy too, but I will open a PR directly against clippy for that part (although it will currently fail to build there).
2020-10-06 16:26:11 +09:00
Dylan MacKenzie
29d43f63bd clippy: (Body, DefId) -> Body 2020-10-04 16:07:03 -07:00
Robin Schoonover
f34f4a7327 Change clippy's Constant back to refcount clone byte strings 2020-10-04 15:53:37 -06:00
Michael Howell
840f7daaad Deprecate clippy lint 2020-10-02 11:34:14 -07:00
Oliver Scherer
7072e45c6c Remove all unstable feature support in the missing_const_for_fn lint 2020-09-26 16:23:56 +02:00
Oliver Scherer
a6fda14394 Move qualify_min_const_fn out of rustc into clippy 2020-09-26 16:08:24 +02:00
bors
6273be6fc2 Auto merge of #77144 - flip1995:clippyup, r=Manishearth
Update Clippy

Bi-weekly Clippy update.

This includes a `Cargo.lock` update (d445493479), so probably needs `rollup=never`.

r? `@Manishearth`
2020-09-25 06:23:55 +00:00
Jonas Schievink
a8c6073278 Rollup merge of #76724 - ecstatic-morse:dataflow-pass-names, r=lcnr
Allow a unique name to be assigned to dataflow graphviz output

Previously, if the same analysis were invoked multiple times in a single compilation session, the graphviz output for later runs would overwrite that of previous runs. Allow callers to add a unique identifier to each run so this can be avoided.
2020-09-25 02:29:31 +02:00
flip1995
d1f9cad102 Merge commit 'e636b88aa180e8cab9e28802aac90adbc984234d' into clippyup 2020-09-24 14:49:22 +02:00
Christiaan Dirkx
141b9c2890 Remove can_suggest from Clippy.
Removes `can_suggest` from as it is no longer used.
Reverts rust-clippy#5724.
2020-09-21 00:00:33 +02:00
bors
a334ae658b Auto merge of #76136 - CDirkx:const-result, r=dtolnay
Stabilize some Result methods as const

Stabilize the following methods of Result as const:
 - `is_ok`
 - `is_err`
 - `as_ref`

A test is also included, analogous to the test for `const_option`.

These methods are currently const under the unstable feature `const_result` (tracking issue: #67520).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](https://github.com/rust-lang/rust/pull/75463) and [PR#76135](https://github.com/rust-lang/rust/pull/76135).

Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.

Related: #76225
2020-09-20 13:07:11 +00:00
CDirkx
ac0d069616 Update src/tools/clippy/clippy_lints/src/matches.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-09-20 12:21:23 +02:00
Christiaan Dirkx
292e2f71a7 Remove can_suggest check for is_ok and is_err.
`is_ok` and `is_err` are stabilized as const and can thus always be suggested.
2020-09-20 10:46:30 +02:00
Lzu Tao
78f9ea5431 Fix clippy hard-code slice::Iter path 2020-09-15 10:21:40 +00:00
Dylan MacKenzie
72b402ed38 Add pass names to some common dataflow analyses 2020-09-14 17:56:39 -07:00
bors
519799f099 Auto merge of #75800 - Aaron1011:feature/full-nt-tokens, r=petrochenkov
Attach tokens to all AST types used in `Nonterminal`

We perform token capturing when we have outer attributes (for nonterminals that support attributes - e.g. `Stmt`), or when we parse a `Nonterminal` for a `macro_rules!` argument. The full list of `Nonterminals` affected by this PR is:

* `NtBlock`
* `NtStmt`
* `NtTy`
* `NtMeta`
* `NtPath`
* `NtVis`
* `NtLiteral`

Of these nonterminals, only `NtStmt` and `NtLiteral` (which is actually just an `Expr`), support outer attributes - the rest only ever have token capturing perform when they match a `macro_rules!` argument.

This makes progress towards solving https://github.com/rust-lang/rust/issues/43081 - we now collect tokens for everything that might need them. However, we still need to handle `#[cfg]`, inner attributes, and misc pretty-printing issues (e.g. #75734)

I've separated the changes into (mostly) independent commits, which could be split into individual PRs for each `Nonterminal` variant. The purpose of having them all in one PR is to do a single Crater run for all of them.

Most of the changes in this PR are trivial (adding `tokens: None` everywhere we construct the various AST structs). The significant changes are:

* `ast::Visibility` is changed from `type Visibility = Spanned<VisibilityKind>` to a `struct Visibility { kind, span, tokens }`.
* `maybe_collect_tokens` is made generic, and used for both `ast::Expr` and `ast::Stmt`.
* Some of the statement-parsing functions are refactored so that we can capture the trailing semicolon.
* `Nonterminal` and `Expr` both grew by 8 bytes, as some of the structs which are stored inline (rather than behind a `P`) now have an `Option<TokenStream>` field. Hopefully the performance impact of doing this is negligible.
2020-09-11 02:35:01 +00:00
Aaron Hill
8808dc6abf Fully integrate token collection for additional AST structs
This commit contains miscellaneous changes that don't fit into any of
the other commits in this PR
2020-09-10 17:58:14 -04:00
flip1995
a12828a80a Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup 2020-09-10 17:47:07 +02:00
bors
961f18317d Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk
Add CONST_ITEM_MUTATION lint

Fixes #74053
Fixes #55721

This PR adds a new lint `CONST_ITEM_MUTATION`.
Given an item `const FOO: SomeType = ..`, this lint fires on:

* Attempting to write directly to a field (`FOO.field = some_val`) or
  array entry (`FOO.array_field[0] = val`)
* Taking a mutable reference to the `const` item (`&mut FOO`), including
  through an autoderef `FOO.some_mut_self_method()`

The lint message explains that since each use of a constant creates a
new temporary, the original `const` item will not be modified.
2020-09-10 05:54:26 +00:00
Aaron Hill
f23670ed68 Adjust Clippy for CONST_ITEM_MUTATION lint
We no longer lint assignments to const item fields in the
`temporary_assignment` lint, since this is now covered by the
`CONST_ITEM_MUTATION` lint.

Additionally, we `#![allow(const_item_mutation)]` in the
`borrow_interior_mutable_const.rs` test. Clippy UI tests are run with
`-D warnings`, which seems to cause builtin lints to prevent Clippy
lints from running.
2020-09-08 17:59:56 -04:00
bors
3ffe9f843c Auto merge of #76044 - ecstatic-morse:dataflow-lattice, r=oli-obk
Support dataflow problems on arbitrary lattices

This PR implements last of the proposed extensions I mentioned in the design meeting for the original dataflow refactor. It extends the current dataflow framework to work with arbitrary lattices, not just `BitSet`s. This is a prerequisite for dataflow-enabled MIR const-propagation. Personally, I am skeptical of the usefulness of doing const-propagation pre-monomorphization, since many useful constants only become known after monomorphization (e.g. `size_of::<T>()`) and users have a natural tendency to hand-optimize the rest. It's probably worth exprimenting with, however, and others have shown interest cc `@rust-lang/wg-mir-opt.`

The `Idx` associated type is moved from `AnalysisDomain` to `GenKillAnalysis` and replaced with an associated `Domain` type that must implement `JoinSemiLattice`. Like before, each `Analysis` defines the "bottom value" for its domain, but can no longer override the dataflow join operator. Analyses that want to use set intersection must now use the `lattice::Dual` newtype. `GenKillAnalysis` impls have an additional requirement that `Self::Domain: BorrowMut<BitSet<Self::Idx>>`, which effectively means that they must use `BitSet<Self::Idx>` or `lattice::Dual<BitSet<Self::Idx>>` as their domain.

Most of these changes were mechanical. However, because a `Domain` is no longer always a powerset of some index type, we can no longer use an `IndexVec<BasicBlock, GenKillSet<A::Idx>>>` to store cached block transfer functions. Instead, we use a boxed `dyn Fn` trait object. I discuss a few alternatives to the current approach in a commit message.

The majority of new lines of code are to preserve existing Graphviz diagrams for those unlucky enough to have to debug dataflow analyses. I find these diagrams incredibly useful when things are going wrong and considered regressing them unacceptable, especially the pretty-printing of `MovePathIndex`s, which are used in many dataflow analyses. This required a parallel `fmt` trait used only for printing dataflow domains, as well as a refactoring of the `graphviz` module now that we cannot expect the domain to be a `BitSet`. Some features did have to be removed, such as the gen/kill display mode (which I didn't use but existed to mirror the output of the old dataflow framework) and line wrapping. Since I had to rewrite much of it anyway, I took the opportunity to switch to a `Visitor` for printing dataflow state diffs instead of using cursors, which are error prone for code that must be generic over both forward and backward analyses. As a side-effect of this change, we no longer have quadratic behavior when writing graphviz diagrams for backward dataflow analyses.

r? `@pnkfelix`
2020-09-07 21:29:43 +00:00
LeSeulArtichaut
4286d9c87a ty.flags -> ty.flags() 2020-09-04 18:28:20 +02:00
LeSeulArtichaut
28f9b84042 ty.kind -> ty.kind() in rustdoc and clippy 2020-09-04 18:27:33 +02:00