Skip to content

Commit fb4fa60

Browse files
committed
Auto merge of #42894 - petrochenkov:deny, r=nikomatsakis
Make sufficiently old or low-impact compatibility lints deny-by-default Needs crater run before proceeding. r? @nikomatsakis
2 parents 9b85e1c + 9196f87 commit fb4fa60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+101
-130
lines changed

src/librustc/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ use std::mem::transmute;
614614
struct Foo<T>(Vec<T>);
615615
616616
trait MyTransmutableType: Sized {
617-
fn transmute(Vec<Self>) -> Foo<Self>;
617+
fn transmute(_: Vec<Self>) -> Foo<Self>;
618618
}
619619
620620
impl MyTransmutableType for u8 {

src/librustc/lint/builtin.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ declare_lint! {
130130
"detect private items in public interfaces not caught by the old implementation"
131131
}
132132

133+
declare_lint! {
134+
pub PUB_USE_OF_PRIVATE_EXTERN_CRATE,
135+
Deny,
136+
"detect public reexports of private extern crates"
137+
}
138+
133139
declare_lint! {
134140
pub INVALID_TYPE_PARAM_DEFAULT,
135141
Deny,
@@ -144,14 +150,14 @@ declare_lint! {
144150

145151
declare_lint! {
146152
pub RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
147-
Warn,
153+
Deny,
148154
"attempt to resolve a trait on an expression whose type cannot be inferred but which \
149155
currently defaults to ()"
150156
}
151157

152158
declare_lint! {
153159
pub SAFE_EXTERN_STATICS,
154-
Warn,
160+
Deny,
155161
"safe access to extern statics was erroneously allowed"
156162
}
157163

@@ -169,14 +175,14 @@ declare_lint! {
169175

170176
declare_lint! {
171177
pub LEGACY_DIRECTORY_OWNERSHIP,
172-
Warn,
178+
Deny,
173179
"non-inline, non-`#[path]` modules (e.g. `mod foo;`) were erroneously allowed in some files \
174180
not named `mod.rs`"
175181
}
176182

177183
declare_lint! {
178184
pub LEGACY_IMPORTS,
179-
Warn,
185+
Deny,
180186
"detects names that resolve to ambiguous glob imports with RFC 1560"
181187
}
182188

@@ -188,13 +194,13 @@ declare_lint! {
188194

189195
declare_lint! {
190196
pub MISSING_FRAGMENT_SPECIFIER,
191-
Warn,
197+
Deny,
192198
"detects missing fragment specifiers in unused `macro_rules!` patterns"
193199
}
194200

195201
declare_lint! {
196202
pub PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
197-
Warn,
203+
Deny,
198204
"detects parenthesized generic parameters in type and module names"
199205
}
200206

@@ -230,6 +236,7 @@ impl LintPass for HardwiredLints {
230236
TRIVIAL_CASTS,
231237
TRIVIAL_NUMERIC_CASTS,
232238
PRIVATE_IN_PUBLIC,
239+
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
233240
INVALID_TYPE_PARAM_DEFAULT,
234241
CONST_ERR,
235242
RENAMED_AND_REMOVED_LINTS,

src/librustc_lint/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
184184
id: LintId::of(PRIVATE_IN_PUBLIC),
185185
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
186186
},
187+
FutureIncompatibleInfo {
188+
id: LintId::of(PUB_USE_OF_PRIVATE_EXTERN_CRATE),
189+
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
190+
},
187191
FutureIncompatibleInfo {
188192
id: LintId::of(PATTERNS_IN_FNS_WITHOUT_BODY),
189193
reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",

src/librustc_resolve/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ impl Something {} // ok!
837837
trait Foo {
838838
type N;
839839
840-
fn bar(Self::N); // ok!
840+
fn bar(_: Self::N); // ok!
841841
}
842842
843843
// or:

src/librustc_resolve/resolve_imports.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use {names_to_string, module_to_string};
1818
use {resolve_error, ResolutionError};
1919

2020
use rustc::ty;
21-
use rustc::lint::builtin::PRIVATE_IN_PUBLIC;
21+
use rustc::lint::builtin::PUB_USE_OF_PRIVATE_EXTERN_CRATE;
2222
use rustc::hir::def_id::DefId;
2323
use rustc::hir::def::*;
2424
use rustc::util::nodemap::FxHashMap;
@@ -296,7 +296,8 @@ impl<'a> Resolver<'a> {
296296
pub fn import(&self, binding: &'a NameBinding<'a>, directive: &'a ImportDirective<'a>)
297297
-> &'a NameBinding<'a> {
298298
let vis = if binding.pseudo_vis().is_at_least(directive.vis.get(), self) ||
299-
!directive.is_glob() && binding.is_extern_crate() { // c.f. `PRIVATE_IN_PUBLIC`
299+
// c.f. `PUB_USE_OF_PRIVATE_EXTERN_CRATE`
300+
!directive.is_glob() && binding.is_extern_crate() {
300301
directive.vis.get()
301302
} else {
302303
binding.pseudo_vis()
@@ -735,7 +736,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
735736
let msg = format!("extern crate `{}` is private, and cannot be reexported \
736737
(error E0365), consider declaring with `pub`",
737738
ident);
738-
self.session.add_lint(PRIVATE_IN_PUBLIC, directive.id, directive.span, msg);
739+
self.session.add_lint(PUB_USE_OF_PRIVATE_EXTERN_CRATE,
740+
directive.id, directive.span, msg);
739741
} else if ns == TypeNS {
740742
struct_span_err!(self.session, directive.span, E0365,
741743
"`{}` is private, and cannot be reexported", ident)

src/librustc_typeck/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ trait T2 {
24762476
type Bar;
24772477
24782478
// error: Baz is used but not declared
2479-
fn return_bool(&self, &Self::Bar, &Self::Baz) -> bool;
2479+
fn return_bool(&self, _: &Self::Bar, _: &Self::Baz) -> bool;
24802480
}
24812481
```
24822482
@@ -2498,7 +2498,7 @@ trait T2 {
24982498
type Baz; // we declare `Baz` in our trait.
24992499
25002500
// and now we can use it here:
2501-
fn return_bool(&self, &Self::Bar, &Self::Baz) -> bool;
2501+
fn return_bool(&self, _: &Self::Bar, _: &Self::Baz) -> bool;
25022502
}
25032503
```
25042504
"##,

src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub trait Sized {
2525
trait Add<RHS=Self> {
2626
type Output;
2727

28-
fn add(self, RHS) -> Self::Output;
28+
fn add(self, _: RHS) -> Self::Output;
2929
}
3030

3131
fn ice<A>(a: A) {

src/test/compile-fail/defaulted-unit-warning.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(dead_code)]
12-
#![allow(unreachable_code)]
13-
#![deny(resolve_trait_on_defaulted_unit)]
11+
#![allow(unused)]
1412

1513
trait Deserialize: Sized {
1614
fn deserialize() -> Result<Self, String>;
@@ -38,4 +36,3 @@ fn smeg() {
3836
fn main() {
3937
smeg();
4038
}
41-

src/test/compile-fail/directory_ownership/backcompat-warnings.rs

-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010

1111
// error-pattern: cannot declare a new module at this location
1212
// error-pattern: will become a hard error
13-
// error-pattern: compilation successful
14-
15-
#![feature(rustc_attrs)]
1613

1714
#[path="mod_file_not_owning_aux3.rs"]
1815
mod foo;
1916

20-
#[rustc_error]
2117
fn main() {}

src/test/compile-fail/imports/rfc-1560-warning-cycle.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(rustc_attrs)]
1211
#![allow(unused)]
1312

1413
pub struct Foo;
@@ -20,12 +19,11 @@ mod bar {
2019
use *; //~ NOTE `Foo` could refer to the name imported here
2120
use bar::*; //~ NOTE `Foo` could also refer to the name imported here
2221
fn f(_: Foo) {}
23-
//~^ WARN `Foo` is ambiguous
22+
//~^ ERROR `Foo` is ambiguous
2423
//~| WARN hard error in a future release
2524
//~| NOTE see issue #38260
26-
//~| NOTE #[warn(legacy_imports)] on by default
25+
//~| NOTE #[deny(legacy_imports)] on by default
2726
}
2827
}
2928

30-
#[rustc_error]
31-
fn main() {} //~ ERROR compilation successful
29+
fn main() {}

src/test/compile-fail/issue-13853-5.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
trait Deserializer<'a> { }
1212

1313
trait Deserializable {
14-
fn deserialize_token<'a, D: Deserializer<'a>>(D, &'a str) -> Self;
14+
fn deserialize_token<'a, D: Deserializer<'a>>(_: D, _: &'a str) -> Self;
1515
}
1616

1717
impl<'a, T: Deserializable> Deserializable for &'a str {

src/test/compile-fail/issue-18400.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
trait Set<T> {
12-
fn contains(&self, T) -> bool;
13-
fn set(&mut self, T);
12+
fn contains(&self, _: T) -> bool;
13+
fn set(&mut self, _: T);
1414
}
1515

1616
impl<'a, T, S> Set<&'a [T]> for S where

src/test/compile-fail/issue-20831-debruijn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait Subscriber {
2222

2323
pub trait Publisher<'a> {
2424
type Output;
25-
fn subscribe(&mut self, Box<Subscriber<Input=Self::Output> + 'a>);
25+
fn subscribe(&mut self, _: Box<Subscriber<Input=Self::Output> + 'a>);
2626
}
2727

2828
pub trait Processor<'a> : Subscriber + Publisher<'a> { }

src/test/compile-fail/issue-32995-2.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![deny(parenthesized_params_in_types_and_modules)]
12-
//~^ NOTE lint level defined here
13-
//~| NOTE lint level defined here
14-
//~| NOTE lint level defined here
15-
#![allow(dead_code, unused_variables)]
1611
#![feature(conservative_impl_trait)]
12+
#![allow(unused)]
1713

1814
fn main() {
1915
{ fn f<X: ::std::marker()::Send>() {} }
2016
//~^ ERROR parenthesized parameters may only be used with a trait
2117
//~| WARN previously accepted
22-
//~| NOTE issue #42238
2318

2419
{ fn f() -> impl ::std::marker()::Send { } }
2520
//~^ ERROR parenthesized parameters may only be used with a trait
2621
//~| WARN previously accepted
27-
//~| NOTE issue #42238
2822
}
2923

3024
#[derive(Clone)]
@@ -33,4 +27,3 @@ struct X;
3327
impl ::std::marker()::Copy for X {}
3428
//~^ ERROR parenthesized parameters may only be used with a trait
3529
//~| WARN previously accepted
36-
//~| NOTE issue #42238

src/test/compile-fail/issue-32995.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![deny(parenthesized_params_in_types_and_modules)]
12-
//~^ NOTE lint level defined here
13-
//~| NOTE lint level defined here
14-
//~| NOTE lint level defined here
15-
//~| NOTE lint level defined here
16-
//~| NOTE lint level defined here
17-
//~| NOTE lint level defined here
18-
//~| NOTE lint level defined here
19-
#![allow(dead_code, unused_variables)]
11+
#![allow(unused)]
2012

2113
fn main() {
2214
let x: usize() = 1;
2315
//~^ ERROR parenthesized parameters may only be used with a trait
2416
//~| WARN previously accepted
25-
//~| NOTE issue #42238
2617

2718
let b: ::std::boxed()::Box<_> = Box::new(1);
2819
//~^ ERROR parenthesized parameters may only be used with a trait
2920
//~| WARN previously accepted
30-
//~| NOTE issue #42238
3121

3222
macro_rules! pathexpr {
3323
($p:path) => { $p }
@@ -36,27 +26,22 @@ fn main() {
3626
let p = pathexpr!(::std::str()::from_utf8)(b"foo").unwrap();
3727
//~^ ERROR parenthesized parameters may only be used with a trait
3828
//~| WARN previously accepted
39-
//~| NOTE issue #42238
4029

4130
let p = pathexpr!(::std::str::from_utf8())(b"foo").unwrap();
4231
//~^ ERROR parenthesized parameters may only be used with a trait
4332
//~| WARN previously accepted
44-
//~| NOTE issue #42238
4533

4634
let o : Box<::std::marker()::Send> = Box::new(1);
4735
//~^ ERROR parenthesized parameters may only be used with a trait
4836
//~| WARN previously accepted
49-
//~| NOTE issue #42238
5037

5138
let o : Box<Send + ::std::marker()::Sync> = Box::new(1);
5239
//~^ ERROR parenthesized parameters may only be used with a trait
5340
//~| WARN previously accepted
54-
//~| NOTE issue #42238
5541
}
5642

5743
fn foo<X:Default>() {
5844
let d : X() = Default::default();
5945
//~^ ERROR parenthesized parameters may only be used with a trait
6046
//~| WARN previously accepted
61-
//~| NOTE issue #42238
6247
}

src/test/compile-fail/issue-35869.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#![feature(conservative_impl_trait)]
1212

1313
trait Foo {
14-
fn foo(fn(u8) -> ()); //~ NOTE type in trait
15-
fn bar(Option<u8>); //~ NOTE type in trait
16-
fn baz((u8, u16)); //~ NOTE type in trait
14+
fn foo(_: fn(u8) -> ()); //~ NOTE type in trait
15+
fn bar(_: Option<u8>); //~ NOTE type in trait
16+
fn baz(_: (u8, u16)); //~ NOTE type in trait
1717
fn qux() -> u8; //~ NOTE type in trait
1818
}
1919

src/test/compile-fail/issue-38293.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// Test that `fn foo::bar::{self}` only imports `bar` in the type namespace.
1212

1313
#![allow(unused)]
14-
#![deny(legacy_imports)]
1514

1615
mod foo {
1716
pub fn f() { }

src/test/compile-fail/issue-39404.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![deny(missing_fragment_specifier)] //~ NOTE lint level defined here
12-
#![allow(unused_macros)]
11+
#![allow(unused)]
1312

1413
macro_rules! m { ($i) => {} }
1514
//~^ ERROR missing fragment specifier
1615
//~| WARN previously accepted
17-
//~| NOTE issue #40107
1816

1917
fn main() {}

src/test/compile-fail/no-patterns-in-args-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ trait Tr {
1717
//~^ WARN was previously accepted
1818
fn g1(arg: u8); // OK
1919
fn g2(_: u8); // OK
20+
#[allow(anonymous_parameters)]
2021
fn g3(u8); // OK
2122
}
2223

src/test/compile-fail/pub-reexport-priv-extern-crate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![allow(unused)]
12-
#![deny(private_in_public)]
1312

1413
extern crate core;
1514
pub use core as reexported_core; //~ ERROR `core` is private, and cannot be reexported

src/test/compile-fail/safe-extern-statics-mut.rs

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
// aux-build:extern-statics.rs
1212

13-
#![allow(unused)]
14-
#![deny(safe_extern_statics)]
15-
1613
extern crate extern_statics;
1714
use extern_statics::*;
1815

src/test/compile-fail/safe-extern-statics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// aux-build:extern-statics.rs
1212

1313
#![allow(unused)]
14-
#![deny(safe_extern_statics)]
1514

1615
extern crate extern_statics;
1716
use extern_statics::*;

0 commit comments

Comments
 (0)