From d1a627ab3bd801879a565cc9e68a322d8d28bcbf Mon Sep 17 00:00:00 2001 From: boolean_coercion Date: Thu, 11 Feb 2021 12:46:11 +0200 Subject: [PATCH] Ran bless and rustfmt --- clippy_lints/src/from_str_radix_10.rs | 14 +++++------ tests/ui/from_str_radix_10.rs | 2 +- tests/ui/from_str_radix_10.stderr | 34 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 tests/ui/from_str_radix_10.stderr diff --git a/clippy_lints/src/from_str_radix_10.rs b/clippy_lints/src/from_str_radix_10.rs index 9371104bf9b..9a8d4542616 100644 --- a/clippy_lints/src/from_str_radix_10.rs +++ b/clippy_lints/src/from_str_radix_10.rs @@ -1,8 +1,8 @@ -use rustc_lint::{LateLintPass, LateContext}; -use rustc_session::{declare_lint_pass, declare_tool_lint}; -use rustc_hir::*; -use rustc_errors::Applicability; use if_chain::if_chain; +use rustc_errors::Applicability; +use rustc_hir::*; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_session::{declare_lint_pass, declare_tool_lint}; use crate::utils::span_lint_and_sugg; @@ -16,7 +16,7 @@ /// and complexity. /// /// **Known problems:** None. - /// + /// /// **Example:** /// /// ```rust @@ -77,6 +77,6 @@ fn is_primitive_integer_ty(ty: PrimTy) -> bool { match ty { PrimTy::Int(_) => true, PrimTy::Uint(_) => true, - _ => false + _ => false, } -} \ No newline at end of file +} diff --git a/tests/ui/from_str_radix_10.rs b/tests/ui/from_str_radix_10.rs index 795e795fcb3..2d8106da7ba 100644 --- a/tests/ui/from_str_radix_10.rs +++ b/tests/ui/from_str_radix_10.rs @@ -33,4 +33,4 @@ fn main() -> Result<(), Box> { from_str_radix("50", 6)?; Ok(()) -} \ No newline at end of file +} diff --git a/tests/ui/from_str_radix_10.stderr b/tests/ui/from_str_radix_10.stderr new file mode 100644 index 00000000000..376d0dd56ea --- /dev/null +++ b/tests/ui/from_str_radix_10.stderr @@ -0,0 +1,34 @@ +error: This call to `from_str_radix` can be shortened to a call to str::parse + --> $DIR/from_str_radix_10.rs:17:5 + | +LL | u32::from_str_radix("30", 10)?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("30").parse()` + | + = note: `-D clippy::from-str-radix-10` implied by `-D warnings` + +error: This call to `from_str_radix` can be shortened to a call to str::parse + --> $DIR/from_str_radix_10.rs:18:5 + | +LL | i64::from_str_radix("24", 10)?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("24").parse()` + +error: This call to `from_str_radix` can be shortened to a call to str::parse + --> $DIR/from_str_radix_10.rs:19:5 + | +LL | isize::from_str_radix("100", 10)?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("100").parse()` + +error: This call to `from_str_radix` can be shortened to a call to str::parse + --> $DIR/from_str_radix_10.rs:20:5 + | +LL | u8::from_str_radix("7", 10)?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("7").parse()` + +error: This call to `from_str_radix` can be shortened to a call to str::parse + --> $DIR/from_str_radix_10.rs:23:5 + | +LL | i32::from_str_radix(string, 10)?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(string).parse()` + +error: aborting due to 5 previous errors +