Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sufficiently old or low-impact compatibility lints deny-by-default #42894

Merged
merged 4 commits into from
Jul 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ use std::mem::transmute;
struct Foo<T>(Vec<T>);

trait MyTransmutableType: Sized {
fn transmute(Vec<Self>) -> Foo<Self>;
fn transmute(_: Vec<Self>) -> Foo<Self>;
}

impl MyTransmutableType for u8 {
Expand Down
19 changes: 13 additions & 6 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -144,14 +150,14 @@ 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"
}

Expand All @@ -169,14 +175,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"
}

Expand All @@ -188,13 +194,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"
}

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
id: LintId::of(PRIVATE_IN_PUBLIC),
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
},
FutureIncompatibleInfo {
id: LintId::of(PUB_USE_OF_PRIVATE_EXTERN_CRATE),
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
},
FutureIncompatibleInfo {
id: LintId::of(PATTERNS_IN_FNS_WITHOUT_BODY),
reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ impl Something {} // ok!
trait Foo {
type N;

fn bar(Self::N); // ok!
fn bar(_: Self::N); // ok!
}

// or:
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
```

Expand All @@ -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;
}
```
"##,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub trait Sized {
trait Add<RHS=Self> {
type Output;

fn add(self, RHS) -> Self::Output;
fn add(self, _: RHS) -> Self::Output;
}

fn ice<A>(a: A) {
Expand Down
5 changes: 1 addition & 4 deletions src/test/compile-fail/defaulted-unit-warning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self, String>;
Expand Down Expand Up @@ -38,4 +36,3 @@ fn smeg() {
fn main() {
smeg();
}

Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
8 changes: 3 additions & 5 deletions src/test/compile-fail/imports/rfc-1560-warning-cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-13853-5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-18400.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// except according to those terms.

trait Set<T> {
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
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-20831-debruijn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub trait Subscriber {

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

pub trait Processor<'a> : Subscriber + Publisher<'a> { }
Expand Down
9 changes: 1 addition & 8 deletions src/test/compile-fail/issue-32995-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<X: ::std::marker()::Send>() {} }
//~^ 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)]
Expand All @@ -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
17 changes: 1 addition & 16 deletions src/test/compile-fail/issue-32995.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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<Send + ::std::marker()::Sync> = Box::new(1);
//~^ ERROR parenthesized parameters may only be used with a trait
//~| WARN previously accepted
//~| NOTE issue #42238
}

fn foo<X:Default>() {
let d : X() = Default::default();
//~^ ERROR parenthesized parameters may only be used with a trait
//~| WARN previously accepted
//~| NOTE issue #42238
}
6 changes: 3 additions & 3 deletions src/test/compile-fail/issue-35869.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#![feature(conservative_impl_trait)]

trait Foo {
fn foo(fn(u8) -> ()); //~ NOTE type in trait
fn bar(Option<u8>); //~ NOTE type in trait
fn baz((u8, u16)); //~ NOTE type in trait
fn foo(_: fn(u8) -> ()); //~ NOTE type in trait
fn bar(_: Option<u8>); //~ NOTE type in trait
fn baz(_: (u8, u16)); //~ NOTE type in trait
fn qux() -> u8; //~ NOTE type in trait
}

Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/issue-38293.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
Expand Down
4 changes: 1 addition & 3 deletions src/test/compile-fail/issue-39404.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
1 change: 1 addition & 0 deletions src/test/compile-fail/no-patterns-in-args-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ trait Tr {
//~^ WARN was previously accepted
fn g1(arg: u8); // OK
fn g2(_: u8); // OK
#[allow(anonymous_parameters)]
fn g3(u8); // OK
}

Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/pub-reexport-priv-extern-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/test/compile-fail/safe-extern-statics-mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

// aux-build:extern-statics.rs

#![allow(unused)]
#![deny(safe_extern_statics)]

extern crate extern_statics;
use extern_statics::*;

Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/safe-extern-statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// aux-build:extern-statics.rs

#![allow(unused)]
#![deny(safe_extern_statics)]

extern crate extern_statics;
use extern_statics::*;
Expand Down
Loading