Skip to content

Commit a6b3a40

Browse files
committed
Auto merge of #6277 - ebroto:rustup, r=ebroto
Rustup changelog: none
2 parents 084b203 + 2eb248d commit a6b3a40

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

.github/driver.sh

+8-10
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ sysroot=$(./target/debug/clippy-driver --print sysroot)
77
test "$sysroot" = "$(rustc --print sysroot)"
88

99
if [[ ${OS} == "Windows" ]]; then
10-
desired_sysroot=C:/tmp
10+
desired_sysroot=C:/tmp
1111
else
12-
desired_sysroot=/tmp
12+
desired_sysroot=/tmp
1313
fi
1414
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
1515
test "$sysroot" = $desired_sysroot
@@ -22,20 +22,18 @@ unset CARGO_MANIFEST_DIR
2222

2323
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
2424
# FIXME: How to match the clippy invocation in compile-test.rs?
25-
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2> double_neg.stderr && exit 1
26-
sed -e "s,tests/ui,\$DIR," -e "/= help/d" double_neg.stderr > normalized.stderr
25+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2>double_neg.stderr && exit 1
26+
sed -e "s,tests/ui,\$DIR," -e "/= help/d" double_neg.stderr >normalized.stderr
2727
diff -u normalized.stderr tests/ui/double_neg.stderr
2828

29-
3029
# make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same
31-
SYSROOT=`rustc --print sysroot`
30+
SYSROOT=$(rustc --print sysroot)
3231
diff -u <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)
3332

34-
35-
echo "fn main() {}" > target/driver_test.rs
33+
echo "fn main() {}" >target/driver_test.rs
3634
# we can't run 2 rustcs on the same file at the same time
37-
CLIPPY=`LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc`
38-
RUSTC=`rustc ./target/driver_test.rs`
35+
CLIPPY=$(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc)
36+
RUSTC=$(rustc ./target/driver_test.rs)
3937
diff -u <($CLIPPY) <($RUSTC)
4038

4139
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR

clippy_lints/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(or_patterns)]
1212
#![feature(rustc_private)]
1313
#![feature(stmt_expr_attributes)]
14+
#![feature(control_flow_enum)]
1415
#![recursion_limit = "512"]
1516
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
1617
#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)]

clippy_lints/src/redundant_clone.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_mir::dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, Re
1818
use rustc_session::{declare_lint_pass, declare_tool_lint};
1919
use rustc_span::source_map::{BytePos, Span};
2020
use std::convert::TryFrom;
21+
use std::ops::ControlFlow;
2122

2223
macro_rules! unwrap_or_continue {
2324
($x:expr) => {
@@ -517,7 +518,10 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
517518
self.possible_borrower.add(borrowed.local, lhs);
518519
},
519520
other => {
520-
if !ContainsRegion.visit_ty(place.ty(&self.body.local_decls, self.cx.tcx).ty) {
521+
if ContainsRegion
522+
.visit_ty(place.ty(&self.body.local_decls, self.cx.tcx).ty)
523+
.is_continue()
524+
{
521525
return;
522526
}
523527
rvalue_locals(other, |rhs| {
@@ -539,7 +543,7 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
539543
// If the call returns something with lifetimes,
540544
// let's conservatively assume the returned value contains lifetime of all the arguments.
541545
// For example, given `let y: Foo<'a> = foo(x)`, `y` is considered to be a possible borrower of `x`.
542-
if !ContainsRegion.visit_ty(&self.body.local_decls[*dest].ty) {
546+
if ContainsRegion.visit_ty(&self.body.local_decls[*dest].ty).is_continue() {
543547
return;
544548
}
545549

@@ -558,8 +562,8 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
558562
struct ContainsRegion;
559563

560564
impl TypeVisitor<'_> for ContainsRegion {
561-
fn visit_region(&mut self, _: ty::Region<'_>) -> bool {
562-
true
565+
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<()> {
566+
ControlFlow::BREAK
563567
}
564568
}
565569

0 commit comments

Comments
 (0)