Skip to content

Commit

Permalink
submodules: update clippy from 7b8e829 to 7a943a9
Browse files Browse the repository at this point in the history
Changes:
````
Normalize custom ICE test
Rustup to rust-lang/rust#64736
Use assert_crate_local for a more explicit error
Rustup to rust-lang/rust#66789
account for external macro in MISSING_INLINE_IN_PUBLIC_ITEMS lint
build(tests/fmt): use shared target dir
chore: fix and split some ui tests on 32bit system
build: set up build job for i686 targets
remove needless my_lint ui test
git quiet
deploy: cd to out/ before adding files to git
Less needless_doctest_main false positives
fmt
Feed the dog
Use rustc_env instead of exec_env for test
Make triggering this lint less likely 📎
Use exec_env to set backtrace level and normalize output
Update custom ICE function with latest rustc
Use Clippy version in ICE message
Add custom ICE message that points to Clippy repo
Fix master deployment
Run update_lints
Add projections check to EUV for escape analysis
Use infer_ctxt
Move use_self to nursery
Use `println!` on success instead of `eprintln!`
Revert "Disable chalk integration test. Output too large"
Remove the old integration-tests.sh script
Use rust implementation for integration tests in CI
Rust implementation of integration test
Don't error on clippy.toml of dependencies
Fix categorizations
Fix arguments on ExprUseVisitor::new
euv moved from middle to typeck
cmt_ -> Place
build: check if RTIM is not installed
make use of Result::map_or
trigger string_lit_as_bytes when literal has escapes
Remove negative float literal checks.
Enable deny-warnings feature everywhere in CI
Remove unused debugging feature
implemented `as_conversions` lint
fixing a typo
[comparison_chain] rust-lang#4827 Check `core::cmp::Ord` is implemented
add a good example for the approx_const lint
Add suggested good cases in docs for lifetimes lint
````
  • Loading branch information
matthiaskrgr committed Dec 2, 2019
1 parent ee1aa9a commit ab2dd0d
Show file tree
Hide file tree
Showing 71 changed files with 1,189 additions and 347 deletions.
2 changes: 2 additions & 0 deletions .github/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ if git diff --exit-code --quiet; then
echo "No changes to the output on this push; exiting."
exit 0
fi
cd -

# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
ENCRYPTION_LABEL=e3a2d77100be
Expand All @@ -72,6 +73,7 @@ chmod 600 .github/deploy_key
eval "$(ssh-agent -s)"
ssh-add .github/deploy_key

cd out
git add .
git commit -m "Automatic deploy to GitHub Pages: ${SHA}"

Expand Down
27 changes: 19 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
dist: xenial
language: bash
git:
depth: 1
quiet: true

branches:
# Don't build these branches
Expand All @@ -22,6 +25,7 @@ env:
- secure: "OKulfkA5OGd/d1IhvBKzRkHQwMcWjzrzbimo7+5NhkUkWxndAzl+719TB3wWvIh1i2wXXrEXsyZkXM5FtRrHm55v1VKQ5ibjEvFg1w3NIg81iDyoLq186fLqywvxGkOAFPrsePPsBj5USd5xvhwwbrjO6L7/RK6Z8shBwOSc41s="

before_install:
- export CARGO_TARGET_DIR="$TRAVIS_BUILD_DIR/target"
- curl -sSL https://sh.rustup.rs | sh -s -- -y --default-toolchain=nightly --profile=minimal
- export PATH="$HOME/.cargo/bin:$PATH"
install:
Expand All @@ -48,6 +52,15 @@ matrix:
include:
# Builds that are executed for every PR
- os: linux
# i686 toolchain could run on x86_64 system.
- os: linux
env: HOST_TOOLCHAIN=i686-unknown-linux-gnu
addons:
apt:
packages:
- gcc-multilib
- libssl-dev:i386 # openssl dev in Cargo.toml
if: branch IN (auto, try)
- os: windows
env: CARGO_INCREMENTAL=0 OS_WINDOWS=true

Expand All @@ -61,14 +74,12 @@ matrix:
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
- env: INTEGRATION=rust-lang/cargo
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
# FIXME: Output too large
# - env: INTEGRATION=rust-lang-nursery/chalk
# if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
- env: INTEGRATION=rust-lang/chalk
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
- env: INTEGRATION=Geal/nom
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
# FIXME blocked on https://github.com/rust-lang/rust-clippy/issues/4727
#- env: INTEGRATION=rust-lang/rustfmt
# if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
- env: INTEGRATION=rust-lang/rustfmt
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
- env: INTEGRATION=hyperium/hyper
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try)
- env: INTEGRATION=bluss/rust-itertools
Expand Down Expand Up @@ -116,7 +127,7 @@ before_script:
SYSROOT=$(rustc --print sysroot)
case "$TRAVIS_OS_NAME" in
windows ) export PATH="${SYSROOT}/bin:${PATH}" ;;
linux ) export LD_LIBRARY_PATH="${SYSROOT}/lib" ;;
linux ) export LD_LIBRARY_PATH="${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" ;;
osx )
# See <https://github.com/nteract/nteract/issues/1523#issuecomment-301623519>
sudo mkdir -p /usr/local/lib
Expand All @@ -127,7 +138,7 @@ before_script:
script:
- |
if [[ -n ${INTEGRATION} ]]; then
./ci/integration-tests.sh && sleep 5
cargo test --test integration --features integration && sleep 5
else
./ci/base-tests.sh && sleep 5
fi
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ Released 2018-09-13
[`absurd_extreme_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
[`assign_op_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
[`assign_ops`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_ops
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ clippy_lints = { version = "0.0.212", path = "clippy_lints" }
regex = "1"
semver = "0.9"
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
git2 = { version = "0.10", optional = true }
tempfile = { version = "3.1.0", optional = true }
lazy_static = "1.0"

[dev-dependencies]
cargo_metadata = "0.9.0"
Expand All @@ -58,4 +61,4 @@ rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}

[features]
deny-warnings = []
debugging = []
integration = ["git2", "tempfile"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

[There are 337 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
[There are 338 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)

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

Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ install:
build: false

build_script:
- cargo build --features debugging
- cargo build --features deny-warnings

test_script:
- cargo test --features debugging
- cargo test --features deny-warnings

notifications:
- provider: Email
Expand Down
14 changes: 5 additions & 9 deletions ci/base-tests.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
#!/usr/bin/env bash
set -ex

# for faster build, share target dir between subcrates
CARGO_TARGET_DIR=$(pwd)/target/
export CARGO_TARGET_DIR

echo "Running clippy base tests"

PATH=$PATH:./node_modules/.bin
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
remark -f ./*.md -f doc/*.md > /dev/null
fi
# build clippy in debug mode and run tests
cargo build --features "debugging deny-warnings"
cargo test --features "debugging deny-warnings"
cargo build --features deny-warnings
cargo test --features deny-warnings

(cd clippy_lints && cargo test)
(cd rustc_tools_util && cargo test)
(cd clippy_dev && cargo test)
(cd clippy_lints && cargo test --features deny-warnings)
(cd rustc_tools_util && cargo test --features deny-warnings)
(cd clippy_dev && cargo test --features deny-warnings)

# make sure clippy can be called via ./path/to/cargo-clippy
(
Expand Down
37 changes: 0 additions & 37 deletions ci/integration-tests.sh

This file was deleted.

3 changes: 3 additions & 0 deletions clippy_dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ regex = "1"
lazy_static = "1.0"
shell-escape = "0.1"
walkdir = "2"

[features]
deny-warnings = []
2 changes: 2 additions & 0 deletions clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(feature = "deny-warnings", deny(warnings))]

use itertools::Itertools;
use lazy_static::lazy_static;
use regex::Regex;
Expand Down
2 changes: 2 additions & 0 deletions clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(feature = "deny-warnings", deny(warnings))]

extern crate clap;
extern crate clippy_dev;
extern crate regex;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ semver = "0.9.0"
url = { version = "2.1.0", features = ["serde"] }

[features]
debugging = []
deny-warnings = []
6 changes: 6 additions & 0 deletions clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// // Bad
/// let x = 3.14;
/// let y = 1_f64 / x;
///
/// // Good
/// let x = std::f32::consts::PI;
/// let y = std::f64::consts::FRAC_1_PI;
/// ```
pub APPROX_CONSTANT,
correctness,
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
},
hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
let ty = cx.tables.expr_ty(arg);
if ty.is_integral() {
if constant_simple(cx, cx.tables, expr).is_none() {
if constant_simple(cx, cx.tables, expr).is_none() {
if ty.is_integral() {
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
self.expr_span = Some(expr.span);
} else if ty.is_floating_point() {
span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected");
self.expr_span = Some(expr.span);
}
} else if ty.is_floating_point() {
span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected");
self.expr_span = Some(expr.span);
}
},
_ => (),
Expand Down
56 changes: 56 additions & 0 deletions clippy_lints/src/as_conversions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
use syntax::ast::*;

use crate::utils::span_help_and_lint;

declare_clippy_lint! {
/// **What it does:** Checks for usage of `as` conversions.
///
/// **Why is this bad?** `as` conversions will perform many kinds of
/// conversions, including silently lossy conversions and dangerous coercions.
/// There are cases when it makes sense to use `as`, so the lint is
/// Allow by default.
///
/// **Known problems:** None.
///
/// **Example:**
/// ```rust,ignore
/// let a: u32;
/// ...
/// f(a as u16);
/// ```
///
/// Usually better represents the semantics you expect:
/// ```rust,ignore
/// f(a.try_into()?);
/// ```
/// or
/// ```rust,ignore
/// f(a.try_into().expect("Unexpected u16 overflow in f"));
/// ```
///
pub AS_CONVERSIONS,
restriction,
"using a potentially dangerous silent `as` conversion"
}

declare_lint_pass!(AsConversions => [AS_CONVERSIONS]);

impl EarlyLintPass for AsConversions {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
if in_external_macro(cx.sess(), expr.span) {
return;
}

if let ExprKind::Cast(_, _) = expr.kind {
span_help_and_lint(
cx,
AS_CONVERSIONS,
expr.span,
"using a potentially dangerous silent `as` conversion",
"consider using a safe wrapper for this conversion",
);
}
}
}
12 changes: 11 additions & 1 deletion clippy_lints/src/comparison_chain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::utils::{if_sequence, parent_node_is_if_expr, span_help_and_lint, SpanlessEq};
use crate::utils::{
get_trait_def_id, if_sequence, implements_trait, parent_node_is_if_expr, paths, span_help_and_lint, SpanlessEq,
};
use rustc::hir::*;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -84,6 +86,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ComparisonChain {
{
return;
}

// Check that the type being compared implements `core::cmp::Ord`
let ty = cx.tables.expr_ty(lhs1);
let is_ord = get_trait_def_id(cx, &paths::ORD).map_or(false, |id| implements_trait(cx, ty, id, &[]));

if !is_ord {
return;
}
} else {
// We only care about comparison chains
return;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
}

fn check_code(cx: &LateContext<'_, '_>, text: &str, span: Span) {
if text.contains("fn main() {") {
if text.contains("fn main() {") && !(text.contains("static") || text.contains("fn main() {}")) {
span_lint(cx, NEEDLESS_DOCTEST_MAIN, span, "needless `fn main` in doctest");
}
}
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ declare_clippy_lint! {
///
/// **Example:**
/// ```rust
/// # #[cfg(target_pointer_width = "64")]
/// #[repr(usize)]
/// enum NonPortable {
/// X = 0x1_0000_0000,
Expand Down
Loading

0 comments on commit ab2dd0d

Please sign in to comment.