Auto merge of #48309 - mark-i-m:anon_param_lint, r=nikomatsakis
Make anon params lint warn-by-default This is intended as a followup on anonymous parameters deprecation. Cross-posting from #41686: > After having read a bit more of the discussion that I can find, I propose a more aggressive deprecation strategy: > - We make the lint warn-by-default as soon as possible > - We make anon parameters a hard error at the epoch boundary cc @matklad @est31 @aturon
This commit is contained in:
commit
5f308ee419
16 changed files with 114 additions and 27 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(plugin_registrar, rustc_private)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(plugin_registrar)]
|
||||
#![feature(box_syntax, rustc_private)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
|
||||
// Load rustc as a plugin to get macros
|
||||
#[macro_use]
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(plugin_registrar)]
|
||||
#![feature(box_syntax, rustc_private)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
|
||||
extern crate syntax;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@
|
|||
// Test for the anonymous_parameters deprecation lint (RFC 1685)
|
||||
|
||||
trait T {
|
||||
fn foo(i32); //~ ERROR use of deprecated anonymous parameter
|
||||
fn foo(i32); //~ ERROR anonymous parameters are deprecated
|
||||
//~| WARNING hard error
|
||||
|
||||
fn bar_with_default_impl(String, String) {}
|
||||
//~^ ERROR use of deprecated anonymous parameter
|
||||
//~^ ERROR anonymous parameters are deprecated
|
||||
//~| WARNING hard error
|
||||
//~| ERROR use of deprecated anonymous parameter
|
||||
//~| ERROR anonymous parameters are deprecated
|
||||
//~| WARNING hard error
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#![deny(future_incompatible)]
|
||||
|
||||
trait Tr {
|
||||
fn f(u8) {} //~ ERROR use of deprecated anonymous parameter
|
||||
fn f(u8) {} //~ ERROR anonymous parameters are deprecated
|
||||
//~^ WARN this was previously accepted
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(plugin_registrar, rustc_private)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
#![feature(box_syntax, plugin, plugin_registrar, rustc_private)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
#![crate_type = "dylib"]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(plugin_registrar)]
|
||||
#![feature(box_syntax, rustc_private)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
|
||||
// Load rustc as a plugin to get macros
|
||||
#[macro_use]
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(plugin_registrar)]
|
||||
#![feature(box_syntax, rustc_private)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(macro_at_most_once_rep)]
|
||||
|
||||
extern crate syntax;
|
||||
|
||||
|
|
|
|||
23
src/test/ui/lint-anon-param-edition.fixed
Normal file
23
src/test/ui/lint-anon-param-edition.fixed
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// tests that the anonymous_parameters lint is warn-by-default on the 2018 edition
|
||||
|
||||
// compile-pass
|
||||
// compile-flags: --edition=2018
|
||||
// run-rustfix
|
||||
|
||||
trait Foo {
|
||||
fn foo(_: u8);
|
||||
//^ WARN anonymous parameters are deprecated
|
||||
//| WARN this was previously accepted
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
23
src/test/ui/lint-anon-param-edition.rs
Normal file
23
src/test/ui/lint-anon-param-edition.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// tests that the anonymous_parameters lint is warn-by-default on the 2018 edition
|
||||
|
||||
// compile-pass
|
||||
// compile-flags: --edition=2018
|
||||
// run-rustfix
|
||||
|
||||
trait Foo {
|
||||
fn foo(u8);
|
||||
//^ WARN anonymous parameters are deprecated
|
||||
//| WARN this was previously accepted
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
10
src/test/ui/lint-anon-param-edition.stderr
Normal file
10
src/test/ui/lint-anon-param-edition.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
warning: anonymous parameters are deprecated and will be removed in the next edition.
|
||||
--> $DIR/lint-anon-param-edition.rs:18:12
|
||||
|
|
||||
LL | fn foo(u8);
|
||||
| ^^ help: Try naming the parameter or explicitly ignoring it: `_: u8`
|
||||
|
|
||||
= note: #[warn(anonymous_parameters)] on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue