diff options
| author | bors <bors@rust-lang.org> | 2020-10-31 08:52:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-31 08:52:32 +0000 |
| commit | a6b3a403ac161824d42bc248b5c50ea74aa18ea5 (patch) | |
| tree | 070d57d6d5e3b0b6a782fa66a9f7215ebf8a9c9f | |
| parent | 084b203988e04bcf89d3b2d6bbc77b65ecfab553 (diff) | |
| parent | 2eb248dd16f6727a2cdaa66f3f529a53bbcc54c7 (diff) | |
| download | rust-a6b3a403ac161824d42bc248b5c50ea74aa18ea5.tar.gz rust-a6b3a403ac161824d42bc248b5c50ea74aa18ea5.zip | |
Auto merge of #6277 - ebroto:rustup, r=ebroto
Rustup changelog: none
| -rw-r--r-- | .github/driver.sh | 18 | ||||
| -rw-r--r-- | clippy_lints/src/lib.rs | 1 | ||||
| -rw-r--r-- | clippy_lints/src/redundant_clone.rs | 12 |
3 files changed, 17 insertions, 14 deletions
diff --git a/.github/driver.sh b/.github/driver.sh index 561954e7c3a..6ff189fc859 100644 --- a/.github/driver.sh +++ b/.github/driver.sh @@ -7,9 +7,9 @@ sysroot=$(./target/debug/clippy-driver --print sysroot) test "$sysroot" = "$(rustc --print sysroot)" if [[ ${OS} == "Windows" ]]; then - desired_sysroot=C:/tmp + desired_sysroot=C:/tmp else - desired_sysroot=/tmp + desired_sysroot=/tmp fi sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) test "$sysroot" = $desired_sysroot @@ -22,20 +22,18 @@ unset CARGO_MANIFEST_DIR # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 # FIXME: How to match the clippy invocation in compile-test.rs? -./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2> double_neg.stderr && exit 1 -sed -e "s,tests/ui,\$DIR," -e "/= help/d" double_neg.stderr > normalized.stderr +./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2>double_neg.stderr && exit 1 +sed -e "s,tests/ui,\$DIR," -e "/= help/d" double_neg.stderr >normalized.stderr diff -u normalized.stderr tests/ui/double_neg.stderr - # make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same -SYSROOT=`rustc --print sysroot` +SYSROOT=$(rustc --print sysroot) diff -u <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose) - -echo "fn main() {}" > target/driver_test.rs +echo "fn main() {}" >target/driver_test.rs # we can't run 2 rustcs on the same file at the same time -CLIPPY=`LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc` -RUSTC=`rustc ./target/driver_test.rs` +CLIPPY=$(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc) +RUSTC=$(rustc ./target/driver_test.rs) diff -u <($CLIPPY) <($RUSTC) # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 97358e06c63..5c3af014ee1 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -11,6 +11,7 @@ #![feature(or_patterns)] #![feature(rustc_private)] #![feature(stmt_expr_attributes)] +#![feature(control_flow_enum)] #![recursion_limit = "512"] #![cfg_attr(feature = "deny-warnings", deny(warnings))] #![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)] diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index b4502c668dc..344ed02361d 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -18,6 +18,7 @@ use rustc_mir::dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, Re use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::source_map::{BytePos, Span}; use std::convert::TryFrom; +use std::ops::ControlFlow; macro_rules! unwrap_or_continue { ($x:expr) => { @@ -517,7 +518,10 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> { self.possible_borrower.add(borrowed.local, lhs); }, other => { - if !ContainsRegion.visit_ty(place.ty(&self.body.local_decls, self.cx.tcx).ty) { + if ContainsRegion + .visit_ty(place.ty(&self.body.local_decls, self.cx.tcx).ty) + .is_continue() + { return; } rvalue_locals(other, |rhs| { @@ -539,7 +543,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> { // If the call returns something with lifetimes, // let's conservatively assume the returned value contains lifetime of all the arguments. // For example, given `let y: Foo<'a> = foo(x)`, `y` is considered to be a possible borrower of `x`. - if !ContainsRegion.visit_ty(&self.body.local_decls[*dest].ty) { + if ContainsRegion.visit_ty(&self.body.local_decls[*dest].ty).is_continue() { return; } @@ -558,8 +562,8 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> { struct ContainsRegion; impl TypeVisitor<'_> for ContainsRegion { - fn visit_region(&mut self, _: ty::Region<'_>) -> bool { - true + fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<()> { + ControlFlow::BREAK } } |
