Commit graph

13743 commits

Author SHA1 Message Date
bors
ff0a3687d8 Auto merge of #8520 - J-ZhengLi:issue8506, r=xFrednet
fix suggestion on `[map_flatten]` being cropped causing possible information loss

fixes #8506

Multi-line suggestion given by the lint is missing its bottom part, which could potentially contains useful information about the fix.

---

changelog: [`map_flatten`]: Long suggestions will now be splitup into two help messages
2022-03-21 19:51:56 +00:00
J-ZhengLi
5b6295d663 allowing [map_flatten] to split long suggestions
add new function `span_lint_and_sugg_` for edges in `clippy_utils::diagnostics`
2022-03-21 14:11:22 +08:00
Max Baumann
765cce11b1
refactor: remove need for MethodCall matching 2022-03-21 00:04:37 +01:00
Max Baumann
4580c8a9b7
refactor: use is_lang_ctor() 2022-03-20 23:54:04 +01:00
Max Baumann
0f83753934
feat: change error message 2022-03-20 23:43:17 +01:00
bors
47b93ea5ef Auto merge of #8559 - pickfire:patch-1, r=xFrednet
Fix typo in bug report

repoduce -> reproduce

---

changelog: none
2022-03-20 22:32:12 +00:00
Camille GILLOT
94c727eccf Take &mut Diagnostic in emit_diagnostic.
Taking a Diagnostic by move would break the usual pattern
`diag.label(..).emit()`.
2022-03-20 20:36:08 +01:00
Max Baumann
20c352a4f6
test: add method chain test 2022-03-19 18:17:43 +01:00
Max Baumann
895de1f13e
feat: make fixable 2022-03-18 23:18:36 +01:00
Max Baumann
f00e844a1f
feat: use span_lint_and_sugg 2022-03-18 22:44:56 +01:00
Max Baumann
34ad33c57a
refactor: move into methods module 2022-03-18 21:11:54 +01:00
bors
a31dcb77be Auto merge of #8562 - Jarcho:enum_tuple_variant_as_int, r=Manishearth
Add lint `cast_enum_constructor`

fixes: #1116

changelog: Add lint `cast_enum_constructor`
2022-03-18 15:54:45 +00:00
Max Baumann
fd2c860171
feat: add comment 2022-03-18 14:45:48 +01:00
bors
9fd3c2d788 Auto merge of #8543 - dswij:8393, r=giraffate
`unnecessary_lazy_eval` show suggestions on multiline lint

Closes #8393

changelog: [`unnecessary_lazy_eval`] now shows suggestions for long-line lints
2022-03-18 00:42:18 +00:00
Max Baumann
3c4192f3e9
fix: ran update_lints 2022-03-18 01:12:39 +01:00
Max Baumann
05e05eaed7
refactor: rename lint to or_then_unwrap 2022-03-18 01:04:33 +01:00
Jason Newcomb
39329d1d40 Add lint cast_enum_constructor 2022-03-17 19:57:35 -04:00
Max Baumann
44c62c9aa2
feat: add tests and fix existing ones 2022-03-18 00:51:26 +01:00
Max Baumann
17ff85081d
feat: rename variable in example 2022-03-18 00:34:24 +01:00
Max Baumann
4493fc7d27
refactor: use pattern matching for MethodCall arguments
Co-authored-by: xFrednet <xFrednet@gmail.com>
2022-03-18 00:23:55 +01:00
Dylan DPC
1f069c0ce7 Rollup merge of #94960 - codehorseman:master, r=oli-obk
Fix many spelling mistakes

Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-17 22:55:05 +01:00
Dylan DPC
59dd179ad3 Rollup merge of #94309 - eholk:issue-57017, r=tmandry
[generator_interior] Be more precise with scopes of borrowed places

Previously the generator interior type checking analysis would use the nearest temporary scope as the scope of a borrowed value. This ends up being overly broad for cases such as:

```rust
fn status(_client_status: &Client) -> i16 {
    200
}

fn main() {
    let client = Client;
    let g = move || match status(&client) {
        _status => yield,
    };
    assert_send(g);
}
```

In this case, the borrow `&client` could be considered in scope for the entirety of the `match` expression, meaning it would be viewed as live across the `yield`, therefore making the generator not `Send`.

In most cases, we want to use the enclosing expression as the scope for a borrowed value which will be less than or equal to the nearest temporary scope. This PR changes the analysis to use the enclosing expression as the scope for most borrows, with the exception of borrowed RValues which are true temporary values that should have the temporary scope. There's one further exception where borrows of a copy such as happens in autoref cases also should be ignored despite being RValues.

Joint work with `@nikomatsakis`

Fixes #57017

r? `@tmandry`
2022-03-17 22:55:02 +01:00
Max Baumann
c22ff6cd6e
fix: fix clippy_lints 2022-03-17 19:52:07 +01:00
Max Baumann
747bb245e7
fix: fix broken dogfood tests 2022-03-17 19:29:59 +01:00
Max Baumann
3f00f074de
fix: fix tests 2022-03-17 19:13:44 +01:00
Max Baumann
f49a2c3457
feat: add use_unwrap_or 2022-03-17 18:57:28 +01:00
bors
8d5c0eadde Auto merge of #8552 - Jarcho:ptr_arg_8495, r=xFrednet
Don't lint `ptr_arg` on `&mut Cow<_>`

fixes: #8495

changelog: Don't lint `ptr_arg` on `&mut Cow<_>`
2022-03-17 17:05:26 +00:00
J-ZhengLi
4b128624ed fix #8551, add test cases, and some code improvement 2022-03-17 23:06:31 +08:00
Ivan Tham
3ede557a62
Fix typo in bug report
repoduce -> reproduce
2022-03-17 22:53:27 +08:00
dswij
bd888d4354 Add some comments 2022-03-17 14:38:39 +08:00
Jason Newcomb
773d20341a Fix mixed enum variant kinds + code cleanup 2022-03-17 01:09:25 -04:00
bors
65e5cd0e95 Auto merge of #8553 - Jarcho:transmute_undefined_8499, r=llogiq
Don't lint `transmute_undefined_repr` when changing the type of generic params

Partially fixes #8499

changelog: Don't lint `transmute_undefined_repr` when changing the type of generic params
2022-03-16 19:27:44 +00:00
Jason Newcomb
08a7157a37 Improve message for match_single_arms 2022-03-16 13:58:09 -04:00
Jason Newcomb
4f8f4b4c82 Handle slice patterns in match_same_arms 2022-03-16 13:53:52 -04:00
Jason Newcomb
5508f461b8 Use DroplessArena when allocating ResolvedPats
Fix tuple handling in `match_same_arms`
2022-03-16 13:49:19 -04:00
Jason Newcomb
b37317b028 Check if there are any overlapping patterns between equal arm bodies in match_same_arm 2022-03-16 13:18:29 -04:00
Jason Newcomb
8e5208cbff Don't lint transmute_undefined_repr when changing the type of generic params 2022-03-16 12:56:23 -04:00
Jason Newcomb
851e715e5a Don't lint ptr_arg on &mut Cow<_> 2022-03-16 12:00:27 -04:00
codehorseman
4beda1be70 resolve the conflict in compiler/rustc_session/src/parse.rs
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-16 20:12:30 +08:00
bors
d23ddab82d Auto merge of #8544 - nellorocca:dev/5757, r=flip1995
Moved ``[try_err]`` to restriction

Fixes #5757

changelog: Moved try_err lint to rescrition for #5757
2022-03-16 09:55:39 +00:00
bors
2b0e730bf3 Auto merge of #8547 - Jarcho:transmute_8501, r=flip1995
More `transmute_undefined_repr` fixes

fixes: #8498
fixes: #8501
fixes: #8503

changelog: Allow `transumte_undefined_repr` between fat pointers and `(usize, usize)`
changelog: Allow `transumte_undefined_repr` when one side is a union
changelog: Fix `transumte_undefined_repr` on tuples with one non-zero-sized type.
2022-03-16 09:39:22 +00:00
J-ZhengLi
2909b33a24 quick fix of issue#8542 for lint [needless_match]
remove `ref`/`ref mut` check
2022-03-16 16:26:56 +08:00
bors
d6a3fbf8da Auto merge of #8546 - KisaragiEffective:patch-1, r=llogiq
[`collapsible_if`] fix typo in code-block kind specifier

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`collapsible_if`] fix typo in code-block kind specifier
2022-03-16 06:20:45 +00:00
Jason Newcomb
47c9ed697b Fix checking transmutes with adjusted types 2022-03-15 23:11:11 -04:00
Jason Newcomb
911e10562a Don't lint transmute_undefined_repr on unions. 2022-03-15 22:38:15 -04:00
Jason Newcomb
7fd52b5e3c Small simplification to transmute_undefined_repr 2022-03-15 22:33:26 -04:00
Jason Newcomb
442d4ce1c3 Don't lint fat pointer to (usize, usize) conversion in transmute_undefined_repr 2022-03-15 22:31:07 -04:00
Jason Newcomb
e71ac41d44 Fix transmute_undefined_repr for single element tuples 2022-03-15 21:51:07 -04:00
Kisaragi
9f95e7622d
fix typo in code-block kind specifier 2022-03-16 10:19:19 +09:00
Kisaragi
fc5cbba1a4
fix typo in code-block kind specifier 2022-03-16 08:50:30 +09:00