Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 978f8c6

Browse files
committed
Renamed forced_return to missing_returns.
Better clarification in the docs. Ran `update_lints`.
1 parent d5d6692 commit 978f8c6

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ All notable changes to this project will be documented in this file.
756756
[`misrefactored_assign_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#misrefactored_assign_op
757757
[`missing_docs_in_private_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_docs_in_private_items
758758
[`missing_inline_in_public_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_inline_in_public_items
759+
[`missing_returns`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_returns
759760
[`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes
760761
[`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals
761762
[`module_inception`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_inception

clippy_lints/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ pub mod misc;
152152
pub mod misc_early;
153153
pub mod missing_doc;
154154
pub mod missing_inline;
155+
pub mod missing_returns;
155156
pub mod multiple_crate_versions;
156157
pub mod mut_mut;
157158
pub mod mut_reference;
@@ -185,7 +186,6 @@ pub mod reference;
185186
pub mod regex;
186187
pub mod replace_consts;
187188
pub mod returns;
188-
pub mod forced_return;
189189
pub mod serde_api;
190190
pub mod shadow;
191191
pub mod slow_vector_initialization;
@@ -372,7 +372,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
372372
reg.register_late_lint_pass(box unicode::Unicode);
373373
reg.register_late_lint_pass(box strings::StringAdd);
374374
reg.register_early_lint_pass(box returns::ReturnPass);
375-
reg.register_late_lint_pass(box forced_return::ForcedReturnPass);
375+
reg.register_late_lint_pass(box missing_returns::MissingReturnsPass);
376376
reg.register_late_lint_pass(box methods::Pass);
377377
reg.register_late_lint_pass(box map_clone::Pass);
378378
reg.register_late_lint_pass(box shadow::Pass);
@@ -498,13 +498,13 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
498498
misc::FLOAT_CMP_CONST,
499499
missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
500500
missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
501+
missing_returns::MISSING_RETURNS,
501502
panic_unimplemented::UNIMPLEMENTED,
502503
shadow::SHADOW_REUSE,
503504
shadow::SHADOW_SAME,
504505
strings::STRING_ADD,
505506
write::PRINT_STDOUT,
506507
write::USE_DEBUG,
507-
forced_return::FORCED_RETURN,
508508
]);
509509

510510
reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![

clippy_lints/src/forced_return.rs renamed to clippy_lints/src/missing_returns.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use crate::utils::{snippet_opt, span_lint_and_then};
1616

1717
/// **What it does:** Checks for missing return statements at the end of a block.
1818
///
19-
/// **Why is this bad?** Actually it is idiomatic Rust code. Programmers coming
20-
/// from other languages might prefer the expressiveness of `return`.
19+
/// **Why is this bad?** Actually omitting the return keyword is idiomatic Rust code. Programmers
20+
/// coming from other languages might prefer the expressiveness of `return`.
2121
///
2222
/// **Known problems:** None.
2323
///
@@ -34,16 +34,16 @@ use crate::utils::{snippet_opt, span_lint_and_then};
3434
/// }
3535
/// ```
3636
declare_clippy_lint! {
37-
pub FORCED_RETURN,
37+
pub MISSING_RETURNS,
3838
restriction,
3939
"use a return statement like `return expr` instead of an expression"
4040
}
4141

42-
pub struct ForcedReturnPass;
42+
pub struct MissingReturnsPass;
4343

44-
impl ForcedReturnPass {
44+
impl MissingReturnsPass {
4545
fn show_suggestion(cx: &LateContext<'_, '_>, span: syntax_pos::Span) {
46-
span_lint_and_then(cx, FORCED_RETURN, span, "missing return statement", |db| {
46+
span_lint_and_then(cx, MISSING_RETURNS, span, "missing return statement", |db| {
4747
if let Some(snippet) = snippet_opt(cx, span) {
4848
db.span_suggestion_with_applicability(
4949
span,
@@ -80,13 +80,13 @@ impl ForcedReturnPass {
8080
}
8181
}
8282

83-
impl LintPass for ForcedReturnPass {
83+
impl LintPass for MissingReturnsPass {
8484
fn get_lints(&self) -> LintArray {
85-
lint_array!(FORCED_RETURN)
85+
lint_array!(MISSING_RETURNS)
8686
}
8787
}
8888

89-
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ForcedReturnPass {
89+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingReturnsPass {
9090
fn check_fn(
9191
&mut self,
9292
cx: &LateContext<'a, 'tcx>,

tests/ui/forced_return.rs renamed to tests/ui/missing_returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313

14-
#![warn(clippy::forced_return)]
14+
#![warn(clippy::missing_returns)]
1515

1616
fn test_end_of_fn() -> bool {
1717
if true {

tests/ui/forced_return.stderr renamed to tests/ui/missing_returns.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
error: missing return statement
2-
--> $DIR/forced_return.rs:21:5
2+
--> $DIR/missing_returns.rs:21:5
33
|
44
21 | true
55
| ^^^^ help: add `return` as shown: `return true`
66
|
7-
= note: `-D clippy::forced-return` implied by `-D warnings`
7+
= note: `-D clippy::missing-returns` implied by `-D warnings`
88

99
error: missing return statement
10-
--> $DIR/forced_return.rs:27:9
10+
--> $DIR/missing_returns.rs:27:9
1111
|
1212
27 | true
1313
| ^^^^ help: add `return` as shown: `return true`
1414

1515
error: missing return statement
16-
--> $DIR/forced_return.rs:29:9
16+
--> $DIR/missing_returns.rs:29:9
1717
|
1818
29 | false
1919
| ^^^^^ help: add `return` as shown: `return false`
2020

2121
error: missing return statement
22-
--> $DIR/forced_return.rs:36:17
22+
--> $DIR/missing_returns.rs:36:17
2323
|
2424
36 | true => false,
2525
| ^^^^^ help: add `return` as shown: `return false`
2626

2727
error: missing return statement
28-
--> $DIR/forced_return.rs:38:13
28+
--> $DIR/missing_returns.rs:38:13
2929
|
3030
38 | true
3131
| ^^^^ help: add `return` as shown: `return true`
3232

3333
error: missing return statement
34-
--> $DIR/forced_return.rs:45:9
34+
--> $DIR/missing_returns.rs:45:9
3535
|
3636
45 | true
3737
| ^^^^ help: add `return` as shown: `return true`
3838

3939
error: missing return statement
40-
--> $DIR/forced_return.rs:47:16
40+
--> $DIR/missing_returns.rs:47:16
4141
|
4242
47 | let _ = || true;
4343
| ^^^^ help: add `return` as shown: `return true`

0 commit comments

Comments
 (0)