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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 13 additions & 6 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 3 additions & 5 deletions
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() {}

0 commit comments

Comments
 (0)