Skip to content

Commit 2ed90a6

Browse files
committed
submodules: Update clippy
1 parent ed13f9e commit 2ed90a6

File tree

110 files changed

+1132
-482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1132
-482
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env:
2222
install:
2323
- |
2424
if [ -z ${INTEGRATION} ]; then
25-
# rustup component add rustfmt || cargo install --git https://github.com/rust-lang/rustfmt/ --force
25+
rustup component add rustfmt || cargo install --git https://github.com/rust-lang/rustfmt/ --force
2626
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
2727
. $HOME/.nvm/nvm.sh
2828
nvm install stable

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ Released 2018-09-13
10001000
[`let_unit_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
10011001
[`linkedlist`]: https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist
10021002
[`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
1003+
[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
10031004
[`manual_memcpy`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_memcpy
10041005
[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
10051006
[`many_single_char_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names

README.md

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

77
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
88

9-
[There are 309 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are 310 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1010

1111
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
1212

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ install:
2222
- del rust-toolchain
2323
- cargo install rustup-toolchain-install-master --debug || echo "rustup-toolchain-install-master already installed"
2424
- rustup-toolchain-install-master %RUSTC_HASH% -f -n master
25-
#- rustup component add rustfmt --toolchain nightly
25+
- rustup component add rustfmt --toolchain nightly & exit 0 # Format test handles missing rustfmt
2626
- rustup default master
2727
- set PATH=%PATH%;C:\Users\appveyor\.rustup\toolchains\master\bin
2828
- rustc -V

clippy_dev/src/fmt.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ pub enum CliError {
1010
CommandFailed(String),
1111
IoError(io::Error),
1212
ProjectRootNotFound,
13+
RustfmtNotInstalled,
1314
WalkDirError(walkdir::Error),
1415
}
1516

1617
impl From<io::Error> for CliError {
1718
fn from(error: io::Error) -> Self {
18-
CliError::IoError(error)
19+
Self::IoError(error)
1920
}
2021
}
2122

2223
impl From<walkdir::Error> for CliError {
2324
fn from(error: walkdir::Error) -> Self {
24-
CliError::WalkDirError(error)
25+
Self::WalkDirError(error)
2526
}
2627
}
2728

@@ -36,6 +37,8 @@ pub fn run(check: bool, verbose: bool) {
3637

3738
let project_root = project_root()?;
3839

40+
rustfmt_test(context)?;
41+
3942
success &= cargo_fmt(context, project_root.as_path())?;
4043
success &= cargo_fmt(context, &project_root.join("clippy_dev"))?;
4144
success &= cargo_fmt(context, &project_root.join("rustc_tools_util"))?;
@@ -69,6 +72,9 @@ pub fn run(check: bool, verbose: bool) {
6972
CliError::ProjectRootNotFound => {
7073
eprintln!("error: Can't determine root of project. Please run inside a Clippy working dir.");
7174
},
75+
CliError::RustfmtNotInstalled => {
76+
eprintln!("error: rustfmt nightly is not installed.");
77+
},
7278
CliError::WalkDirError(err) => {
7379
eprintln!("error: {}", err);
7480
},
@@ -139,6 +145,29 @@ fn cargo_fmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
139145
Ok(success)
140146
}
141147

148+
fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> {
149+
let program = "rustfmt";
150+
let dir = std::env::current_dir()?;
151+
let args = &["+nightly", "--version"];
152+
153+
if context.verbose {
154+
println!("{}", format_command(&program, &dir, args));
155+
}
156+
157+
let output = Command::new(&program).current_dir(&dir).args(args.iter()).output()?;
158+
159+
if output.status.success() {
160+
Ok(())
161+
} else if std::str::from_utf8(&output.stderr)
162+
.unwrap_or("")
163+
.starts_with("error: 'rustfmt' is not installed")
164+
{
165+
Err(CliError::RustfmtNotInstalled)
166+
} else {
167+
Err(CliError::CommandFailed(format_command(&program, &dir, args)))
168+
}
169+
}
170+
142171
fn rustfmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
143172
let mut args = vec!["+nightly".as_ref(), path.as_os_str()];
144173
if context.check {

clippy_lints/src/arithmetic.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ declare_clippy_lint! {
1616
///
1717
/// **Example:**
1818
/// ```rust
19-
/// a + 1
19+
/// # let a = 0;
20+
/// a + 1;
2021
/// ```
2122
pub INTEGER_ARITHMETIC,
2223
restriction,
@@ -33,7 +34,8 @@ declare_clippy_lint! {
3334
///
3435
/// **Example:**
3536
/// ```rust
36-
/// a + 1.0
37+
/// # let a = 0.0;
38+
/// a + 1.0;
3739
/// ```
3840
pub FLOAT_ARITHMETIC,
3941
restriction,

clippy_lints/src/assign_ops.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ declare_clippy_lint! {
4545
/// **Example:**
4646
/// ```rust
4747
/// let mut a = 5;
48-
/// ...
48+
/// let b = 2;
49+
/// // ...
4950
/// a += a + b;
5051
/// ```
5152
pub MISREFACTORED_ASSIGN_OP,

clippy_lints/src/attrs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ declare_clippy_lint! {
113113
///
114114
/// **Example:**
115115
/// ```rust
116-
/// // Bad
117-
/// #[inline(always)]
118-
///
119-
/// fn not_quite_good_code(..) { ... }
120-
///
121116
/// // Good (as inner attribute)
122117
/// #![inline(always)]
123118
///
124-
/// fn this_is_fine(..) { ... }
119+
/// fn this_is_fine() { }
120+
///
121+
/// // Bad
122+
/// #[inline(always)]
123+
///
124+
/// fn not_quite_good_code() { }
125125
///
126126
/// // Good (as outer attribute)
127127
/// #[inline(always)]
128-
/// fn this_is_fine_too(..) { ... }
128+
/// fn this_is_fine_too() { }
129129
/// ```
130130
pub EMPTY_LINE_AFTER_OUTER_ATTR,
131131
nursery,

clippy_lints/src/bytecount.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ declare_clippy_lint! {
2424
/// **Example:**
2525
///
2626
/// ```rust
27-
/// &my_data.filter(|&x| x == 0u8).count() // use bytecount::count instead
27+
/// # let vec = vec![1_u8];
28+
/// &vec.iter().filter(|x| **x == 0u8).count(); // use bytecount::count instead
2829
/// ```
2930
pub NAIVE_BYTECOUNT,
3031
perf,

clippy_lints/src/checked_conversions.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ declare_clippy_lint! {
2727
/// Could be written:
2828
///
2929
/// ```rust
30+
/// # use std::convert::TryFrom;
31+
/// # let foo = 1;
3032
/// # let _ =
3133
/// i32::try_from(foo).is_ok()
3234
/// # ;
@@ -160,12 +162,12 @@ impl ConversionType {
160162
/// Creates a conversion type if the type is allowed & conversion is valid
161163
fn try_new(from: &str, to: &str) -> Option<Self> {
162164
if UINTS.contains(&from) {
163-
Some(ConversionType::FromUnsigned)
165+
Some(Self::FromUnsigned)
164166
} else if SINTS.contains(&from) {
165167
if UINTS.contains(&to) {
166-
Some(ConversionType::SignedToUnsigned)
168+
Some(Self::SignedToUnsigned)
167169
} else if SINTS.contains(&to) {
168-
Some(ConversionType::SignedToSigned)
170+
Some(Self::SignedToSigned)
169171
} else {
170172
None
171173
}

0 commit comments

Comments
 (0)