Skip to content

Commit

Permalink
Auto merge of #53272 - mark-i-m:anon_param_error_now, r=nikomatsakis
Browse files Browse the repository at this point in the history
Warn on anon params in 2015 edition

cc #41686 rust-lang/rfcs#2522
cc  @Centril @nikomatsakis

TODO:
- [x] Make sure the tests pass.
- [x] Make sure there is rustfix-able suggestion. Current plan is to just suggest `_ : Foo`
- [x] Add a rustfix ui test.

EDIT: It seems I already did the last two in #48309
  • Loading branch information
bors committed Aug 28, 2018
2 parents 8c2b371 + 548f28e commit f33921b
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ macro_rules! late_lint_methods {

macro_rules! expand_lint_pass_methods {
($context:ty, [$($(#[$attr:meta])* fn $name:ident($($param:ident: $arg:ty),*);)*]) => (
$(#[inline(always)] fn $name(&mut self, $context, $(_: $arg),*) {})*
$(#[inline(always)] fn $name(&mut self, _: $context, $(_: $arg),*) {})*
)
}

Expand Down
4 changes: 1 addition & 3 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use syntax::tokenstream::{TokenTree, TokenStream};
use syntax::ast;
use syntax::attr;
use syntax::source_map::Spanned;
use syntax::edition::Edition;
use syntax::feature_gate::{AttributeGate, AttributeType, Stability, deprecated_attributes};
use syntax_pos::{BytePos, Span, SyntaxContext};
use syntax::symbol::keywords;
Expand Down Expand Up @@ -629,8 +628,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
declare_lint! {
pub ANONYMOUS_PARAMETERS,
Allow,
"detects anonymous parameters",
Edition::Edition2018 => Warn
"detects anonymous parameters"
}

/// Checks for use of anonymous parameters (RFC 1685)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
FutureIncompatibleInfo {
id: LintId::of(ANONYMOUS_PARAMETERS),
reference: "issue #41686 <https://github.com/rust-lang/rust/issues/41686>",
edition: None,
edition: Some(Edition::Edition2018),
},
FutureIncompatibleInfo {
id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES),
Expand Down
9 changes: 8 additions & 1 deletion src/libstd/sys/windows/backtrace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ type StackWalk64Fn = unsafe extern "system" fn(
trait StackWalker {
type Item: StackFrame;

fn walk(&self, c::DWORD, c::HANDLE, c::HANDLE, &mut Self::Item, &mut c::CONTEXT) -> c::BOOL;
fn walk(
&self,
_: c::DWORD,
_: c::HANDLE,
_: c::HANDLE,
_: &mut Self::Item,
_: &mut c::CONTEXT
) -> c::BOOL;
}

impl StackWalker for StackWalkExFn {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/anon-params-deprecated.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: lint level defined here
|
LL | #![warn(anonymous_parameters)]
| ^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

warning: anonymous parameters are deprecated and will be removed in the next edition.
Expand All @@ -18,7 +18,7 @@ warning: anonymous parameters are deprecated and will be removed in the next edi
LL | fn bar_with_default_impl(String, String) {}
| ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

warning: anonymous parameters are deprecated and will be removed in the next edition.
Expand All @@ -27,6 +27,6 @@ warning: anonymous parameters are deprecated and will be removed in the next edi
LL | fn bar_with_default_impl(String, String) {}
| ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

6 changes: 3 additions & 3 deletions src/test/ui/chalkify/lower_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#[rustc_dump_program_clauses] //~ ERROR program clause dump
trait Foo<S, T, U> {
fn s(S) -> S;
fn t(T) -> T;
fn u(U) -> U;
fn s(_: S) -> S;
fn t(_: T) -> T;
fn u(_: U) -> U;
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/chalkify/lower_trait_higher_rank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#[rustc_dump_program_clauses] //~ ERROR program clause dump
trait Foo<F> where for<'a> F: Fn(&'a (u8, u16)) -> &'a u8
{
fn s(F) -> F;
fn s(_: F) -> F;
}

fn main() {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/chalkify/lower_trait_where_clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use std::borrow::Borrow;

#[rustc_dump_program_clauses] //~ ERROR program clause dump
trait Foo<'a, 'b, S, T, U> where S: Debug, T: Borrow<U>, U: ?Sized, 'a: 'b, U: 'b {
fn s(S) -> S;
fn t(T) -> T;
fn u(U) -> U;
fn s(_: S) -> S;
fn t(_: T) -> T;
fn u(_: U) -> U;
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/future-incompatible-lint-group.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: lint level defined here
LL | #![deny(future_incompatible)]
| ^^^^^^^^^^^^^^^^^^^
= note: #[deny(anonymous_parameters)] implied by #[deny(future_incompatible)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/impl-trait/where-allowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ trait InTraitDefnReturn {
// Allowed and disallowed in trait impls
trait DummyTrait {
type Out;
fn in_trait_impl_parameter(impl Debug);
fn in_trait_impl_parameter(_: impl Debug);
fn in_trait_impl_return() -> Self::Out;
}
impl DummyTrait for () {
Expand Down

0 comments on commit f33921b

Please sign in to comment.