Renamed forced_return to missing_returns.

Better clarification in the docs.
Ran `update_lints`.
This commit is contained in:
daxpedda
2018-12-05 10:54:21 +01:00
parent d5d6692288
commit 978f8c65ee
5 changed files with 22 additions and 21 deletions

View File

@@ -756,6 +756,7 @@ All notable changes to this project will be documented in this file.
[`misrefactored_assign_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#misrefactored_assign_op [`misrefactored_assign_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#misrefactored_assign_op
[`missing_docs_in_private_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_docs_in_private_items [`missing_docs_in_private_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_docs_in_private_items
[`missing_inline_in_public_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_inline_in_public_items [`missing_inline_in_public_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_inline_in_public_items
[`missing_returns`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_returns
[`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes [`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes
[`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals [`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals
[`module_inception`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_inception [`module_inception`]: https://rust-lang.github.io/rust-clippy/master/index.html#module_inception

View File

@@ -152,6 +152,7 @@ pub mod misc;
pub mod misc_early; pub mod misc_early;
pub mod missing_doc; pub mod missing_doc;
pub mod missing_inline; pub mod missing_inline;
pub mod missing_returns;
pub mod multiple_crate_versions; pub mod multiple_crate_versions;
pub mod mut_mut; pub mod mut_mut;
pub mod mut_reference; pub mod mut_reference;
@@ -185,7 +186,6 @@ pub mod reference;
pub mod regex; pub mod regex;
pub mod replace_consts; pub mod replace_consts;
pub mod returns; pub mod returns;
pub mod forced_return;
pub mod serde_api; pub mod serde_api;
pub mod shadow; pub mod shadow;
pub mod slow_vector_initialization; pub mod slow_vector_initialization;
@@ -372,7 +372,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
reg.register_late_lint_pass(box unicode::Unicode); reg.register_late_lint_pass(box unicode::Unicode);
reg.register_late_lint_pass(box strings::StringAdd); reg.register_late_lint_pass(box strings::StringAdd);
reg.register_early_lint_pass(box returns::ReturnPass); reg.register_early_lint_pass(box returns::ReturnPass);
reg.register_late_lint_pass(box forced_return::ForcedReturnPass); reg.register_late_lint_pass(box missing_returns::MissingReturnsPass);
reg.register_late_lint_pass(box methods::Pass); reg.register_late_lint_pass(box methods::Pass);
reg.register_late_lint_pass(box map_clone::Pass); reg.register_late_lint_pass(box map_clone::Pass);
reg.register_late_lint_pass(box shadow::Pass); reg.register_late_lint_pass(box shadow::Pass);
@@ -498,13 +498,13 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
misc::FLOAT_CMP_CONST, misc::FLOAT_CMP_CONST,
missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS, missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS, missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
missing_returns::MISSING_RETURNS,
panic_unimplemented::UNIMPLEMENTED, panic_unimplemented::UNIMPLEMENTED,
shadow::SHADOW_REUSE, shadow::SHADOW_REUSE,
shadow::SHADOW_SAME, shadow::SHADOW_SAME,
strings::STRING_ADD, strings::STRING_ADD,
write::PRINT_STDOUT, write::PRINT_STDOUT,
write::USE_DEBUG, write::USE_DEBUG,
forced_return::FORCED_RETURN,
]); ]);
reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![ reg.register_lint_group("clippy::pedantic", Some("clippy_pedantic"), vec![

View File

@@ -16,8 +16,8 @@ use crate::utils::{snippet_opt, span_lint_and_then};
/// **What it does:** Checks for missing return statements at the end of a block. /// **What it does:** Checks for missing return statements at the end of a block.
/// ///
/// **Why is this bad?** Actually it is idiomatic Rust code. Programmers coming /// **Why is this bad?** Actually omitting the return keyword is idiomatic Rust code. Programmers
/// from other languages might prefer the expressiveness of `return`. /// coming from other languages might prefer the expressiveness of `return`.
/// ///
/// **Known problems:** None. /// **Known problems:** None.
/// ///
@@ -34,16 +34,16 @@ use crate::utils::{snippet_opt, span_lint_and_then};
/// } /// }
/// ``` /// ```
declare_clippy_lint! { declare_clippy_lint! {
pub FORCED_RETURN, pub MISSING_RETURNS,
restriction, restriction,
"use a return statement like `return expr` instead of an expression" "use a return statement like `return expr` instead of an expression"
} }
pub struct ForcedReturnPass; pub struct MissingReturnsPass;
impl ForcedReturnPass { impl MissingReturnsPass {
fn show_suggestion(cx: &LateContext<'_, '_>, span: syntax_pos::Span) { fn show_suggestion(cx: &LateContext<'_, '_>, span: syntax_pos::Span) {
span_lint_and_then(cx, FORCED_RETURN, span, "missing return statement", |db| { span_lint_and_then(cx, MISSING_RETURNS, span, "missing return statement", |db| {
if let Some(snippet) = snippet_opt(cx, span) { if let Some(snippet) = snippet_opt(cx, span) {
db.span_suggestion_with_applicability( db.span_suggestion_with_applicability(
span, span,
@@ -80,13 +80,13 @@ impl ForcedReturnPass {
} }
} }
impl LintPass for ForcedReturnPass { impl LintPass for MissingReturnsPass {
fn get_lints(&self) -> LintArray { fn get_lints(&self) -> LintArray {
lint_array!(FORCED_RETURN) lint_array!(MISSING_RETURNS)
} }
} }
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ForcedReturnPass { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingReturnsPass {
fn check_fn( fn check_fn(
&mut self, &mut self,
cx: &LateContext<'a, 'tcx>, cx: &LateContext<'a, 'tcx>,

View File

@@ -11,7 +11,7 @@
#![warn(clippy::forced_return)] #![warn(clippy::missing_returns)]
fn test_end_of_fn() -> bool { fn test_end_of_fn() -> bool {
if true { if true {

View File

@@ -1,43 +1,43 @@
error: missing return statement error: missing return statement
--> $DIR/forced_return.rs:21:5 --> $DIR/missing_returns.rs:21:5
| |
21 | true 21 | true
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`
| |
= note: `-D clippy::forced-return` implied by `-D warnings` = note: `-D clippy::missing-returns` implied by `-D warnings`
error: missing return statement error: missing return statement
--> $DIR/forced_return.rs:27:9 --> $DIR/missing_returns.rs:27:9
| |
27 | true 27 | true
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`
error: missing return statement error: missing return statement
--> $DIR/forced_return.rs:29:9 --> $DIR/missing_returns.rs:29:9
| |
29 | false 29 | false
| ^^^^^ help: add `return` as shown: `return false` | ^^^^^ help: add `return` as shown: `return false`
error: missing return statement error: missing return statement
--> $DIR/forced_return.rs:36:17 --> $DIR/missing_returns.rs:36:17
| |
36 | true => false, 36 | true => false,
| ^^^^^ help: add `return` as shown: `return false` | ^^^^^ help: add `return` as shown: `return false`
error: missing return statement error: missing return statement
--> $DIR/forced_return.rs:38:13 --> $DIR/missing_returns.rs:38:13
| |
38 | true 38 | true
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`
error: missing return statement error: missing return statement
--> $DIR/forced_return.rs:45:9 --> $DIR/missing_returns.rs:45:9
| |
45 | true 45 | true
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`
error: missing return statement error: missing return statement
--> $DIR/forced_return.rs:47:16 --> $DIR/missing_returns.rs:47:16
| |
47 | let _ = || true; 47 | let _ = || true;
| ^^^^ help: add `return` as shown: `return true` | ^^^^ help: add `return` as shown: `return true`