Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Clippy #99865

Merged
merged 73 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
417a600
Introduce opaque type to hidden type projection
oli-obk Jun 22, 2022
a2c6252
avoid some `Symbol` to `String` conversions
TaKO8Ki Jul 16, 2022
2300da4
Rollup merge of #99342 - TaKO8Ki:avoid-symbol-to-string-conversions, …
matthiaskrgr Jul 16, 2022
f88a139
Stabilize `let_chains`
c410-f3r Jul 12, 2022
8cf39a8
Fix `mismatching_type_param_order` false positive
arieluy Jul 10, 2022
9ff7c91
Add new lint `obfuscated_if_else`
arieluy Jul 10, 2022
5b3300d
Add `ui_cargo_toml_metadata` test
smoelius Jul 17, 2022
7d4daaa
Merge commit 'fdb84cbfd25908df5683f8f62388f663d9260e39' into clippyup
flip1995 Jul 18, 2022
659a9ac
Rephrased text to remove passive voice for a more active one.
JoelMon Jul 14, 2022
79a0d23
Auto merge of #9176 - JoelMon:patch-1, r=flip1995
bors Jul 18, 2022
7a5965b
unused_self: respect avoid-breaking-exported-api
Xiretza Jul 18, 2022
f4c9183
Auto merge of #9146 - arieluy:type_params, r=dswij
bors Jul 18, 2022
bf70865
Auto merge of #9199 - Xiretza:unused-self-exported-api, r=Jarcho
bors Jul 18, 2022
cce6171
Auto merge of #9148 - arieluy:then_some_unwrap_or, r=Jarcho
bors Jul 18, 2022
c94ca1c
Fix typo in alloc_instead_of_core
totallyuniquelily Jul 18, 2022
e57c6d6
Auto merge of #9202 - PaulTheNeko:patch-1, r=Manishearth
bors Jul 18, 2022
31e5465
Add Arithmetic lint
c410-f3r Jul 18, 2022
30a9533
Mention first and last macro in backtrace
compiler-errors Jun 21, 2022
95c7591
Check for `todo!` on every expression in `SpanlessEq`
Jarcho Jul 19, 2022
4034074
Use parens around [`needless_borrow`] field calls
Jul 19, 2022
e98b3ca
Auto merge of #9210 - evantypanski:issue9160, r=Manishearth
bors Jul 19, 2022
7c8e1bf
Auto merge of #9207 - Jarcho:todo_arm, r=giraffate
bors Jul 20, 2022
bcd2241
Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r…
oli-obk Jul 20, 2022
a2f9b93
Don't lint `assign_op_pattern` when the suggestion would cause borrow…
Jarcho Jul 20, 2022
27d49b0
Enable test for entrypoint_recursion for windows
alex-semenyuk Jul 20, 2022
8dfea74
Remove extra newlines in [`significant_drop_in_scrutinee`] docs
Serial-ATA Jul 21, 2022
d017e2d
Auto merge of #9217 - Serial-ATA:extra-newlines, r=giraffate
bors Jul 21, 2022
bc903cd
Auto merge of #9216 - smoelius:master, r=flip1995
bors Jul 21, 2022
fa3c293
Auto merge of #9215 - alex-semenyuk:enable_test_entrypoint_recursion,…
bors Jul 21, 2022
05a51e5
Auto merge of #9214 - Jarcho:assign_op_prim, r=Manishearth
bors Jul 21, 2022
6620aa0
update case_sensitive_file_extension_comparisons example
FoseFx Jul 22, 2022
632f994
Do not resolve associated const when there is no provided value
compiler-errors Jul 15, 2022
75dcbd5
Auto merge of #9229 - FoseFx:case_sensitive_file_extension_comparison…
bors Jul 23, 2022
a738955
fix outdated lint names in docs
RalfJung Jul 23, 2022
580f642
Auto merge of #9230 - RalfJung:fix-doc-lint-names, r=Alexendoo
bors Jul 23, 2022
663cddc
Fix src link
alex-semenyuk Jul 24, 2022
4a5b7e2
Auto merge of #9235 - alex-semenyuk:fixing_guide_link, r=llogiq
bors Jul 24, 2022
d60d5e8
Fix `useless_format` spans for `format!("{foo}")`
Alexendoo Jul 24, 2022
20e4204
Auto merge of #9237 - Alexendoo:useless-format-spans, r=Jarcho
bors Jul 24, 2022
ab6463e
Fix ICE in `miri_to_const`
Jarcho Jul 24, 2022
2255cfd
Fix ICE in `question_mark`
Jarcho Jul 25, 2022
6bc024d
Improve `[std|alloc]_instead_of_[alloc|core]` lints
Jarcho Jul 25, 2022
af33de7
Auto merge of #9244 - Jarcho:ice-9242, r=flip1995
bors Jul 25, 2022
b5e5b42
Enable test multiple_config_files on windows
alex-semenyuk Jul 25, 2022
f847795
Auto merge of #9245 - alex-semenyuk:enable_multiple_config_files_on_w…
bors Jul 25, 2022
4773564
check macro statements in non_copy_const.rs
kyoto7250 Jul 25, 2022
b6c3010
fixed tests to not use tokio
kyoto7250 Jul 25, 2022
a14edd5
Auto merge of #9246 - kyoto7250:reopen_issue_8493, r=Jarcho
bors Jul 25, 2022
8454602
Add `[assertions_on_result_states]` lint
tabokie Jul 22, 2022
1cce047
Auto merge of #9225 - tabokie:assert_ok, r=Jarcho
bors Jul 25, 2022
c76db5c
Auto merge of #9243 - Jarcho:std_core, r=Manishearth
bors Jul 25, 2022
419d39c
Clippy fallout.
cjgillot Jun 6, 2022
6654aab
Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkov
bors Jul 25, 2022
8882578
Auto merge of #9130 - c410-f3r:arith, r=llogiq
bors Jul 25, 2022
d72e5f2
Auto merge of #9241 - Jarcho:ice_9238, r=xFrednet
bors Jul 25, 2022
51cd5a8
Add `--type` flag to `dev new_lint`
Serial-ATA Jul 14, 2022
034b6f9
Replace LifetimeRes::Anonymous by LifetimeRes::Infer.
cjgillot Jun 13, 2022
8edcf6c
Clippy fallout.
cjgillot Jun 13, 2022
c8ee8c3
Give the user more information during creation
Serial-ATA Jul 26, 2022
f319370
Implicitly set `--type=cargo` when using `--category=cargo`
Serial-ATA Jul 26, 2022
9164e3a
Use `action/checkout@v3` in the book
JohnTitor Jul 27, 2022
d814681
Auto merge of #9249 - JohnTitor:book-prefer-checkout-v3, r=flip1995
bors Jul 27, 2022
2572591
lint: add bad opt access internal lint
davidtwco Jul 25, 2022
c31637e
Rollup merge of #99728 - cjgillot:ast-lifetimes-anon-clean, r=petroch…
GuillaumeGomez Jul 27, 2022
8319196
Document `--type` flag
Serial-ATA Jul 27, 2022
cdd4dfc
Auto merge of #9182 - Serial-ATA:new_lint-type-flag, r=xFrednet
bors Jul 27, 2022
1ed7bff
Tell the user how to revert `dev setup intellij`
Serial-ATA Jul 28, 2022
70bca29
Auto merge of #9253 - Serial-ATA:fix-fmt-err, r=flip1995
bors Jul 28, 2022
0905ec4
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jul 28, 2022
510effc
Bump nightly version -> 2022-07-28
flip1995 Jul 28, 2022
3c7e7db
Auto merge of #9257 - flip1995:rustup, r=flip1995
bors Jul 28, 2022
7a78253
Merge commit '3c7e7dbc1583a0b06df5bd7623dd354a4debd23d' into clippyup
flip1995 Jul 28, 2022
d673219
Update Cargo.lock
flip1995 Jul 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ dependencies = [
"tester",
"tokio",
"toml",
"walkdir",
]

[[package]]
Expand Down
3 changes: 3 additions & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3437,9 +3437,11 @@ Released 2018-09-13
[`almost_complete_letter_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_letter_range
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
[`arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic
[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
[`as_underscore`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore
[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
[`assertions_on_result_states`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states
[`assign_op_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
[`assign_ops`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_ops
[`async_yields_async`]: https://rust-lang.github.io/rust-clippy/master/index.html#async_yields_async
Expand Down Expand Up @@ -3793,6 +3795,7 @@ Released 2018-09-13
[`nonsensical_open_options`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonsensical_open_options
[`nonstandard_macro_braces`]: https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
[`not_unsafe_ptr_arg_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref
[`obfuscated_if_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#obfuscated_if_else
[`octal_escapes`]: https://rust-lang.github.io/rust-clippy/master/index.html#octal_escapes
[`ok_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#ok_expect
[`only_used_in_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#only_used_in_recursion
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ compiletest_rs = { version = "0.8", features = ["tmp"] }
tester = "0.9"
regex = "1.5"
toml = "0.5"
walkdir = "2.3"
# This is used by the `collect-metadata` alias.
filetime = "0.2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GitHub Actions

On the GitHub hosted runners, Clippy from the latest stable Rust version comes
pre-installed. So all you have to do is to run `cargo clippy`.
GitHub hosted runners using the latest stable version of Rust have Clippy pre-installed.
It is as simple as running `cargo clippy` to run lints against the codebase.

```yml
on: push
Expand All @@ -15,7 +15,7 @@ jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Run Clippy
run: cargo clippy --all-targets --all-features
```
45 changes: 35 additions & 10 deletions src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ because that's clearly a non-descriptive name.
- [Adding a new lint](#adding-a-new-lint)
- [Setup](#setup)
- [Getting Started](#getting-started)
- [Defining Our Lint](#defining-our-lint)
- [Standalone](#standalone)
- [Specific Type](#specific-type)
- [Tests Location](#tests-location)
- [Testing](#testing)
- [Cargo lints](#cargo-lints)
- [Rustfix tests](#rustfix-tests)
Expand All @@ -36,17 +40,38 @@ See the [Basics](basics.md#get-the-code) documentation.
## Getting Started

There is a bit of boilerplate code that needs to be set up when creating a new
lint. Fortunately, you can use the clippy dev tools to handle this for you. We
lint. Fortunately, you can use the Clippy dev tools to handle this for you. We
are naming our new lint `foo_functions` (lints are generally written in snake
case), and we don't need type information so it will have an early pass type
(more on this later on). If you're not sure if the name you chose fits the lint,
take a look at our [lint naming guidelines][lint_naming]. To get started on this
lint you can run `cargo dev new_lint --name=foo_functions --pass=early
--category=pedantic` (category will default to nursery if not provided). This
command will create two files: `tests/ui/foo_functions.rs` and
`clippy_lints/src/foo_functions.rs`, as well as [registering the
lint](#lint-registration). For cargo lints, two project hierarchies (fail/pass)
will be created by default under `tests/ui-cargo`.
case), and we don't need type information, so it will have an early pass type
(more on this later). If you're unsure if the name you chose fits the lint,
take a look at our [lint naming guidelines][lint_naming].

## Defining Our Lint
To get started, there are two ways to define our lint.

### Standalone
Command: `cargo dev new_lint --name=foo_functions --pass=early --category=pedantic`
(category will default to nursery if not provided)

This command will create a new file: `clippy_lints/src/foo_functions.rs`, as well
as [register the lint](#lint-registration).

### Specific Type
Command: `cargo dev new_lint --name=foo_functions --type=functions --category=pedantic`

This command will create a new file: `clippy_lints/src/{type}/foo_functions.rs`.

Notice how this command has a `--type` flag instead of `--pass`. Unlike a standalone
definition, this lint won't be registered in the traditional sense. Instead, you will
call your lint from within the type's lint pass, found in `clippy_lints/src/{type}/mod.rs`.

A "type" is just the name of a directory in `clippy_lints/src`, like `functions` in
the example command. These are groupings of lints with common behaviors, so if your
lint falls into one, it would be best to add it to that type.

### Tests Location
Both commands will create a file: `tests/ui/foo_functions.rs`. For cargo lints,
two project hierarchies (fail/pass) will be created by default under `tests/ui-cargo`.

Next, we'll open up these files and add our lint!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ instructions for other options.
## Make changes

The book's
[src](https://github.com/joshrotenberg/rust-clippy/tree/clippy_guide/book/src)
[src](https://github.com/rust-lang/rust-clippy/tree/master/book/src)
directory contains all of the markdown files used to generate the book. If you
want to see your changes in real time, you can use the mdbook `serve` command to
run a web server locally that will automatically update changes as they are
Expand Down
8 changes: 4 additions & 4 deletions src/tools/clippy/clippy_dev/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum CliError {
IoError(io::Error),
RustfmtNotInstalled,
WalkDirError(walkdir::Error),
RaSetupActive,
IntellijSetupActive,
}

impl From<io::Error> for CliError {
Expand Down Expand Up @@ -48,7 +48,7 @@ pub fn run(check: bool, verbose: bool) {
.expect("Failed to read clippy Cargo.toml")
.contains(&"[target.'cfg(NOT_A_PLATFORM)'.dependencies]")
{
return Err(CliError::RaSetupActive);
return Err(CliError::IntellijSetupActive);
}

rustfmt_test(context)?;
Expand Down Expand Up @@ -93,11 +93,11 @@ pub fn run(check: bool, verbose: bool) {
CliError::WalkDirError(err) => {
eprintln!("error: {}", err);
},
CliError::RaSetupActive => {
CliError::IntellijSetupActive => {
eprintln!(
"error: a local rustc repo is enabled as path dependency via `cargo dev setup intellij`.
Not formatting because that would format the local repo as well!
Please revert the changes to Cargo.tomls first."
Please revert the changes to Cargo.tomls with `cargo dev remove intellij`."
);
},
}
Expand Down
11 changes: 9 additions & 2 deletions src/tools/clippy/clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ fn main() {
match new_lint::create(
matches.get_one::<String>("pass"),
matches.get_one::<String>("name"),
matches.get_one::<String>("category"),
matches.get_one::<String>("category").map(String::as_str),
matches.get_one::<String>("type").map(String::as_str),
matches.contains_id("msrv"),
) {
Ok(_) => update_lints::update(update_lints::UpdateMode::Change),
Expand Down Expand Up @@ -157,7 +158,8 @@ fn get_clap_config() -> ArgMatches {
.help("Specify whether the lint runs during the early or late pass")
.takes_value(true)
.value_parser([PossibleValue::new("early"), PossibleValue::new("late")])
.required(true),
.conflicts_with("type")
.required_unless_present("type"),
Arg::new("name")
.short('n')
.long("name")
Expand All @@ -183,6 +185,11 @@ fn get_clap_config() -> ArgMatches {
PossibleValue::new("internal_warn"),
])
.takes_value(true),
Arg::new("type")
.long("type")
.help("What directory the lint belongs in")
.takes_value(true)
.required(false),
Arg::new("msrv").long("msrv").help("Add MSRV config code to the lint"),
]),
Command::new("setup")
Expand Down
Loading