Commit Graph

14802 Commits

Author SHA1 Message Date
bors
491483358d Auto merge of #9279 - tabokie:weight-loss, r=flip1995
chore: a few small improvements to code quality

Some improvements:
- Simplify implementation of `is_unit_type`
- Use slice matching to destruct `Call` or `MethodCall` whenever possible

changelog: none

r? `@flip1995`
2022-08-02 10:33:19 +00:00
tabokie
ac7a91ea16 use slice match more often
Signed-off-by: tabokie <xy.tao@outlook.com>
2022-08-02 18:12:31 +08:00
tabokie
9ab6146afe simplify unit type check
Signed-off-by: tabokie <xy.tao@outlook.com>
2022-08-02 17:56:20 +08:00
tabokie
2fcaac79bc move [assertions_on_result_states] to restriction
Signed-off-by: tabokie <xy.tao@outlook.com>
2022-08-02 10:13:51 +02:00
bors
367d09fc4e Auto merge of #9254 - alex-semenyuk:enable_empty_loop_no_std_on_windows, r=dswij
Enable test empty_loop_no_std on windows

Verified that it actully works on windows
changelog: none
2022-08-02 06:44:03 +00:00
Federico Guerinoni
0696624ba7 Add elapsed_instant lint
Closes #8603

Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>
2022-08-01 23:39:00 +02:00
Camille GILLOT
119247ad32 Remove DefId from AssocItemContainer. 2022-08-01 21:38:45 +02:00
Camille GILLOT
d17a30a05d Store associated item defaultness in impl_defaultness. 2022-08-01 21:38:16 +02:00
bors
80a56878cf Auto merge of #99884 - nnethercote:lexer-improvements, r=matklad
Lexer improvements

Some cleanups and small speed improvements.

r? `@matklad`
2022-08-01 12:52:49 +00:00
bors
a5a6c95da8 Auto merge of #9273 - tabokie:assert_ok_fp, r=flip1995
Move [`assertions_on_result_states`] to restriction

Close #9263

This lint causes regression on readability of code and log output. And printing runtime values is not particularly useful for majority of tests which should be reproducible.

changelog: Move [`assertions_on_result_states`] to restriction and don't lint it for unit type

Signed-off-by: tabokie <xy.tao@outlook.com>
2022-08-01 12:16:45 +00:00
tabokie
48ad9d8bc7 do not apply [assertions_on_result_states] to unwrap unit type
Signed-off-by: tabokie <xy.tao@outlook.com>
2022-08-01 20:13:33 +08:00
bors
7c427f0fda Auto merge of #9270 - schubart:link_to_developer_guide, r=xFrednet
Make it easier to find the developer guide

changelog: none
2022-08-01 08:11:50 +00:00
Michael Schubart
72e7064b01 Make it easier to find the developer guide
Adding the link that I wish had been there when I first looked for
this info.
2022-08-01 08:36:17 +01:00
tabokie
e00ceb99cd move [assertions_on_result_states] to restriction
Signed-off-by: tabokie <xy.tao@outlook.com>
2022-08-01 13:22:20 +08:00
bors
a591e725a6 Auto merge of #9223 - sgued:unwrap-expect-used, r=giraffate
unwrap_used: Don't recommend using `expect` when the `expect_used` lint is not allowed

Fixes #9222

```
changelog: [`unwrap_used`]: Don't recommend using `expect` when the `expect_used` lint is not allowed
```
2022-08-01 01:27:03 +00:00
Nicholas Nethercote
09f9acea0a Shrink Token.
From 72 bytes to 12 bytes (on x86-64).

There are two parts to this:
- Changing various source code offsets from 64-bit to 32-bit. This is
  not a problem because the rest of rustc also uses 32-bit source code
  offsets. This means `Token` is no longer `Copy` but this causes no
  problems.
- Removing the `RawStrError` from `LiteralKind`. Raw string literal
  invalidity is now indicated by a `None` value within
  `RawStr`/`RawByteStr`, and the new `validate_raw_str` function can be
  used to re-lex an invalid raw string literal to get the `RawStrError`.

There is one very small change in behaviour. Previously, if a raw string
literal matched both the `InvalidStarter` and `TooManyHashes` cases,
the latter would override the former. This has now changed, because
`raw_double_quoted_string` now uses `?` and so returns immediately upon
detecting the `InvalidStarter` case. I think this is a slight
improvement to report the earlier-detected error, and it explains the
change in the `test_too_many_hashes` test.

The commit also removes a couple of comments that refer to #77629 and
say that the size of these types don't affect performance. These
comments are wrong, though the performance effect is small.
2022-08-01 08:53:04 +10:00
Alex Macleod
cd13574992 Always include a position span in rustc_parse_format::Argument 2022-07-31 15:11:33 +00:00
Dylan DPC
72649cf2a6 Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillot
Use LocalDefId for closures more
2022-07-31 17:36:40 +05:30
Cameron Steffen
62907727af Use LocalDefId for closures more 2022-07-30 15:59:17 -05:00
bors
3641b0ca30 Auto merge of #99948 - Dylan-DPC:rollup-ed5136t, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #99311 (change maybe_body_owned_by to take local def id)
 - #99862 (Improve type mismatch w/ function signatures)
 - #99895 (don't call type ascription "cast")
 - #99900 (remove some manual hash stable impls)
 - #99903 (Add diagnostic when using public instead of pub)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-30 17:30:50 +00:00
bors
ab7e555ad9 Auto merge of #99887 - nnethercote:rm-TreeAndSpacing, r=petrochenkov
Remove `TreeAndSpacing`.

A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is
not quite right. `Spacing` makes sense for `TokenTree::Token`, but does
not make sense for `TokenTree::Delimited`, because a
`TokenTree::Delimited` cannot be joined with another `TokenTree`.

This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`,
changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the
`TreeAndSpacing` typedef.

The commit removes these two impls:
- `impl From<TokenTree> for TokenStream`
- `impl From<TokenTree> for TreeAndSpacing`

These were useful, but also resulted in code with many `.into()` calls
that was hard to read, particularly for anyone not highly familiar with
the relevant types. This commit makes some other changes to compensate:
- `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`.
- `TokenStream::token_{alone,joint}()` are added.
- `TokenStream::delimited` is added.

This results in things like this:
```rust
TokenTree::token(token::Semi, stmt.span).into()
```
changing to this:
```rust
TokenStream::token_alone(token::Semi, stmt.span)
```
This makes the type of the result, and its spacing, clearer.

These changes also simplifies `Cursor` and `CursorRef`, because they no longer
need to distinguish between `next` and `next_with_spacing`.

r? `@petrochenkov`
2022-07-30 14:50:05 +00:00
Sosthene
23b4fe6da5
Apply suggestions from code review
The expect_used lint is allow-by-default, so it would be better to show the case where this is enabled.

Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2022-07-30 13:17:51 +02:00
Miguel Guarniz
6c1110ef5b Avoid ICE when fetching LocalDefId
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Miguel Guarniz
ce5fa10cce Change enclosing_body_owner to return LocalDefId
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Miguel Guarniz
29a0f69f9c Rename local_did to def_id
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Miguel Guarniz
ca0996e3a0 Change maybe_body_owned_by to take local def id
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:25:58 -04:00
bors
a0ed68776e Auto merge of #8974 - Metaswitch:remove-blacklist-terminology, r=Manishearth
Remove "blacklist" terminology

Picking up where https://github.com/rust-lang/rust-clippy/pull/5896 left off, this renames the `blacklisted_name` lint to `disallowed_names` (pluralised for compliance with naming conventions).  The old name is still available though is deprecated (both in the lint name, and in the TOML configuration file).

This has been proposed/requested a few times, most recently in https://github.com/rust-lang/rust-clippy/issues/7582 where `@xFrednet` suggested pinging the Clippy team when a PR was created hence...

cc: `@rust-lang/clippy`

changelog: [`disallowed_names`] lint replaces `blacklisted_name`
2022-07-29 19:12:49 +00:00
Andy Caldwell
56c9cc458d
Add deprecation test for old configuration entry 2022-07-29 19:39:20 +01:00
Andy Caldwell
66b46749e6
Change lint name to plural 2022-07-29 19:35:39 +01:00
Andy Caldwell
2f48257cfb
Rename "blacklisted name" to "disallowed name" throughout 2022-07-29 19:35:18 +01:00
Nicholas Nethercote
1a6f02b1f2 Remove TreeAndSpacing.
A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is
not quite right. `Spacing` makes sense for `TokenTree::Token`, but does
not make sense for `TokenTree::Delimited`, because a
`TokenTree::Delimited` cannot be joined with another `TokenTree`.

This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`,
changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the
`TreeAndSpacing` typedef.

The commit removes these two impls:
- `impl From<TokenTree> for TokenStream`
- `impl From<TokenTree> for TreeAndSpacing`

These were useful, but also resulted in code with many `.into()` calls
that was hard to read, particularly for anyone not highly familiar with
the relevant types. This commit makes some other changes to compensate:
- `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`.
- `TokenStream::token_{alone,joint}()` are added.
- `TokenStream::delimited` is added.

This results in things like this:
```rust
TokenTree::token(token::Semi, stmt.span).into()
```
changing to this:
```rust
TokenStream::token_alone(token::Semi, stmt.span)
```
This makes the type of the result, and its spacing, clearer.

These changes also simplifies `Cursor` and `CursorRef`, because they no longer
need to distinguish between `next` and `next_with_spacing`.
2022-07-29 15:52:15 +10:00
bors
61c6d16ade Auto merge of #99660 - PrestonFrom:issue_99265, r=compiler-errors
Generate correct suggestion with named arguments used positionally

Address issue #99265 by checking each positionally used argument
to see if the argument is named and adding a lint to use the name
instead. This way, when named arguments are used positionally in a
different order than their argument order, the suggested lint is
correct.

For example:
```
println!("{b} {}", a=1, b=2);
```
This will now generate the suggestion:
```
println!("{b} {a}", a=1, b=2);
```

Additionally, this check now also correctly replaces or inserts
only where the positional argument is (or would be if implicit).
Also, width and precision are replaced with their argument names
when they exists.

Since the issues were so closely related, this fix for issue #99265
also fixes issue #99266.

Fixes #99265
Fixes #99266
2022-07-29 04:23:08 +00:00
bors
53a09d4855 Auto merge of #9252 - Metaswitch:use-deprecated-config, r=Jarcho
Read and use deprecated configuration (as well as emitting a warning)

Original change written by `@flip1995` I've simply rebased to master and fixed up the formatting/tests.  This change teaches the configuration parser which config key replaced a deprecated key and attempts to populate the latter from the former.  If both keys are provided this fails with a duplicate key error (rather than attempting to guess which the user intended).

Currently this on affects `cyclomatic-complexity-threshold` -> `cognitive-complexity-threshold` but will also be used in #8974 to handle `blacklisted-names` -> `disallowed-names`.

```
changelog: deprecated configuration keys are still applied as if they were provided as their non-deprecated name.
```

- [x] `cargo test` passes locally
- [x] Run `cargo dev fmt`
2022-07-29 00:54:10 +00:00
Andy Caldwell
ea25ef10cf
Harden duplicates checking and add tests 2022-07-28 23:05:24 +01:00
Sosthène Guédon
1fd9f2d271 Fix tests 2022-07-28 22:27:57 +02:00
Sosthène Guédon
307b800f27 unwrap_used: Fix doc to not recommend expect when expect_used is not allowed 2022-07-28 22:08:48 +02:00
Philipp Krones
67c405cc1d Merge commit '3c7e7dbc1583a0b06df5bd7623dd354a4debd23d' into clippyup 2022-07-28 19:08:22 +02:00
bors
3c7e7dbc15 Auto merge of #9257 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-07-28 16:56:38 +00:00
Philipp Krones
510effce59
Bump nightly version -> 2022-07-28 2022-07-28 18:56:16 +02:00
Philipp Krones
0905ec465d
Merge remote-tracking branch 'upstream/master' into rustup 2022-07-28 18:55:32 +02:00
alex-semenyuk
38e80132d5 Enable test empty_loop_no_std on windows 2022-07-28 10:57:01 +03:00
bors
70bca2988b Auto merge of #9253 - Serial-ATA:fix-fmt-err, r=flip1995
Tell the user how to revert `dev setup intellij`

changelog: none
2022-07-28 07:54:15 +00:00
Serial
1ed7bff32c Tell the user how to revert dev setup intellij 2022-07-28 03:40:21 -04:00
bors
cdd4dfc6d6 Auto merge of #9182 - Serial-ATA:new_lint-type-flag, r=xFrednet
Add `--type` flag to `dev new_lint`

changelog: none

This only works with directories, `--type={copies, doc, ...}` won't work. Should they be counted?
2022-07-27 22:17:29 +00:00
Serial
8319196499 Document --type flag 2022-07-27 17:59:56 -04:00
Philipp Krones
08e7ec4047
Read and use deprecated configuration (as well as emitting a warning)
Co-authored-by: Andy Caldwell <andycaldwell@microsoft.com>
2022-07-27 17:47:20 +01:00
Guillaume Gomez
c31637e082 Rollup merge of #99728 - cjgillot:ast-lifetimes-anon-clean, r=petrochenkov
Clean up HIR-based lifetime resolution

Based on https://github.com/rust-lang/rust/pull/97313.

Fixes #98932.

r? `@petrochenkov`
2022-07-27 17:55:07 +02:00
David Wood
257259118c lint: add bad opt access internal lint
Some command-line options accessible through `sess.opts` are best
accessed through wrapper functions on `Session`, `TyCtxt` or otherwise,
rather than through field access on the option struct in the `Session`.

Adds a new lint which triggers on those options that should be accessed
through a wrapper function so that this is prohibited. Options are
annotated with a new attribute `rustc_lint_opt_deny_field_access` which
can specify the error message (i.e. "use this other function instead")
to be emitted.

A simpler alternative would be to simply rename the options in the
option type so that it is clear they should not be used, however this
doesn't prevent uses, just discourages them. Another alternative would
be to make the option fields private, and adding accessor functions on
the option types, however the wrapper functions sometimes rely on
additional state from `Session` or `TyCtxt` which wouldn't be available
in an function on the option type, so the accessor would simply make the
field available and its use would be discouraged too.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27 11:24:27 +01:00
bors
d814681429 Auto merge of #9249 - JohnTitor:book-prefer-checkout-v3, r=flip1995
Use `action/checkout@v3` in the book

As this type of document is often copied/pasted, using a newer version of `actions/checkout` would be better.

changelog: none

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-27 08:20:55 +00:00
Yuki Okushi
9164e3aa52
Use action/checkout@v3 in the book
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-27 16:49:34 +09:00