commit
a6b3a403ac
18
.github/driver.sh
vendored
18
.github/driver.sh
vendored
@ -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
|
||||
|
@ -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)]
|
||||
|
@ -18,6 +18,7 @@
|
||||
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 @@ fn visit_assign(&mut self, place: &mir::Place<'tcx>, rvalue: &mir::Rvalue<'_>, _
|
||||
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 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Loca
|
||||
// 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 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Loca
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user