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

Rollup of 7 pull requests #101092

Closed
wants to merge 37 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e540425
Add a `File::create_new` constructor
joshtriplett Jul 2, 2022
c04568b
Stabilize `std::io::read_to_string`
camelid Aug 9, 2022
7b4cd17
Start uplifting `clippy::for_loops_over_fallibles`
WaffleLapkin Jul 17, 2022
810cf60
Use structured suggestions for `for_loop_over_fallibles` lint
WaffleLapkin Jul 18, 2022
b661157
`for_loop_over_fallibles`: Suggest removing `.next()`
WaffleLapkin Jul 24, 2022
7cf94ad
`for_loop_over_fallibles`: suggest `while let` loop
WaffleLapkin Jul 24, 2022
14b8f24
`for_loop_over_fallibles`: suggest using `?` in some cases
WaffleLapkin Jul 24, 2022
2bf213b
`for_loop_over_fallibles`: remove duplication from the message
WaffleLapkin Jul 24, 2022
5128140
Add a test for the `for_loop_over_fallibles` lint
WaffleLapkin Jul 24, 2022
34815a9
`for_loop_over_fallibles`: fix suggestion for "remove `.next()`" case
WaffleLapkin Jul 24, 2022
c4ab59e
`for_loop_over_fallibles`: don't use `MachineApplicable`
WaffleLapkin Jul 24, 2022
41fccb1
allow or avoid for loops over option in compiler and tests
WaffleLapkin Jul 26, 2022
86360f4
allow `for_loop_over_fallibles` in a `core` test
WaffleLapkin Jul 26, 2022
d7b8a65
Edit documentation for `for_loop_over_fallibles` lint
WaffleLapkin Aug 14, 2022
aed1ae4
remove an infinite loop
WaffleLapkin Aug 15, 2022
71b8c89
fix `for_loop_over_fallibles` lint docs
WaffleLapkin Aug 18, 2022
36c42fa
Use `DisplayBuffer` for socket addresses.
reitermarkus Aug 16, 2022
63700a8
Add tests for `SockAddr` `Display`.
reitermarkus Aug 19, 2022
89c74e8
Move `net::parser` into `net::addr` module.
reitermarkus Aug 19, 2022
d61ecec
Flatten `net` module again.
reitermarkus Aug 24, 2022
4e97626
Call them constants instead of types
compiler-errors Aug 12, 2022
4ff5872
Note binding obligation causes for const equate errors
compiler-errors Aug 12, 2022
d464d3a
Add test for #100414
compiler-errors Aug 12, 2022
8189a45
Use ExprItemObligation and ExprBindingObligation too
compiler-errors Aug 23, 2022
252c65e
Fix clippy tests that trigger `for_loop_over_fallibles` lint
WaffleLapkin Aug 25, 2022
c3f568b
Do not report too many expr field candidates
compiler-errors Aug 23, 2022
3e567bc
Make invalid-value trigger on uninit primitives
5225225 Jul 4, 2022
57ddb2d
Creating uninitialized integers is UB
5225225 Jul 5, 2022
73a30f8
More tests for invalid_value lint
5225225 Jul 5, 2022
5e8f95b
Re-add some justification
5225225 Jul 5, 2022
db9a7fc
Rollup merge of #98801 - joshtriplett:file-create-new, r=thomcc
Dylan-DPC Aug 27, 2022
1c22c94
Rollup merge of #98919 - 5225225:stricter-invalid-value, r=RalfJung
Dylan-DPC Aug 27, 2022
dad93c1
Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-dead
Dylan-DPC Aug 27, 2022
b98848b
Rollup merge of #100337 - camelid:stabilize-io_read_to_string, r=John…
Dylan-DPC Aug 27, 2022
50bc88e
Rollup merge of #100437 - compiler-errors:better-const-mismatch-err, …
Dylan-DPC Aug 27, 2022
6185c88
Rollup merge of #100640 - reitermarkus:socket-display-buffer, r=thomcc
Dylan-DPC Aug 27, 2022
11905c6
Rollup merge of #100898 - compiler-errors:too-many-expr-fields, r=spa…
Dylan-DPC Aug 27, 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
Prev Previous commit
Next Next commit
for_loop_over_fallibles: suggest while let loop
WaffleLapkin committed Aug 14, 2022
commit 7cf94ad91568cc1f2e94c0cca4987dc40aa4e452
10 changes: 10 additions & 0 deletions compiler/rustc_lint/src/for_loop_over_fallibles.rs
Original file line number Diff line number Diff line change
@@ -84,6 +84,16 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopOverFallibles {
"",
Applicability::MaybeIncorrect
);
} else {
warn.multipart_suggestion_verbose(
format!("to check pattern in a loop use `while let`"),
vec![
// NB can't use `until` here because `expr.span` and `pat.span` have different syntax contexts
(expr.span.with_hi(pat.span.lo()), format!("while let {var}(")),
(pat.span.between(arg.span), format!(") = ")),
],
Applicability::MaybeIncorrect
);
}

warn.multipart_suggestion_verbose(