From affb8ee8316c7720a1f752d70d3fa2542100f425 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 25 Jun 2017 05:29:10 +0300 Subject: [PATCH 1/4] Remove more anonymous trait method parameters --- src/librustc/diagnostics.rs | 2 +- src/librustc_resolve/diagnostics.rs | 2 +- src/librustc_typeck/diagnostics.rs | 4 ++-- ...ssociated-types-ICE-when-projecting-out-of-err.rs | 2 +- src/test/compile-fail/issue-13853-5.rs | 2 +- src/test/compile-fail/issue-18400.rs | 4 ++-- src/test/compile-fail/issue-20831-debruijn.rs | 2 +- src/test/compile-fail/issue-35869.rs | 6 +++--- .../type-params-in-different-spaces-2.rs | 2 +- src/test/compile-fail/variance-trait-bounds.rs | 2 +- .../associated-types-projection-in-object-type.rs | 2 +- src/test/run-pass/auxiliary/issue_3979_traits.rs | 2 +- .../auxiliary/xcrate-trait-lifetime-param.rs | 2 +- src/test/run-pass/dropck_legal_cycles.rs | 8 ++++---- src/test/run-pass/issue-13105.rs | 1 + src/test/run-pass/issue-13775.rs | 1 + src/test/run-pass/issue-14919.rs | 2 +- src/test/run-pass/issue-19098.rs | 2 +- src/test/run-pass/issue-21726.rs | 2 +- src/test/run-pass/issue-34074.rs | 3 ++- src/test/run-pass/issue-3979-generics.rs | 2 +- src/test/run-pass/issue-3979.rs | 2 +- src/test/run-pass/issue-4107.rs | 2 +- src/test/run-pass/issue-6128.rs | 5 ++--- src/test/run-pass/issue-6157.rs | 2 +- src/test/run-pass/issue-9129.rs | 2 +- src/test/run-pass/regions-early-bound-trait-param.rs | 2 +- src/test/run-pass/supertrait-default-generics.rs | 2 +- src/test/run-pass/trait-inheritance-static.rs | 2 +- src/test/run-pass/trait-inheritance-static2.rs | 2 +- src/test/run-pass/trait-object-generics.rs | 2 +- .../run-pass/where-clause-bounds-inconsistency.rs | 8 ++++---- src/test/ui/span/issue-7575.rs | 8 ++++---- src/test/ui/span/issue-7575.stderr | 12 ++++++------ 34 files changed, 54 insertions(+), 52 deletions(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 035640b9710e2..08184d62679ea 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -614,7 +614,7 @@ use std::mem::transmute; struct Foo(Vec); trait MyTransmutableType: Sized { - fn transmute(Vec) -> Foo; + fn transmute(_: Vec) -> Foo; } impl MyTransmutableType for u8 { diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 28b5b7c440cfd..9193ac0fcd66e 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -837,7 +837,7 @@ impl Something {} // ok! trait Foo { type N; - fn bar(Self::N); // ok! + fn bar(_: Self::N); // ok! } // or: diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 368fada511b9f..2f111c9e9d11a 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2476,7 +2476,7 @@ trait T2 { type Bar; // error: Baz is used but not declared - fn return_bool(&self, &Self::Bar, &Self::Baz) -> bool; + fn return_bool(&self, _: &Self::Bar, _: &Self::Baz) -> bool; } ``` @@ -2498,7 +2498,7 @@ trait T2 { type Baz; // we declare `Baz` in our trait. // and now we can use it here: - fn return_bool(&self, &Self::Bar, &Self::Baz) -> bool; + fn return_bool(&self, _: &Self::Bar, _: &Self::Baz) -> bool; } ``` "##, diff --git a/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs b/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs index 5a19aecf667f0..74a388e726991 100644 --- a/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs +++ b/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs @@ -25,7 +25,7 @@ pub trait Sized { trait Add { type Output; - fn add(self, RHS) -> Self::Output; + fn add(self, _: RHS) -> Self::Output; } fn ice(a: A) { diff --git a/src/test/compile-fail/issue-13853-5.rs b/src/test/compile-fail/issue-13853-5.rs index 6a017f7bb30c1..78b079a7c44a4 100644 --- a/src/test/compile-fail/issue-13853-5.rs +++ b/src/test/compile-fail/issue-13853-5.rs @@ -11,7 +11,7 @@ trait Deserializer<'a> { } trait Deserializable { - fn deserialize_token<'a, D: Deserializer<'a>>(D, &'a str) -> Self; + fn deserialize_token<'a, D: Deserializer<'a>>(_: D, _: &'a str) -> Self; } impl<'a, T: Deserializable> Deserializable for &'a str { diff --git a/src/test/compile-fail/issue-18400.rs b/src/test/compile-fail/issue-18400.rs index f8d85f939374d..dd17189aeea68 100644 --- a/src/test/compile-fail/issue-18400.rs +++ b/src/test/compile-fail/issue-18400.rs @@ -9,8 +9,8 @@ // except according to those terms. trait Set { - fn contains(&self, T) -> bool; - fn set(&mut self, T); + fn contains(&self, _: T) -> bool; + fn set(&mut self, _: T); } impl<'a, T, S> Set<&'a [T]> for S where diff --git a/src/test/compile-fail/issue-20831-debruijn.rs b/src/test/compile-fail/issue-20831-debruijn.rs index dac1625159748..323cd24d8dda5 100644 --- a/src/test/compile-fail/issue-20831-debruijn.rs +++ b/src/test/compile-fail/issue-20831-debruijn.rs @@ -22,7 +22,7 @@ pub trait Subscriber { pub trait Publisher<'a> { type Output; - fn subscribe(&mut self, Box + 'a>); + fn subscribe(&mut self, _: Box + 'a>); } pub trait Processor<'a> : Subscriber + Publisher<'a> { } diff --git a/src/test/compile-fail/issue-35869.rs b/src/test/compile-fail/issue-35869.rs index d1d6390cce35b..1942fd38d11fa 100644 --- a/src/test/compile-fail/issue-35869.rs +++ b/src/test/compile-fail/issue-35869.rs @@ -11,9 +11,9 @@ #![feature(conservative_impl_trait)] trait Foo { - fn foo(fn(u8) -> ()); //~ NOTE type in trait - fn bar(Option); //~ NOTE type in trait - fn baz((u8, u16)); //~ NOTE type in trait + fn foo(_: fn(u8) -> ()); //~ NOTE type in trait + fn bar(_: Option); //~ NOTE type in trait + fn baz(_: (u8, u16)); //~ NOTE type in trait fn qux() -> u8; //~ NOTE type in trait } diff --git a/src/test/compile-fail/type-params-in-different-spaces-2.rs b/src/test/compile-fail/type-params-in-different-spaces-2.rs index d07282763d85b..7de061eaf077d 100644 --- a/src/test/compile-fail/type-params-in-different-spaces-2.rs +++ b/src/test/compile-fail/type-params-in-different-spaces-2.rs @@ -12,7 +12,7 @@ // type parameters on a trait correctly. trait Tr : Sized { - fn op(T) -> Self; + fn op(_: T) -> Self; } trait A: Tr { diff --git a/src/test/compile-fail/variance-trait-bounds.rs b/src/test/compile-fail/variance-trait-bounds.rs index 9b88e38e08554..ff446f175b756 100644 --- a/src/test/compile-fail/variance-trait-bounds.rs +++ b/src/test/compile-fail/variance-trait-bounds.rs @@ -19,7 +19,7 @@ trait Getter { } trait Setter { - fn get(&self, T); + fn get(&self, _: T); } #[rustc_variance] diff --git a/src/test/run-pass/associated-types-projection-in-object-type.rs b/src/test/run-pass/associated-types-projection-in-object-type.rs index 3b146792fdade..14e94dbff6caf 100644 --- a/src/test/run-pass/associated-types-projection-in-object-type.rs +++ b/src/test/run-pass/associated-types-projection-in-object-type.rs @@ -26,7 +26,7 @@ pub trait Subscriber { pub trait Publisher<'a> { type Output; - fn subscribe(&mut self, Box + 'a>); + fn subscribe(&mut self, _: Box + 'a>); } pub trait Processor<'a> : Subscriber + Publisher<'a> { } diff --git a/src/test/run-pass/auxiliary/issue_3979_traits.rs b/src/test/run-pass/auxiliary/issue_3979_traits.rs index 5c306be69c429..46035731c30a1 100644 --- a/src/test/run-pass/auxiliary/issue_3979_traits.rs +++ b/src/test/run-pass/auxiliary/issue_3979_traits.rs @@ -13,7 +13,7 @@ #![crate_type = "lib"] pub trait Positioned { - fn SetX(&mut self, isize); + fn SetX(&mut self, _: isize); fn X(&self) -> isize; } diff --git a/src/test/run-pass/auxiliary/xcrate-trait-lifetime-param.rs b/src/test/run-pass/auxiliary/xcrate-trait-lifetime-param.rs index e8e5cc53aa32d..66c0300e260b8 100644 --- a/src/test/run-pass/auxiliary/xcrate-trait-lifetime-param.rs +++ b/src/test/run-pass/auxiliary/xcrate-trait-lifetime-param.rs @@ -9,5 +9,5 @@ // except according to those terms. pub trait FromBuf<'a> { - fn from_buf(&'a [u8]) -> Self; + fn from_buf(_: &'a [u8]) -> Self; } diff --git a/src/test/run-pass/dropck_legal_cycles.rs b/src/test/run-pass/dropck_legal_cycles.rs index 2f8ecbe693f07..b6e640ab5b5b6 100644 --- a/src/test/run-pass/dropck_legal_cycles.rs +++ b/src/test/run-pass/dropck_legal_cycles.rs @@ -442,7 +442,7 @@ pub fn main() { } trait Named { - fn new(&'static str) -> Self; + fn new(_: &'static str) -> Self; fn name(&self) -> &str; } @@ -932,9 +932,9 @@ trait Context { } trait PrePost { - fn pre(&mut self, &T); - fn post(&mut self, &T); - fn hit_limit(&mut self, &T); + fn pre(&mut self, _: &T); + fn post(&mut self, _: &T); + fn hit_limit(&mut self, _: &T); } trait Children<'a> { diff --git a/src/test/run-pass/issue-13105.rs b/src/test/run-pass/issue-13105.rs index ca68272d2d0f2..f2a606a8bba30 100644 --- a/src/test/run-pass/issue-13105.rs +++ b/src/test/run-pass/issue-13105.rs @@ -11,6 +11,7 @@ // pretty-expanded FIXME #23616 trait Foo { + #[allow(anonymous_parameters)] fn quux(u8) {} } diff --git a/src/test/run-pass/issue-13775.rs b/src/test/run-pass/issue-13775.rs index 3b70bea719b2f..c69ae6a15cd37 100644 --- a/src/test/run-pass/issue-13775.rs +++ b/src/test/run-pass/issue-13775.rs @@ -11,6 +11,7 @@ // pretty-expanded FIXME #23616 trait Foo { + #[allow(anonymous_parameters)] fn bar(&self, isize) {} } diff --git a/src/test/run-pass/issue-14919.rs b/src/test/run-pass/issue-14919.rs index df5d62e7699bb..5d0fde01798dc 100644 --- a/src/test/run-pass/issue-14919.rs +++ b/src/test/run-pass/issue-14919.rs @@ -26,7 +26,7 @@ impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> { } trait IntoMatcher<'a, T> { - fn into_matcher(self, &'a str) -> T; + fn into_matcher(self, _: &'a str) -> T; } impl<'a, 'b, F> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for F where F: FnMut(char) -> bool + 'b { diff --git a/src/test/run-pass/issue-19098.rs b/src/test/run-pass/issue-19098.rs index e54fdfb5b5e81..e526dd2903e53 100644 --- a/src/test/run-pass/issue-19098.rs +++ b/src/test/run-pass/issue-19098.rs @@ -9,7 +9,7 @@ // except according to those terms. pub trait Handler { - fn handle(&self, &mut String); + fn handle(&self, _: &mut String); } impl Handler for F where F: for<'a, 'b> Fn(&'a mut String) { diff --git a/src/test/run-pass/issue-21726.rs b/src/test/run-pass/issue-21726.rs index e1d1b908e0117..9fdd89e25a194 100644 --- a/src/test/run-pass/issue-21726.rs +++ b/src/test/run-pass/issue-21726.rs @@ -23,7 +23,7 @@ fn foo<'a>(s: &'a str) { trait IntoRef<'a> { type T: Clone; - fn into_ref(self, &'a str) -> Self::T; + fn into_ref(self, _: &'a str) -> Self::T; } impl<'a> IntoRef<'a> for () { diff --git a/src/test/run-pass/issue-34074.rs b/src/test/run-pass/issue-34074.rs index 169a87f0b12fc..17d2bee746619 100644 --- a/src/test/run-pass/issue-34074.rs +++ b/src/test/run-pass/issue-34074.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Make sure several unnamed function arguments don't conflict with each other +// Make sure several unnamed function parameters don't conflict with each other trait Tr { + #[allow(anonymous_parameters)] fn f(u8, u8) {} } diff --git a/src/test/run-pass/issue-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs index 6ba566012c3be..2b56799f6b07c 100644 --- a/src/test/run-pass/issue-3979-generics.rs +++ b/src/test/run-pass/issue-3979-generics.rs @@ -12,7 +12,7 @@ use std::ops::Add; trait Positioned { - fn SetX(&mut self, S); + fn SetX(&mut self, _: S); fn X(&self) -> S; } diff --git a/src/test/run-pass/issue-3979.rs b/src/test/run-pass/issue-3979.rs index 184682255d936..9b5f7296ab592 100644 --- a/src/test/run-pass/issue-3979.rs +++ b/src/test/run-pass/issue-3979.rs @@ -10,7 +10,7 @@ trait Positioned { - fn SetX(&mut self, isize); + fn SetX(&mut self, _: isize); fn X(&self) -> isize; } diff --git a/src/test/run-pass/issue-4107.rs b/src/test/run-pass/issue-4107.rs index fa5ed26847b57..6c5f4bf36de83 100644 --- a/src/test/run-pass/issue-4107.rs +++ b/src/test/run-pass/issue-4107.rs @@ -13,7 +13,7 @@ pub fn main() { let _id: &Mat2 = &Matrix::identity(1.0); } -pub trait Index { fn get(&self, Index) -> Result { panic!() } } +pub trait Index { fn get(&self, _: Index) -> Result { panic!() } } pub trait Dimensional: Index { } pub struct Mat2 { x: T } diff --git a/src/test/run-pass/issue-6128.rs b/src/test/run-pass/issue-6128.rs index 8725b13789657..b52900746e3c4 100644 --- a/src/test/run-pass/issue-6128.rs +++ b/src/test/run-pass/issue-6128.rs @@ -14,9 +14,8 @@ use std::collections::HashMap; trait Graph { - fn f(&self, Edge); - fn g(&self, Node); - + fn f(&self, _: Edge); + fn g(&self, _: Node); } impl Graph for HashMap { diff --git a/src/test/run-pass/issue-6157.rs b/src/test/run-pass/issue-6157.rs index c7832ae41e3fb..2c5bc48abe840 100644 --- a/src/test/run-pass/issue-6157.rs +++ b/src/test/run-pass/issue-6157.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -pub trait OpInt { fn call(&mut self, isize, isize) -> isize; } +pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; } impl OpInt for F where F: FnMut(isize, isize) -> isize { fn call(&mut self, a:isize, b:isize) -> isize { diff --git a/src/test/run-pass/issue-9129.rs b/src/test/run-pass/issue-9129.rs index c46e8494e73b8..a9f29fdb38caf 100644 --- a/src/test/run-pass/issue-9129.rs +++ b/src/test/run-pass/issue-9129.rs @@ -13,7 +13,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -pub trait bomb { fn boom(&self, Ident); } +pub trait bomb { fn boom(&self, _: Ident); } pub struct S; impl bomb for S { fn boom(&self, _: Ident) { } } diff --git a/src/test/run-pass/regions-early-bound-trait-param.rs b/src/test/run-pass/regions-early-bound-trait-param.rs index 4ba04aa7091a8..86fcfb9e6dd89 100644 --- a/src/test/run-pass/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions-early-bound-trait-param.rs @@ -63,7 +63,7 @@ fn make_val() -> T { } trait RefMakerTrait<'q> { - fn mk(Self) -> &'q Self; + fn mk(_: Self) -> &'q Self; } fn make_ref<'r, T:RefMakerTrait<'r>>(t:T) -> &'r T { diff --git a/src/test/run-pass/supertrait-default-generics.rs b/src/test/run-pass/supertrait-default-generics.rs index e014ce1966bc5..8351cc50fd822 100644 --- a/src/test/run-pass/supertrait-default-generics.rs +++ b/src/test/run-pass/supertrait-default-generics.rs @@ -14,7 +14,7 @@ use std::ops::Add; trait Positioned { - fn SetX(&mut self, S); + fn SetX(&mut self, _: S); fn X(&self) -> S; } diff --git a/src/test/run-pass/trait-inheritance-static.rs b/src/test/run-pass/trait-inheritance-static.rs index 8e56582951154..aae6b76087fe4 100644 --- a/src/test/run-pass/trait-inheritance-static.rs +++ b/src/test/run-pass/trait-inheritance-static.rs @@ -10,7 +10,7 @@ pub trait MyNum { - fn from_int(isize) -> Self; + fn from_int(_: isize) -> Self; } pub trait NumExt: MyNum { } diff --git a/src/test/run-pass/trait-inheritance-static2.rs b/src/test/run-pass/trait-inheritance-static2.rs index 67bea3864a772..dd942fbfa08c8 100644 --- a/src/test/run-pass/trait-inheritance-static2.rs +++ b/src/test/run-pass/trait-inheritance-static2.rs @@ -11,7 +11,7 @@ pub trait MyEq {} pub trait MyNum { - fn from_int(isize) -> Self; + fn from_int(_: isize) -> Self; } pub trait NumExt: MyEq + MyNum { } diff --git a/src/test/run-pass/trait-object-generics.rs b/src/test/run-pass/trait-object-generics.rs index 33bee3ea06f4d..61d32bd6ffc17 100644 --- a/src/test/run-pass/trait-object-generics.rs +++ b/src/test/run-pass/trait-object-generics.rs @@ -41,7 +41,7 @@ impl Impl { enum Type { Constant(T) } trait Trait { - fn method(&self,Type<(K,V)>) -> isize; + fn method(&self, _: Type<(K,V)>) -> isize; } impl Trait for () { diff --git a/src/test/run-pass/where-clause-bounds-inconsistency.rs b/src/test/run-pass/where-clause-bounds-inconsistency.rs index d4823b8a33cc5..fa07861d79932 100644 --- a/src/test/run-pass/where-clause-bounds-inconsistency.rs +++ b/src/test/run-pass/where-clause-bounds-inconsistency.rs @@ -15,10 +15,10 @@ trait Bound { } trait Trait { - fn a(&self, T) where T: Bound; - fn b(&self, T) where T: Bound; - fn c(&self, T); - fn d(&self, T); + fn a(&self, _: T) where T: Bound; + fn b(&self, _: T) where T: Bound; + fn c(&self, _: T); + fn d(&self, _: T); } impl Trait for bool { diff --git a/src/test/ui/span/issue-7575.rs b/src/test/ui/span/issue-7575.rs index 2d271f0bf1708..b74036c4f5ce8 100644 --- a/src/test/ui/span/issue-7575.rs +++ b/src/test/ui/span/issue-7575.rs @@ -12,12 +12,12 @@ // ignore-tidy-linelength trait CtxtFn { - fn f8(self, usize) -> usize; - fn f9(usize) -> usize; //~ NOTE candidate + fn f8(self, _: usize) -> usize; + fn f9(_: usize) -> usize; //~ NOTE candidate } trait OtherTrait { - fn f9(usize) -> usize; //~ NOTE candidate + fn f9(_: usize) -> usize; //~ NOTE candidate } // Note: this trait is not implemented, but we can't really tell @@ -26,7 +26,7 @@ trait OtherTrait { // candidate. This seems not unreasonable -- perhaps the user meant to // implement it, after all. trait UnusedTrait { - fn f9(usize) -> usize; //~ NOTE candidate + fn f9(_: usize) -> usize; //~ NOTE candidate } impl CtxtFn for usize { diff --git a/src/test/ui/span/issue-7575.stderr b/src/test/ui/span/issue-7575.stderr index 858c099d37434..ff62adbfbd5fc 100644 --- a/src/test/ui/span/issue-7575.stderr +++ b/src/test/ui/span/issue-7575.stderr @@ -8,20 +8,20 @@ error[E0599]: no method named `f9` found for type `usize` in the current scope note: candidate #1 is defined in the trait `CtxtFn` --> $DIR/issue-7575.rs:16:5 | -16 | fn f9(usize) -> usize; //~ NOTE candidate - | ^^^^^^^^^^^^^^^^^^^^^^ +16 | fn f9(_: usize) -> usize; //~ NOTE candidate + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to disambiguate the method call, write `CtxtFn::f9(u, 342)` instead note: candidate #2 is defined in the trait `OtherTrait` --> $DIR/issue-7575.rs:20:5 | -20 | fn f9(usize) -> usize; //~ NOTE candidate - | ^^^^^^^^^^^^^^^^^^^^^^ +20 | fn f9(_: usize) -> usize; //~ NOTE candidate + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to disambiguate the method call, write `OtherTrait::f9(u, 342)` instead note: candidate #3 is defined in the trait `UnusedTrait` --> $DIR/issue-7575.rs:29:5 | -29 | fn f9(usize) -> usize; //~ NOTE candidate - | ^^^^^^^^^^^^^^^^^^^^^^ +29 | fn f9(_: usize) -> usize; //~ NOTE candidate + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to disambiguate the method call, write `UnusedTrait::f9(u, 342)` instead = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `f9`, perhaps you need to implement one of them: From 96bcdac9e483e0e7d8a02f82c0ab961a536cafc4 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 25 Jun 2017 05:30:20 +0300 Subject: [PATCH 2/4] Make sufficiently old or low-impact compatibility lints deny-by-default --- src/librustc/lint/builtin.rs | 14 +++++++------- src/test/compile-fail/defaulted-unit-warning.rs | 5 +---- .../directory_ownership/backcompat-warnings.rs | 4 ---- .../imports/rfc-1560-warning-cycle.rs | 8 +++----- src/test/compile-fail/issue-32995-2.rs | 9 +-------- src/test/compile-fail/issue-32995.rs | 17 +---------------- src/test/compile-fail/issue-38293.rs | 1 - src/test/compile-fail/issue-39404.rs | 4 +--- src/test/compile-fail/no-patterns-in-args-2.rs | 3 +-- .../compile-fail/safe-extern-statics-mut.rs | 3 --- src/test/compile-fail/safe-extern-statics.rs | 1 - .../compile-fail/type-parameter-invalid-lint.rs | 1 - .../ui/compare-method/proj-outlives-region.rs | 3 --- .../compare-method/proj-outlives-region.stderr | 6 +++--- src/test/ui/compare-method/region-extra.rs | 3 --- src/test/ui/compare-method/region-extra.stderr | 6 +++--- src/test/ui/compare-method/region-unrelated.rs | 3 --- .../ui/compare-method/region-unrelated.stderr | 6 +++--- 18 files changed, 24 insertions(+), 73 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 736c3b289e198..dd6e78b87afb9 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -144,20 +144,20 @@ declare_lint! { declare_lint! { pub RESOLVE_TRAIT_ON_DEFAULTED_UNIT, - Warn, + Deny, "attempt to resolve a trait on an expression whose type cannot be inferred but which \ currently defaults to ()" } declare_lint! { pub SAFE_EXTERN_STATICS, - Warn, + Deny, "safe access to extern statics was erroneously allowed" } declare_lint! { pub PATTERNS_IN_FNS_WITHOUT_BODY, - Warn, + Deny, "patterns in functions without body were erroneously allowed" } @@ -169,14 +169,14 @@ declare_lint! { declare_lint! { pub LEGACY_DIRECTORY_OWNERSHIP, - Warn, + Deny, "non-inline, non-`#[path]` modules (e.g. `mod foo;`) were erroneously allowed in some files \ not named `mod.rs`" } declare_lint! { pub LEGACY_IMPORTS, - Warn, + Deny, "detects names that resolve to ambiguous glob imports with RFC 1560" } @@ -188,13 +188,13 @@ declare_lint! { declare_lint! { pub MISSING_FRAGMENT_SPECIFIER, - Warn, + Deny, "detects missing fragment specifiers in unused `macro_rules!` patterns" } declare_lint! { pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, - Warn, + Deny, "detects parenthesized generic parameters in type and module names" } diff --git a/src/test/compile-fail/defaulted-unit-warning.rs b/src/test/compile-fail/defaulted-unit-warning.rs index ed6263d0fdbd1..3f4e1cce548b9 100644 --- a/src/test/compile-fail/defaulted-unit-warning.rs +++ b/src/test/compile-fail/defaulted-unit-warning.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(dead_code)] -#![allow(unreachable_code)] -#![deny(resolve_trait_on_defaulted_unit)] +#![allow(unused)] trait Deserialize: Sized { fn deserialize() -> Result; @@ -38,4 +36,3 @@ fn smeg() { fn main() { smeg(); } - diff --git a/src/test/compile-fail/directory_ownership/backcompat-warnings.rs b/src/test/compile-fail/directory_ownership/backcompat-warnings.rs index 75e3426a39935..519792dfa3a8f 100644 --- a/src/test/compile-fail/directory_ownership/backcompat-warnings.rs +++ b/src/test/compile-fail/directory_ownership/backcompat-warnings.rs @@ -10,12 +10,8 @@ // error-pattern: cannot declare a new module at this location // error-pattern: will become a hard error -// error-pattern: compilation successful - -#![feature(rustc_attrs)] #[path="mod_file_not_owning_aux3.rs"] mod foo; -#[rustc_error] fn main() {} diff --git a/src/test/compile-fail/imports/rfc-1560-warning-cycle.rs b/src/test/compile-fail/imports/rfc-1560-warning-cycle.rs index 1d67bf3a1cdda..95bdf5e9b1565 100644 --- a/src/test/compile-fail/imports/rfc-1560-warning-cycle.rs +++ b/src/test/compile-fail/imports/rfc-1560-warning-cycle.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(rustc_attrs)] #![allow(unused)] pub struct Foo; @@ -20,12 +19,11 @@ mod bar { use *; //~ NOTE `Foo` could refer to the name imported here use bar::*; //~ NOTE `Foo` could also refer to the name imported here fn f(_: Foo) {} - //~^ WARN `Foo` is ambiguous + //~^ ERROR `Foo` is ambiguous //~| WARN hard error in a future release //~| NOTE see issue #38260 - //~| NOTE #[warn(legacy_imports)] on by default + //~| NOTE #[deny(legacy_imports)] on by default } } -#[rustc_error] -fn main() {} //~ ERROR compilation successful +fn main() {} diff --git a/src/test/compile-fail/issue-32995-2.rs b/src/test/compile-fail/issue-32995-2.rs index cb68d52ef968d..0e917ad95d95b 100644 --- a/src/test/compile-fail/issue-32995-2.rs +++ b/src/test/compile-fail/issue-32995-2.rs @@ -8,23 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(parenthesized_params_in_types_and_modules)] -//~^ NOTE lint level defined here -//~| NOTE lint level defined here -//~| NOTE lint level defined here -#![allow(dead_code, unused_variables)] #![feature(conservative_impl_trait)] +#![allow(unused)] fn main() { { fn f() {} } //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 { fn f() -> impl ::std::marker()::Send { } } //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 } #[derive(Clone)] @@ -33,4 +27,3 @@ struct X; impl ::std::marker()::Copy for X {} //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted -//~| NOTE issue #42238 diff --git a/src/test/compile-fail/issue-32995.rs b/src/test/compile-fail/issue-32995.rs index f2ed8bf53eade..4b7f82943bac1 100644 --- a/src/test/compile-fail/issue-32995.rs +++ b/src/test/compile-fail/issue-32995.rs @@ -8,26 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(parenthesized_params_in_types_and_modules)] -//~^ NOTE lint level defined here -//~| NOTE lint level defined here -//~| NOTE lint level defined here -//~| NOTE lint level defined here -//~| NOTE lint level defined here -//~| NOTE lint level defined here -//~| NOTE lint level defined here -#![allow(dead_code, unused_variables)] +#![allow(unused)] fn main() { let x: usize() = 1; //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 let b: ::std::boxed()::Box<_> = Box::new(1); //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 macro_rules! pathexpr { ($p:path) => { $p } @@ -36,27 +26,22 @@ fn main() { let p = pathexpr!(::std::str()::from_utf8)(b"foo").unwrap(); //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 let p = pathexpr!(::std::str::from_utf8())(b"foo").unwrap(); //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 let o : Box<::std::marker()::Send> = Box::new(1); //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 let o : Box = Box::new(1); //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 } fn foo() { let d : X() = Default::default(); //~^ ERROR parenthesized parameters may only be used with a trait //~| WARN previously accepted - //~| NOTE issue #42238 } diff --git a/src/test/compile-fail/issue-38293.rs b/src/test/compile-fail/issue-38293.rs index bf24621a869fb..bd352b204bddf 100644 --- a/src/test/compile-fail/issue-38293.rs +++ b/src/test/compile-fail/issue-38293.rs @@ -11,7 +11,6 @@ // Test that `fn foo::bar::{self}` only imports `bar` in the type namespace. #![allow(unused)] -#![deny(legacy_imports)] mod foo { pub fn f() { } diff --git a/src/test/compile-fail/issue-39404.rs b/src/test/compile-fail/issue-39404.rs index 8b49772494a66..56bfe27a4ffd0 100644 --- a/src/test/compile-fail/issue-39404.rs +++ b/src/test/compile-fail/issue-39404.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(missing_fragment_specifier)] //~ NOTE lint level defined here -#![allow(unused_macros)] +#![allow(unused)] macro_rules! m { ($i) => {} } //~^ ERROR missing fragment specifier //~| WARN previously accepted -//~| NOTE issue #40107 fn main() {} diff --git a/src/test/compile-fail/no-patterns-in-args-2.rs b/src/test/compile-fail/no-patterns-in-args-2.rs index 385d012cadee6..ca5ba4c063c71 100644 --- a/src/test/compile-fail/no-patterns-in-args-2.rs +++ b/src/test/compile-fail/no-patterns-in-args-2.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(patterns_in_fns_without_body)] - trait Tr { fn f1(mut arg: u8); //~ ERROR patterns aren't allowed in methods without bodies //~^ WARN was previously accepted @@ -17,6 +15,7 @@ trait Tr { //~^ WARN was previously accepted fn g1(arg: u8); // OK fn g2(_: u8); // OK + #[allow(anonymous_parameters)] fn g3(u8); // OK } diff --git a/src/test/compile-fail/safe-extern-statics-mut.rs b/src/test/compile-fail/safe-extern-statics-mut.rs index b5f3b4535df92..ed8d5900776a9 100644 --- a/src/test/compile-fail/safe-extern-statics-mut.rs +++ b/src/test/compile-fail/safe-extern-statics-mut.rs @@ -10,9 +10,6 @@ // aux-build:extern-statics.rs -#![allow(unused)] -#![deny(safe_extern_statics)] - extern crate extern_statics; use extern_statics::*; diff --git a/src/test/compile-fail/safe-extern-statics.rs b/src/test/compile-fail/safe-extern-statics.rs index 7e96897ee882b..4d939f33c46dc 100644 --- a/src/test/compile-fail/safe-extern-statics.rs +++ b/src/test/compile-fail/safe-extern-statics.rs @@ -11,7 +11,6 @@ // aux-build:extern-statics.rs #![allow(unused)] -#![deny(safe_extern_statics)] extern crate extern_statics; use extern_statics::*; diff --git a/src/test/compile-fail/type-parameter-invalid-lint.rs b/src/test/compile-fail/type-parameter-invalid-lint.rs index c7a1197372dee..f424cbf0c32a6 100644 --- a/src/test/compile-fail/type-parameter-invalid-lint.rs +++ b/src/test/compile-fail/type-parameter-invalid-lint.rs @@ -10,7 +10,6 @@ // gate-test-default_type_parameter_fallback -#![deny(invalid_type_param_default)] #![allow(unused)] fn avg(_: T) {} diff --git a/src/test/ui/compare-method/proj-outlives-region.rs b/src/test/ui/compare-method/proj-outlives-region.rs index 54cfe4be9c101..eab01e9e98268 100644 --- a/src/test/ui/compare-method/proj-outlives-region.rs +++ b/src/test/ui/compare-method/proj-outlives-region.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(dead_code)] -#![deny(extra_requirement_in_impl)] - // Test that we elaborate `Type: 'region` constraints and infer various important things. trait Master<'a, T: ?Sized, U> { diff --git a/src/test/ui/compare-method/proj-outlives-region.stderr b/src/test/ui/compare-method/proj-outlives-region.stderr index 2a707c6eb8b10..b1b5aedea70d8 100644 --- a/src/test/ui/compare-method/proj-outlives-region.stderr +++ b/src/test/ui/compare-method/proj-outlives-region.stderr @@ -1,10 +1,10 @@ error[E0276]: impl has stricter requirements than trait - --> $DIR/proj-outlives-region.rs:22:5 + --> $DIR/proj-outlives-region.rs:19:5 | -17 | fn foo() where T: 'a; +14 | fn foo() where T: 'a; | --------------------- definition of `foo` from trait ... -22 | fn foo() where U: 'a { } //~ ERROR E0276 +19 | fn foo() where U: 'a { } //~ ERROR E0276 | ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a` | = note: #[deny(extra_requirement_in_impl)] on by default diff --git a/src/test/ui/compare-method/region-extra.rs b/src/test/ui/compare-method/region-extra.rs index d61d0250211dc..e359f08096885 100644 --- a/src/test/ui/compare-method/region-extra.rs +++ b/src/test/ui/compare-method/region-extra.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(dead_code)] -#![deny(extra_requirement_in_impl)] - // Test that you cannot add an extra where clause in the impl relating // two regions. diff --git a/src/test/ui/compare-method/region-extra.stderr b/src/test/ui/compare-method/region-extra.stderr index e657813221a12..bc42b505818b8 100644 --- a/src/test/ui/compare-method/region-extra.stderr +++ b/src/test/ui/compare-method/region-extra.stderr @@ -1,10 +1,10 @@ error[E0276]: impl has stricter requirements than trait - --> $DIR/region-extra.rs:22:5 + --> $DIR/region-extra.rs:19:5 | -18 | fn foo(); +15 | fn foo(); | --------- definition of `foo` from trait ... -22 | fn foo() where 'a: 'b { } +19 | fn foo() where 'a: 'b { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b` error: aborting due to previous error diff --git a/src/test/ui/compare-method/region-unrelated.rs b/src/test/ui/compare-method/region-unrelated.rs index 8f79b30bd5f31..719e15fdb61fe 100644 --- a/src/test/ui/compare-method/region-unrelated.rs +++ b/src/test/ui/compare-method/region-unrelated.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(dead_code)] -#![deny(extra_requirement_in_impl)] - // Test that we elaborate `Type: 'region` constraints and infer various important things. trait Master<'a, T: ?Sized, U> { diff --git a/src/test/ui/compare-method/region-unrelated.stderr b/src/test/ui/compare-method/region-unrelated.stderr index 9e822bd8b0790..b02aa5eeb2f54 100644 --- a/src/test/ui/compare-method/region-unrelated.stderr +++ b/src/test/ui/compare-method/region-unrelated.stderr @@ -1,10 +1,10 @@ error[E0276]: impl has stricter requirements than trait - --> $DIR/region-unrelated.rs:22:5 + --> $DIR/region-unrelated.rs:19:5 | -17 | fn foo() where T: 'a; +14 | fn foo() where T: 'a; | --------------------- definition of `foo` from trait ... -22 | fn foo() where V: 'a { } +19 | fn foo() where V: 'a { } | ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `V: 'a` | = note: #[deny(extra_requirement_in_impl)] on by default From bdffb9722d9330d3815be356a5ccedae07555328 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 25 Jun 2017 05:50:51 +0300 Subject: [PATCH 3/4] Move public reexports of private extern crates into a separate lint This is going to be a hard error while all private-in-public errors from rustc_privacy will be reclassified into lints. --- src/librustc/lint/builtin.rs | 7 +++++++ src/librustc_lint/lib.rs | 4 ++++ src/librustc_resolve/resolve_imports.rs | 8 +++++--- src/test/compile-fail/pub-reexport-priv-extern-crate.rs | 1 - 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index dd6e78b87afb9..ce120a32d906b 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -130,6 +130,12 @@ declare_lint! { "detect private items in public interfaces not caught by the old implementation" } +declare_lint! { + pub PUB_USE_OF_PRIVATE_EXTERN_CRATE, + Deny, + "detect public reexports of private extern crates" +} + declare_lint! { pub INVALID_TYPE_PARAM_DEFAULT, Deny, @@ -230,6 +236,7 @@ impl LintPass for HardwiredLints { TRIVIAL_CASTS, TRIVIAL_NUMERIC_CASTS, PRIVATE_IN_PUBLIC, + PUB_USE_OF_PRIVATE_EXTERN_CRATE, INVALID_TYPE_PARAM_DEFAULT, CONST_ERR, RENAMED_AND_REMOVED_LINTS, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index f5c43c7b57d2c..a03f12c3dfbca 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -184,6 +184,10 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { id: LintId::of(PRIVATE_IN_PUBLIC), reference: "issue #34537 ", }, + FutureIncompatibleInfo { + id: LintId::of(PUB_USE_OF_PRIVATE_EXTERN_CRATE), + reference: "issue #34537 ", + }, FutureIncompatibleInfo { id: LintId::of(PATTERNS_IN_FNS_WITHOUT_BODY), reference: "issue #35203 ", diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 405b2ed6ba9c8..4bff5da3d6b09 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -18,7 +18,7 @@ use {names_to_string, module_to_string}; use {resolve_error, ResolutionError}; use rustc::ty; -use rustc::lint::builtin::PRIVATE_IN_PUBLIC; +use rustc::lint::builtin::PUB_USE_OF_PRIVATE_EXTERN_CRATE; use rustc::hir::def_id::DefId; use rustc::hir::def::*; use rustc::util::nodemap::FxHashMap; @@ -296,7 +296,8 @@ impl<'a> Resolver<'a> { pub fn import(&self, binding: &'a NameBinding<'a>, directive: &'a ImportDirective<'a>) -> &'a NameBinding<'a> { let vis = if binding.pseudo_vis().is_at_least(directive.vis.get(), self) || - !directive.is_glob() && binding.is_extern_crate() { // c.f. `PRIVATE_IN_PUBLIC` + // c.f. `PUB_USE_OF_PRIVATE_EXTERN_CRATE` + !directive.is_glob() && binding.is_extern_crate() { directive.vis.get() } else { binding.pseudo_vis() @@ -735,7 +736,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { let msg = format!("extern crate `{}` is private, and cannot be reexported \ (error E0365), consider declaring with `pub`", ident); - self.session.add_lint(PRIVATE_IN_PUBLIC, directive.id, directive.span, msg); + self.session.add_lint(PUB_USE_OF_PRIVATE_EXTERN_CRATE, + directive.id, directive.span, msg); } else if ns == TypeNS { struct_span_err!(self.session, directive.span, E0365, "`{}` is private, and cannot be reexported", ident) diff --git a/src/test/compile-fail/pub-reexport-priv-extern-crate.rs b/src/test/compile-fail/pub-reexport-priv-extern-crate.rs index 185da379694bc..5479be54533e0 100644 --- a/src/test/compile-fail/pub-reexport-priv-extern-crate.rs +++ b/src/test/compile-fail/pub-reexport-priv-extern-crate.rs @@ -9,7 +9,6 @@ // except according to those terms. #![allow(unused)] -#![deny(private_in_public)] extern crate core; pub use core as reexported_core; //~ ERROR `core` is private, and cannot be reexported From 9196f874e4003bf766288c82ee857a7fa2588d8a Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 8 Jul 2017 03:01:11 +0300 Subject: [PATCH 4/4] Make `patterns_in_fns_without_body` warn-by-default again Fix some tests on Linux --- src/librustc/lint/builtin.rs | 2 +- src/test/compile-fail/no-patterns-in-args-2.rs | 2 ++ src/test/run-pass/linkage1.rs | 8 +++++--- src/test/run-pass/thread-local-extern-static.rs | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index ce120a32d906b..2d088c4f6d172 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -163,7 +163,7 @@ declare_lint! { declare_lint! { pub PATTERNS_IN_FNS_WITHOUT_BODY, - Deny, + Warn, "patterns in functions without body were erroneously allowed" } diff --git a/src/test/compile-fail/no-patterns-in-args-2.rs b/src/test/compile-fail/no-patterns-in-args-2.rs index ca5ba4c063c71..967c292fa68d2 100644 --- a/src/test/compile-fail/no-patterns-in-args-2.rs +++ b/src/test/compile-fail/no-patterns-in-args-2.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![deny(patterns_in_fns_without_body)] + trait Tr { fn f1(mut arg: u8); //~ ERROR patterns aren't allowed in methods without bodies //~^ WARN was previously accepted diff --git a/src/test/run-pass/linkage1.rs b/src/test/run-pass/linkage1.rs index 17abf9cb1f251..591610e88b1a6 100644 --- a/src/test/run-pass/linkage1.rs +++ b/src/test/run-pass/linkage1.rs @@ -32,7 +32,9 @@ fn main() { // discarded. By adding and calling `other::bar`, we get around this problem. other::bar(); - assert!(!foo.is_null()); - assert_eq!(unsafe { *foo }, 3); - assert!(something_that_should_never_exist.is_null()); + unsafe { + assert!(!foo.is_null()); + assert_eq!(*foo, 3); + assert!(something_that_should_never_exist.is_null()); + } } diff --git a/src/test/run-pass/thread-local-extern-static.rs b/src/test/run-pass/thread-local-extern-static.rs index 92a95cad0d38a..87188db9dc0ed 100644 --- a/src/test/run-pass/thread-local-extern-static.rs +++ b/src/test/run-pass/thread-local-extern-static.rs @@ -22,5 +22,7 @@ extern { } fn main() { - assert_eq!(FOO, 3); + unsafe { + assert_eq!(FOO, 3); + } }