about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/tools/check_intrinsics_duplicates.py
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-23 20:28:07 +0000
committerbors <bors@rust-lang.org>2023-07-23 20:28:07 +0000
commite4923c21c88b850538aef2804d328ed00add60cc (patch)
tree2ac9facd814101181f296f24f2b4e49a622a4bc0 /compiler/rustc_codegen_gcc/tools/check_intrinsics_duplicates.py
parent58775046a9d9bacc150a502a180b1cd9e220203b (diff)
parent99202a0b56e2ac801dfc8d6fe1a5ae539e6dbc15 (diff)
downloadrust-e4923c21c88b850538aef2804d328ed00add60cc.tar.gz
rust-e4923c21c88b850538aef2804d328ed00add60cc.zip
Auto merge of #10120 - smoelius:or_insert_with, r=blyxyas
`unwrap_or_else_default` -> `unwrap_or_default` and improve resulting lint

Resolves #10080 (though it doesn't implement exactly what's described there)

This PR does the following:
1. Merges `unwrap_or_else_default.rs`'s code into `or_fun_call.rs`
2. Extracts the code to handle `unwrap_or(/* default value */)` and similar, and moves it into `unwrap_or_else_default`
3. Implements the missing functionality from #9342, e.g.,, to handle `or_insert_with(Default::default)`
4. Renames `unwrap_or_else_default` to `unwrap_or_default` (since the "new" lint handles both `unwrap_or` and `unwrap_or_else`, it seemed sensible to use the shortened name)

This PR is currently two commits. The first implements 1-3, the second implements 4.

A word about 2: the `or_fun_call` lint currently produces warnings like the following:
```
error: use of `unwrap_or` followed by a call to `new`
  --> $DIR/or_fun_call.rs:56:14
   |
LL |     with_new.unwrap_or(Vec::new());
   |              ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
```
To me, such warnings look like they should come from `unwrap_or_else_default`, not `or_fun_call`, especially since `or_fun_call` is [in the nursery](https://github.com/rust-lang/rust-clippy/pull/9829).

---

changelog: Move: Renamed `unwrap_or_else_default` to [`unwrap_or_default`]
[#10120](https://github.com/rust-lang/rust-clippy/pull/10120)
changelog: Enhancement: [`unwrap_or_default`]: Now handles more functions, like `or_insert_with`
[#10120](https://github.com/rust-lang/rust-clippy/pull/10120)
<!-- changelog_checked-->
Diffstat (limited to 'compiler/rustc_codegen_gcc/tools/check_intrinsics_duplicates.py')
0 files changed, 0 insertions, 0 deletions