1
Fork 0

Rollup merge of #64078 - Mark-Simulacrum:compiletest-lint-unused, r=petrochenkov

compiletest: disable -Aunused for run-pass tests

Disabled the flag, but that led to quite a bit of fall out -- I think most of it is benign but I've not investigated thoroughly.

r? @petrochenkov
This commit is contained in:
Mazdak Farrokhzad 2019-09-08 22:34:22 +02:00 committed by GitHub
commit 510976b4e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 131 additions and 69 deletions

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![feature(associated_type_bounds)]

View file

@ -1,6 +1,7 @@
// run-pass
// aux-build:fn-aux.rs
#![allow(unused)]
#![feature(associated_type_bounds)]
extern crate fn_aux;

View file

@ -1,6 +1,7 @@
// run-pass
// aux-build:fn-dyn-aux.rs
#![allow(unused)]
#![feature(associated_type_bounds)]
extern crate fn_dyn_aux;

View file

@ -1,6 +1,7 @@
// run-pass
// aux-build:fn-aux.rs
#![allow(unused)]
#![feature(associated_type_bounds)]
extern crate fn_aux;

View file

@ -1,6 +1,7 @@
// run-pass
// aux-build:fn-aux.rs
#![allow(unused)]
#![feature(associated_type_bounds)]
extern crate fn_aux;

View file

@ -2,6 +2,7 @@
// aux-build:fn-aux.rs
#![feature(associated_type_bounds)]
#![allow(dead_code)]
extern crate fn_aux;

View file

@ -1,5 +1,6 @@
// run-pass
#![allow(unused)]
#![feature(associated_type_bounds)]
trait Tr1 { type As1; }

View file

@ -1,7 +1,6 @@
// edition:2018
// run-pass
// check-pass
#![allow(unused_variables)]
#![deny(unused_mut)]
type A = Vec<u32>;

View file

@ -1,5 +1,7 @@
// run-pass
#![allow(unused)]
// edition:2018
// aux-build:arc_wake.rs

View file

@ -3,6 +3,9 @@
// run-pass
#![deny(dead_code)]
#![allow(unused_variables)]
#![allow(unused_must_use)]
#![allow(path_statements)]
// Test that the drop order for locals in a fn and async fn matches up.
extern crate arc_wake;
@ -10,7 +13,6 @@ extern crate arc_wake;
use arc_wake::ArcWake;
use std::cell::RefCell;
use std::future::Future;
use std::marker::PhantomData;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::Arc;
@ -42,7 +44,7 @@ struct NeverReady;
impl Future for NeverReady {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
Poll::Pending
}
}

View file

@ -6,6 +6,8 @@
// parameters (used or unused) are not dropped until the async fn is cancelled.
// This file is mostly copy-pasted from drop-order-for-async-fn-parameters.rs
#![allow(unused_variables)]
extern crate arc_wake;
use arc_wake::ArcWake;
@ -43,7 +45,7 @@ struct NeverReady;
impl Future for NeverReady {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
Poll::Pending
}
}

View file

@ -0,0 +1,8 @@
warning: unnecessary parentheses around assigned value
--> $DIR/issue-54752-async-block.rs:6:22
|
LL | fn main() { let _a = (async { }); }
| ^^^^^^^^^^^^ help: remove these parentheses
|
= note: `#[warn(unused_parens)]` on by default

View file

@ -4,7 +4,7 @@
// run-pass
// compile-flags: --edition=2018
// compile-flags: --edition=2018 -Aunused
pub enum Uninhabited { }

View file

@ -1,5 +1,5 @@
// edition:2018
// run-pass
// check-pass
// Test that we can use async fns with multiple arbitrary lifetimes.

View file

@ -17,7 +17,7 @@
// revisions: zflag edition
//[zflag]compile-flags: -Z borrowck=migrate
//[edition]edition:2018
//[zflag] run-pass
//[zflag] check-pass
pub struct Block<'a> {
current: &'a u8,

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
enum Nat {
S(Box<Nat>),

View file

@ -11,7 +11,7 @@ pub trait FakeRead {
}
impl FakeRead for Foo {
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
fn read_to_end(&mut self, _buf: &mut Vec<u8>) -> Result<usize> {
Ok(4)
}
}
@ -19,5 +19,5 @@ impl FakeRead for Foo {
fn main() {
let mut a = Foo {};
let mut v = Vec::new();
a.read_to_end(&mut v);
a.read_to_end(&mut v).unwrap();
}

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

View file

@ -3,6 +3,8 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
#![allow(dead_code)]
struct ArrayStruct<T, const N: usize> {
data: [T; N],
}

View file

@ -3,7 +3,7 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
#[allow(dead_code)]
#![allow(dead_code, unused_variables)]
struct ConstArray<T, const LEN: usize> {
array: [T; LEN],

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
@ -8,7 +8,7 @@ use std::mem;
fn foo<const SIZE: usize>() {
let arr: [u8; SIZE] = unsafe {
#[allow(deprecated)]
let mut array: [u8; SIZE] = mem::uninitialized();
let array: [u8; SIZE] = mem::uninitialized();
array
};
}

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

View file

@ -1,6 +1,7 @@
// run-pass
#![feature(const_fn_union)]
#![allow(dead_code)]
#[repr(C)]
union Transmute<T: Copy, U: Copy> {

View file

@ -1,4 +1,4 @@
// run-pass
// build-pass
// Using labeled break in a while loop has caused an illegal instruction being
// generated, and an ICE later.

View file

@ -0,0 +1,8 @@
warning: unreachable pattern
--> $DIR/packed_pattern.rs:16:9
|
LL | FOO => unreachable!(),
| ^^^
|
= note: `#[warn(unreachable_patterns)]` on by default

View file

@ -0,0 +1,8 @@
warning: unreachable pattern
--> $DIR/packed_pattern2.rs:24:9
|
LL | FOO => unreachable!(),
| ^^^
|
= note: `#[warn(unreachable_patterns)]` on by default

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![deny(deprecated_in_future)]

View file

@ -8,6 +8,7 @@
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(slice_patterns)]
#![allow(unused)]
use std::{
cell::{Cell, RefCell},

View file

@ -10,7 +10,7 @@
//
// See [this comment on GitHub][c] for more details.
//
// run-pass
// check-pass
//
// [c]: https://github.com/rust-lang/rust/issues/57639#issuecomment-455685861

View file

@ -0,0 +1,8 @@
warning: unreachable block in `if` expression
--> $DIR/if-ret.rs:6:24
|
LL | fn foo() { if (return) { } }
| ^^^
|
= note: `#[warn(unreachable_code)]` on by default

View file

@ -5,7 +5,7 @@
// `foo` and hence is treated opaquely within the closure body. This
// resulted in a failed subtype relationship.
//
// run-pass
// check-pass
fn foo() -> impl Copy { || foo(); }
fn bar() -> impl Copy { || bar(); }

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![feature(type_alias_impl_trait)]
@ -9,7 +9,7 @@ fn bar<F: Fn(&i32) + Clone>(f: F) -> F {
}
fn foo() -> X {
bar(|x| ())
bar(|_| ())
}
fn main() {}

View file

@ -1,5 +1,5 @@
// edition:2018
// run-pass
// check-pass
// revisions: migrate mir
//[mir]compile-flags: -Z borrowck=mir

View file

@ -1,9 +1,7 @@
// run-pass
// check-pass
#![feature(member_constraints)]
use std::fmt::Debug;
trait MultiRegionTrait<'a, 'b> {}
impl<'a, 'b> MultiRegionTrait<'a, 'b> for (&'a u32, &'b u32) {}

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
pub struct Bar<T> {
items: Vec<&'static str>,

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
pub struct Item {
_inner: &'static str,

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
use std::ops::Deref;

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
struct S<T> {
t : T,

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
#![deny(unused_results)]

View file

@ -3,6 +3,8 @@
// run-pass
#![allow(dead_code)]
struct Inner<I, V> {
iterator: I,
item: V,

View file

@ -1,7 +1,7 @@
// Regression test for #48132. This was failing due to problems around
// the projection caching and dropck type enumeration.
// run-pass
// check-pass
pub struct Container<T: Iterator> {
value: Option<T::Item>,

View file

@ -5,7 +5,7 @@
// aux-build:xcrate-issue-61711-b.rs
// compile-flags:--extern xcrate_issue_61711_b
// run-pass
// build-pass
fn f<F: Fn(xcrate_issue_61711_b::Struct)>(_: F) { }
fn main() { }

View file

@ -1,6 +1,6 @@
#![feature(lint_reasons)]
// run-pass
// check-pass
// Empty (and reason-only) lint attributes are legal—although we may want to
// lint them in the future (Issue #55112).

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
struct Slice(&'static [&'static [u8]]);

View file

@ -30,7 +30,6 @@ fn digits(x: u8) -> u32 {
OneDigit::FIRST..=OneDigit::LAST => 1,
TwoDigits::FIRST..=TwoDigits::LAST => 2,
ThreeDigits::FIRST..=ThreeDigits::LAST => 3,
_ => unreachable!(),
}
}

View file

@ -1,6 +1,6 @@
// Check that lifetime bounds get checked the right way around with NLL enabled.
//run-pass
// check-pass
trait Visitor<'d> {
type Value;

View file

@ -1,11 +1,11 @@
// Check that mutable promoted length zero arrays don't check for conflicting
// access
// run-pass
// check-pass
pub fn main() {
let mut x: Vec<&[i32; 0]> = Vec::new();
for i in 0..10 {
for _ in 0..10 {
x.push(&[]);
}
}

View file

@ -3,7 +3,7 @@
// The `Self::HASH_LEN` here expands to a "self-type" where `T` is not
// known. This unbound inference variable was causing an ICE.
//
// run-pass
// check-pass
pub struct Foo<T>(T);

View file

@ -2,7 +2,7 @@
// the inherent impl requires normalization to be equal to the
// user-provided type.
//
// run-pass
// check-pass
trait Mirror {
type Me;
@ -15,7 +15,7 @@ impl<T> Mirror for T {
struct Foo<A, B>(A, B);
impl<A> Foo<A, <A as Mirror>::Me> {
fn m(b: A) { }
fn m(_: A) { }
}
fn main() {

View file

@ -11,8 +11,8 @@ use std::sync::mpsc::channel;
fn main() {
let (tx, rx) = channel();
let x = Some(rx);
tx.send(false);
tx.send(false);
tx.send(false).unwrap();
tx.send(false).unwrap();
match x {
Some(z) if z.recv().unwrap() => { panic!() },
Some(z) => { assert!(!z.recv().unwrap()); },

View file

@ -10,11 +10,11 @@ pub enum NonExhaustiveVariants {
fn main() {
let variant_tuple = NonExhaustiveVariants::Tuple(340);
let variant_struct = NonExhaustiveVariants::Struct { field: 340 };
let _variant_struct = NonExhaustiveVariants::Struct { field: 340 };
match variant_tuple {
NonExhaustiveVariants::Unit => "",
NonExhaustiveVariants::Tuple(fe_tpl) => "",
NonExhaustiveVariants::Struct { field } => ""
NonExhaustiveVariants::Tuple(_fe_tpl) => "",
NonExhaustiveVariants::Struct { field: _ } => ""
};
}

View file

@ -2,8 +2,6 @@
#![allow(irrefutable_let_patterns)]
use std::ops::Range;
fn main() {
let x: bool;
// This should associate as: `(x = (true && false));`.

View file

@ -0,0 +1,8 @@
warning: unreachable block in `if` expression
--> $DIR/protect-precedences.rs:13:41
|
LL | if let _ = return true && false {};
| ^^
|
= note: `#[warn(unreachable_code)]` on by default

View file

@ -1,4 +1,4 @@
// run-pass
// check-pass
// This test checks that trait objects involving trait aliases are well-formed.

View file

@ -9,13 +9,13 @@
#![allow(irrefutable_let_patterns)]
enum Enum<T> { TSVariant(T), SVariant { v: T }, UVariant }
enum Enum<T> { TSVariant(T), SVariant { _v: T }, UVariant }
type Alias<T> = Enum<T>;
type AliasFixed = Enum<()>;
macro_rules! is_variant {
(TSVariant, $expr:expr) => (is_variant!(@check TSVariant, (_), $expr));
(SVariant, $expr:expr) => (is_variant!(@check SVariant, { v: _ }, $expr));
(SVariant, $expr:expr) => (is_variant!(@check SVariant, { _v: _ }, $expr));
(UVariant, $expr:expr) => (is_variant!(@check UVariant, {}, $expr));
(@check $variant:ident, $matcher:tt, $expr:expr) => (
assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false },
@ -37,14 +37,14 @@ fn main() {
// Struct variant
is_variant!(SVariant, Enum::SVariant { v: () });
is_variant!(SVariant, Enum::SVariant::<()> { v: () });
is_variant!(SVariant, Enum::<()>::SVariant { v: () });
is_variant!(SVariant, Enum::SVariant { _v: () });
is_variant!(SVariant, Enum::SVariant::<()> { _v: () });
is_variant!(SVariant, Enum::<()>::SVariant { _v: () });
is_variant!(SVariant, Alias::SVariant { v: () });
is_variant!(SVariant, Alias::<()>::SVariant { v: () });
is_variant!(SVariant, Alias::SVariant { _v: () });
is_variant!(SVariant, Alias::<()>::SVariant { _v: () });
is_variant!(SVariant, AliasFixed::SVariant { v: () });
is_variant!(SVariant, AliasFixed::SVariant { _v: () });
// Unit variant

View file

@ -1,5 +1,6 @@
// run-pass
#[allow(dead_code)]
fn macros() {
macro_rules! foo{
($p:pat, $e:expr, $b:block) => {{
@ -12,16 +13,16 @@ fn macros() {
}}
}
foo!(a, 1, { //~ WARN irrefutable while-let
foo!(_a, 1, { //~ WARN irrefutable while-let
println!("irrefutable pattern");
});
bar!(a, 1, { //~ WARN irrefutable while-let
bar!(_a, 1, { //~ WARN irrefutable while-let
println!("irrefutable pattern");
});
}
pub fn main() {
while let a = 1 { //~ WARN irrefutable while-let
while let _a = 1 { //~ WARN irrefutable while-let
println!("irrefutable pattern");
break;
}

View file

@ -1,10 +1,10 @@
warning: irrefutable while-let pattern
--> $DIR/while-let.rs:6:13
--> $DIR/while-let.rs:7:13
|
LL | while let $p = $e $b
| ^^^^^
...
LL | / foo!(a, 1, {
LL | / foo!(_a, 1, {
LL | | println!("irrefutable pattern");
LL | | });
| |_______- in this macro invocation
@ -12,20 +12,20 @@ LL | | });
= note: `#[warn(irrefutable_let_patterns)]` on by default
warning: irrefutable while-let pattern
--> $DIR/while-let.rs:6:13
--> $DIR/while-let.rs:7:13
|
LL | while let $p = $e $b
| ^^^^^
...
LL | / bar!(a, 1, {
LL | / bar!(_a, 1, {
LL | | println!("irrefutable pattern");
LL | | });
| |_______- in this macro invocation
warning: irrefutable while-let pattern
--> $DIR/while-let.rs:24:5
--> $DIR/while-let.rs:25:5
|
LL | / while let a = 1 {
LL | / while let _a = 1 {
LL | | println!("irrefutable pattern");
LL | | break;
LL | | }

View file

@ -628,6 +628,11 @@ impl TestProps {
}
self.pass_mode
}
// does not consider CLI override for pass mode
pub fn local_pass_mode(&self) -> Option<PassMode> {
self.pass_mode
}
}
fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {

View file

@ -1557,7 +1557,11 @@ impl<'test> TestCx<'test> {
// want to actually assert warnings about all this code. Instead
// let's just ignore unused code warnings by defaults and tests
// can turn it back on if needed.
if !self.config.src_base.ends_with("rustdoc-ui") {
if !self.config.src_base.ends_with("rustdoc-ui") &&
// Note that we don't call pass_mode() here as we don't want
// to set unused to allow if we've overriden the pass mode
// via command line flags.
self.props.local_pass_mode() != Some(PassMode::Run) {
rustc.args(&["-A", "unused"]);
}
}