From a4b67ee1952367403290392db428d2eb499454d1 Mon Sep 17 00:00:00 2001 From: stepnivlk Date: Sat, 16 Mar 2019 14:51:59 +0100 Subject: [PATCH 1/8] Mention `no merge policy` in the CONTRIBUTING guide --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e785f03d7de2b..5757773e12203 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -119,6 +119,13 @@ bring those changes into the source repository. Please make pull requests against the `master` branch. +Rust follows a no merge policy, meaning, when you encounter merge +conflicts you are expected to always rebase instead of merge. +E.g. always use rebase when bringing the latest changes from +the master branch to your feature branch. +Also, please make sure that fixup commits are squashed into other related +commits with meaningful commit messages. + Please make sure your pull request is in compliance with Rust's style guidelines by running From 45c82abf13385f22d10dccecd1e54b28cfbeb5cc Mon Sep 17 00:00:00 2001 From: Yuki OKUSHI Date: Sun, 31 Mar 2019 06:30:45 +0900 Subject: [PATCH 2/8] Distinguish depending on error level Remove unnecessary comment --- src/librustc_errors/emitter.rs | 17 ++++++++++++++--- src/test/ui/imports/import-crate-var.stderr | 2 +- .../ui/macros/must-use-in-macro-55516.stderr | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index e9f269b6e2410..1c5d0c5bab129 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -6,6 +6,7 @@ use crate::{ Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SuggestionStyle, SourceMapperDyn, DiagnosticId, }; +use crate::Level::Error; use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style}; use crate::styled_buffer::StyledBuffer; @@ -72,6 +73,7 @@ impl Emitter for EmitterWriter { self.fix_multispans_in_std_macros(&mut primary_span, &mut children, + &db.level, db.handler.flags.external_macro_backtrace); self.emit_messages_default(&db.level, @@ -856,18 +858,27 @@ impl EmitterWriter { fn fix_multispans_in_std_macros(&mut self, span: &mut MultiSpan, children: &mut Vec, + level: &Level, backtrace: bool) { let mut spans_updated = self.fix_multispan_in_std_macros(span, backtrace); for child in children.iter_mut() { spans_updated |= self.fix_multispan_in_std_macros(&mut child.span, backtrace); } + let msg = if level == &Error { + "this error originates in a macro outside of the current crate \ + (in Nightly builds, run with -Z external-macro-backtrace \ + for more info)".to_string() + } else { + "this warning originates in a macro outside of the current crate \ + (in Nightly builds, run with -Z external-macro-backtrace \ + for more info)".to_string() + }; + if spans_updated { children.push(SubDiagnostic { level: Level::Note, message: vec![ - ("this error originates in a macro outside of the current crate \ - (in Nightly builds, run with -Z external-macro-backtrace \ - for more info)".to_string(), + (msg, Style::NoStyle), ], span: MultiSpan::new(), diff --git a/src/test/ui/imports/import-crate-var.stderr b/src/test/ui/imports/import-crate-var.stderr index 928256543bcb9..4c358a81cc1a4 100644 --- a/src/test/ui/imports/import-crate-var.stderr +++ b/src/test/ui/imports/import-crate-var.stderr @@ -5,5 +5,5 @@ LL | m!(); | ^^^^^ | = note: `use $crate;` was erroneously allowed and will become a hard error in a future release - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) diff --git a/src/test/ui/macros/must-use-in-macro-55516.stderr b/src/test/ui/macros/must-use-in-macro-55516.stderr index 623b5745a357d..302c8aa7e6a55 100644 --- a/src/test/ui/macros/must-use-in-macro-55516.stderr +++ b/src/test/ui/macros/must-use-in-macro-55516.stderr @@ -6,5 +6,5 @@ LL | write!(&mut example, "{}", 42); | = note: `-W unused-must-use` implied by `-W unused` = note: this `Result` may be an `Err` variant, which should be handled - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) From 3829746ef9356be7ab766efcbc328aeb1d5a555f Mon Sep 17 00:00:00 2001 From: David Wood Date: Sat, 30 Mar 2019 20:30:36 +0100 Subject: [PATCH 3/8] Include bounds in generic reordering diagnostic. This commit extends the existing generic re-ordering diagnostic to include any bounds on the generic parameter, thus producing correct suggestions. --- src/librustc_passes/ast_validation.rs | 37 ++++++++++++++++++--------- src/test/ui/issue-59508.fixed | 16 ++++++++++++ src/test/ui/issue-59508.rs | 16 ++++++++++++ src/test/ui/issue-59508.stderr | 8 ++++++ 4 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 src/test/ui/issue-59508.fixed create mode 100644 src/test/ui/issue-59508.rs create mode 100644 src/test/ui/issue-59508.stderr diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 4e2aefe623167..917564b17dfd0 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -361,7 +361,14 @@ enum GenericPosition { fn validate_generics_order<'a>( handler: &errors::Handler, - generics: impl Iterator)>, + generics: impl Iterator< + Item = ( + ParamKindOrd, + Option<&'a [GenericBound]>, + Span, + Option + ), + >, pos: GenericPosition, span: Span, ) { @@ -369,9 +376,9 @@ fn validate_generics_order<'a>( let mut out_of_order = FxHashMap::default(); let mut param_idents = vec![]; - for (kind, span, ident) in generics { + for (kind, bounds, span, ident) in generics { if let Some(ident) = ident { - param_idents.push((kind, param_idents.len(), ident)); + param_idents.push((kind, bounds, param_idents.len(), ident)); } let max_param = &mut max_param; match max_param { @@ -385,13 +392,19 @@ fn validate_generics_order<'a>( let mut ordered_params = "<".to_string(); if !out_of_order.is_empty() { - param_idents.sort_by_key(|&(po, i, _)| (po, i)); + param_idents.sort_by_key(|&(po, _, i, _)| (po, i)); let mut first = true; - for (_, _, ident) in param_idents { + for (_, bounds, _, ident) in param_idents { if !first { ordered_params += ", "; } ordered_params += &ident; + if let Some(bounds) = bounds { + if !bounds.is_empty() { + ordered_params += ": "; + ordered_params += &pprust::bounds_to_string(&bounds); + } + } first = false; } } @@ -701,7 +714,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { GenericArg::Lifetime(..) => ParamKindOrd::Lifetime, GenericArg::Type(..) => ParamKindOrd::Type, GenericArg::Const(..) => ParamKindOrd::Const, - }, arg.span(), None) + }, None, arg.span(), None) }), GenericPosition::Arg, generic_args.span()); // Type bindings such as `Item=impl Debug` in `Iterator` @@ -736,16 +749,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } validate_generics_order(self.err_handler(), generics.params.iter().map(|param| { - let span = param.ident.span; let ident = Some(param.ident.to_string()); - match ¶m.kind { - GenericParamKind::Lifetime { .. } => (ParamKindOrd::Lifetime, span, ident), - GenericParamKind::Type { .. } => (ParamKindOrd::Type, span, ident), + let (kind, ident) = match ¶m.kind { + GenericParamKind::Lifetime { .. } => (ParamKindOrd::Lifetime, ident), + GenericParamKind::Type { .. } => (ParamKindOrd::Type, ident), GenericParamKind::Const { ref ty } => { let ty = pprust::ty_to_string(ty); - (ParamKindOrd::Const, span, Some(format!("const {}: {}", param.ident, ty))) + (ParamKindOrd::Const, Some(format!("const {}: {}", param.ident, ty))) } - } + }; + (kind, Some(&*param.bounds), param.ident.span, ident) }), GenericPosition::Param, generics.span); for predicate in &generics.where_clause.predicates { diff --git a/src/test/ui/issue-59508.fixed b/src/test/ui/issue-59508.fixed new file mode 100644 index 0000000000000..b5c60a1626f53 --- /dev/null +++ b/src/test/ui/issue-59508.fixed @@ -0,0 +1,16 @@ +// run-rustfix + +#![allow(dead_code)] + +// This test checks that generic parameter re-ordering diagnostic suggestions contain bounds. + +struct A; + +impl A { + pub fn do_things<'a, 'b: 'a, T>() { + //~^ ERROR lifetime parameters must be declared prior to type parameters + println!("panic"); + } +} + +fn main() {} diff --git a/src/test/ui/issue-59508.rs b/src/test/ui/issue-59508.rs new file mode 100644 index 0000000000000..0b39c5d8f2aec --- /dev/null +++ b/src/test/ui/issue-59508.rs @@ -0,0 +1,16 @@ +// run-rustfix + +#![allow(dead_code)] + +// This test checks that generic parameter re-ordering diagnostic suggestions contain bounds. + +struct A; + +impl A { + pub fn do_things() { + //~^ ERROR lifetime parameters must be declared prior to type parameters + println!("panic"); + } +} + +fn main() {} diff --git a/src/test/ui/issue-59508.stderr b/src/test/ui/issue-59508.stderr new file mode 100644 index 0000000000000..33e967cebffcc --- /dev/null +++ b/src/test/ui/issue-59508.stderr @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-59508.rs:10:25 + | +LL | pub fn do_things() { + | ----^^--^^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b: 'a, T>` + +error: aborting due to previous error + From 0270d565d9f6287bce6a7e64e55aac245288541e Mon Sep 17 00:00:00 2001 From: David Wood Date: Sat, 30 Mar 2019 20:57:04 +0100 Subject: [PATCH 4/8] Only mention const generics if enabled. This commit updates the generic parameter re-ordering diagnostic to only mention const generics if the feature is enabled. --- src/librustc_passes/ast_validation.rs | 57 ++++++++++++------- src/test/ui/issue-59508-1.rs | 18 ++++++ src/test/ui/issue-59508-1.stderr | 14 +++++ src/test/ui/issue-59508.stderr | 2 +- .../ui/lifetime-before-type-params.stderr | 8 +-- src/test/ui/parser/issue-14303-enum.stderr | 2 +- src/test/ui/parser/issue-14303-fn-def.stderr | 2 +- src/test/ui/parser/issue-14303-impl.stderr | 2 +- src/test/ui/parser/issue-14303-struct.stderr | 2 +- src/test/ui/parser/issue-14303-trait.stderr | 2 +- .../suggestions/suggest-move-lifetimes.stderr | 8 +-- 11 files changed, 83 insertions(+), 34 deletions(-) create mode 100644 src/test/ui/issue-59508-1.rs create mode 100644 src/test/ui/issue-59508-1.stderr diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 917564b17dfd0..5c325c55b619d 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -360,6 +360,7 @@ enum GenericPosition { } fn validate_generics_order<'a>( + sess: &Session, handler: &errors::Handler, generics: impl Iterator< Item = ( @@ -426,7 +427,11 @@ fn validate_generics_order<'a>( if let GenericPosition::Param = pos { err.span_suggestion( span, - &format!("reorder the {}s: lifetimes, then types, then consts", pos_str), + &format!( + "reorder the {}s: lifetimes, then types{}", + pos_str, + if sess.features_untracked().const_generics { ", then consts" } else { "" }, + ), ordered_params.clone(), Applicability::MachineApplicable, ); @@ -709,13 +714,19 @@ impl<'a> Visitor<'a> for AstValidator<'a> { match *generic_args { GenericArgs::AngleBracketed(ref data) => { walk_list!(self, visit_generic_arg, &data.args); - validate_generics_order(self.err_handler(), data.args.iter().map(|arg| { - (match arg { - GenericArg::Lifetime(..) => ParamKindOrd::Lifetime, - GenericArg::Type(..) => ParamKindOrd::Type, - GenericArg::Const(..) => ParamKindOrd::Const, - }, None, arg.span(), None) - }), GenericPosition::Arg, generic_args.span()); + validate_generics_order( + self.session, + self.err_handler(), + data.args.iter().map(|arg| { + (match arg { + GenericArg::Lifetime(..) => ParamKindOrd::Lifetime, + GenericArg::Type(..) => ParamKindOrd::Type, + GenericArg::Const(..) => ParamKindOrd::Const, + }, None, arg.span(), None) + }), + GenericPosition::Arg, + generic_args.span(), + ); // Type bindings such as `Item=impl Debug` in `Iterator` // are allowed to contain nested `impl Trait`. @@ -748,18 +759,24 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } } - validate_generics_order(self.err_handler(), generics.params.iter().map(|param| { - let ident = Some(param.ident.to_string()); - let (kind, ident) = match ¶m.kind { - GenericParamKind::Lifetime { .. } => (ParamKindOrd::Lifetime, ident), - GenericParamKind::Type { .. } => (ParamKindOrd::Type, ident), - GenericParamKind::Const { ref ty } => { - let ty = pprust::ty_to_string(ty); - (ParamKindOrd::Const, Some(format!("const {}: {}", param.ident, ty))) - } - }; - (kind, Some(&*param.bounds), param.ident.span, ident) - }), GenericPosition::Param, generics.span); + validate_generics_order( + self.session, + self.err_handler(), + generics.params.iter().map(|param| { + let ident = Some(param.ident.to_string()); + let (kind, ident) = match ¶m.kind { + GenericParamKind::Lifetime { .. } => (ParamKindOrd::Lifetime, ident), + GenericParamKind::Type { .. } => (ParamKindOrd::Type, ident), + GenericParamKind::Const { ref ty } => { + let ty = pprust::ty_to_string(ty); + (ParamKindOrd::Const, Some(format!("const {}: {}", param.ident, ty))) + } + }; + (kind, Some(&*param.bounds), param.ident.span, ident) + }), + GenericPosition::Param, + generics.span, + ); for predicate in &generics.where_clause.predicates { if let WherePredicate::EqPredicate(ref predicate) = *predicate { diff --git a/src/test/ui/issue-59508-1.rs b/src/test/ui/issue-59508-1.rs new file mode 100644 index 0000000000000..4fbed9b08f215 --- /dev/null +++ b/src/test/ui/issue-59508-1.rs @@ -0,0 +1,18 @@ +#![allow(dead_code)] +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +// This test checks that generic parameter re-ordering diagnostic suggestions mention that +// consts come after types and lifetimes when the `const_generics` feature is enabled. +// We cannot run rustfix on this test because of the above const generics warning. + +struct A; + +impl A { + pub fn do_things() { + //~^ ERROR lifetime parameters must be declared prior to type parameters + println!("panic"); + } +} + +fn main() {} diff --git a/src/test/ui/issue-59508-1.stderr b/src/test/ui/issue-59508-1.stderr new file mode 100644 index 0000000000000..8fb7d7c3c84dc --- /dev/null +++ b/src/test/ui/issue-59508-1.stderr @@ -0,0 +1,14 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-59508-1.rs:2:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-59508-1.rs:12:25 + | +LL | pub fn do_things() { + | ----^^--^^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b: 'a, T>` + +error: aborting due to previous error + diff --git a/src/test/ui/issue-59508.stderr b/src/test/ui/issue-59508.stderr index 33e967cebffcc..c0fdb2ef34ac4 100644 --- a/src/test/ui/issue-59508.stderr +++ b/src/test/ui/issue-59508.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-59508.rs:10:25 | LL | pub fn do_things() { - | ----^^--^^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b: 'a, T>` + | ----^^--^^----- help: reorder the parameters: lifetimes, then types: `<'a, 'b: 'a, T>` error: aborting due to previous error diff --git a/src/test/ui/lifetime-before-type-params.stderr b/src/test/ui/lifetime-before-type-params.stderr index 3cef5db66c66f..ffc6784bafed8 100644 --- a/src/test/ui/lifetime-before-type-params.stderr +++ b/src/test/ui/lifetime-before-type-params.stderr @@ -2,25 +2,25 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/lifetime-before-type-params.rs:2:13 | LL | fn first() {} - | ----^^--^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` + | ----^^--^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` error: lifetime parameters must be declared prior to type parameters --> $DIR/lifetime-before-type-params.rs:4:18 | LL | fn second<'a, T, 'b>() {} - | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` error: lifetime parameters must be declared prior to type parameters --> $DIR/lifetime-before-type-params.rs:6:16 | LL | fn third() {} - | -------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` + | -------^^- help: reorder the parameters: lifetimes, then types: `<'a, T, U>` error: lifetime parameters must be declared prior to type parameters --> $DIR/lifetime-before-type-params.rs:8:18 | LL | fn fourth<'a, T, 'b, U, 'c, V>() {} - | --------^^-----^^---- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, 'c, T, U, V>` + | --------^^-----^^---- help: reorder the parameters: lifetimes, then types: `<'a, 'b, 'c, T, U, V>` error[E0601]: `main` function not found in crate `lifetime_before_type_params` | diff --git a/src/test/ui/parser/issue-14303-enum.stderr b/src/test/ui/parser/issue-14303-enum.stderr index bcecd75b1abba..46f16ea0cc41c 100644 --- a/src/test/ui/parser/issue-14303-enum.stderr +++ b/src/test/ui/parser/issue-14303-enum.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-enum.rs:1:15 | LL | enum X<'a, T, 'b> { - | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-14303-fn-def.stderr b/src/test/ui/parser/issue-14303-fn-def.stderr index 082c37e0be795..8cbab4b9653a0 100644 --- a/src/test/ui/parser/issue-14303-fn-def.stderr +++ b/src/test/ui/parser/issue-14303-fn-def.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-fn-def.rs:1:15 | LL | fn foo<'a, T, 'b>(x: &'a T) {} - | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-14303-impl.stderr b/src/test/ui/parser/issue-14303-impl.stderr index 3b5615d2a9eca..56cd4fb381038 100644 --- a/src/test/ui/parser/issue-14303-impl.stderr +++ b/src/test/ui/parser/issue-14303-impl.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-impl.rs:3:13 | LL | impl<'a, T, 'b> X {} - | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-14303-struct.stderr b/src/test/ui/parser/issue-14303-struct.stderr index dbd0b987dd190..f31cb92ad66ce 100644 --- a/src/test/ui/parser/issue-14303-struct.stderr +++ b/src/test/ui/parser/issue-14303-struct.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-struct.rs:1:17 | LL | struct X<'a, T, 'b> { - | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/parser/issue-14303-trait.stderr b/src/test/ui/parser/issue-14303-trait.stderr index 7dfa62d823fd8..0e7399102bf17 100644 --- a/src/test/ui/parser/issue-14303-trait.stderr +++ b/src/test/ui/parser/issue-14303-trait.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-trait.rs:1:18 | LL | trait Foo<'a, T, 'b> {} - | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>` + | --------^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, T>` error: aborting due to previous error diff --git a/src/test/ui/suggestions/suggest-move-lifetimes.stderr b/src/test/ui/suggestions/suggest-move-lifetimes.stderr index 657914d1c8c0c..1851c8deaa8b4 100644 --- a/src/test/ui/suggestions/suggest-move-lifetimes.stderr +++ b/src/test/ui/suggestions/suggest-move-lifetimes.stderr @@ -2,25 +2,25 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/suggest-move-lifetimes.rs:1:13 | LL | struct A { - | ----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T>` + | ----^^- help: reorder the parameters: lifetimes, then types: `<'a, T>` error: lifetime parameters must be declared prior to type parameters --> $DIR/suggest-move-lifetimes.rs:5:13 | LL | struct B { - | ----^^---- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` + | ----^^---- help: reorder the parameters: lifetimes, then types: `<'a, T, U>` error: lifetime parameters must be declared prior to type parameters --> $DIR/suggest-move-lifetimes.rs:10:16 | LL | struct C { - | -------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>` + | -------^^- help: reorder the parameters: lifetimes, then types: `<'a, T, U>` error: lifetime parameters must be declared prior to type parameters --> $DIR/suggest-move-lifetimes.rs:15:16 | LL | struct D { - | -------^^--^^-----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, 'c, T, U, V>` + | -------^^--^^-----^^- help: reorder the parameters: lifetimes, then types: `<'a, 'b, 'c, T, U, V>` error: aborting due to 4 previous errors From 379c380a60e7b3adb6c6f595222cbfa2d9160a20 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 1 Mar 2019 09:34:11 +0100 Subject: [PATCH 5/8] libstd: deny(elided_lifetimes_in_paths) --- src/libstd/collections/hash/map.rs | 54 +++++++++---------- src/libstd/collections/hash/set.rs | 20 +++---- src/libstd/collections/hash/table.rs | 14 ++--- src/libstd/env.rs | 16 +++--- src/libstd/error.rs | 32 +++++------ src/libstd/ffi/c_str.rs | 14 ++--- src/libstd/ffi/os_str.rs | 8 +-- src/libstd/fs.rs | 6 +-- src/libstd/io/buffered.rs | 8 +-- src/libstd/io/error.rs | 10 ++-- src/libstd/io/impls.rs | 4 +- src/libstd/io/mod.rs | 8 +-- src/libstd/io/stdio.rs | 32 +++++------ src/libstd/io/util.rs | 6 +-- src/libstd/lib.rs | 1 - src/libstd/net/addr.rs | 10 ++-- src/libstd/net/ip.rs | 12 ++--- src/libstd/net/parser.rs | 44 +++++++-------- src/libstd/net/tcp.rs | 6 +-- src/libstd/net/udp.rs | 2 +- src/libstd/panic.rs | 2 +- src/libstd/panicking.rs | 16 +++--- src/libstd/path.rs | 38 ++++++------- src/libstd/primitive_docs.rs | 4 +- src/libstd/process.rs | 16 +++--- src/libstd/sync/barrier.rs | 4 +- src/libstd/sync/condvar.rs | 2 +- src/libstd/sync/mpsc/mod.rs | 24 ++++----- src/libstd/sync/mpsc/select.rs | 4 +- src/libstd/sync/mpsc/shared.rs | 4 +- src/libstd/sync/mpsc/sync.rs | 6 +-- src/libstd/sync/mutex.rs | 14 ++--- src/libstd/sync/once.rs | 2 +- src/libstd/sync/rwlock.rs | 22 ++++---- src/libstd/sys/cloudabi/backtrace.rs | 4 +- src/libstd/sys/cloudabi/shims/fs.rs | 8 +-- src/libstd/sys/cloudabi/shims/net.rs | 6 +-- src/libstd/sys/cloudabi/shims/os.rs | 2 +- src/libstd/sys/cloudabi/shims/process.rs | 6 +-- src/libstd/sys/redox/backtrace/tracing.rs | 4 +- src/libstd/sys/redox/ext/net.rs | 6 +-- src/libstd/sys/redox/fs.rs | 4 +- src/libstd/sys/redox/os.rs | 4 +- src/libstd/sys/redox/path.rs | 2 +- src/libstd/sys/redox/process.rs | 4 +- src/libstd/sys/redox/syscall/error.rs | 4 +- src/libstd/sys/redox/time.rs | 4 +- src/libstd/sys/sgx/backtrace.rs | 4 +- src/libstd/sys/sgx/fs.rs | 8 +-- src/libstd/sys/sgx/net.rs | 4 +- src/libstd/sys/sgx/os.rs | 4 +- src/libstd/sys/sgx/path.rs | 2 +- src/libstd/sys/sgx/process.rs | 6 +-- .../sys/unix/backtrace/tracing/gcc_s.rs | 6 +-- src/libstd/sys/unix/ext/net.rs | 10 ++-- src/libstd/sys/unix/fs.rs | 4 +- src/libstd/sys/unix/l4re.rs | 6 +-- src/libstd/sys/unix/os.rs | 4 +- src/libstd/sys/unix/path.rs | 2 +- src/libstd/sys/unix/process/process_common.rs | 4 +- src/libstd/sys/unix/time.rs | 6 +-- src/libstd/sys/wasm/fs.rs | 8 +-- src/libstd/sys/wasm/net.rs | 6 +-- src/libstd/sys/wasm/os.rs | 4 +- src/libstd/sys/wasm/path.rs | 2 +- src/libstd/sys/wasm/process.rs | 6 +-- src/libstd/sys/windows/args.rs | 4 +- src/libstd/sys/windows/ext/ffi.rs | 4 +- src/libstd/sys/windows/fs.rs | 4 +- src/libstd/sys/windows/os.rs | 4 +- src/libstd/sys/windows/os_str.rs | 10 ++-- src/libstd/sys/windows/path.rs | 2 +- src/libstd/sys/windows/process.rs | 4 +- src/libstd/sys/windows/time.rs | 2 +- src/libstd/sys_common/bytestring.rs | 6 +-- src/libstd/sys_common/mutex.rs | 2 +- src/libstd/sys_common/net.rs | 6 +-- src/libstd/sys_common/os_str_bytes.rs | 10 ++-- src/libstd/sys_common/poison.rs | 8 +-- src/libstd/sys_common/remutex.rs | 10 ++-- src/libstd/sys_common/util.rs | 4 +- src/libstd/sys_common/wtf8.rs | 18 +++---- src/libstd/thread/local.rs | 12 ++--- src/libstd/thread/mod.rs | 4 +- src/libstd/time.rs | 6 +-- 85 files changed, 372 insertions(+), 367 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 1d45df499d86b..ac3cfde47b520 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -534,7 +534,7 @@ fn search_hashed_nonempty_mut(table: M, hash: SafeHash, mut is_match } } -fn pop_internal(starting_bucket: FullBucketMut) +fn pop_internal(starting_bucket: FullBucketMut<'_, K, V>) -> (K, V, &mut RawTable) { let (empty, retkey, retval) = starting_bucket.take(); @@ -759,7 +759,7 @@ impl HashMap { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn keys(&self) -> Keys { + pub fn keys(&self) -> Keys<'_, K, V> { Keys { inner: self.iter() } } @@ -781,7 +781,7 @@ impl HashMap { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn values(&self) -> Values { + pub fn values(&self) -> Values<'_, K, V> { Values { inner: self.iter() } } @@ -808,7 +808,7 @@ impl HashMap { /// } /// ``` #[stable(feature = "map_values_mut", since = "1.10.0")] - pub fn values_mut(&mut self) -> ValuesMut { + pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> { ValuesMut { inner: self.iter_mut() } } @@ -830,7 +830,7 @@ impl HashMap { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, K, V> { Iter { inner: self.table.iter() } } @@ -858,7 +858,7 @@ impl HashMap { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { IterMut { inner: self.table.iter_mut() } } @@ -918,7 +918,7 @@ impl HashMap { /// ``` #[inline] #[stable(feature = "drain", since = "1.6.0")] - pub fn drain(&mut self) -> Drain { + pub fn drain(&mut self) -> Drain<'_, K, V> { Drain { inner: self.table.drain() } } @@ -1270,7 +1270,7 @@ impl HashMap /// assert_eq!(letters.get(&'y'), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn entry(&mut self, key: K) -> Entry { + pub fn entry(&mut self, key: K) -> Entry<'_, K, V> { // Gotta resize now. self.reserve(1); let hash = self.make_hash(&key); @@ -1571,7 +1571,7 @@ impl HashMap /// are free to assume this doesn't happen (within the limits of memory-safety). #[inline(always)] #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut { + pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<'_, K, V, S> { self.reserve(1); RawEntryBuilderMut { map: self } } @@ -1592,7 +1592,7 @@ impl HashMap /// /// Immutable raw entries have very limited use; you might instead want `raw_entry_mut`. #[unstable(feature = "hash_raw_entry", issue = "56167")] - pub fn raw_entry(&self) -> RawEntryBuilder { + pub fn raw_entry(&self) -> RawEntryBuilder<'_, K, V, S> { RawEntryBuilder { map: self } } } @@ -1626,7 +1626,7 @@ impl Debug for HashMap V: Debug, S: BuildHasher { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_map().entries(self.iter()).finish() } } @@ -1683,7 +1683,7 @@ impl Clone for Iter<'_, K, V> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Iter<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.clone()) .finish() @@ -1736,7 +1736,7 @@ impl Clone for Keys<'_, K, V> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Keys<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.clone()) .finish() @@ -1765,7 +1765,7 @@ impl Clone for Values<'_, K, V> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Values<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.clone()) .finish() @@ -2244,7 +2244,7 @@ impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> { #[unstable(feature = "hash_raw_entry", issue = "56167")] impl Debug for RawEntryBuilderMut<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RawEntryBuilder") .finish() } @@ -2252,7 +2252,7 @@ impl Debug for RawEntryBuilderMut<'_, K, V, S> { #[unstable(feature = "hash_raw_entry", issue = "56167")] impl Debug for RawEntryMut<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { RawEntryMut::Vacant(ref v) => { f.debug_tuple("RawEntry") @@ -2270,7 +2270,7 @@ impl Debug for RawEntryMut<'_, K, V, S> { #[unstable(feature = "hash_raw_entry", issue = "56167")] impl Debug for RawOccupiedEntryMut<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RawOccupiedEntryMut") .field("key", self.key()) .field("value", self.get()) @@ -2280,7 +2280,7 @@ impl Debug for RawOccupiedEntryMut<'_, K, V> { #[unstable(feature = "hash_raw_entry", issue = "56167")] impl Debug for RawVacantEntryMut<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RawVacantEntryMut") .finish() } @@ -2288,7 +2288,7 @@ impl Debug for RawVacantEntryMut<'_, K, V, S> { #[unstable(feature = "hash_raw_entry", issue = "56167")] impl Debug for RawEntryBuilder<'_, K, V, S> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RawEntryBuilder") .finish() } @@ -2315,7 +2315,7 @@ pub enum Entry<'a, K: 'a, V: 'a> { #[stable(feature= "debug_hash_map", since = "1.12.0")] impl Debug for Entry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Vacant(ref v) => { f.debug_tuple("Entry") @@ -2348,7 +2348,7 @@ unsafe impl<'a, K: 'a + Sync, V: 'a + Sync> Sync for OccupiedEntry<'a, K, V> {} #[stable(feature= "debug_hash_map", since = "1.12.0")] impl Debug for OccupiedEntry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("OccupiedEntry") .field("key", self.key()) .field("value", self.get()) @@ -2374,7 +2374,7 @@ unsafe impl<'a, K: 'a + Sync, V: 'a + Sync> Sync for VacantEntry<'a, K, V> {} #[stable(feature= "debug_hash_map", since = "1.12.0")] impl Debug for VacantEntry<'_, K, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("VacantEntry") .field(self.key()) .finish() @@ -2489,7 +2489,7 @@ impl fmt::Debug for IterMut<'_, K, V> where K: fmt::Debug, V: fmt::Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.inner.iter()) .finish() @@ -2521,7 +2521,7 @@ impl FusedIterator for IntoIter {} #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for IntoIter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.inner.iter()) .finish() @@ -2602,7 +2602,7 @@ impl fmt::Debug for ValuesMut<'_, K, V> where K: fmt::Debug, V: fmt::Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.inner.inner.iter()) .finish() @@ -2637,7 +2637,7 @@ impl fmt::Debug for Drain<'_, K, V> where K: fmt::Debug, V: fmt::Debug, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.inner.iter()) .finish() @@ -3257,7 +3257,7 @@ impl Default for RandomState { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for RandomState { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("RandomState { .. }") } } diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index c026de35da63d..89d5b2ff30f9f 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -182,7 +182,7 @@ impl HashSet { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { iter: self.map.keys() } } @@ -239,7 +239,7 @@ impl HashSet { /// ``` #[inline] #[stable(feature = "drain", since = "1.6.0")] - pub fn drain(&mut self) -> Drain { + pub fn drain(&mut self) -> Drain<'_, T> { Drain { iter: self.map.drain() } } @@ -801,7 +801,7 @@ impl fmt::Debug for HashSet where T: Eq + Hash + fmt::Debug, S: BuildHasher { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_set().entries(self.iter()).finish() } } @@ -1135,7 +1135,7 @@ impl FusedIterator for Iter<'_, K> {} #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Iter<'_, K> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -1162,7 +1162,7 @@ impl FusedIterator for IntoIter {} #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for IntoIter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let entries_iter = self.iter .inner .iter() @@ -1193,7 +1193,7 @@ impl FusedIterator for Drain<'_, K> {} #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Drain<'_, K> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let entries_iter = self.iter .inner .iter() @@ -1236,7 +1236,7 @@ impl fmt::Debug for Intersection<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -1289,7 +1289,7 @@ impl fmt::Debug for Difference<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -1328,7 +1328,7 @@ impl fmt::Debug for SymmetricDifference<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } @@ -1352,7 +1352,7 @@ impl fmt::Debug for Union<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } } diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 31e7a6931356c..2113b448910ab 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -772,7 +772,7 @@ impl RawTable { self.size } - fn raw_buckets(&self) -> RawBuckets { + fn raw_buckets(&self) -> RawBuckets<'_, K, V> { RawBuckets { raw: self.raw_bucket_at(0), elems_left: self.size, @@ -780,13 +780,13 @@ impl RawTable { } } - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, K, V> { Iter { iter: self.raw_buckets(), } } - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { IterMut { iter: self.raw_buckets(), _marker: marker::PhantomData, @@ -806,7 +806,7 @@ impl RawTable { } } - pub fn drain(&mut self) -> Drain { + pub fn drain(&mut self) -> Drain<'_, K, V> { let RawBuckets { raw, elems_left, .. } = self.raw_buckets(); // Replace the marker regardless of lifetime bounds on parameters. Drain { @@ -936,7 +936,7 @@ unsafe impl Sync for IterMut<'_, K, V> {} unsafe impl Send for IterMut<'_, K, V> {} impl<'a, K: 'a, V: 'a> IterMut<'a, K, V> { - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, K, V> { Iter { iter: self.iter.clone(), } @@ -953,7 +953,7 @@ unsafe impl Sync for IntoIter {} unsafe impl Send for IntoIter {} impl IntoIter { - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, K, V> { Iter { iter: self.iter.clone(), } @@ -971,7 +971,7 @@ unsafe impl Sync for Drain<'_, K, V> {} unsafe impl Send for Drain<'_, K, V> {} impl<'a, K, V> Drain<'a, K, V> { - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, K, V> { Iter { iter: self.iter.clone(), } diff --git a/src/libstd/env.rs b/src/libstd/env.rs index f723a2b0bb281..01b301cb43d54 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -156,7 +156,7 @@ impl Iterator for Vars { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Vars { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Vars { .. }") } } @@ -170,7 +170,7 @@ impl Iterator for VarsOs { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for VarsOs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("VarsOs { .. }") } } @@ -253,7 +253,7 @@ pub enum VarError { #[stable(feature = "env", since = "1.0.0")] impl fmt::Display for VarError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { VarError::NotPresent => write!(f, "environment variable not found"), VarError::NotUnicode(ref s) => { @@ -387,7 +387,7 @@ pub struct SplitPaths<'a> { inner: os_imp::SplitPaths<'a> } /// } /// ``` #[stable(feature = "env", since = "1.0.0")] -pub fn split_paths + ?Sized>(unparsed: &T) -> SplitPaths { +pub fn split_paths + ?Sized>(unparsed: &T) -> SplitPaths<'_> { SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) } } @@ -400,7 +400,7 @@ impl<'a> Iterator for SplitPaths<'a> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for SplitPaths<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("SplitPaths { .. }") } } @@ -488,7 +488,7 @@ pub fn join_paths(paths: I) -> Result #[stable(feature = "env", since = "1.0.0")] impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } @@ -757,7 +757,7 @@ impl DoubleEndedIterator for Args { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Args { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Args") .field("inner", &self.inner.inner.inner_debug()) .finish() @@ -790,7 +790,7 @@ impl DoubleEndedIterator for ArgsOs { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for ArgsOs { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("ArgsOs") .field("inner", &self.inner.inner_debug()) .finish() diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 3eb289501cb0f..89051030f6683 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -84,7 +84,7 @@ pub trait Error: Debug + Display { /// } /// /// impl fmt::Display for SuperError { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "SuperError is here!") /// } /// } @@ -103,7 +103,7 @@ pub trait Error: Debug + Display { /// struct SuperErrorSideKick; /// /// impl fmt::Display for SuperErrorSideKick { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "SuperErrorSideKick is here!") /// } /// } @@ -149,7 +149,7 @@ pub trait Error: Debug + Display { /// } /// /// impl fmt::Display for SuperError { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "SuperError is here!") /// } /// } @@ -168,7 +168,7 @@ pub trait Error: Debug + Display { /// struct SuperErrorSideKick; /// /// impl fmt::Display for SuperErrorSideKick { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "SuperErrorSideKick is here!") /// } /// } @@ -219,7 +219,7 @@ impl<'a, E: Error + 'a> From for Box { /// struct AnError; /// /// impl fmt::Display for AnError { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f , "An error") /// } /// } @@ -256,7 +256,7 @@ impl<'a, E: Error + Send + Sync + 'a> From for Box fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f , "An error") /// } /// } @@ -306,7 +306,7 @@ impl From for Box { } impl Display for StringError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Display::fmt(&self.0, f) } } @@ -686,13 +686,13 @@ impl dyn Error { /// struct B(Option>); /// /// impl fmt::Display for A { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "A") /// } /// } /// /// impl fmt::Display for B { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "B") /// } /// } @@ -721,7 +721,7 @@ impl dyn Error { /// [`source`]: trait.Error.html#method.source #[unstable(feature = "error_iter", issue = "58520")] #[inline] - pub fn iter_chain(&self) -> ErrorIter { + pub fn iter_chain(&self) -> ErrorIter<'_> { ErrorIter { current: Some(self), } @@ -747,19 +747,19 @@ impl dyn Error { /// struct C(Option>); /// /// impl fmt::Display for A { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "A") /// } /// } /// /// impl fmt::Display for B { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "B") /// } /// } /// /// impl fmt::Display for C { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "C") /// } /// } @@ -795,7 +795,7 @@ impl dyn Error { /// [`source`]: trait.Error.html#method.source #[inline] #[unstable(feature = "error_iter", issue = "58520")] - pub fn iter_sources(&self) -> ErrorIter { + pub fn iter_sources(&self) -> ErrorIter<'_> { ErrorIter { current: self.source(), } @@ -861,12 +861,12 @@ mod tests { struct B; impl fmt::Display for A { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "A") } } impl fmt::Display for B { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "B") } } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index ad3f45bfadaf4..f93583dff818f 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -628,7 +628,7 @@ impl ops::Deref for CString { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for CString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } @@ -649,7 +649,7 @@ impl From for Vec { #[stable(feature = "cstr_debug", since = "1.3.0")] impl fmt::Debug for CStr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "\"")?; for byte in self.to_bytes().iter().flat_map(|&b| ascii::escape_default(b)) { f.write_char(byte as char)?; @@ -847,7 +847,7 @@ impl Error for NulError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for NulError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "nul byte found in provided data at position: {}", self.0) } } @@ -878,7 +878,7 @@ impl Error for FromBytesWithNulError { #[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")] impl fmt::Display for FromBytesWithNulError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.description())?; if let FromBytesWithNulErrorKind::InteriorNul(pos) = self.kind { write!(f, " at byte pos {}", pos)?; @@ -917,7 +917,7 @@ impl Error for IntoStringError { #[stable(feature = "cstring_into", since = "1.7.0")] impl fmt::Display for IntoStringError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.description().fmt(f) } } @@ -1208,11 +1208,11 @@ impl CStr { /// .expect("CStr::from_bytes_with_nul failed"); /// assert_eq!( /// c_str.to_string_lossy(), - /// Cow::Owned(String::from("Hello �World")) as Cow + /// Cow::Owned(String::from("Hello �World")) as Cow<'_, str> /// ); /// ``` #[stable(feature = "cstr_to_str", since = "1.4.0")] - pub fn to_string_lossy(&self) -> Cow { + pub fn to_string_lossy(&self) -> Cow<'_, str> { String::from_utf8_lossy(self.to_bytes()) } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 3a0590021c917..01e7a57cd003f 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -394,7 +394,7 @@ impl Default for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for OsString { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, formatter) } } @@ -563,7 +563,7 @@ impl OsStr { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn to_string_lossy(&self) -> Cow { + pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() } @@ -891,13 +891,13 @@ impl Hash for OsStr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for OsStr { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.inner, formatter) } } impl OsStr { - pub(crate) fn display(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + pub(crate) fn display(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.inner, formatter) } } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index dfff44b88ea78..705dc8f40b5a0 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -597,7 +597,7 @@ impl IntoInner for File { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for File { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } @@ -1087,7 +1087,7 @@ impl Metadata { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Metadata { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Metadata") .field("file_type", &self.file_type()) .field("is_dir", &self.is_dir()) @@ -1394,7 +1394,7 @@ impl DirEntry { #[stable(feature = "dir_entry_debug", since = "1.13.0")] impl fmt::Debug for DirEntry { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("DirEntry") .field(&self.path()) .finish() diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 441f6b95d0b67..3370a447fcc8e 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -291,7 +291,7 @@ impl BufRead for BufReader { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for BufReader where R: fmt::Debug { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("BufReader") .field("reader", &self.inner) .field("buffer", &format_args!("{}/{}", self.cap - self.pos, self.buf.len())) @@ -631,7 +631,7 @@ impl Write for BufWriter { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for BufWriter where W: fmt::Debug { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("BufWriter") .field("writer", &self.inner.as_ref().unwrap()) .field("buffer", &format_args!("{}/{}", self.buf.len(), self.buf.capacity())) @@ -739,7 +739,7 @@ impl error::Error for IntoInnerError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for IntoInnerError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.error().fmt(f) } } @@ -981,7 +981,7 @@ impl Write for LineWriter { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for LineWriter where W: fmt::Debug { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("LineWriter") .field("writer", &self.inner.inner) .field("buffer", diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index 614b79124cc68..c29a68e6f02b8 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -59,7 +59,7 @@ pub struct Error { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.repr, f) } } @@ -413,7 +413,7 @@ impl Error { /// } /// /// impl Display for MyError { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "MyError: {}", &self.v) /// } /// } @@ -512,7 +512,7 @@ impl Error { } impl fmt::Debug for Repr { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Repr::Os(code) => fmt.debug_struct("Os") @@ -527,7 +527,7 @@ impl fmt::Debug for Repr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self.repr { Repr::Os(code) => { let detail = sys::os::error_string(code); @@ -612,7 +612,7 @@ mod test { struct TestError; impl fmt::Display for TestError { - fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { Ok(()) } } diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index b286e4016da7f..0eac96fc39a4b 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -58,7 +58,7 @@ impl Write for &mut W { } #[inline] - fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> { + fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> { (**self).write_fmt(fmt) } } @@ -137,7 +137,7 @@ impl Write for Box { } #[inline] - fn write_fmt(&mut self, fmt: fmt::Arguments) -> io::Result<()> { + fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> { (**self).write_fmt(fmt) } } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 14a16f3fc0f04..1ce66b931df14 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -917,7 +917,7 @@ pub struct IoVecMut<'a>(sys::io::IoVecMut<'a>); #[unstable(feature = "iovec", issue = "58452")] impl<'a> fmt::Debug for IoVecMut<'a> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(self.0.as_slice(), fmt) } } @@ -964,7 +964,7 @@ pub struct IoVec<'a>(sys::io::IoVec<'a>); #[unstable(feature = "iovec", issue = "58452")] impl<'a> fmt::Debug for IoVec<'a> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(self.0.as_slice(), fmt) } } @@ -1255,7 +1255,7 @@ pub trait Write { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<()> { // Create a shim which translates a Write to a fmt::Write and saves // off I/O errors. instead of discarding them struct Adaptor<'a, T: ?Sized + 'a> { @@ -1906,7 +1906,7 @@ impl Chain { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Chain { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Chain") .field("t", &self.first) .field("u", &self.second) diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 7e151041a9ea8..0bbff5769ab82 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -255,7 +255,7 @@ impl Stdin { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn lock(&self) -> StdinLock { + pub fn lock(&self) -> StdinLock<'_> { StdinLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) } } @@ -295,7 +295,7 @@ impl Stdin { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stdin { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Stdin { .. }") } } @@ -339,7 +339,7 @@ impl BufRead for StdinLock<'_> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for StdinLock<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("StdinLock { .. }") } } @@ -466,14 +466,14 @@ impl Stdout { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn lock(&self) -> StdoutLock { + pub fn lock(&self) -> StdoutLock<'_> { StdoutLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) } } } #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stdout { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Stdout { .. }") } } @@ -489,7 +489,7 @@ impl Write for Stdout { fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { self.lock().write_all(buf) } - fn write_fmt(&mut self, args: fmt::Arguments) -> io::Result<()> { + fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> { self.lock().write_fmt(args) } } @@ -505,7 +505,7 @@ impl Write for StdoutLock<'_> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for StdoutLock<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("StdoutLock { .. }") } } @@ -619,14 +619,14 @@ impl Stderr { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn lock(&self) -> StderrLock { + pub fn lock(&self) -> StderrLock<'_> { StderrLock { inner: self.inner.lock().unwrap_or_else(|e| e.into_inner()) } } } #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stderr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Stderr { .. }") } } @@ -642,7 +642,7 @@ impl Write for Stderr { fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { self.lock().write_all(buf) } - fn write_fmt(&mut self, args: fmt::Arguments) -> io::Result<()> { + fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> io::Result<()> { self.lock().write_fmt(args) } } @@ -658,7 +658,7 @@ impl Write for StderrLock<'_> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for StderrLock<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("StderrLock { .. }") } } @@ -720,7 +720,7 @@ pub fn set_print(sink: Option>) -> Option( - args: fmt::Arguments, + args: fmt::Arguments<'_>, local_s: &'static LocalKey>>>, global_s: fn() -> T, label: &str, @@ -749,7 +749,7 @@ where issue = "0")] #[doc(hidden)] #[cfg(not(test))] -pub fn _print(args: fmt::Arguments) { +pub fn _print(args: fmt::Arguments<'_>) { print_to(args, &LOCAL_STDOUT, stdout, "stdout"); } @@ -758,7 +758,7 @@ pub fn _print(args: fmt::Arguments) { issue = "0")] #[doc(hidden)] #[cfg(not(test))] -pub fn _eprint(args: fmt::Arguments) { +pub fn _eprint(args: fmt::Arguments<'_>) { print_to(args, &LOCAL_STDERR, stderr, "stderr"); } @@ -777,7 +777,7 @@ mod tests { } #[test] fn stdoutlock_unwind_safe() { - assert_unwind_safe::(); + assert_unwind_safe::>(); assert_unwind_safe::>(); } #[test] @@ -786,7 +786,7 @@ mod tests { } #[test] fn stderrlock_unwind_safe() { - assert_unwind_safe::(); + assert_unwind_safe::>(); assert_unwind_safe::>(); } diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 6aaf8f1889ac0..d2638be4e2db5 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -111,7 +111,7 @@ impl BufRead for Empty { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Empty { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Empty { .. }") } } @@ -169,7 +169,7 @@ impl Read for Repeat { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Repeat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Repeat { .. }") } } @@ -217,7 +217,7 @@ impl Write for Sink { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Sink { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Sink { .. }") } } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 296c4c887274e..d11dee8fc9707 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -211,7 +211,6 @@ #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] -#![allow(elided_lifetimes_in_paths)] // Tell the compiler to link to either panic_abort or panic_unwind #![needs_panic_runtime] diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index eaa6a070154f7..ec54d8a042a3c 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -587,7 +587,7 @@ impl<'a> IntoInner<(*const c::sockaddr, c::socklen_t)> for &'a SocketAddr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for SocketAddr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { SocketAddr::V4(ref a) => a.fmt(f), SocketAddr::V6(ref a) => a.fmt(f), @@ -597,28 +597,28 @@ impl fmt::Display for SocketAddr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for SocketAddrV4 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}:{}", self.ip(), self.port()) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for SocketAddrV4 { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self, fmt) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for SocketAddrV6 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "[{}]:{}", self.ip(), self.port()) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for SocketAddrV6 { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self, fmt) } } diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index fa256ce508655..7f9f3b91a600b 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -658,7 +658,7 @@ impl Ipv4Addr { #[stable(feature = "ip_addr", since = "1.7.0")] impl fmt::Display for IpAddr { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self { IpAddr::V4(ip) => ip.fmt(fmt), IpAddr::V6(ip) => ip.fmt(fmt), @@ -682,7 +682,7 @@ impl From for IpAddr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Ipv4Addr { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let octets = self.octets(); write!(fmt, "{}.{}.{}.{}", octets[0], octets[1], octets[2], octets[3]) } @@ -690,7 +690,7 @@ impl fmt::Display for Ipv4Addr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Ipv4Addr { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self, fmt) } } @@ -1229,7 +1229,7 @@ impl Ipv6Addr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Ipv6Addr { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self.segments() { // We need special cases for :: and ::1, otherwise they're formatted // as ::0.0.0.[01] @@ -1276,7 +1276,7 @@ impl fmt::Display for Ipv6Addr { let (zeros_at, zeros_len) = find_zero_slice(&self.segments()); if zeros_len > 1 { - fn fmt_subslice(segments: &[u16], fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt_subslice(segments: &[u16], fmt: &mut fmt::Formatter<'_>) -> fmt::Result { if !segments.is_empty() { write!(fmt, "{:x}", segments[0])?; for &seg in &segments[1..] { @@ -1301,7 +1301,7 @@ impl fmt::Display for Ipv6Addr { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Ipv6Addr { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self, fmt) } } diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index 7951cd6bcf28c..5a76139530a46 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -28,7 +28,7 @@ impl<'a> Parser<'a> { // Commit only if parser returns Some fn read_atomically(&mut self, cb: F) -> Option where - F: FnOnce(&mut Parser) -> Option, + F: FnOnce(&mut Parser<'_>) -> Option, { let pos = self.pos; let r = cb(self); @@ -40,7 +40,7 @@ impl<'a> Parser<'a> { // Commit only if parser read till EOF fn read_till_eof(&mut self, cb: F) -> Option where - F: FnOnce(&mut Parser) -> Option, + F: FnOnce(&mut Parser<'_>) -> Option, { self.read_atomically(move |p| { cb(p).filter(|_| p.is_eof()) @@ -48,10 +48,10 @@ impl<'a> Parser<'a> { } // Return result of first successful parser - fn read_or(&mut self, parsers: &mut [Box Option + 'static>]) + fn read_or(&mut self, parsers: &mut [Box) -> Option + 'static>]) -> Option { for pf in parsers { - if let Some(r) = self.read_atomically(|p: &mut Parser| pf(p)) { + if let Some(r) = self.read_atomically(|p: &mut Parser<'_>| pf(p)) { return Some(r); } } @@ -64,9 +64,9 @@ impl<'a> Parser<'a> { pb: PB, pc: PC) -> Option<(A, B, C)> where - PA: FnOnce(&mut Parser) -> Option, - PB: FnOnce(&mut Parser) -> Option, - PC: FnOnce(&mut Parser) -> Option, + PA: FnOnce(&mut Parser<'_>) -> Option, + PB: FnOnce(&mut Parser<'_>) -> Option, + PC: FnOnce(&mut Parser<'_>) -> Option, { self.read_atomically(move |p| { let a = pa(p); @@ -177,7 +177,7 @@ impl<'a> Parser<'a> { Ipv6Addr::new(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7]) } - fn read_groups(p: &mut Parser, groups: &mut [u16; 8], limit: usize) + fn read_groups(p: &mut Parser<'_>, groups: &mut [u16; 8], limit: usize) -> (usize, bool) { let mut i = 0; while i < limit { @@ -244,15 +244,15 @@ impl<'a> Parser<'a> { } fn read_ip_addr(&mut self) -> Option { - let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(IpAddr::V4); - let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(IpAddr::V6); + let ipv4_addr = |p: &mut Parser<'_>| p.read_ipv4_addr().map(IpAddr::V4); + let ipv6_addr = |p: &mut Parser<'_>| p.read_ipv6_addr().map(IpAddr::V6); self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) } fn read_socket_addr_v4(&mut self) -> Option { - let ip_addr = |p: &mut Parser| p.read_ipv4_addr(); - let colon = |p: &mut Parser| p.read_given_char(':'); - let port = |p: &mut Parser| { + let ip_addr = |p: &mut Parser<'_>| p.read_ipv4_addr(); + let colon = |p: &mut Parser<'_>| p.read_given_char(':'); + let port = |p: &mut Parser<'_>| { p.read_number(10, 5, 0x10000).map(|n| n as u16) }; @@ -263,14 +263,14 @@ impl<'a> Parser<'a> { } fn read_socket_addr_v6(&mut self) -> Option { - let ip_addr = |p: &mut Parser| { - let open_br = |p: &mut Parser| p.read_given_char('['); - let ip_addr = |p: &mut Parser| p.read_ipv6_addr(); - let clos_br = |p: &mut Parser| p.read_given_char(']'); + let ip_addr = |p: &mut Parser<'_>| { + let open_br = |p: &mut Parser<'_>| p.read_given_char('['); + let ip_addr = |p: &mut Parser<'_>| p.read_ipv6_addr(); + let clos_br = |p: &mut Parser<'_>| p.read_given_char(']'); p.read_seq_3(open_br, ip_addr, clos_br).map(|t| t.1) }; - let colon = |p: &mut Parser| p.read_given_char(':'); - let port = |p: &mut Parser| { + let colon = |p: &mut Parser<'_>| p.read_given_char(':'); + let port = |p: &mut Parser<'_>| { p.read_number(10, 5, 0x10000).map(|n| n as u16) }; @@ -281,8 +281,8 @@ impl<'a> Parser<'a> { } fn read_socket_addr(&mut self) -> Option { - let v4 = |p: &mut Parser| p.read_socket_addr_v4().map(SocketAddr::V4); - let v6 = |p: &mut Parser| p.read_socket_addr_v6().map(SocketAddr::V6); + let v4 = |p: &mut Parser<'_>| p.read_socket_addr_v4().map(SocketAddr::V4); + let v6 = |p: &mut Parser<'_>| p.read_socket_addr_v6().map(SocketAddr::V6); self.read_or(&mut [Box::new(v4), Box::new(v6)]) } } @@ -391,7 +391,7 @@ pub struct AddrParseError(()); #[stable(feature = "addr_parse_error_error", since = "1.4.0")] impl fmt::Display for AddrParseError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.write_str(self.description()) } } diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 7e14de7cc4f4a..cb8928866cbce 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -626,7 +626,7 @@ impl IntoInner for TcpStream { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for TcpStream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -771,7 +771,7 @@ impl TcpListener { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn incoming(&self) -> Incoming { + pub fn incoming(&self) -> Incoming<'_> { Incoming { listener: self } } @@ -922,7 +922,7 @@ impl IntoInner for TcpListener { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for TcpListener { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 836d1f8be632b..d4187d2932b12 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -832,7 +832,7 @@ impl IntoInner for UdpSocket { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for UdpSocket { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 6a16414c1417e..cc147d851de54 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -312,7 +312,7 @@ impl R> FnOnce<()> for AssertUnwindSafe { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for AssertUnwindSafe { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("AssertUnwindSafe") .field(&self.0) .finish() diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index eae885602d3e7..27b8a110ca71e 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -51,7 +51,7 @@ extern { #[derive(Copy, Clone)] enum Hook { Default, - Custom(*mut (dyn Fn(&PanicInfo) + 'static + Sync + Send)), + Custom(*mut (dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send)), } static HOOK_LOCK: RWLock = RWLock::new(); @@ -91,7 +91,7 @@ static mut HOOK: Hook = Hook::Default; /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] -pub fn set_hook(hook: Box) { +pub fn set_hook(hook: Box) + 'static + Sync + Send>) { if thread::panicking() { panic!("cannot modify the panic hook from a panicking thread"); } @@ -136,7 +136,7 @@ pub fn set_hook(hook: Box) { /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] -pub fn take_hook() -> Box { +pub fn take_hook() -> Box) + 'static + Sync + Send> { if thread::panicking() { panic!("cannot modify the panic hook from a panicking thread"); } @@ -154,7 +154,7 @@ pub fn take_hook() -> Box { } } -fn default_hook(info: &PanicInfo) { +fn default_hook(info: &PanicInfo<'_>) { #[cfg(feature = "backtrace")] use crate::sys_common::backtrace; @@ -304,7 +304,7 @@ pub fn panicking() -> bool { #[cfg(not(test))] #[panic_handler] #[unwind(allowed)] -pub fn rust_begin_panic(info: &PanicInfo) -> ! { +pub fn rust_begin_panic(info: &PanicInfo<'_>) -> ! { continue_panic_fmt(&info) } @@ -322,7 +322,7 @@ pub fn rust_begin_panic(info: &PanicInfo) -> ! { // otherwise avoid inlining because of it is cold path. #[cfg_attr(not(feature="panic_immediate_abort"),inline(never))] #[cfg_attr( feature="panic_immediate_abort" ,inline)] -pub fn begin_panic_fmt(msg: &fmt::Arguments, +pub fn begin_panic_fmt(msg: &fmt::Arguments<'_>, file_line_col: &(&'static str, u32, u32)) -> ! { if cfg!(feature = "panic_immediate_abort") { unsafe { intrinsics::abort() } @@ -336,7 +336,7 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments, continue_panic_fmt(&info) } -fn continue_panic_fmt(info: &PanicInfo) -> ! { +fn continue_panic_fmt(info: &PanicInfo<'_>) -> ! { struct PanicPayload<'a> { inner: &'a fmt::Arguments<'a>, string: Option, @@ -441,7 +441,7 @@ pub fn begin_panic(msg: M, file_line_col: &(&'static str, u32, u3 /// panics, panic hooks, and finally dispatching to the panic runtime to either /// abort or unwind. fn rust_panic_with_hook(payload: &mut dyn BoxMeUp, - message: Option<&fmt::Arguments>, + message: Option<&fmt::Arguments<'_>>, file_line_col: &(&str, u32, u32)) -> ! { let (file, line, col) = *file_line_col; diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 4048bc4da2557..71e82f0a9b02e 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -323,7 +323,7 @@ fn has_redox_scheme(s: &[u8]) -> bool { //////////////////////////////////////////////////////////////////////////////// /// Says whether the first byte after the prefix is a separator. -fn has_physical_root(s: &[u8], prefix: Option) -> bool { +fn has_physical_root(s: &[u8], prefix: Option>) -> bool { let path = if let Some(p) = prefix { &s[p.len()..] } else { @@ -630,11 +630,11 @@ pub struct Iter<'a> { #[stable(feature = "path_components_debug", since = "1.13.0")] impl fmt::Debug for Components<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { struct DebugHelper<'a>(&'a Path); impl fmt::Debug for DebugHelper<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.0.components()) .finish() @@ -828,11 +828,11 @@ impl AsRef for Components<'_> { #[stable(feature = "path_iter_debug", since = "1.13.0")] impl fmt::Debug for Iter<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { struct DebugHelper<'a>(&'a Path); impl fmt::Debug for DebugHelper<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.0.iter()) .finish() @@ -1559,7 +1559,7 @@ impl> iter::Extend

for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for PathBuf { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, formatter) } } @@ -1857,7 +1857,7 @@ impl Path { /// Had `path` contained invalid unicode, the `to_string_lossy` call might /// have returned `"fo�.txt"`. #[stable(feature = "rust1", since = "1.0.0")] - pub fn to_string_lossy(&self) -> Cow { + pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() } @@ -1926,7 +1926,7 @@ impl Path { !self.is_absolute() } - fn prefix(&self) -> Option { + fn prefix(&self) -> Option> { self.components().prefix } @@ -2007,7 +2007,7 @@ impl Path { /// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`parent`]: struct.Path.html#method.parent #[stable(feature = "path_ancestors", since = "1.28.0")] - pub fn ancestors(&self) -> Ancestors { + pub fn ancestors(&self) -> Ancestors<'_> { Ancestors { next: Some(&self), } @@ -2305,7 +2305,7 @@ impl Path { /// [`Component`]: enum.Component.html /// [`CurDir`]: enum.Component.html#variant.CurDir #[stable(feature = "rust1", since = "1.0.0")] - pub fn components(&self) -> Components { + pub fn components(&self) -> Components<'_> { let prefix = parse_prefix(self.as_os_str()); Components { path: self.as_u8_slice(), @@ -2339,7 +2339,7 @@ impl Path { /// assert_eq!(it.next(), None) /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_> { Iter { inner: self.components() } } @@ -2358,7 +2358,7 @@ impl Path { /// println!("{}", path.display()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn display(&self) -> Display { + pub fn display(&self) -> Display<'_> { Display { path: self } } @@ -2578,7 +2578,7 @@ impl AsRef for Path { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Path { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.inner, formatter) } } @@ -2610,14 +2610,14 @@ pub struct Display<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Display<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.path, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Display<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.path.inner.display(f) } } @@ -2805,7 +2805,7 @@ impl_cmp_os_str!(Cow<'a, Path>, OsString); #[stable(since = "1.7.0", feature = "strip_prefix")] impl fmt::Display for StripPrefixError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.description().fmt(f) } } @@ -2915,7 +2915,7 @@ mod tests { { let path: &Path = &pathbuf; - let borrowed_cow_path: Cow = path.into(); + let borrowed_cow_path: Cow<'_, Path> = path.into(); assert_eq!(static_cow_path, borrowed_cow_path); } @@ -4013,8 +4013,8 @@ mod tests { let mut owned: PathBuf = PathBuf::new(); owned.push("foo"); owned.push("bar"); - let borrowed_cow: Cow = borrowed.into(); - let owned_cow: Cow = owned.clone().into(); + let borrowed_cow: Cow<'_, Path> = borrowed.into(); + let owned_cow: Cow<'_, Path> = owned.clone().into(); macro_rules! t { ($($current:expr),+) => { diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 6bb7f28efebcf..94fece10e0fbc 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -204,10 +204,10 @@ mod prim_bool { } /// #![feature(never_type)] /// # use std::fmt; /// # trait Debug { -/// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result; +/// # fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result; /// # } /// impl Debug for ! { -/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { /// *self /// } /// } diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 054b398b01f26..e0c9b7cad86ca 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -194,7 +194,7 @@ impl IntoInner for Child { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Child { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Child") .field("stdin", &self.stdin) .field("stdout", &self.stdout) @@ -246,7 +246,7 @@ impl FromInner for ChildStdin { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for ChildStdin { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("ChildStdin { .. }") } } @@ -293,7 +293,7 @@ impl FromInner for ChildStdout { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for ChildStdout { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("ChildStdout { .. }") } } @@ -340,7 +340,7 @@ impl FromInner for ChildStderr { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for ChildStderr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("ChildStderr { .. }") } } @@ -803,7 +803,7 @@ impl fmt::Debug for Command { /// Format the program and arguments of a Command for display. Any /// non-utf8 data is lossily converted using the utf8 replacement /// character. - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } } @@ -844,7 +844,7 @@ pub struct Output { // strings, otherwise it prints the byte sequence instead #[stable(feature = "process_output_debug", since = "1.7.0")] impl fmt::Debug for Output { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let stdout_utf8 = str::from_utf8(&self.stdout); let stdout_debug: &dyn fmt::Debug = match stdout_utf8 { @@ -1002,7 +1002,7 @@ impl FromInner for Stdio { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stdio { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Stdio { .. }") } } @@ -1199,7 +1199,7 @@ impl FromInner for ExitStatus { #[stable(feature = "process", since = "1.0.0")] impl fmt::Display for ExitStatus { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs index a4205daba8b6e..23ba63a61098d 100644 --- a/src/libstd/sync/barrier.rs +++ b/src/libstd/sync/barrier.rs @@ -59,7 +59,7 @@ pub struct BarrierWaitResult(bool); #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Barrier { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Barrier { .. }") } } @@ -151,7 +151,7 @@ impl Barrier { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for BarrierWaitResult { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("BarrierWaitResult") .field("is_leader", &self.is_leader()) .finish() diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 2e8182671dd6f..ffb9ce1c81a53 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -589,7 +589,7 @@ impl Condvar { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Condvar { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Condvar { .. }") } } diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 4ed2bfb175a46..bc32b8e47b316 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -914,7 +914,7 @@ impl Drop for Sender { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl fmt::Debug for Sender { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Sender").finish() } } @@ -1044,7 +1044,7 @@ impl Drop for SyncSender { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl fmt::Debug for SyncSender { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SyncSender").finish() } } @@ -1463,7 +1463,7 @@ impl Receiver { /// assert_eq!(iter.next(), None); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { rx: self } } @@ -1506,7 +1506,7 @@ impl Receiver { /// assert_eq!(iter.next(), None); /// ``` #[stable(feature = "receiver_try_iter", since = "1.15.0")] - pub fn try_iter(&self) -> TryIter { + pub fn try_iter(&self) -> TryIter<'_, T> { TryIter { rx: self } } @@ -1636,21 +1636,21 @@ impl Drop for Receiver { #[stable(feature = "mpsc_debug", since = "1.8.0")] impl fmt::Debug for Receiver { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Receiver").finish() } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for SendError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "SendError(..)".fmt(f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for SendError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "sending on a closed channel".fmt(f) } } @@ -1668,7 +1668,7 @@ impl error::Error for SendError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for TrySendError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { TrySendError::Full(..) => "Full(..)".fmt(f), TrySendError::Disconnected(..) => "Disconnected(..)".fmt(f), @@ -1678,7 +1678,7 @@ impl fmt::Debug for TrySendError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for TrySendError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { TrySendError::Full(..) => { "sending on a full channel".fmt(f) @@ -1720,7 +1720,7 @@ impl From> for TrySendError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for RecvError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "receiving on a closed channel".fmt(f) } } @@ -1739,7 +1739,7 @@ impl error::Error for RecvError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for TryRecvError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { TryRecvError::Empty => { "receiving on an empty channel".fmt(f) @@ -1781,7 +1781,7 @@ impl From for TryRecvError { #[stable(feature = "mpsc_recv_timeout_error", since = "1.15.0")] impl fmt::Display for RecvTimeoutError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { RecvTimeoutError::Timeout => { "timed out waiting on channel".fmt(f) diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 19c9490864545..d1b5f2deccc1c 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -340,13 +340,13 @@ impl Iterator for Packets { } impl fmt::Debug for Select { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Select").finish() } } impl fmt::Debug for Handle<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Handle").finish() } } diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index 6a5d861f0e9cd..cc70a62036590 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -78,7 +78,7 @@ impl Packet { // In other case mutex data will be duplicated while cloning // and that could cause problems on platforms where it is // represented by opaque data structure - pub fn postinit_lock(&self) -> MutexGuard<()> { + pub fn postinit_lock(&self) -> MutexGuard<'_, ()> { self.select_lock.lock().unwrap() } @@ -89,7 +89,7 @@ impl Packet { // This can only be called at channel-creation time pub fn inherit_blocker(&self, token: Option, - guard: MutexGuard<()>) { + guard: MutexGuard<'_, ()>) { token.map(|token| { assert_eq!(self.cnt.load(Ordering::SeqCst), 0); assert_eq!(self.to_wake.load(Ordering::SeqCst), 0); diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs index 485234a9495f3..b2d9f4c6491e4 100644 --- a/src/libstd/sync/mpsc/sync.rs +++ b/src/libstd/sync/mpsc/sync.rs @@ -153,7 +153,7 @@ fn abort_selection<'a, T>(guard: &mut MutexGuard<'a , State>) -> bool { } /// Wakes up a thread, dropping the lock at the correct time -fn wakeup(token: SignalToken, guard: MutexGuard>) { +fn wakeup(token: SignalToken, guard: MutexGuard<'_, State>) { // We need to be careful to wake up the waiting thread *outside* of the mutex // in case it incurs a context switch. drop(guard); @@ -184,7 +184,7 @@ impl Packet { // wait until a send slot is available, returning locked access to // the channel state. - fn acquire_send_slot(&self) -> MutexGuard> { + fn acquire_send_slot(&self) -> MutexGuard<'_, State> { let mut node = Node { token: None, next: ptr::null_mut() }; loop { let mut guard = self.lock.lock().unwrap(); @@ -316,7 +316,7 @@ impl Packet { // * `waited` - flag if the receiver blocked to receive some data, or if it // just picked up some data on the way out // * `guard` - the lock guard that is held over this channel's lock - fn wakeup_senders(&self, waited: bool, mut guard: MutexGuard>) { + fn wakeup_senders(&self, waited: bool, mut guard: MutexGuard<'_, State>) { let pending_sender1: Option = guard.queue.dequeue(); // If this is a no-buffer channel (cap == 0), then if we didn't wait we diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 6b812e65b7269..11ac34fcb24f6 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -215,7 +215,7 @@ impl Mutex { /// assert_eq!(*mutex.lock().unwrap(), 10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn lock(&self) -> LockResult> { + pub fn lock(&self) -> LockResult> { unsafe { self.inner.raw_lock(); MutexGuard::new(self) @@ -258,7 +258,7 @@ impl Mutex { /// assert_eq!(*mutex.lock().unwrap(), 10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn try_lock(&self) -> TryLockResult> { + pub fn try_lock(&self) -> TryLockResult> { unsafe { if self.inner.try_lock() { Ok(MutexGuard::new(self)?) @@ -391,7 +391,7 @@ impl Default for Mutex { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Mutex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.try_lock() { Ok(guard) => f.debug_struct("Mutex").field("data", &&*guard).finish(), Err(TryLockError::Poisoned(err)) => { @@ -400,7 +400,9 @@ impl fmt::Debug for Mutex { Err(TryLockError::WouldBlock) => { struct LockedPlaceholder; impl fmt::Debug for LockedPlaceholder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("") } + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("") + } } f.debug_struct("Mutex").field("data", &LockedPlaceholder).finish() @@ -449,14 +451,14 @@ impl Drop for MutexGuard<'_, T> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for MutexGuard<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "std_guard_impls", since = "1.20.0")] impl fmt::Display for MutexGuard<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index a036c2666625c..0c91249402417 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -431,7 +431,7 @@ impl Once { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Once { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Once { .. }") } } diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 0be83c76d6259..1299a74409560 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -180,7 +180,7 @@ impl RwLock { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn read(&self) -> LockResult> { + pub fn read(&self) -> LockResult> { unsafe { self.inner.read(); RwLockReadGuard::new(self) @@ -219,7 +219,7 @@ impl RwLock { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn try_read(&self) -> TryLockResult> { + pub fn try_read(&self) -> TryLockResult> { unsafe { if self.inner.try_read() { Ok(RwLockReadGuard::new(self)?) @@ -262,7 +262,7 @@ impl RwLock { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn write(&self) -> LockResult> { + pub fn write(&self) -> LockResult> { unsafe { self.inner.write(); RwLockWriteGuard::new(self) @@ -301,7 +301,7 @@ impl RwLock { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn try_write(&self) -> TryLockResult> { + pub fn try_write(&self) -> TryLockResult> { unsafe { if self.inner.try_write() { Ok(RwLockWriteGuard::new(self)?) @@ -421,7 +421,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for RwLock { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.try_read() { Ok(guard) => f.debug_struct("RwLock").field("data", &&*guard).finish(), Err(TryLockError::Poisoned(err)) => { @@ -430,7 +430,9 @@ impl fmt::Debug for RwLock { Err(TryLockError::WouldBlock) => { struct LockedPlaceholder; impl fmt::Debug for LockedPlaceholder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("") } + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("") + } } f.debug_struct("RwLock").field("data", &LockedPlaceholder).finish() @@ -481,7 +483,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for RwLockReadGuard<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RwLockReadGuard") .field("lock", &self.__lock) .finish() @@ -490,14 +492,14 @@ impl fmt::Debug for RwLockReadGuard<'_, T> { #[stable(feature = "std_guard_impls", since = "1.20.0")] impl fmt::Display for RwLockReadGuard<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for RwLockWriteGuard<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RwLockWriteGuard") .field("lock", &self.__lock) .finish() @@ -506,7 +508,7 @@ impl fmt::Debug for RwLockWriteGuard<'_, T> { #[stable(feature = "std_guard_impls", since = "1.20.0")] impl fmt::Display for RwLockWriteGuard<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } diff --git a/src/libstd/sys/cloudabi/backtrace.rs b/src/libstd/sys/cloudabi/backtrace.rs index a15d2238e5563..0d6429c5febbb 100644 --- a/src/libstd/sys/cloudabi/backtrace.rs +++ b/src/libstd/sys/cloudabi/backtrace.rs @@ -24,7 +24,7 @@ impl Error for UnwindError { } impl fmt::Display for UnwindError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}: {:?}", self.description(), self.0) } } @@ -54,7 +54,7 @@ extern "C" fn trace_fn( ctx: *mut uw::_Unwind_Context, arg: *mut libc::c_void, ) -> uw::_Unwind_Reason_Code { - let cx = unsafe { &mut *(arg as *mut Context) }; + let cx = unsafe { &mut *(arg as *mut Context<'_>) }; if cx.idx >= cx.frames.len() { return uw::_URC_NORMAL_STOP; } diff --git a/src/libstd/sys/cloudabi/shims/fs.rs b/src/libstd/sys/cloudabi/shims/fs.rs index 56667bef00706..ee045b8e51544 100644 --- a/src/libstd/sys/cloudabi/shims/fs.rs +++ b/src/libstd/sys/cloudabi/shims/fs.rs @@ -81,7 +81,7 @@ impl PartialEq for FilePermissions { impl Eq for FilePermissions {} impl fmt::Debug for FilePermissions { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -123,13 +123,13 @@ impl Hash for FileType { } impl fmt::Debug for FileType { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } impl fmt::Debug for ReadDir { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -234,7 +234,7 @@ impl DirBuilder { } impl fmt::Debug for File { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 4364a1365443a..7cf23748e1bf0 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -97,7 +97,7 @@ impl TcpStream { } impl fmt::Debug for TcpStream { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -147,7 +147,7 @@ impl TcpListener { } impl fmt::Debug for TcpListener { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -281,7 +281,7 @@ impl UdpSocket { } impl fmt::Debug for UdpSocket { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/cloudabi/shims/os.rs b/src/libstd/sys/cloudabi/shims/os.rs index 0c4690e12b052..83ef69eb666b3 100644 --- a/src/libstd/sys/cloudabi/shims/os.rs +++ b/src/libstd/sys/cloudabi/shims/os.rs @@ -57,7 +57,7 @@ where } impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "not supported on CloudABI yet".fmt(f) } } diff --git a/src/libstd/sys/cloudabi/shims/process.rs b/src/libstd/sys/cloudabi/shims/process.rs index 710c42c114902..e719b362cbf55 100644 --- a/src/libstd/sys/cloudabi/shims/process.rs +++ b/src/libstd/sys/cloudabi/shims/process.rs @@ -71,7 +71,7 @@ impl From for Stdio { } impl fmt::Debug for Command { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { Ok(()) } } @@ -105,13 +105,13 @@ impl PartialEq for ExitStatus { impl Eq for ExitStatus {} impl fmt::Debug for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } impl fmt::Display for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/redox/backtrace/tracing.rs b/src/libstd/sys/redox/backtrace/tracing.rs index e7a68eadbde3a..37f9ed6dc1355 100644 --- a/src/libstd/sys/redox/backtrace/tracing.rs +++ b/src/libstd/sys/redox/backtrace/tracing.rs @@ -21,7 +21,7 @@ impl Error for UnwindError { } impl fmt::Display for UnwindError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}: {:?}", self.description(), self.0) } } @@ -57,7 +57,7 @@ pub fn unwind_backtrace(frames: &mut [Frame]) extern fn trace_fn(ctx: *mut uw::_Unwind_Context, arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code { - let cx = unsafe { &mut *(arg as *mut Context) }; + let cx = unsafe { &mut *(arg as *mut Context<'_>) }; if cx.idx >= cx.frames.len() { return uw::_URC_NORMAL_STOP; } diff --git a/src/libstd/sys/redox/ext/net.rs b/src/libstd/sys/redox/ext/net.rs index 2c121787804d1..096d0681959cd 100644 --- a/src/libstd/sys/redox/ext/net.rs +++ b/src/libstd/sys/redox/ext/net.rs @@ -90,7 +90,7 @@ impl SocketAddr { } #[stable(feature = "unix_socket_redox", since = "1.29")] impl fmt::Debug for SocketAddr { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "SocketAddr") } } @@ -114,7 +114,7 @@ pub struct UnixStream(FileDesc); #[stable(feature = "unix_socket_redox", since = "1.29")] impl fmt::Debug for UnixStream { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut builder = fmt.debug_struct("UnixStream"); builder.field("fd", &self.0.raw()); if let Ok(addr) = self.local_addr() { @@ -503,7 +503,7 @@ pub struct UnixListener(FileDesc); #[stable(feature = "unix_socket_redox", since = "1.29")] impl fmt::Debug for UnixListener { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut builder = fmt.debug_struct("UnixListener"); builder.field("fd", &self.0.raw()); if let Ok(addr) = self.local_addr() { diff --git a/src/libstd/sys/redox/fs.rs b/src/libstd/sys/redox/fs.rs index 159ee9911bd3a..3ef9925705fb8 100644 --- a/src/libstd/sys/redox/fs.rs +++ b/src/libstd/sys/redox/fs.rs @@ -123,7 +123,7 @@ impl FromInner for FilePermissions { } impl fmt::Debug for ReadDir { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // This will only be called from std::fs::ReadDir, which will add a "ReadDir()" frame. // Thus the result will be e g 'ReadDir("/home")' fmt::Debug::fmt(&*self.root, f) @@ -341,7 +341,7 @@ impl FromInner for File { } impl fmt::Debug for File { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut b = f.debug_struct("File"); b.field("fd", &self.0.raw()); if let Ok(path) = self.path() { diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs index 76e43a83b7372..3ae201f698c2b 100644 --- a/src/libstd/sys/redox/os.rs +++ b/src/libstd/sys/redox/os.rs @@ -58,7 +58,7 @@ pub struct SplitPaths<'a> { fn(&'a [u8]) -> PathBuf>, } -pub fn split_paths(unparsed: &OsStr) -> SplitPaths { +pub fn split_paths(unparsed: &OsStr) -> SplitPaths<'_> { fn bytes_to_path(b: &[u8]) -> PathBuf { PathBuf::from(::from_bytes(b)) } @@ -97,7 +97,7 @@ pub fn join_paths(paths: I) -> Result } impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "path segment contains separator `:`".fmt(f) } } diff --git a/src/libstd/sys/redox/path.rs b/src/libstd/sys/redox/path.rs index 618d61e6fcb45..b62d6c9878211 100644 --- a/src/libstd/sys/redox/path.rs +++ b/src/libstd/sys/redox/path.rs @@ -11,7 +11,7 @@ pub fn is_verbatim_sep(b: u8) -> bool { b == b'/' } -pub fn parse_prefix(path: &OsStr) -> Option { +pub fn parse_prefix(path: &OsStr) -> Option> { if let Some(path_str) = path.to_str() { if let Some(_i) = path_str.find(':') { // FIXME: Redox specific prefix diff --git a/src/libstd/sys/redox/process.rs b/src/libstd/sys/redox/process.rs index 8830cdf333ef8..8e6f50773abfe 100644 --- a/src/libstd/sys/redox/process.rs +++ b/src/libstd/sys/redox/process.rs @@ -492,7 +492,7 @@ impl ChildStdio { } impl fmt::Debug for Command { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.program)?; for arg in &self.args { write!(f, " {:?}", arg)?; @@ -542,7 +542,7 @@ impl From for ExitStatus { } impl fmt::Display for ExitStatus { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(code) = self.code() { write!(f, "exit code: {}", code) } else { diff --git a/src/libstd/sys/redox/syscall/error.rs b/src/libstd/sys/redox/syscall/error.rs index f5b7bf75f305b..da84ffb042359 100644 --- a/src/libstd/sys/redox/syscall/error.rs +++ b/src/libstd/sys/redox/syscall/error.rs @@ -38,13 +38,13 @@ impl Error { } impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.text()) } } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(self.text()) } } diff --git a/src/libstd/sys/redox/time.rs b/src/libstd/sys/redox/time.rs index 881ad5c0aeb14..081437459cc40 100644 --- a/src/libstd/sys/redox/time.rs +++ b/src/libstd/sys/redox/time.rs @@ -151,7 +151,7 @@ impl Instant { } impl fmt::Debug for Instant { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Instant") .field("tv_sec", &self.t.t.tv_sec) .field("tv_nsec", &self.t.t.tv_nsec) @@ -185,7 +185,7 @@ impl From for SystemTime { } impl fmt::Debug for SystemTime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SystemTime") .field("tv_sec", &self.t.t.tv_sec) .field("tv_nsec", &self.t.t.tv_nsec) diff --git a/src/libstd/sys/sgx/backtrace.rs b/src/libstd/sys/sgx/backtrace.rs index d0361574e39d6..fcea2752d2cfc 100644 --- a/src/libstd/sys/sgx/backtrace.rs +++ b/src/libstd/sys/sgx/backtrace.rs @@ -23,7 +23,7 @@ impl Error for UnwindError { } impl fmt::Display for UnwindError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}: {:?}", self.description(), self.0) } } @@ -53,7 +53,7 @@ extern "C" fn trace_fn( ctx: *mut uw::_Unwind_Context, arg: *mut libc::c_void, ) -> uw::_Unwind_Reason_Code { - let cx = unsafe { &mut *(arg as *mut Context) }; + let cx = unsafe { &mut *(arg as *mut Context<'_>) }; if cx.idx >= cx.frames.len() { return uw::_URC_NORMAL_STOP; } diff --git a/src/libstd/sys/sgx/fs.rs b/src/libstd/sys/sgx/fs.rs index 485d2c87fbd2d..68c8e9356a89a 100644 --- a/src/libstd/sys/sgx/fs.rs +++ b/src/libstd/sys/sgx/fs.rs @@ -82,7 +82,7 @@ impl Eq for FilePermissions { } impl fmt::Debug for FilePermissions { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -125,13 +125,13 @@ impl Hash for FileType { } impl fmt::Debug for FileType { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } impl fmt::Debug for ReadDir { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -236,7 +236,7 @@ impl DirBuilder { } impl fmt::Debug for File { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index 0e7602a906efa..b103f7e9a406a 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -421,7 +421,7 @@ impl UdpSocket { } impl fmt::Debug for UdpSocket { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -438,7 +438,7 @@ impl error::Error for NonIpSockAddr { } impl fmt::Display for NonIpSockAddr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Failed to convert address to SocketAddr: {}", self.host) } } diff --git a/src/libstd/sys/sgx/os.rs b/src/libstd/sys/sgx/os.rs index 0bb7b897058db..8b12c49edbaae 100644 --- a/src/libstd/sys/sgx/os.rs +++ b/src/libstd/sys/sgx/os.rs @@ -37,7 +37,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { pub struct SplitPaths<'a>(&'a Void); -pub fn split_paths(_unparsed: &OsStr) -> SplitPaths { +pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") } @@ -58,7 +58,7 @@ pub fn join_paths(_paths: I) -> Result } impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "not supported in SGX yet".fmt(f) } } diff --git a/src/libstd/sys/sgx/path.rs b/src/libstd/sys/sgx/path.rs index 1115de1fbe5ba..b5fd7e3ae6d1e 100644 --- a/src/libstd/sys/sgx/path.rs +++ b/src/libstd/sys/sgx/path.rs @@ -11,7 +11,7 @@ pub fn is_verbatim_sep(b: u8) -> bool { b == b'/' } -pub fn parse_prefix(_: &OsStr) -> Option { +pub fn parse_prefix(_: &OsStr) -> Option> { None } diff --git a/src/libstd/sys/sgx/process.rs b/src/libstd/sys/sgx/process.rs index c49daaa16320e..a02e009d95356 100644 --- a/src/libstd/sys/sgx/process.rs +++ b/src/libstd/sys/sgx/process.rs @@ -73,7 +73,7 @@ impl From for Stdio { } impl fmt::Debug for Command { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { Ok(()) } } @@ -108,13 +108,13 @@ impl Eq for ExitStatus { } impl fmt::Debug for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } impl fmt::Display for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs index abbeca0fde6e7..e6379132bafbe 100644 --- a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs +++ b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs @@ -21,7 +21,7 @@ impl Error for UnwindError { } impl fmt::Display for UnwindError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}: {:?}", self.description(), self.0) } } @@ -37,7 +37,7 @@ pub fn unwind_backtrace(frames: &mut [Frame]) }; let result_unwind = unsafe { uw::_Unwind_Backtrace(trace_fn, - &mut cx as *mut Context + &mut cx as *mut Context<'_> as *mut libc::c_void) }; // See libunwind:src/unwind/Backtrace.c for the return values. @@ -57,7 +57,7 @@ pub fn unwind_backtrace(frames: &mut [Frame]) extern fn trace_fn(ctx: *mut uw::_Unwind_Context, arg: *mut libc::c_void) -> uw::_Unwind_Reason_Code { - let cx = unsafe { &mut *(arg as *mut Context) }; + let cx = unsafe { &mut *(arg as *mut Context<'_>) }; if cx.idx >= cx.frames.len() { return uw::_URC_NORMAL_STOP; } diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 4fc79efe7ceb5..406863a6cba24 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -219,7 +219,7 @@ impl SocketAddr { #[stable(feature = "unix_socket", since = "1.10.0")] impl fmt::Debug for SocketAddr { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self.address() { AddressKind::Unnamed => write!(fmt, "(unnamed)"), AddressKind::Abstract(name) => write!(fmt, "{} (abstract)", AsciiEscaped(name)), @@ -231,7 +231,7 @@ impl fmt::Debug for SocketAddr { struct AsciiEscaped<'a>(&'a [u8]); impl<'a> fmt::Display for AsciiEscaped<'a> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "\"")?; for byte in self.0.iter().cloned().flat_map(ascii::escape_default) { write!(fmt, "{}", byte as char)?; @@ -259,7 +259,7 @@ pub struct UnixStream(Socket); #[stable(feature = "unix_socket", since = "1.10.0")] impl fmt::Debug for UnixStream { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut builder = fmt.debug_struct("UnixStream"); builder.field("fd", self.0.as_inner()); if let Ok(addr) = self.local_addr() { @@ -719,7 +719,7 @@ pub struct UnixListener(Socket); #[stable(feature = "unix_socket", since = "1.10.0")] impl fmt::Debug for UnixListener { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut builder = fmt.debug_struct("UnixListener"); builder.field("fd", self.0.as_inner()); if let Ok(addr) = self.local_addr() { @@ -998,7 +998,7 @@ pub struct UnixDatagram(Socket); #[stable(feature = "unix_socket", since = "1.10.0")] impl fmt::Debug for UnixDatagram { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut builder = fmt.debug_struct("UnixDatagram"); builder.field("fd", self.0.as_inner()); if let Ok(addr) = self.local_addr() { diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index c73f7983146d4..a36dae2f5a19d 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -206,7 +206,7 @@ impl FromInner for FilePermissions { } impl fmt::Debug for ReadDir { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // This will only be called from std::fs::ReadDir, which will add a "ReadDir()" frame. // Thus the result will be e g 'ReadDir("/home")' fmt::Debug::fmt(&*self.inner.root, f) @@ -627,7 +627,7 @@ impl FromInner for File { } impl fmt::Debug for File { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { #[cfg(target_os = "linux")] fn get_path(fd: c_int) -> Option { let mut p = PathBuf::from("/proc/self/fd"); diff --git a/src/libstd/sys/unix/l4re.rs b/src/libstd/sys/unix/l4re.rs index b3dd1cf6aaac7..f52fe8070906e 100644 --- a/src/libstd/sys/unix/l4re.rs +++ b/src/libstd/sys/unix/l4re.rs @@ -212,7 +212,7 @@ pub mod net { } impl fmt::Debug for TcpStream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "No networking support available on L4Re") } } @@ -274,7 +274,7 @@ pub mod net { } impl fmt::Debug for TcpListener { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "No networking support available on L4Re.") } } @@ -424,7 +424,7 @@ pub mod net { } impl fmt::Debug for UdpSocket { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "No networking support on L4Re available.") } } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index e16d50d437b22..726b17969b7c3 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -152,7 +152,7 @@ pub struct SplitPaths<'a> { fn(&'a [u8]) -> PathBuf>, } -pub fn split_paths(unparsed: &OsStr) -> SplitPaths { +pub fn split_paths(unparsed: &OsStr) -> SplitPaths<'_> { fn bytes_to_path(b: &[u8]) -> PathBuf { PathBuf::from(::from_bytes(b)) } @@ -191,7 +191,7 @@ pub fn join_paths(paths: I) -> Result } impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "path segment contains separator `:`".fmt(f) } } diff --git a/src/libstd/sys/unix/path.rs b/src/libstd/sys/unix/path.rs index 5c062e7c97cd3..7a18395610785 100644 --- a/src/libstd/sys/unix/path.rs +++ b/src/libstd/sys/unix/path.rs @@ -11,7 +11,7 @@ pub fn is_verbatim_sep(b: u8) -> bool { b == b'/' } -pub fn parse_prefix(_: &OsStr) -> Option { +pub fn parse_prefix(_: &OsStr) -> Option> { None } diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 856d202be03f3..f6a12a16396b4 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -330,7 +330,7 @@ impl ChildStdio { } impl fmt::Debug for Command { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.program)?; for arg in &self.args { write!(f, " {:?}", arg)?; @@ -380,7 +380,7 @@ impl From for ExitStatus { } impl fmt::Display for ExitStatus { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(code) = self.code() { write!(f, "exit code: {}", code) } else { diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index 6b5a89aee7d69..127ae6aa10481 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -213,7 +213,7 @@ mod inner { } impl fmt::Debug for SystemTime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SystemTime") .field("tv_sec", &self.t.t.tv_sec) .field("tv_nsec", &self.t.t.tv_nsec) @@ -298,7 +298,7 @@ mod inner { } impl fmt::Debug for Instant { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Instant") .field("tv_sec", &self.t.t.tv_sec) .field("tv_nsec", &self.t.t.tv_nsec) @@ -332,7 +332,7 @@ mod inner { } impl fmt::Debug for SystemTime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SystemTime") .field("tv_sec", &self.t.t.tv_sec) .field("tv_nsec", &self.t.t.tv_nsec) diff --git a/src/libstd/sys/wasm/fs.rs b/src/libstd/sys/wasm/fs.rs index 485d2c87fbd2d..68c8e9356a89a 100644 --- a/src/libstd/sys/wasm/fs.rs +++ b/src/libstd/sys/wasm/fs.rs @@ -82,7 +82,7 @@ impl Eq for FilePermissions { } impl fmt::Debug for FilePermissions { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -125,13 +125,13 @@ impl Hash for FileType { } impl fmt::Debug for FileType { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } impl fmt::Debug for ReadDir { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -236,7 +236,7 @@ impl DirBuilder { } impl fmt::Debug for File { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs index c85dd000afe6f..38552eab0a655 100644 --- a/src/libstd/sys/wasm/net.rs +++ b/src/libstd/sys/wasm/net.rs @@ -94,7 +94,7 @@ impl TcpStream { } impl fmt::Debug for TcpStream { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -144,7 +144,7 @@ impl TcpListener { } impl fmt::Debug for TcpListener { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -282,7 +282,7 @@ impl UdpSocket { } impl fmt::Debug for UdpSocket { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/wasm/os.rs b/src/libstd/sys/wasm/os.rs index 145f9ccd73a8f..5d21999a991e1 100644 --- a/src/libstd/sys/wasm/os.rs +++ b/src/libstd/sys/wasm/os.rs @@ -24,7 +24,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { pub struct SplitPaths<'a>(&'a Void); -pub fn split_paths(_unparsed: &OsStr) -> SplitPaths { +pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") } @@ -45,7 +45,7 @@ pub fn join_paths(_paths: I) -> Result } impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "not supported on wasm yet".fmt(f) } } diff --git a/src/libstd/sys/wasm/path.rs b/src/libstd/sys/wasm/path.rs index 5c062e7c97cd3..7a18395610785 100644 --- a/src/libstd/sys/wasm/path.rs +++ b/src/libstd/sys/wasm/path.rs @@ -11,7 +11,7 @@ pub fn is_verbatim_sep(b: u8) -> bool { b == b'/' } -pub fn parse_prefix(_: &OsStr) -> Option { +pub fn parse_prefix(_: &OsStr) -> Option> { None } diff --git a/src/libstd/sys/wasm/process.rs b/src/libstd/sys/wasm/process.rs index c49daaa16320e..a02e009d95356 100644 --- a/src/libstd/sys/wasm/process.rs +++ b/src/libstd/sys/wasm/process.rs @@ -73,7 +73,7 @@ impl From for Stdio { } impl fmt::Debug for Command { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { Ok(()) } } @@ -108,13 +108,13 @@ impl Eq for ExitStatus { } impl fmt::Debug for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } impl fmt::Display for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/windows/args.rs b/src/libstd/sys/windows/args.rs index 3f10e6e5983eb..b04bb484eedb9 100644 --- a/src/libstd/sys/windows/args.rs +++ b/src/libstd/sys/windows/args.rs @@ -164,13 +164,13 @@ pub struct ArgsInnerDebug<'a> { } impl<'a> fmt::Debug for ArgsInnerDebug<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.args.parsed_args_list.as_slice().fmt(f) } } impl Args { - pub fn inner_debug(&self) -> ArgsInnerDebug { + pub fn inner_debug(&self) -> ArgsInnerDebug<'_> { ArgsInnerDebug { args: self } diff --git a/src/libstd/sys/windows/ext/ffi.rs b/src/libstd/sys/windows/ext/ffi.rs index 547b1ef796b4a..1381825806f63 100644 --- a/src/libstd/sys/windows/ext/ffi.rs +++ b/src/libstd/sys/windows/ext/ffi.rs @@ -131,12 +131,12 @@ pub trait OsStrExt { /// /// [`OsString::from_wide`]: ./trait.OsStringExt.html#tymethod.from_wide #[stable(feature = "rust1", since = "1.0.0")] - fn encode_wide(&self) -> EncodeWide; + fn encode_wide(&self) -> EncodeWide<'_>; } #[stable(feature = "rust1", since = "1.0.0")] impl OsStrExt for OsStr { - fn encode_wide(&self) -> EncodeWide { + fn encode_wide(&self) -> EncodeWide<'_> { self.as_inner().inner.encode_wide() } } diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index daf8aae24dde5..4ebbb0707f78a 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -74,7 +74,7 @@ pub struct FilePermissions { attrs: c::DWORD } pub struct DirBuilder; impl fmt::Debug for ReadDir { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // This will only be called from std::fs::ReadDir, which will add a "ReadDir()" frame. // Thus the result will be e g 'ReadDir("C:\")' fmt::Debug::fmt(&*self.root, f) @@ -435,7 +435,7 @@ impl FromInner for File { } impl fmt::Debug for File { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // FIXME(#24570): add more info here (e.g., mode) let mut b = f.debug_struct("File"); b.field("handle", &self.handle.raw()); diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 5b433ddfb4a38..4e50b5521eb04 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -136,7 +136,7 @@ pub struct SplitPaths<'a> { must_yield: bool, } -pub fn split_paths(unparsed: &OsStr) -> SplitPaths { +pub fn split_paths(unparsed: &OsStr) -> SplitPaths<'_> { SplitPaths { data: unparsed.encode_wide(), must_yield: true, @@ -212,7 +212,7 @@ pub fn join_paths(paths: I) -> Result } impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "path segment contains `\"`".fmt(f) } } diff --git a/src/libstd/sys/windows/os_str.rs b/src/libstd/sys/windows/os_str.rs index 8befa66ecdc9c..c7a82e092528e 100644 --- a/src/libstd/sys/windows/os_str.rs +++ b/src/libstd/sys/windows/os_str.rs @@ -33,13 +33,13 @@ impl AsInner for Buf { } impl fmt::Debug for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(self.as_slice(), formatter) } } impl fmt::Display for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self.as_slice(), formatter) } } @@ -49,13 +49,13 @@ pub struct Slice { } impl fmt::Debug for Slice { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.inner, formatter) } } impl fmt::Display for Slice { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.inner, formatter) } } @@ -139,7 +139,7 @@ impl Slice { self.inner.as_str() } - pub fn to_string_lossy(&self) -> Cow { + pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() } diff --git a/src/libstd/sys/windows/path.rs b/src/libstd/sys/windows/path.rs index b8532ca9b0d4e..f3178a5e9e690 100644 --- a/src/libstd/sys/windows/path.rs +++ b/src/libstd/sys/windows/path.rs @@ -19,7 +19,7 @@ pub fn is_verbatim_sep(b: u8) -> bool { b == b'\\' } -pub fn parse_prefix<'a>(path: &'a OsStr) -> Option { +pub fn parse_prefix<'a>(path: &'a OsStr) -> Option> { use crate::path::Prefix::*; unsafe { // The unsafety here stems from converting between &OsStr and &[u8] diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 95f061d22bd43..e39b7ae889025 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -219,7 +219,7 @@ impl Command { } impl fmt::Debug for Command { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.program)?; for arg in &self.args { write!(f, " {:?}", arg)?; @@ -393,7 +393,7 @@ impl From for ExitStatus { } impl fmt::Display for ExitStatus { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Windows exit codes with the high bit set typically mean some form of // unhandled exception or warning. In this scenario printing the exit // code in decimal doesn't always make sense because it's a very large diff --git a/src/libstd/sys/windows/time.rs b/src/libstd/sys/windows/time.rs index aa53f1194fdb4..4c9d2aee15709 100644 --- a/src/libstd/sys/windows/time.rs +++ b/src/libstd/sys/windows/time.rs @@ -139,7 +139,7 @@ impl Ord for SystemTime { } impl fmt::Debug for SystemTime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SystemTime") .field("intervals", &self.intervals()) .finish() diff --git a/src/libstd/sys_common/bytestring.rs b/src/libstd/sys_common/bytestring.rs index 273d586a5a0b2..429ecf6281b3e 100644 --- a/src/libstd/sys_common/bytestring.rs +++ b/src/libstd/sys_common/bytestring.rs @@ -3,9 +3,9 @@ use crate::fmt::{Formatter, Result, Write}; use core::str::lossy::{Utf8Lossy, Utf8LossyChunk}; -pub fn debug_fmt_bytestring(slice: &[u8], f: &mut Formatter) -> Result { +pub fn debug_fmt_bytestring(slice: &[u8], f: &mut Formatter<'_>) -> Result { // Writes out a valid unicode string with the correct escape sequences - fn write_str_escaped(f: &mut Formatter, s: &str) -> Result { + fn write_str_escaped(f: &mut Formatter<'_>, s: &str) -> Result { for c in s.chars().flat_map(|c| c.escape_debug()) { f.write_char(c)? } @@ -32,7 +32,7 @@ mod tests { struct Helper<'a>(&'a [u8]); impl Debug for Helper<'_> { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { debug_fmt_bytestring(self.0, f) } } diff --git a/src/libstd/sys_common/mutex.rs b/src/libstd/sys_common/mutex.rs index 4b58cac7941b9..28d85949ffa3c 100644 --- a/src/libstd/sys_common/mutex.rs +++ b/src/libstd/sys_common/mutex.rs @@ -38,7 +38,7 @@ impl Mutex { /// Calls raw_lock() and then returns an RAII guard to guarantee the mutex /// will be unlocked. #[inline] - pub unsafe fn lock(&self) -> MutexGuard { + pub unsafe fn lock(&self) -> MutexGuard<'_> { self.raw_lock(); MutexGuard(&self.0) } diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index b77bcee4b9d04..02bd91c438104 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -328,7 +328,7 @@ impl FromInner for TcpStream { } impl fmt::Debug for TcpStream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut res = f.debug_struct("TcpStream"); if let Ok(addr) = self.socket_addr() { @@ -435,7 +435,7 @@ impl FromInner for TcpListener { } impl fmt::Debug for TcpListener { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut res = f.debug_struct("TcpListener"); if let Ok(addr) = self.socket_addr() { @@ -644,7 +644,7 @@ impl FromInner for UdpSocket { } impl fmt::Debug for UdpSocket { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut res = f.debug_struct("UdpSocket"); if let Ok(addr) = self.socket_addr() { diff --git a/src/libstd/sys_common/os_str_bytes.rs b/src/libstd/sys_common/os_str_bytes.rs index 5a9235a608cd4..7cc93477a73c7 100644 --- a/src/libstd/sys_common/os_str_bytes.rs +++ b/src/libstd/sys_common/os_str_bytes.rs @@ -23,25 +23,25 @@ pub(crate) struct Slice { } impl fmt::Debug for Slice { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { debug_fmt_bytestring(&self.inner, formatter) } } impl fmt::Display for Slice { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&Utf8Lossy::from_bytes(&self.inner), formatter) } } impl fmt::Debug for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(self.as_slice(), formatter) } } impl fmt::Display for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self.as_slice(), formatter) } } @@ -148,7 +148,7 @@ impl Slice { str::from_utf8(&self.inner).ok() } - pub fn to_string_lossy(&self) -> Cow { + pub fn to_string_lossy(&self) -> Cow<'_, str> { String::from_utf8_lossy(&self.inner) } diff --git a/src/libstd/sys_common/poison.rs b/src/libstd/sys_common/poison.rs index d229423566649..adac45f2d59da 100644 --- a/src/libstd/sys_common/poison.rs +++ b/src/libstd/sys_common/poison.rs @@ -136,14 +136,14 @@ pub type TryLockResult = Result>; #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for PoisonError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "PoisonError { inner: .. }".fmt(f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for PoisonError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "poisoned lock: another task failed inside".fmt(f) } } @@ -214,7 +214,7 @@ impl From> for TryLockError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for TryLockError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { TryLockError::Poisoned(..) => "Poisoned(..)".fmt(f), TryLockError::WouldBlock => "WouldBlock".fmt(f) @@ -224,7 +224,7 @@ impl fmt::Debug for TryLockError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for TryLockError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { TryLockError::Poisoned(..) => "poisoned lock: another task failed inside", TryLockError::WouldBlock => "try_lock failed because the operation would block" diff --git a/src/libstd/sys_common/remutex.rs b/src/libstd/sys_common/remutex.rs index 2aec361d7a493..f08b13c4aa274 100644 --- a/src/libstd/sys_common/remutex.rs +++ b/src/libstd/sys_common/remutex.rs @@ -72,7 +72,7 @@ impl ReentrantMutex { /// If another user of this mutex panicked while holding the mutex, then /// this call will return failure if the mutex would otherwise be /// acquired. - pub fn lock(&self) -> LockResult> { + pub fn lock(&self) -> LockResult> { unsafe { self.inner.lock() } ReentrantMutexGuard::new(&self) } @@ -89,7 +89,7 @@ impl ReentrantMutex { /// If another user of this mutex panicked while holding the mutex, then /// this call will return failure if the mutex would otherwise be /// acquired. - pub fn try_lock(&self) -> TryLockResult> { + pub fn try_lock(&self) -> TryLockResult> { if unsafe { self.inner.try_lock() } { Ok(ReentrantMutexGuard::new(&self)?) } else { @@ -108,7 +108,7 @@ impl Drop for ReentrantMutex { } impl fmt::Debug for ReentrantMutex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.try_lock() { Ok(guard) => f.debug_struct("ReentrantMutex").field("data", &*guard).finish(), Err(TryLockError::Poisoned(err)) => { @@ -117,7 +117,9 @@ impl fmt::Debug for ReentrantMutex { Err(TryLockError::WouldBlock) => { struct LockedPlaceholder; impl fmt::Debug for LockedPlaceholder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("") } + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("") + } } f.debug_struct("ReentrantMutex").field("data", &LockedPlaceholder).finish() diff --git a/src/libstd/sys_common/util.rs b/src/libstd/sys_common/util.rs index 206443a673692..7936dd35999e2 100644 --- a/src/libstd/sys_common/util.rs +++ b/src/libstd/sys_common/util.rs @@ -3,7 +3,7 @@ use crate::io::prelude::*; use crate::sys::stdio::panic_output; use crate::thread; -pub fn dumb_print(args: fmt::Arguments) { +pub fn dumb_print(args: fmt::Arguments<'_>) { if let Some(mut out) = panic_output() { let _ = out.write_fmt(args); } @@ -14,7 +14,7 @@ pub fn dumb_print(args: fmt::Arguments) { // crate::intrinsics::abort() may be used instead. The above implementations cover // all targets currently supported by libstd. -pub fn abort(args: fmt::Arguments) -> ! { +pub fn abort(args: fmt::Arguments<'_>) -> ! { dumb_print(format_args!("fatal runtime error: {}\n", args)); unsafe { crate::sys::abort_internal(); } } diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index b15239e8d877e..7fe1818291e5d 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -46,7 +46,7 @@ pub struct CodePoint { /// Example: `U+1F4A9` impl fmt::Debug for CodePoint { #[inline] - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "U+{:04X}", self.value) } } @@ -134,7 +134,7 @@ impl ops::DerefMut for Wtf8Buf { /// Example: `"a\u{D800}"` for a string with code points [U+0061, U+D800] impl fmt::Debug for Wtf8Buf { #[inline] - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, formatter) } } @@ -411,8 +411,8 @@ impl AsInner<[u8]> for Wtf8 { /// and surrogates as `\u` followed by four hexadecimal digits. /// Example: `"a\u{D800}"` for a slice with code points [U+0061, U+D800] impl fmt::Debug for Wtf8 { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - fn write_str_escaped(f: &mut fmt::Formatter, s: &str) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + fn write_str_escaped(f: &mut fmt::Formatter<'_>, s: &str) -> fmt::Result { use crate::fmt::Write; for c in s.chars().flat_map(|c| c.escape_debug()) { f.write_char(c)? @@ -441,7 +441,7 @@ impl fmt::Debug for Wtf8 { } impl fmt::Display for Wtf8 { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let wtf8_bytes = &self.bytes; let mut pos = 0; loop { @@ -522,7 +522,7 @@ impl Wtf8 { /// Returns an iterator for the string’s code points. #[inline] - pub fn code_points(&self) -> Wtf8CodePoints { + pub fn code_points(&self) -> Wtf8CodePoints<'_> { Wtf8CodePoints { bytes: self.bytes.iter() } } @@ -547,7 +547,7 @@ impl Wtf8 { /// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”). /// /// This only copies the data if necessary (if it contains any surrogate). - pub fn to_string_lossy(&self) -> Cow { + pub fn to_string_lossy(&self) -> Cow<'_, str> { let surrogate_pos = match self.next_surrogate(0) { None => return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }), Some((pos, _)) => pos, @@ -579,7 +579,7 @@ impl Wtf8 { /// calling `Wtf8Buf::from_ill_formed_utf16` on the resulting code units /// would always return the original WTF-8 string. #[inline] - pub fn encode_wide(&self) -> EncodeWide { + pub fn encode_wide(&self) -> EncodeWide<'_> { EncodeWide { code_points: self.code_points(), extra: 0 } } @@ -1228,7 +1228,7 @@ mod tests { assert_eq!(Wtf8::from_str("aé 💩").to_string_lossy(), Cow::Borrowed("aé 💩")); let mut string = Wtf8Buf::from_str("aé 💩"); string.push(CodePoint::from_u32(0xD800).unwrap()); - let expected: Cow = Cow::Owned(String::from("aé 💩�")); + let expected: Cow<'_, str> = Cow::Owned(String::from("aé 💩�")); assert_eq!(string.to_string_lossy(), expected); } diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index b73c5856b8805..bfc1deddf7bdb 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -100,7 +100,7 @@ pub struct LocalKey { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for LocalKey { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("LocalKey { .. }") } } @@ -204,14 +204,14 @@ pub struct AccessError { #[stable(feature = "thread_local_try_with", since = "1.26.0")] impl fmt::Debug for AccessError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("AccessError").finish() } } #[stable(feature = "thread_local_try_with", since = "1.26.0")] impl fmt::Display for AccessError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt("already destroyed", f) } } @@ -319,7 +319,7 @@ pub mod statik { unsafe impl Sync for Key { } impl fmt::Debug for Key { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Key { .. }") } } @@ -356,7 +356,7 @@ pub mod fast { } impl fmt::Debug for Key { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Key { .. }") } } @@ -424,7 +424,7 @@ pub mod os { } impl fmt::Debug for Key { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Key { .. }") } } diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 058fee4484d68..cb507971091a4 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1256,7 +1256,7 @@ impl Thread { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Thread { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Thread") .field("id", &self.id()) .field("name", &self.name()) @@ -1469,7 +1469,7 @@ impl IntoInner for JoinHandle { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for JoinHandle { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("JoinHandle { .. }") } } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index ab1a43d6672e4..dc97f8c04a839 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -349,7 +349,7 @@ impl Sub for Instant { #[stable(feature = "time2", since = "1.8.0")] impl fmt::Debug for Instant { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -513,7 +513,7 @@ impl SubAssign for SystemTime { #[stable(feature = "time2", since = "1.8.0")] impl fmt::Debug for SystemTime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -581,7 +581,7 @@ impl Error for SystemTimeError { #[stable(feature = "time2", since = "1.8.0")] impl fmt::Display for SystemTimeError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "second time provided was later than self") } } From 6f4df8c0c20969a1059a4b0cdf63e4ac33447e1b Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 30 Mar 2019 10:30:57 +0100 Subject: [PATCH 6/8] libstd: deny(elided_lifetimes_in_paths), fixes in cloudabi --- src/libstd/sys/cloudabi/backtrace.rs | 5 +++-- src/libstd/sys/cloudabi/shims/os.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libstd/sys/cloudabi/backtrace.rs b/src/libstd/sys/cloudabi/backtrace.rs index 0d6429c5febbb..17719a29b6ed6 100644 --- a/src/libstd/sys/cloudabi/backtrace.rs +++ b/src/libstd/sys/cloudabi/backtrace.rs @@ -33,8 +33,9 @@ impl fmt::Display for UnwindError { // tracing pub fn unwind_backtrace(frames: &mut [Frame]) -> io::Result<(usize, BacktraceContext)> { let mut cx = Context { idx: 0, frames }; - let result_unwind = - unsafe { uw::_Unwind_Backtrace(trace_fn, &mut cx as *mut Context as *mut libc::c_void) }; + let result_unwind = unsafe { + uw::_Unwind_Backtrace(trace_fn, &mut cx as *mut Context<'_> as *mut libc::c_void) + }; // See libunwind:src/unwind/Backtrace.c for the return values. // No, there is no doc. match result_unwind { diff --git a/src/libstd/sys/cloudabi/shims/os.rs b/src/libstd/sys/cloudabi/shims/os.rs index 83ef69eb666b3..944b9525b3b60 100644 --- a/src/libstd/sys/cloudabi/shims/os.rs +++ b/src/libstd/sys/cloudabi/shims/os.rs @@ -34,7 +34,7 @@ pub fn unsetenv(_: &OsStr) -> io::Result<()> { pub struct SplitPaths<'a>(&'a Void); -pub fn split_paths(_unparsed: &OsStr) -> SplitPaths { +pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") } From c5d60910ca81736e498b307dbf7dcea26867f9b1 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 30 Mar 2019 15:22:19 +0100 Subject: [PATCH 7/8] libstd: deny(elided_lifetimes_in_paths), fixes in wasi --- src/libstd/sys/wasi/fd.rs | 24 ++++++++++++------------ src/libstd/sys/wasi/fs.rs | 8 ++++---- src/libstd/sys/wasi/net.rs | 6 +++--- src/libstd/sys/wasi/os.rs | 4 ++-- src/libstd/sys/wasi/path.rs | 2 +- src/libstd/sys/wasi/process.rs | 6 +++--- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/libstd/sys/wasi/fd.rs b/src/libstd/sys/wasi/fd.rs index 1e05e7017594a..29e1880b8f135 100644 --- a/src/libstd/sys/wasi/fd.rs +++ b/src/libstd/sys/wasi/fd.rs @@ -23,25 +23,25 @@ pub type RiFlags = u16; pub type RoFlags = u16; pub type SiFlags = u16; -fn iovec(a: &mut [IoVecMut]) -> (*const libc::__wasi_iovec_t, usize) { +fn iovec(a: &mut [IoVecMut<'_>]) -> (*const libc::__wasi_iovec_t, usize) { assert_eq!( - mem::size_of::(), + mem::size_of::>(), mem::size_of::() ); assert_eq!( - mem::align_of::(), + mem::align_of::>(), mem::align_of::() ); (a.as_ptr() as *const libc::__wasi_iovec_t, a.len()) } -fn ciovec(a: &[IoVec]) -> (*const libc::__wasi_ciovec_t, usize) { +fn ciovec(a: &[IoVec<'_>]) -> (*const libc::__wasi_ciovec_t, usize) { assert_eq!( - mem::size_of::(), + mem::size_of::>(), mem::size_of::() ); assert_eq!( - mem::align_of::(), + mem::align_of::>(), mem::align_of::() ); (a.as_ptr() as *const libc::__wasi_ciovec_t, a.len()) @@ -56,28 +56,28 @@ impl WasiFd { cvt_wasi(unsafe { libc::__wasi_fd_datasync(self.fd) }) } - pub fn pread(&self, bufs: &mut [IoVecMut], offset: u64) -> io::Result { + pub fn pread(&self, bufs: &mut [IoVecMut<'_>], offset: u64) -> io::Result { let mut read = 0; let (ptr, len) = iovec(bufs); cvt_wasi(unsafe { libc::__wasi_fd_pread(self.fd, ptr, len, offset, &mut read) })?; Ok(read) } - pub fn pwrite(&self, bufs: &[IoVec], offset: u64) -> io::Result { + pub fn pwrite(&self, bufs: &[IoVec<'_>], offset: u64) -> io::Result { let mut read = 0; let (ptr, len) = ciovec(bufs); cvt_wasi(unsafe { libc::__wasi_fd_pwrite(self.fd, ptr, len, offset, &mut read) })?; Ok(read) } - pub fn read(&self, bufs: &mut [IoVecMut]) -> io::Result { + pub fn read(&self, bufs: &mut [IoVecMut<'_>]) -> io::Result { let mut read = 0; let (ptr, len) = iovec(bufs); cvt_wasi(unsafe { libc::__wasi_fd_read(self.fd, ptr, len, &mut read) })?; Ok(read) } - pub fn write(&self, bufs: &[IoVec]) -> io::Result { + pub fn write(&self, bufs: &[IoVec<'_>]) -> io::Result { let mut read = 0; let (ptr, len) = ciovec(bufs); cvt_wasi(unsafe { libc::__wasi_fd_write(self.fd, ptr, len, &mut read) })?; @@ -281,7 +281,7 @@ impl WasiFd { pub fn sock_recv( &self, - ri_data: &mut [IoVecMut], + ri_data: &mut [IoVecMut<'_>], ri_flags: RiFlags, ) -> io::Result<(usize, RoFlags)> { let mut ro_datalen = 0; @@ -293,7 +293,7 @@ impl WasiFd { Ok((ro_datalen, ro_flags)) } - pub fn sock_send(&self, si_data: &[IoVec], si_flags: SiFlags) -> io::Result { + pub fn sock_send(&self, si_data: &[IoVec<'_>], si_flags: SiFlags) -> io::Result { let mut so_datalen = 0; let (ptr, len) = ciovec(si_data); cvt_wasi(unsafe { libc::__wasi_sock_send(self.fd, ptr, len, si_flags, &mut so_datalen) })?; diff --git a/src/libstd/sys/wasi/fs.rs b/src/libstd/sys/wasi/fs.rs index 485d2c87fbd2d..68c8e9356a89a 100644 --- a/src/libstd/sys/wasi/fs.rs +++ b/src/libstd/sys/wasi/fs.rs @@ -82,7 +82,7 @@ impl Eq for FilePermissions { } impl fmt::Debug for FilePermissions { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -125,13 +125,13 @@ impl Hash for FileType { } impl fmt::Debug for FileType { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } impl fmt::Debug for ReadDir { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -236,7 +236,7 @@ impl DirBuilder { } impl fmt::Debug for File { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/wasi/net.rs b/src/libstd/sys/wasi/net.rs index af9a22f5b7a36..1579aa4b572b0 100644 --- a/src/libstd/sys/wasi/net.rs +++ b/src/libstd/sys/wasi/net.rs @@ -94,7 +94,7 @@ impl TcpStream { } impl fmt::Debug for TcpStream { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -144,7 +144,7 @@ impl TcpListener { } impl fmt::Debug for TcpListener { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } @@ -282,7 +282,7 @@ impl UdpSocket { } impl fmt::Debug for UdpSocket { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } diff --git a/src/libstd/sys/wasi/os.rs b/src/libstd/sys/wasi/os.rs index de18e4ba95075..6d4d6aae61b9f 100644 --- a/src/libstd/sys/wasi/os.rs +++ b/src/libstd/sys/wasi/os.rs @@ -41,7 +41,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { pub struct SplitPaths<'a>(&'a Void); -pub fn split_paths(_unparsed: &OsStr) -> SplitPaths { +pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") } @@ -62,7 +62,7 @@ pub fn join_paths(_paths: I) -> Result } impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "not supported on wasm yet".fmt(f) } } diff --git a/src/libstd/sys/wasi/path.rs b/src/libstd/sys/wasi/path.rs index 5c062e7c97cd3..7a18395610785 100644 --- a/src/libstd/sys/wasi/path.rs +++ b/src/libstd/sys/wasi/path.rs @@ -11,7 +11,7 @@ pub fn is_verbatim_sep(b: u8) -> bool { b == b'/' } -pub fn parse_prefix(_: &OsStr) -> Option { +pub fn parse_prefix(_: &OsStr) -> Option> { None } diff --git a/src/libstd/sys/wasi/process.rs b/src/libstd/sys/wasi/process.rs index c49daaa16320e..a02e009d95356 100644 --- a/src/libstd/sys/wasi/process.rs +++ b/src/libstd/sys/wasi/process.rs @@ -73,7 +73,7 @@ impl From for Stdio { } impl fmt::Debug for Command { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { Ok(()) } } @@ -108,13 +108,13 @@ impl Eq for ExitStatus { } impl fmt::Debug for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } impl fmt::Display for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.0 {} } } From 351a20c32fad14760e406e76fab43c8596de694d Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sun, 31 Mar 2019 12:56:42 +0200 Subject: [PATCH 8/8] libstd: deny(elided_lifetimes_in_paths), fixes in sgx --- src/libstd/sys/sgx/abi/tls.rs | 4 ++-- src/libstd/sys/sgx/abi/usercalls/alloc.rs | 4 ++-- src/libstd/sys/sgx/backtrace.rs | 5 +++-- src/libstd/sys/sgx/net.rs | 4 ++-- src/libstd/sys/sgx/rwlock.rs | 8 ++++---- src/libstd/sys/sgx/waitqueue.rs | 14 +++++++------- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/libstd/sys/sgx/abi/tls.rs b/src/libstd/sys/sgx/abi/tls.rs index 6b9ab7e383c01..fa82e8ccf0588 100644 --- a/src/libstd/sys/sgx/abi/tls.rs +++ b/src/libstd/sys/sgx/abi/tls.rs @@ -84,7 +84,7 @@ impl Tls { Tls { data: dup!((* * * * * * *) (Cell::new(ptr::null_mut()))) } } - pub unsafe fn activate(&self) -> ActiveTls { + pub unsafe fn activate(&self) -> ActiveTls<'_> { set_tls_ptr(self as *const Tls as _); ActiveTls { tls: self } } @@ -141,7 +141,7 @@ mod sync_bitset { } /// Not atomic. - pub fn iter(&self) -> SyncBitsetIter { + pub fn iter(&self) -> SyncBitsetIter<'_> { SyncBitsetIter { iter: self.0.iter().enumerate().peekable(), elem_idx: 0, diff --git a/src/libstd/sys/sgx/abi/usercalls/alloc.rs b/src/libstd/sys/sgx/abi/usercalls/alloc.rs index 449a5fe5ae308..ec9c30a3e4f9d 100644 --- a/src/libstd/sys/sgx/abi/usercalls/alloc.rs +++ b/src/libstd/sys/sgx/abi/usercalls/alloc.rs @@ -429,7 +429,7 @@ impl UserRef<[T]> where [T]: UserSafe { } /// Returns an iterator over the slice. - pub fn iter(&self) -> Iter + pub fn iter(&self) -> Iter<'_, T> where T: UserSafe // FIXME: should be implied by [T]: UserSafe? { unsafe { @@ -438,7 +438,7 @@ impl UserRef<[T]> where [T]: UserSafe { } /// Returns an iterator that allows modifying each value. - pub fn iter_mut(&mut self) -> IterMut + pub fn iter_mut(&mut self) -> IterMut<'_, T> where T: UserSafe // FIXME: should be implied by [T]: UserSafe? { unsafe { diff --git a/src/libstd/sys/sgx/backtrace.rs b/src/libstd/sys/sgx/backtrace.rs index fcea2752d2cfc..326737a241863 100644 --- a/src/libstd/sys/sgx/backtrace.rs +++ b/src/libstd/sys/sgx/backtrace.rs @@ -31,8 +31,9 @@ impl fmt::Display for UnwindError { #[inline(never)] // this function call can be skipped it when tracing. pub fn unwind_backtrace(frames: &mut [Frame]) -> io::Result<(usize, BacktraceContext)> { let mut cx = Context { idx: 0, frames }; - let result_unwind = - unsafe { uw::_Unwind_Backtrace(trace_fn, &mut cx as *mut Context as *mut libc::c_void) }; + let result_unwind = unsafe { + uw::_Unwind_Backtrace(trace_fn, &mut cx as *mut Context<'_> as *mut libc::c_void) + }; // See libunwind:src/unwind/Backtrace.c for the return values. // No, there is no doc. let res = match result_unwind { diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index b103f7e9a406a..10cc644a55ec6 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -48,7 +48,7 @@ pub struct TcpStream { } impl fmt::Debug for TcpStream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut res = f.debug_struct("TcpStream"); if let Some(ref addr) = self.inner.local_addr { @@ -213,7 +213,7 @@ pub struct TcpListener { } impl fmt::Debug for TcpListener { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut res = f.debug_struct("TcpListener"); if let Some(ref addr) = self.inner.local_addr { diff --git a/src/libstd/sys/sgx/rwlock.rs b/src/libstd/sys/sgx/rwlock.rs index 784303f3a65e8..4cba36aa64dd5 100644 --- a/src/libstd/sys/sgx/rwlock.rs +++ b/src/libstd/sys/sgx/rwlock.rs @@ -93,8 +93,8 @@ impl RWLock { #[inline] unsafe fn __read_unlock( &self, - mut rguard: SpinMutexGuard>>, - wguard: SpinMutexGuard>, + mut rguard: SpinMutexGuard<'_, WaitVariable>>, + wguard: SpinMutexGuard<'_, WaitVariable>, ) { *rguard.lock_var_mut() = NonZeroUsize::new(rguard.lock_var().unwrap().get() - 1); if rguard.lock_var().is_some() { @@ -120,8 +120,8 @@ impl RWLock { #[inline] unsafe fn __write_unlock( &self, - rguard: SpinMutexGuard>>, - wguard: SpinMutexGuard>, + rguard: SpinMutexGuard<'_, WaitVariable>>, + wguard: SpinMutexGuard<'_, WaitVariable>, ) { if let Err(mut wguard) = WaitQueue::notify_one(wguard) { // No writers waiting, release the write lock diff --git a/src/libstd/sys/sgx/waitqueue.rs b/src/libstd/sys/sgx/waitqueue.rs index 3f5e03ddad69e..f4adb7d1e1606 100644 --- a/src/libstd/sys/sgx/waitqueue.rs +++ b/src/libstd/sys/sgx/waitqueue.rs @@ -140,7 +140,7 @@ impl WaitQueue { /// until a wakeup event. /// /// This function does not return until this thread has been awoken. - pub fn wait(mut guard: SpinMutexGuard>) { + pub fn wait(mut guard: SpinMutexGuard<'_, WaitVariable>) { unsafe { let mut entry = UnsafeListEntry::new(SpinMutex::new(WaitEntry { tcs: thread::current(), @@ -162,8 +162,8 @@ impl WaitQueue { /// /// If a waiter is found, a `WaitGuard` is returned which will notify the /// waiter when it is dropped. - pub fn notify_one(mut guard: SpinMutexGuard>) - -> Result, SpinMutexGuard>> + pub fn notify_one(mut guard: SpinMutexGuard<'_, WaitVariable>) + -> Result, SpinMutexGuard<'_, WaitVariable>> { unsafe { if let Some(entry) = guard.queue.inner.pop() { @@ -186,8 +186,8 @@ impl WaitQueue { /// /// If at least one waiter is found, a `WaitGuard` is returned which will /// notify all waiters when it is dropped. - pub fn notify_all(mut guard: SpinMutexGuard>) - -> Result, SpinMutexGuard>> + pub fn notify_all(mut guard: SpinMutexGuard<'_, WaitVariable>) + -> Result, SpinMutexGuard<'_, WaitVariable>> { unsafe { let mut count = 0; @@ -433,7 +433,7 @@ mod spin_mutex { } #[inline(always)] - pub fn lock(&self) -> SpinMutexGuard { + pub fn lock(&self) -> SpinMutexGuard<'_, T> { loop { match self.try_lock() { None => while self.lock.load(Ordering::Relaxed) { @@ -445,7 +445,7 @@ mod spin_mutex { } #[inline(always)] - pub fn try_lock(&self) -> Option> { + pub fn try_lock(&self) -> Option> { if !self.lock.compare_and_swap(false, true, Ordering::Acquire) { Some(SpinMutexGuard { mutex: self,