Skip to content

Add a text to unreachable!() #4986

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions clippy_lints/src/panic_unimplemented.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, paths, span_lint};
use crate::utils::{is_direct_expn_of, is_expn_of, match_function_call, paths, span_help_and_lint, span_lint};
use if_chain::if_chain;
use rustc::declare_lint_pass;
use rustc::hir::*;
Expand Down Expand Up @@ -110,8 +110,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PanicUnimplemented {
"`todo` should not be present in production code");
} else if is_expn_of(expr.span, "unreachable").is_some() {
let span = get_outer_span(expr);
span_lint(cx, UNREACHABLE, span,
"`unreachable` should not be present in production code");
span_help_and_lint(cx, UNREACHABLE, span,
"`unreachable` should not be present in production code", "ident is neither enable nor disable");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was not, what the issue was talking about. Anyway, the requested lint already exists, so I don't think there is anything that needs to be done here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review and sorry for the misunderstanding. I will fix this.

} else if is_expn_of(expr.span, "panic").is_some() {
let span = get_outer_span(expr);
span_lint(cx, PANIC, span,
Expand Down
7 changes: 6 additions & 1 deletion tests/ui/for_loop_unfixable.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
error[E0465]: multiple rlib candidates for `regex` found
|
= note: candidate #1: /Users/YusukeAbe/code/rust/rust-clippy/target/debug/deps/libregex-a27846278b6a956a.rlib
= note: candidate #2: /Users/YusukeAbe/code/rust/rust-clippy/target/debug/deps/libregex-18da0247c966b574.rlib
Comment on lines +1 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


error[E0425]: cannot find function `f` in this scope
--> $DIR/for_loop_unfixable.rs:37:12
|
LL | if f(&vec[i], &vec[i]) {
| ^ help: a local variable with a similar name exists: `i`

error: aborting due to previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0425`.
7 changes: 6 additions & 1 deletion tests/ui/option_map_unit_fn_unfixable.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
error[E0465]: multiple rlib candidates for `regex` found
|
= note: candidate #1: /Users/YusukeAbe/code/rust/rust-clippy/target/debug/deps/libregex-a27846278b6a956a.rlib
= note: candidate #2: /Users/YusukeAbe/code/rust/rust-clippy/target/debug/deps/libregex-18da0247c966b574.rlib
Comment on lines +1 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again.


error[E0425]: cannot find value `x` in this scope
--> $DIR/option_map_unit_fn_unfixable.rs:17:5
|
Expand All @@ -22,6 +27,6 @@ error[E0425]: cannot find value `x` in this scope
LL | x.field.map(|value| { do_nothing(value); do_nothing(value); });
| ^ not found in this scope

error: aborting due to 4 previous errors
error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0425`.
1 change: 1 addition & 0 deletions tests/ui/panicking_macros.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ LL | unreachable!();
| ^^^^^^^^^^^^^^^
|
= note: `-D clippy::unreachable` implied by `-D warnings`
= help: ident is neither enable nor disable

error: aborting due to 4 previous errors

181 changes: 18 additions & 163 deletions tests/ui/regex.stderr
Original file line number Diff line number Diff line change
@@ -1,171 +1,26 @@
error: trivial regex
--> $DIR/regex.rs:13:45
error[E0465]: multiple rlib candidates for `regex` found
--> $DIR/regex.rs:4:1
|
LL | let pipe_in_wrong_position = Regex::new("|");
| ^^^
LL | extern crate regex;
| ^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::trivial-regex` implied by `-D warnings`
= help: the regex is unlikely to be useful as it is

error: trivial regex
--> $DIR/regex.rs:14:60
|
LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|");
| ^^^
|
= help: the regex is unlikely to be useful as it is

error: regex syntax error: invalid character class range, the start must be <= the end
--> $DIR/regex.rs:15:42
|
LL | let wrong_char_ranice = Regex::new("[z-a]");
| ^^^
|
= note: `-D clippy::invalid-regex` implied by `-D warnings`

error: regex syntax error: invalid character class range, the start must be <= the end
--> $DIR/regex.rs:16:37
|
LL | let some_unicode = Regex::new("[é-è]");
| ^^^

error: regex syntax error on position 0: unclosed group
--> $DIR/regex.rs:18:33
|
LL | let some_regex = Regex::new(OPENING_PAREN);
| ^^^^^^^^^^^^^

error: trivial regex
--> $DIR/regex.rs:20:53
|
LL | let binary_pipe_in_wrong_position = BRegex::new("|");
| ^^^
|
= help: the regex is unlikely to be useful as it is

error: regex syntax error on position 0: unclosed group
--> $DIR/regex.rs:21:41
|
LL | let some_binary_regex = BRegex::new(OPENING_PAREN);
| ^^^^^^^^^^^^^

error: regex syntax error on position 0: unclosed group
--> $DIR/regex.rs:22:56
|
LL | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN);
| ^^^^^^^^^^^^^

error: regex syntax error on position 0: unclosed group
--> $DIR/regex.rs:34:37
|
LL | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]);
| ^^^^^^^^^^^^^

error: regex syntax error on position 0: unclosed group
--> $DIR/regex.rs:35:39
|
LL | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]);
| ^^^^^^^^^^^^^

error: regex syntax error: unrecognized escape sequence
--> $DIR/regex.rs:37:45
|
LL | let raw_string_error = Regex::new(r"[...//...]");
| ^^

error: regex syntax error: unrecognized escape sequence
--> $DIR/regex.rs:38:46
|
LL | let raw_string_error = Regex::new(r#"[...//...]"#);
| ^^

error: trivial regex
--> $DIR/regex.rs:42:33
|
LL | let trivial_eq = Regex::new("^foobar$");
| ^^^^^^^^^^
note: candidate #1: /Users/YusukeAbe/code/rust/rust-clippy/target/debug/deps/libregex-a27846278b6a956a.rlib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it depends on your environment. Shouldn't be changed.
Maybe: cargo clean; cargo test resolves this failure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo update sometimes fixes this for me as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually do rm target/debug/deps/libregex*.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I will fix this.

--> $DIR/regex.rs:4:1
|
= help: consider using `==` on `str`s

error: trivial regex
--> $DIR/regex.rs:44:48
|
LL | let trivial_eq_builder = RegexBuilder::new("^foobar$");
| ^^^^^^^^^^
|
= help: consider using `==` on `str`s

error: trivial regex
--> $DIR/regex.rs:46:42
|
LL | let trivial_starts_with = Regex::new("^foobar");
| ^^^^^^^^^
|
= help: consider using `str::starts_with`

error: trivial regex
--> $DIR/regex.rs:48:40
|
LL | let trivial_ends_with = Regex::new("foobar$");
| ^^^^^^^^^
|
= help: consider using `str::ends_with`

error: trivial regex
--> $DIR/regex.rs:50:39
|
LL | let trivial_contains = Regex::new("foobar");
| ^^^^^^^^
|
= help: consider using `str::contains`

error: trivial regex
--> $DIR/regex.rs:52:39
|
LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX);
| ^^^^^^^^^^^^^^^^
LL | extern crate regex;
| ^^^^^^^^^^^^^^^^^^^
note: candidate #2: /Users/YusukeAbe/code/rust/rust-clippy/target/debug/deps/libregex-18da0247c966b574.rlib
--> $DIR/regex.rs:4:1
|
= help: consider using `str::contains`
LL | extern crate regex;
| ^^^^^^^^^^^^^^^^^^^

error: trivial regex
--> $DIR/regex.rs:54:40
|
LL | let trivial_backslash = Regex::new("a/.b");
| ^^^^^^^
|
= help: consider using `str::contains`

error: trivial regex
--> $DIR/regex.rs:57:36
|
LL | let trivial_empty = Regex::new("");
| ^^
|
= help: the regex is unlikely to be useful as it is

error: trivial regex
--> $DIR/regex.rs:59:36
|
LL | let trivial_empty = Regex::new("^");
| ^^^
|
= help: the regex is unlikely to be useful as it is

error: trivial regex
--> $DIR/regex.rs:61:36
|
LL | let trivial_empty = Regex::new("^$");
| ^^^^
|
= help: consider using `str::is_empty`

error: trivial regex
--> $DIR/regex.rs:63:44
|
LL | let binary_trivial_empty = BRegex::new("^$");
| ^^^^
error[E0463]: can't find crate for `regex`
--> $DIR/regex.rs:4:1
|
= help: consider using `str::is_empty`
LL | extern crate regex;
| ^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to 23 previous errors
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0463`.
7 changes: 6 additions & 1 deletion tests/ui/result_map_unit_fn_unfixable.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
error[E0465]: multiple rlib candidates for `regex` found
|
= note: candidate #1: /Users/YusukeAbe/code/rust/rust-clippy/target/debug/deps/libregex-a27846278b6a956a.rlib
= note: candidate #2: /Users/YusukeAbe/code/rust/rust-clippy/target/debug/deps/libregex-18da0247c966b574.rlib
Comment on lines +1 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


error[E0425]: cannot find value `x` in this scope
--> $DIR/result_map_unit_fn_unfixable.rs:17:5
|
Expand All @@ -22,6 +27,6 @@ error[E0425]: cannot find value `x` in this scope
LL | x.field.map(|value| { do_nothing(value); do_nothing(value); });
| ^ not found in this scope

error: aborting due to 4 previous errors
error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0425`.