From d290849a233bb2b06b01167c242b3886d2cf8681 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 2 May 2017 05:55:20 +0200 Subject: [PATCH 1/2] Removal pass for anonymous parameters Removes occurences of anonymous parameters from the rustc codebase, as they are to be deprecated. See issue #41686 and RFC 1685. --- src/libcore/convert.rs | 2 +- src/libcore/hash/sip.rs | 4 +- src/libcore/ops.rs | 4 +- src/librand/distributions/mod.rs | 2 +- src/librand/lib.rs | 2 +- src/librustc/session/config.rs | 2 +- src/librustc/ty/context.rs | 2 +- src/librustc_data_structures/indexed_vec.rs | 2 +- src/librustc_driver/lib.rs | 2 +- src/librustc_save_analysis/dump.rs | 48 ++++++++++----------- src/librustdoc/clean/mod.rs | 4 +- src/librustdoc/core.rs | 2 +- src/librustdoc/html/highlight.rs | 8 +++- src/libsyntax/ext/build.rs | 2 +- 14 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 084736685e3a7..f5dc38e8aab67 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -276,7 +276,7 @@ pub trait Into: Sized { pub trait From: Sized { /// Performs the conversion. #[stable(feature = "rust1", since = "1.0.0")] - fn from(T) -> Self; + fn from(t: T) -> Self; } /// An attempted conversion that consumes `self`, which may or may not be diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index 5f5d07b668237..db12496b6f320 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -403,8 +403,8 @@ impl Default for Hasher { #[doc(hidden)] trait Sip { - fn c_rounds(&mut State); - fn d_rounds(&mut State); + fn c_rounds(_: &mut State); + fn d_rounds(_: &mut State); } #[derive(Debug, Clone, Default)] diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 175b3a5a69ac1..391b606f613f2 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -2878,10 +2878,10 @@ pub trait Carrier { type Error; /// Create a `Carrier` from a success value. - fn from_success(Self::Success) -> Self; + fn from_success(_: Self::Success) -> Self; /// Create a `Carrier` from an error value. - fn from_error(Self::Error) -> Self; + fn from_error(_: Self::Error) -> Self; /// Translate this `Carrier` to another implementation of `Carrier` with the /// same associated types. diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index eb9476efb7b4c..67b9449981e0f 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -53,7 +53,7 @@ pub trait Sample { // trait called `Sample` and the other should be `DependentSample`. pub trait IndependentSample: Sample { /// Generate a random value. - fn ind_sample(&self, &mut R) -> Support; + fn ind_sample(&self, _: &mut R) -> Support; } /// A wrapper for generating types that implement `Rand` via the diff --git a/src/librand/lib.rs b/src/librand/lib.rs index f2b43a20f944e..ca05db15ffeb9 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -329,7 +329,7 @@ impl<'a, R: fmt::Debug> fmt::Debug for AsciiGenerator<'a, R> { /// the same stream of randomness multiple times. pub trait SeedableRng: Rng { /// Reseed an RNG with the given seed. - fn reseed(&mut self, Seed); + fn reseed(&mut self, _: Seed); /// Create a new RNG with the given seed. fn from_seed(seed: Seed) -> Self; diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 0bb4cd69e0cd1..d107e9a84856f 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1804,7 +1804,7 @@ mod dep_tracking { use rustc_back::PanicStrategy; pub trait DepTrackingHash { - fn hash(&self, &mut DefaultHasher, ErrorOutputType); + fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType); } macro_rules! impl_dep_tracking_hash_via_hash { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ac7a72e66655f..81b547d5a570a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1467,7 +1467,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub trait InternAs { type Output; - fn intern_with(self, F) -> Self::Output + fn intern_with(self, f: F) -> Self::Output where F: FnOnce(&T) -> R; } diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 62c430dda327f..0642ddc71622b 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -24,7 +24,7 @@ use rustc_serialize as serialize; /// /// (purpose: avoid mixing indexes for different bitvector domains.) pub trait Idx: Copy + 'static + Eq + Debug { - fn new(usize) -> Self; + fn new(idx: usize) -> Self; fn index(self) -> usize; } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index e4ed2b8eb8fab..889f4dd4b9aac 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -343,7 +343,7 @@ pub trait CompilerCalls<'a> { // Create a CompilController struct for controlling the behaviour of // compilation. - fn build_controller(&mut self, &Session, &getopts::Matches) -> CompileController<'a>; + fn build_controller(&mut self, _: &Session, _: &getopts::Matches) -> CompileController<'a>; } // CompilerCalls instance for a regular rustc build. diff --git a/src/librustc_save_analysis/dump.rs b/src/librustc_save_analysis/dump.rs index 84e1fb03f624e..795ff58e20607 100644 --- a/src/librustc_save_analysis/dump.rs +++ b/src/librustc_save_analysis/dump.rs @@ -13,28 +13,28 @@ use super::external_data::*; use rls_data::CratePreludeData; pub trait Dump { - fn crate_prelude(&mut self, CratePreludeData) {} - fn enum_data(&mut self, EnumData) {} - fn extern_crate(&mut self, ExternCrateData) {} - fn impl_data(&mut self, ImplData) {} - fn inheritance(&mut self, InheritanceData) {} - fn function(&mut self, FunctionData) {} - fn function_ref(&mut self, FunctionRefData) {} - fn function_call(&mut self, FunctionCallData) {} - fn method(&mut self, MethodData) {} - fn method_call(&mut self, MethodCallData) {} - fn macro_data(&mut self, MacroData) {} - fn macro_use(&mut self, MacroUseData) {} - fn mod_data(&mut self, ModData) {} - fn mod_ref(&mut self, ModRefData) {} - fn struct_data(&mut self, StructData) {} - fn struct_variant(&mut self, StructVariantData) {} - fn trait_data(&mut self, TraitData) {} - fn tuple_variant(&mut self, TupleVariantData) {} - fn type_ref(&mut self, TypeRefData) {} - fn typedef(&mut self, TypeDefData) {} - fn use_data(&mut self, UseData) {} - fn use_glob(&mut self, UseGlobData) {} - fn variable(&mut self, VariableData) {} - fn variable_ref(&mut self, VariableRefData) {} + fn crate_prelude(&mut self, _: CratePreludeData) {} + fn enum_data(&mut self, _: EnumData) {} + fn extern_crate(&mut self, _: ExternCrateData) {} + fn impl_data(&mut self, _: ImplData) {} + fn inheritance(&mut self, _: InheritanceData) {} + fn function(&mut self, _: FunctionData) {} + fn function_ref(&mut self, _: FunctionRefData) {} + fn function_call(&mut self, _: FunctionCallData) {} + fn method(&mut self, _: MethodData) {} + fn method_call(&mut self, _: MethodCallData) {} + fn macro_data(&mut self, _: MacroData) {} + fn macro_use(&mut self, _: MacroUseData) {} + fn mod_data(&mut self, _: ModData) {} + fn mod_ref(&mut self, _: ModRefData) {} + fn struct_data(&mut self, _: StructData) {} + fn struct_variant(&mut self, _: StructVariantData) {} + fn trait_data(&mut self, _: TraitData) {} + fn tuple_variant(&mut self, _: TupleVariantData) {} + fn type_ref(&mut self, _: TypeRefData) {} + fn typedef(&mut self, _: TypeDefData) {} + fn use_data(&mut self, _: UseData) {} + fn use_glob(&mut self, _: UseGlobData) {} + fn variable(&mut self, _: VariableData) {} + fn variable_ref(&mut self, _: VariableRefData) {} } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a25eb60d2a2fc..1229851928e47 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -503,7 +503,7 @@ impl<'a> Iterator for ListAttributesIter<'a> { pub trait AttributesExt { /// Finds an attribute as List and returns the list of attributes nested inside. - fn lists<'a>(&'a self, &'a str) -> ListAttributesIter<'a>; + fn lists<'a>(&'a self, name: &'a str) -> ListAttributesIter<'a>; } impl AttributesExt for [ast::Attribute] { @@ -518,7 +518,7 @@ impl AttributesExt for [ast::Attribute] { pub trait NestedAttributesExt { /// Returns whether the attribute list contains a specific `Word` - fn has_word(self, &str) -> bool; + fn has_word(self, word: &str) -> bool; } impl> NestedAttributesExt for I { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 6417270b9c73b..5879be08881fb 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -89,7 +89,7 @@ impl<'a, 'tcx> DocContext<'a, 'tcx> { } pub trait DocAccessLevels { - fn is_doc_reachable(&self, DefId) -> bool; + fn is_doc_reachable(&self, did: DefId) -> bool; } impl DocAccessLevels for AccessLevels { diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 15dada10c0dc1..c1f1cb43e41db 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -114,7 +114,7 @@ pub enum Class { pub trait Writer { /// Called when we start processing a span of text that should be highlighted. /// The `Class` argument specifies how it should be highlighted. - fn enter_span(&mut self, Class) -> io::Result<()>; + fn enter_span(&mut self, _: Class) -> io::Result<()>; /// Called at the end of a span of highlighted text. fn exit_span(&mut self) -> io::Result<()>; @@ -131,7 +131,11 @@ pub trait Writer { /// ``` /// The latter can be thought of as a shorthand for the former, which is /// more flexible. - fn string(&mut self, T, Class, Option<&TokenAndSpan>) -> io::Result<()>; + fn string(&mut self, + text: T, + klass: Class, + tas: Option<&TokenAndSpan>) + -> io::Result<()>; } // Implement `Writer` for anthing that can be written to, this just implements diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index e0fb46ff5eb09..09f22e8691e4c 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -52,7 +52,7 @@ pub trait AstBuilder { fn ty_mt(&self, ty: P, mutbl: ast::Mutability) -> ast::MutTy; fn ty(&self, span: Span, ty: ast::TyKind) -> P; - fn ty_path(&self, ast::Path) -> P; + fn ty_path(&self, path: ast::Path) -> P; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P; fn ty_rptr(&self, span: Span, From 14bbd0a5a3722bdcb4c5f36d81097e1fb992add3 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 2 May 2017 06:35:36 +0200 Subject: [PATCH 2/2] Address review --- src/libcore/convert.rs | 2 +- src/librustdoc/html/highlight.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index f5dc38e8aab67..21c75ad339511 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -276,7 +276,7 @@ pub trait Into: Sized { pub trait From: Sized { /// Performs the conversion. #[stable(feature = "rust1", since = "1.0.0")] - fn from(t: T) -> Self; + fn from(_: T) -> Self; } /// An attempted conversion that consumes `self`, which may or may not be diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index c1f1cb43e41db..a40d1e6bdc917 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -134,7 +134,7 @@ pub trait Writer { fn string(&mut self, text: T, klass: Class, - tas: Option<&TokenAndSpan>) + tok: Option<&TokenAndSpan>) -> io::Result<()>; }