From 6225b312cf758d078dd37b0e404286aa1b1cbd5b Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Sat, 13 Apr 2019 15:39:49 +1000 Subject: [PATCH 01/24] Make clear that format padding doesn't work for Debug As mentioned in https://github.com/rust-lang/rust/issues/46006#issuecomment-345260633 --- src/liballoc/fmt.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index d2ba9b001916c..68cbc366d7bc2 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -343,9 +343,10 @@ //! * `^` - the argument is center-aligned in `width` columns //! * `>` - the argument is right-aligned in `width` columns //! -//! Note that alignment may not be implemented by some types. A good way -//! to ensure padding is applied is to format your input, then use this -//! resulting string to pad your output. +//! Note that alignment may not be implemented by some types. In particular, it +//! is not generally implemented for the `Debug` trait. A good way to ensure +//! padding is applied is to format your input, then use this resulting string +//! to pad your output. //! //! ## Sign/`#`/`0` //! From cc2689a2539a28d54d0f0ec029c487aadad724f0 Mon Sep 17 00:00:00 2001 From: Adrian Friedli Date: Tue, 16 Apr 2019 20:41:23 +0200 Subject: [PATCH 02/24] implement nth_back for Bytes --- src/libcore/str/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 8d28be621d647..24c008460447e 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -795,6 +795,11 @@ impl DoubleEndedIterator for Bytes<'_> { self.0.next_back() } + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + self.0.nth_back(n) + } + #[inline] fn rfind

(&mut self, predicate: P) -> Option where P: FnMut(&Self::Item) -> bool From fae2a68ba21d5cdd3557cd01ca18b792b0bcbd67 Mon Sep 17 00:00:00 2001 From: Adrian Friedli Date: Tue, 16 Apr 2019 21:40:50 +0200 Subject: [PATCH 03/24] implement nth_back for Fuse --- src/libcore/iter/adapters/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs index cccd51b577930..f08f2a5ec7519 100644 --- a/src/libcore/iter/adapters/mod.rs +++ b/src/libcore/iter/adapters/mod.rs @@ -1789,6 +1789,17 @@ impl DoubleEndedIterator for Fuse where I: DoubleEndedIterator { } } + #[inline] + default fn nth_back(&mut self, n: usize) -> Option<::Item> { + if self.done { + None + } else { + let nth = self.iter.nth_back(n); + self.done = nth.is_none(); + nth + } + } + #[inline] default fn try_rfold(&mut self, init: Acc, fold: Fold) -> R where Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try @@ -1877,6 +1888,11 @@ impl DoubleEndedIterator for Fuse self.iter.next_back() } + #[inline] + fn nth_back(&mut self, n: usize) -> Option<::Item> { + self.iter.nth_back(n) + } + #[inline] fn try_rfold(&mut self, init: Acc, fold: Fold) -> R where Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try From 2605537012022980d5ec69ad11653794db935cf6 Mon Sep 17 00:00:00 2001 From: Adrian Friedli Date: Tue, 16 Apr 2019 23:45:59 +0200 Subject: [PATCH 04/24] implement nth_back for Enumerate --- src/libcore/iter/adapters/mod.rs | 10 ++++++++++ src/libcore/tests/iter.rs | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs index f08f2a5ec7519..9f9146a1523b3 100644 --- a/src/libcore/iter/adapters/mod.rs +++ b/src/libcore/iter/adapters/mod.rs @@ -980,6 +980,16 @@ impl DoubleEndedIterator for Enumerate where }) } + #[inline] + fn nth_back(&mut self, n: usize) -> Option<(usize, ::Item)> { + self.iter.nth_back(n).map(|a| { + let len = self.iter.len(); + // Can safely add, `ExactSizeIterator` promises that the number of + // elements fits into a `usize`. + (self.count + len, a) + }) + } + #[inline] fn try_rfold(&mut self, init: Acc, mut fold: Fold) -> R where Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index d5b581d336d2f..5247331fba24f 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -389,6 +389,24 @@ fn test_iterator_enumerate_nth() { assert_eq!(i, 3); } +#[test] +fn test_iterator_enumerate_nth_back() { + let xs = [0, 1, 2, 3, 4, 5]; + let mut it = xs.iter().enumerate(); + while let Some((i, &x)) = it.nth_back(0) { + assert_eq!(i, x); + } + + let mut it = xs.iter().enumerate(); + while let Some((i, &x)) = it.nth_back(1) { + assert_eq!(i, x); + } + + let (i, &x) = xs.iter().enumerate().nth_back(3).unwrap(); + assert_eq!(i, x); + assert_eq!(i, 2); +} + #[test] fn test_iterator_enumerate_count() { let xs = [0, 1, 2, 3, 4, 5]; From 4fed94bf0dcb3a58ec179f0e0248f493c140f6d0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 17 Apr 2019 10:42:10 +0200 Subject: [PATCH 05/24] Remove unwanted z-index change --- src/librustdoc/html/static/rustdoc.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 8cf70b9a99502..53b08cf569783 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -166,7 +166,6 @@ nav.sub { top: 0; height: 100vh; overflow: auto; - z-index: 1; } .sidebar .block > ul > li { From 98f38b28a21dc087c8176b82717d092fc1028d72 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 17 Apr 2019 22:41:30 +0100 Subject: [PATCH 06/24] Correct E0392 diagnostic --- src/librustc_typeck/check/wfcheck.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index d108e7c3107af..37be1c3b5b7fa 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -938,10 +938,12 @@ fn check_variances_for_type_defn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .map(|(index, _)| Parameter(index as u32)) .collect(); - identify_constrained_generic_params(tcx, - &ty_predicates, - None, - &mut constrained_parameters); + identify_constrained_generic_params( + tcx, + &ty_predicates, + None, + &mut constrained_parameters, + ); for (index, _) in variances.iter().enumerate() { if constrained_parameters.contains(&Parameter(index as u32)) { @@ -949,6 +951,7 @@ fn check_variances_for_type_defn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let param = &hir_generics.params[index]; + match param.name { hir::ParamName::Error => { } _ => report_bivariance(tcx, param.span, param.name.ident().name), @@ -1123,7 +1126,7 @@ fn error_392<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, param_name: ast: -> DiagnosticBuilder<'tcx> { let mut err = struct_span_err!(tcx.sess, span, E0392, "parameter `{}` is never used", param_name); - err.span_label(span, "unused type parameter"); + err.span_label(span, "unused parameter"); err } From ca19ffe13f077c818a3373904308946f48d5aa2e Mon Sep 17 00:00:00 2001 From: topecongiro Date: Thu, 18 Apr 2019 07:42:18 +0900 Subject: [PATCH 07/24] Update rustfmt to 1.2.1 --- Cargo.lock | 17 ++++++++++++++--- src/tools/rustfmt | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc11ff2bbbcc7..95efd04d6f84f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,6 +36,14 @@ dependencies = [ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "annotate-snippets" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ansi_term" version = "0.11.0" @@ -2246,7 +2254,7 @@ dependencies = [ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-workspace-hack 1.0.0", "rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 1.2.0", + "rustfmt-nightly 1.2.1", "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3038,8 +3046,9 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "1.2.0" +version = "1.2.1" dependencies = [ + "annotate-snippets 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "bytecount 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3049,6 +3058,7 @@ dependencies = [ "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "ignore 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3061,7 +3071,7 @@ dependencies = [ "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode_categories 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3987,6 +3997,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" "checksum ammonia 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd4c682378117e4186a492b2252b9537990e1617f44aed9788b9a1149de45477" +"checksum annotate-snippets 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e8bcdcd5b291ce85a78f2b9d082a8de9676c12b1840d386d67bc5eea6f9d2b4e" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arc-swap 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1025aeae2b664ca0ea726a89d574fe8f4e77dd712d443236ad1de00379450cf6" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 09940a70d0a9f..b860feaffccb8 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 09940a70d0a9fabfb4985426aa7d66ca1875c65e +Subproject commit b860feaffccb81199c045e9b1511c2e25825dc0c From 365a48a8bf0d4dbb343889c53f773adad74ef965 Mon Sep 17 00:00:00 2001 From: tyler Date: Wed, 17 Apr 2019 16:38:54 -0700 Subject: [PATCH 08/24] whitelist rtm x86 cpu feature --- src/librustc_codegen_llvm/llvm_util.rs | 1 + src/librustc_typeck/collect.rs | 1 + src/libsyntax/feature_gate.rs | 1 + src/test/ui/target-feature-gate.rs | 1 + src/test/ui/target-feature-gate.stderr | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index 5fea9c8747e0f..0cba15b31668f 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -154,6 +154,7 @@ const X86_WHITELIST: &[(&str, Option<&str>)] = &[ ("popcnt", None), ("rdrand", None), ("rdseed", None), + ("rtm", Some("rtm_target_feature")), ("sha", None), ("sse", None), ("sse2", None), diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 0cd7fe9159493..d601c962fc6af 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2432,6 +2432,7 @@ fn from_target_feature( Some("cmpxchg16b_target_feature") => rust_features.cmpxchg16b_target_feature, Some("adx_target_feature") => rust_features.adx_target_feature, Some("movbe_target_feature") => rust_features.movbe_target_feature, + Some("rtm_target_feature") => rust_features.rtm_target_feature, Some(name) => bug!("unknown target feature gate {}", name), None => true, }; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index c8b020d8c0b03..7bae5ba75719a 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -402,6 +402,7 @@ declare_features! ( (active, adx_target_feature, "1.32.0", Some(44839), None), (active, cmpxchg16b_target_feature, "1.32.0", Some(44839), None), (active, movbe_target_feature, "1.34.0", Some(44839), None), + (active, rtm_target_feature, "1.35.0", Some(44839), None), // Allows macro invocations on modules expressions and statements and // procedural macros to expand to non-items. diff --git a/src/test/ui/target-feature-gate.rs b/src/test/ui/target-feature-gate.rs index 84300301b7629..8f3a52ba5d677 100644 --- a/src/test/ui/target-feature-gate.rs +++ b/src/test/ui/target-feature-gate.rs @@ -23,6 +23,7 @@ // gate-test-adx_target_feature // gate-test-cmpxchg16b_target_feature // gate-test-movbe_target_feature +// gate-test-rtm_target_feature // min-llvm-version 6.0 #[target_feature(enable = "avx512bw")] diff --git a/src/test/ui/target-feature-gate.stderr b/src/test/ui/target-feature-gate.stderr index 155298e5062b5..e142125225fb4 100644 --- a/src/test/ui/target-feature-gate.stderr +++ b/src/test/ui/target-feature-gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `avx512bw` is currently unstable - --> $DIR/target-feature-gate.rs:28:18 + --> $DIR/target-feature-gate.rs:29:18 | LL | #[target_feature(enable = "avx512bw")] | ^^^^^^^^^^^^^^^^^^^ From 007b40be01ca4e0eb0bca875e9134e4f87c9cd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 17 Apr 2019 18:30:26 -0700 Subject: [PATCH 09/24] Point at try `?` on errors affecting the err match arm of the desugared code --- src/librustc/hir/lowering.rs | 22 +++++++++++++------ src/test/ui/issues/issue-32709.stderr | 4 ++-- .../ui/try-block/try-block-bad-type.stderr | 4 ++-- src/test/ui/try-on-option.stderr | 4 ++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index a8269bb139570..42ad571cf2832 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -4685,6 +4685,14 @@ impl<'a> LoweringContext<'a> { Symbol::intern("try_trait") ].into()), ); + let try_span = self.sess.source_map().end_point(e.span); + let try_span = self.mark_span_with_reason( + CompilerDesugaringKind::QuestionMark, + try_span, + Some(vec![ + Symbol::intern("try_trait") + ].into()), + ); // `Try::into_result()` let discr = { @@ -4729,14 +4737,14 @@ impl<'a> LoweringContext<'a> { // return Try::from_error(From::from(err)),` let err_arm = { let err_ident = self.str_to_ident("err"); - let (err_local, err_local_nid) = self.pat_ident(e.span, err_ident); + let (err_local, err_local_nid) = self.pat_ident(try_span, err_ident); let from_expr = { let path = &["convert", "From", "from"]; let from = P(self.expr_std_path( - e.span, path, None, ThinVec::new())); - let err_expr = self.expr_ident(e.span, err_ident, err_local_nid); + try_span, path, None, ThinVec::new())); + let err_expr = self.expr_ident(try_span, err_ident, err_local_nid); - self.expr_call(e.span, from, hir_vec![err_expr]) + self.expr_call(try_span, from, hir_vec![err_expr]) }; let from_err_expr = self.wrap_in_try_constructor("from_error", from_expr, unstable_span); @@ -4745,7 +4753,7 @@ impl<'a> LoweringContext<'a> { let ret_expr = if let Some(catch_node) = catch_scope { let target_id = Ok(self.lower_node_id(catch_node).hir_id); P(self.expr( - e.span, + try_span, hir::ExprKind::Break( hir::Destination { label: None, @@ -4756,10 +4764,10 @@ impl<'a> LoweringContext<'a> { thin_attrs, )) } else { - P(self.expr(e.span, hir::ExprKind::Ret(Some(from_err_expr)), thin_attrs)) + P(self.expr(try_span, hir::ExprKind::Ret(Some(from_err_expr)), thin_attrs)) }; - let err_pat = self.pat_err(e.span, err_local); + let err_pat = self.pat_err(try_span, err_local); self.arm(hir_vec![err_pat], ret_expr) }; diff --git a/src/test/ui/issues/issue-32709.stderr b/src/test/ui/issues/issue-32709.stderr index 9127c7546582a..4a37e0a2e5282 100644 --- a/src/test/ui/issues/issue-32709.stderr +++ b/src/test/ui/issues/issue-32709.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `(): std::convert::From<{integer}>` is not satisfied - --> $DIR/issue-32709.rs:4:5 + --> $DIR/issue-32709.rs:4:11 | LL | Err(5)?; - | ^^^^^^^ the trait `std::convert::From<{integer}>` is not implemented for `()` + | ^ the trait `std::convert::From<{integer}>` is not implemented for `()` | = note: required by `std::convert::From::from` diff --git a/src/test/ui/try-block/try-block-bad-type.stderr b/src/test/ui/try-block/try-block-bad-type.stderr index 07e7149793c14..a39c8cfba12aa 100644 --- a/src/test/ui/try-block/try-block-bad-type.stderr +++ b/src/test/ui/try-block/try-block-bad-type.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `i32: std::convert::From<&str>` is not satisfied - --> $DIR/try-block-bad-type.rs:7:9 + --> $DIR/try-block-bad-type.rs:7:16 | LL | Err("")?; - | ^^^^^^^^ the trait `std::convert::From<&str>` is not implemented for `i32` + | ^ the trait `std::convert::From<&str>` is not implemented for `i32` | = help: the following implementations were found: > diff --git a/src/test/ui/try-on-option.stderr b/src/test/ui/try-on-option.stderr index 7dfa1a7d3a0c0..3e081d0376649 100644 --- a/src/test/ui/try-on-option.stderr +++ b/src/test/ui/try-on-option.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `(): std::convert::From` is not satisfied - --> $DIR/try-on-option.rs:7:5 + --> $DIR/try-on-option.rs:7:6 | LL | x?; - | ^^ the trait `std::convert::From` is not implemented for `()` + | ^ the trait `std::convert::From` is not implemented for `()` | = note: required by `std::convert::From::from` From 1e99b2ec9dc60dc01a413118051d273ed7688c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 17 Apr 2019 19:50:50 -0700 Subject: [PATCH 10/24] Give custom error for E0277 on `?` error case --- src/librustc/traits/error_reporting.rs | 12 ++++++++++++ src/test/ui/issues/issue-32709.stderr | 2 +- src/test/ui/try-block/try-block-bad-type.rs | 2 +- src/test/ui/try-block/try-block-bad-type.stderr | 2 +- src/test/ui/try-on-option.rs | 4 ++-- src/test/ui/try-on-option.stderr | 2 +- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 5b5a7cc9ed85b..14c81a806c259 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -638,6 +638,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let OnUnimplementedNote { message, label, note } = self.on_unimplemented_note(trait_ref, obligation); let have_alt_message = message.is_some() || label.is_some(); + let is_try = self.tcx.sess.source_map().span_to_snippet(span) + .map(|s| &s == "?") + .unwrap_or(false); + let is_from = format!("{}", trait_ref).starts_with("std::convert::From<"); + let message = if is_try && is_from { + Some(format!( + "`?` couldn't convert the error to `{}`", + trait_ref.self_ty(), + )) + } else { + message + }; let mut err = struct_span_err!( self.tcx.sess, diff --git a/src/test/ui/issues/issue-32709.stderr b/src/test/ui/issues/issue-32709.stderr index 4a37e0a2e5282..84cca5b20af47 100644 --- a/src/test/ui/issues/issue-32709.stderr +++ b/src/test/ui/issues/issue-32709.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): std::convert::From<{integer}>` is not satisfied +error[E0277]: `?` couldn't convert the error to `()` --> $DIR/issue-32709.rs:4:11 | LL | Err(5)?; diff --git a/src/test/ui/try-block/try-block-bad-type.rs b/src/test/ui/try-block/try-block-bad-type.rs index 0e297dd8ff16b..4dfc8e6a2fca4 100644 --- a/src/test/ui/try-block/try-block-bad-type.rs +++ b/src/test/ui/try-block/try-block-bad-type.rs @@ -4,7 +4,7 @@ pub fn main() { let res: Result = try { - Err("")?; //~ ERROR the trait bound `i32: std::convert::From<&str>` is not satisfied + Err("")?; //~ ERROR `?` couldn't convert the error 5 }; diff --git a/src/test/ui/try-block/try-block-bad-type.stderr b/src/test/ui/try-block/try-block-bad-type.stderr index a39c8cfba12aa..13593c4e8e72d 100644 --- a/src/test/ui/try-block/try-block-bad-type.stderr +++ b/src/test/ui/try-block/try-block-bad-type.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `i32: std::convert::From<&str>` is not satisfied +error[E0277]: `?` couldn't convert the error to `i32` --> $DIR/try-block-bad-type.rs:7:16 | LL | Err("")?; diff --git a/src/test/ui/try-on-option.rs b/src/test/ui/try-on-option.rs index 9c8e8b33ad68a..5d94cee8e3721 100644 --- a/src/test/ui/try-on-option.rs +++ b/src/test/ui/try-on-option.rs @@ -4,12 +4,12 @@ fn main() {} fn foo() -> Result { let x: Option = None; - x?; //~ the trait bound + x?; //~ ERROR `?` couldn't convert the error Ok(22) } fn bar() -> u32 { let x: Option = None; - x?; //~ the `?` operator + x?; //~ ERROR the `?` operator 22 } diff --git a/src/test/ui/try-on-option.stderr b/src/test/ui/try-on-option.stderr index 3e081d0376649..4465fbe14b75c 100644 --- a/src/test/ui/try-on-option.stderr +++ b/src/test/ui/try-on-option.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): std::convert::From` is not satisfied +error[E0277]: `?` couldn't convert the error to `()` --> $DIR/try-on-option.rs:7:6 | LL | x?; From 379c5412efae5bc86e483999c0f14e329e4ea6e2 Mon Sep 17 00:00:00 2001 From: Jan Nils Ferner Date: Wed, 17 Apr 2019 16:02:17 +0200 Subject: [PATCH 11/24] Simplify the returning of a Result a bit --- src/libstd/fs.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index dea198d8c9178..1772879d01362 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -901,8 +901,7 @@ impl OpenOptions { } fn _open(&self, path: &Path) -> io::Result { - let inner = fs_imp::File::open(path, &self.0)?; - Ok(File { inner }) + fs_imp::File::open(path, &self.0).map(|inner| File { inner }) } } From be69785ea210280e4aaeccbb28f34e153e86c2a0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 18 Apr 2019 14:58:38 +0300 Subject: [PATCH 12/24] Use more realistic example for thread builder Stack size of 10 **bytes** does not make any sense: the minimal possible stack size is greater anyway. --- src/libstd/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index c59226e0c0b98..fce28ffd9c388 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -269,7 +269,7 @@ impl Builder { /// /// let builder = thread::Builder::new() /// .name("foo".into()) - /// .stack_size(10); + /// .stack_size(32 * 1024); /// /// let handler = builder.spawn(|| { /// // thread code From 553ec5d3eb8af66f86599b0abb0efda74393921e Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 17 Apr 2019 12:53:02 +0200 Subject: [PATCH 13/24] Update run-make PGO test to new commandline syntax. --- src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile index dc52e91317a5a..e22fac25cf7a4 100644 --- a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile @@ -2,7 +2,7 @@ all: ifeq ($(PROFILER_SUPPORT),1) - $(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)/test.profraw" --emit=llvm-ir test.rs + $(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)" --emit=llvm-ir test.rs # We expect symbols starting with "__llvm_profile_". $(CGREP) "__llvm_profile_" < $(TMPDIR)/test.ll # We do NOT expect the "__imp_" version of these symbols. From 4269be382fdf1ac92665234502bab33ef9c0d8fa Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 18 Apr 2019 15:21:05 +0200 Subject: [PATCH 14/24] Prefix PROFILER_SUPPORT and SANITIZER_SUPPORT test env vars with RUSTC_ to make things clearer. --- src/bootstrap/test.rs | 4 ++-- src/test/run-make-fulldeps/pgo-gen-lto/Makefile | 2 +- src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile | 2 +- src/test/run-make-fulldeps/pgo-gen/Makefile | 2 +- src/test/run-make-fulldeps/profile/Makefile | 2 +- src/test/run-make-fulldeps/sanitizer-address/Makefile | 4 ++-- src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile | 2 +- src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile | 2 +- .../run-make-fulldeps/sanitizer-invalid-cratetype/Makefile | 4 ++-- src/test/run-make-fulldeps/sanitizer-leak/Makefile | 2 +- src/test/run-make-fulldeps/sanitizer-memory/Makefile | 2 +- src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile | 4 ++-- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index c552f607960b4..a443b7b5863e5 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1268,11 +1268,11 @@ impl Step for Compiletest { builder.add_rust_test_threads(&mut cmd); if builder.config.sanitizers { - cmd.env("SANITIZER_SUPPORT", "1"); + cmd.env("RUSTC_SANITIZER_SUPPORT", "1"); } if builder.config.profiler { - cmd.env("PROFILER_SUPPORT", "1"); + cmd.env("RUSTC_PROFILER_SUPPORT", "1"); } cmd.env("RUST_TEST_TMPDIR", builder.out.join("tmp")); diff --git a/src/test/run-make-fulldeps/pgo-gen-lto/Makefile b/src/test/run-make-fulldeps/pgo-gen-lto/Makefile index 7c19961b1e420..d6e45d838535f 100644 --- a/src/test/run-make-fulldeps/pgo-gen-lto/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-lto/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: -ifeq ($(PROFILER_SUPPORT),1) +ifeq ($(RUSTC_PROFILER_SUPPORT),1) $(RUSTC) -Copt-level=3 -Clto=fat -Z pgo-gen="$(TMPDIR)" test.rs $(call RUN,test) || exit 1 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1) diff --git a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile index e22fac25cf7a4..bfb57bfeefe5c 100644 --- a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: -ifeq ($(PROFILER_SUPPORT),1) +ifeq ($(RUSTC_PROFILER_SUPPORT),1) $(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)" --emit=llvm-ir test.rs # We expect symbols starting with "__llvm_profile_". $(CGREP) "__llvm_profile_" < $(TMPDIR)/test.ll diff --git a/src/test/run-make-fulldeps/pgo-gen/Makefile b/src/test/run-make-fulldeps/pgo-gen/Makefile index 0469c4443d85a..28294f6e1d82d 100644 --- a/src/test/run-make-fulldeps/pgo-gen/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: -ifeq ($(PROFILER_SUPPORT),1) +ifeq ($(RUSTC_PROFILER_SUPPORT),1) $(RUSTC) -g -Z pgo-gen="$(TMPDIR)" test.rs $(call RUN,test) || exit 1 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1) diff --git a/src/test/run-make-fulldeps/profile/Makefile b/src/test/run-make-fulldeps/profile/Makefile index 7300bfc955363..880bc38f408e6 100644 --- a/src/test/run-make-fulldeps/profile/Makefile +++ b/src/test/run-make-fulldeps/profile/Makefile @@ -1,7 +1,7 @@ -include ../tools.mk all: -ifeq ($(PROFILER_SUPPORT),1) +ifeq ($(RUSTC_PROFILER_SUPPORT),1) $(RUSTC) -g -Z profile test.rs $(call RUN,test) || exit 1 [ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1) diff --git a/src/test/run-make-fulldeps/sanitizer-address/Makefile b/src/test/run-make-fulldeps/sanitizer-address/Makefile index 207615bfbd5c6..5f3486a495be2 100644 --- a/src/test/run-make-fulldeps/sanitizer-address/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-address/Makefile @@ -5,11 +5,11 @@ LOG := $(TMPDIR)/log.txt # NOTE the address sanitizer only supports x86_64 linux and macOS ifeq ($(TARGET),x86_64-apple-darwin) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) +ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) EXTRA_RUSTFLAG=-C rpath else ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) +ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) # Apparently there are very specific Linux kernels, notably the one that's # currently on Travis CI, which contain a buggy commit that triggers failures in diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile index 4b7fece36d92a..bb323d2a6341a 100644 --- a/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile @@ -8,7 +8,7 @@ LOG := $(TMPDIR)/log.txt # is correctly detected. ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) +ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) # See comment in sanitizer-address/Makefile for why this is here EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile index 97f6172142224..77f119d889967 100644 --- a/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile @@ -8,7 +8,7 @@ LOG := $(TMPDIR)/log.txt # is correctly detected. ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) +ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) # See comment in sanitizer-address/Makefile for why this is here EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile index dc37c0d0bc946..ac49e519c7b96 100644 --- a/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile @@ -3,11 +3,11 @@ # NOTE the address sanitizer only supports x86_64 linux and macOS ifeq ($(TARGET),x86_64-apple-darwin) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) +ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) EXTRA_RUSTFLAG=-C rpath else ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) +ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) EXTRA_RUSTFLAG= endif endif diff --git a/src/test/run-make-fulldeps/sanitizer-leak/Makefile b/src/test/run-make-fulldeps/sanitizer-leak/Makefile index 0f3c18f9293f5..e84e1cbd2b61b 100644 --- a/src/test/run-make-fulldeps/sanitizer-leak/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-leak/Makefile @@ -6,7 +6,7 @@ # FIXME(#46126) ThinLTO for libstd broke this test all: -ifdef SANITIZER_SUPPORT +ifdef RUSTC_SANITIZER_SUPPORT $(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) librustc_lsan $(TMPDIR)/leak 2>&1 | $(CGREP) 'detected memory leaks' endif diff --git a/src/test/run-make-fulldeps/sanitizer-memory/Makefile b/src/test/run-make-fulldeps/sanitizer-memory/Makefile index 718d9637ea06d..aca3591555cfd 100644 --- a/src/test/run-make-fulldeps/sanitizer-memory/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-memory/Makefile @@ -4,7 +4,7 @@ # only-x86_64 all: -ifdef SANITIZER_SUPPORT +ifdef RUSTC_SANITIZER_SUPPORT $(RUSTC) -g -Z sanitizer=memory -Z print-link-args uninit.rs | $(CGREP) librustc_msan $(TMPDIR)/uninit 2>&1 | $(CGREP) use-of-uninitialized-value endif diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile index 2b444d667bfa3..7a1b9509f4f98 100644 --- a/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile @@ -1,11 +1,11 @@ -include ../tools.mk # This test builds a staticlib, then an executable that links to it. -# The staticlib and executable both are compiled with address sanitizer, +# The staticlib and executable both are compiled with address sanitizer, # and we assert that a fault in the staticlib is correctly detected. ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) +ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) EXTRA_RUSTFLAG= endif From 227be657cdeee2259199b24fb9691f7f8994c5e6 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 18 Apr 2019 15:31:46 +0200 Subject: [PATCH 15/24] compiletest: Allow for tests requiring profiler-rt or sanitizer-rt support. --- src/tools/compiletest/src/header.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 64882c603bad3..fb6ada89171ab 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -88,6 +88,9 @@ impl EarlyProps { } } + let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some(); + let rustc_has_sanitizer_support = env::var_os("RUSTC_SANITIZER_SUPPORT").is_some(); + iter_header(testfile, None, &mut |ln| { // we should check if any only- exists and if it exists // and does not matches the current platform, skip the test @@ -116,6 +119,16 @@ impl EarlyProps { config.parse_needs_matching_clang(ln) { props.ignore = Ignore::Ignore; } + + if !rustc_has_profiler_support && + config.parse_needs_profiler_support(ln) { + props.ignore = Ignore::Ignore; + } + + if !rustc_has_sanitizer_support && + config.parse_needs_sanitizer_support(ln) { + props.ignore = Ignore::Ignore; + } } if (config.mode == common::DebugInfoGdb || config.mode == common::DebugInfoBoth) && @@ -748,6 +761,14 @@ impl Config { self.parse_name_directive(line, "needs-matching-clang") } + fn parse_needs_profiler_support(&self, line: &str) -> bool { + self.parse_name_directive(line, "needs-profiler-support") + } + + fn parse_needs_sanitizer_support(&self, line: &str) -> bool { + self.parse_name_directive(line, "needs-sanitizer-support") + } + /// Parses a name-value directive which contains config-specific information, e.g., `ignore-x86` /// or `normalize-stderr-32bit`. fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> ParsedNameDirective { From e2acaee8bb364197af2ab197f0f641e8f988ae04 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 16 Apr 2019 13:54:01 +0200 Subject: [PATCH 16/24] Add codegen test that makes sure PGO instrumentation is emitted as expected. --- src/test/codegen/pgo-instrumentation.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/codegen/pgo-instrumentation.rs diff --git a/src/test/codegen/pgo-instrumentation.rs b/src/test/codegen/pgo-instrumentation.rs new file mode 100644 index 0000000000000..8493ef565d888 --- /dev/null +++ b/src/test/codegen/pgo-instrumentation.rs @@ -0,0 +1,20 @@ +// Test that `-Zpgo-gen` creates expected instrumentation artifacts in LLVM IR. + +// needs-profiler-support +// compile-flags: -Z pgo-gen -Ccodegen-units=1 + +// CHECK: @__llvm_profile_raw_version = +// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global +// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global +// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}main{{.*}} = private global +// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}main{{.*}} = private global +// CHECK: @__llvm_profile_filename = {{.*}}"default_%m.profraw\00"{{.*}} + +#[inline(never)] +fn some_function() { + +} + +fn main() { + some_function(); +} From d98afc51dcfe254d25925c4b675a6099dede4f47 Mon Sep 17 00:00:00 2001 From: Nathan Kleyn Date: Thu, 18 Apr 2019 14:48:15 +0100 Subject: [PATCH 17/24] Fix small errors in docs for `rchunks_exact` and `rchunks_exact_mut`. The documentation for `rchunks_exact` said it started at the beginning of the slice, bit it actually starts at the end of the slice. In addition, there were a couple of "of the slice of the slice" duplicate phrases going on for `rchunks_exact` and `rchunks_exact_mut`. This fixes #60068. --- src/libcore/slice/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 122ef9c79c276..dc1194d1b2d31 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -838,7 +838,7 @@ impl [T] { } /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the - /// beginning of the slice. + /// end of the slice. /// /// The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the /// slice, then the last up to `chunk_size-1` elements will be omitted and can be retrieved @@ -849,7 +849,7 @@ impl [T] { /// /// See [`rchunks`] for a variant of this iterator that also returns the remainder as a smaller /// chunk, and [`chunks_exact`] for the same iterator but starting at the beginning of the - /// slice of the slice. + /// slice. /// /// # Panics /// @@ -890,7 +890,7 @@ impl [T] { /// /// See [`rchunks_mut`] for a variant of this iterator that also returns the remainder as a /// smaller chunk, and [`chunks_exact_mut`] for the same iterator but starting at the beginning - /// of the slice of the slice. + /// of the slice. /// /// # Panics /// From cc77087d6f6143927d9fe98a07ca3d12b26ce474 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 18 Apr 2019 15:49:41 +0200 Subject: [PATCH 18/24] Use new `needs-(profiler|sanitizer)-support` compiletest directive to clean up some run-make tests. --- src/test/run-make-fulldeps/pgo-gen-lto/Makefile | 4 ++-- src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile | 4 ++-- src/test/run-make-fulldeps/pgo-gen/Makefile | 4 ++-- src/test/run-make-fulldeps/profile/Makefile | 4 ++-- src/test/run-make-fulldeps/sanitizer-address/Makefile | 6 ++---- src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile | 5 ++--- src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile | 6 ++---- .../run-make-fulldeps/sanitizer-invalid-cratetype/Makefile | 6 ++---- src/test/run-make-fulldeps/sanitizer-leak/Makefile | 3 +-- src/test/run-make-fulldeps/sanitizer-memory/Makefile | 3 +-- .../run-make-fulldeps/sanitizer-staticlib-link/Makefile | 5 ++--- 11 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/test/run-make-fulldeps/pgo-gen-lto/Makefile b/src/test/run-make-fulldeps/pgo-gen-lto/Makefile index d6e45d838535f..48181bcbdc6d3 100644 --- a/src/test/run-make-fulldeps/pgo-gen-lto/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-lto/Makefile @@ -1,8 +1,8 @@ +# needs-profiler-support + -include ../tools.mk all: -ifeq ($(RUSTC_PROFILER_SUPPORT),1) $(RUSTC) -Copt-level=3 -Clto=fat -Z pgo-gen="$(TMPDIR)" test.rs $(call RUN,test) || exit 1 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1) -endif diff --git a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile index bfb57bfeefe5c..20977edb88e87 100644 --- a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile @@ -1,11 +1,11 @@ +# needs-profiler-support + -include ../tools.mk all: -ifeq ($(RUSTC_PROFILER_SUPPORT),1) $(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)" --emit=llvm-ir test.rs # We expect symbols starting with "__llvm_profile_". $(CGREP) "__llvm_profile_" < $(TMPDIR)/test.ll # We do NOT expect the "__imp_" version of these symbols. $(CGREP) -v "__imp___llvm_profile_" < $(TMPDIR)/test.ll # 64 bit $(CGREP) -v "__imp____llvm_profile_" < $(TMPDIR)/test.ll # 32 bit -endif diff --git a/src/test/run-make-fulldeps/pgo-gen/Makefile b/src/test/run-make-fulldeps/pgo-gen/Makefile index 28294f6e1d82d..ce44c10a7c2d2 100644 --- a/src/test/run-make-fulldeps/pgo-gen/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen/Makefile @@ -1,8 +1,8 @@ +# needs-profiler-support + -include ../tools.mk all: -ifeq ($(RUSTC_PROFILER_SUPPORT),1) $(RUSTC) -g -Z pgo-gen="$(TMPDIR)" test.rs $(call RUN,test) || exit 1 [ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1) -endif diff --git a/src/test/run-make-fulldeps/profile/Makefile b/src/test/run-make-fulldeps/profile/Makefile index 880bc38f408e6..c12712590e48f 100644 --- a/src/test/run-make-fulldeps/profile/Makefile +++ b/src/test/run-make-fulldeps/profile/Makefile @@ -1,9 +1,9 @@ +# needs-profiler-support + -include ../tools.mk all: -ifeq ($(RUSTC_PROFILER_SUPPORT),1) $(RUSTC) -g -Z profile test.rs $(call RUN,test) || exit 1 [ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1) [ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1) -endif diff --git a/src/test/run-make-fulldeps/sanitizer-address/Makefile b/src/test/run-make-fulldeps/sanitizer-address/Makefile index 5f3486a495be2..51d8a4a947adc 100644 --- a/src/test/run-make-fulldeps/sanitizer-address/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-address/Makefile @@ -1,3 +1,5 @@ +# needs-sanitizer-support + -include ../tools.mk LOG := $(TMPDIR)/log.txt @@ -5,11 +7,9 @@ LOG := $(TMPDIR)/log.txt # NOTE the address sanitizer only supports x86_64 linux and macOS ifeq ($(TARGET),x86_64-apple-darwin) -ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) EXTRA_RUSTFLAG=-C rpath else ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) # Apparently there are very specific Linux kernels, notably the one that's # currently on Travis CI, which contain a buggy commit that triggers failures in @@ -23,7 +23,5 @@ endif endif all: -ifeq ($(ASAN_SUPPORT),1) $(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan $(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile index bb323d2a6341a..36cde355468be 100644 --- a/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile @@ -1,3 +1,5 @@ +# needs-sanitizer-support + -include ../tools.mk LOG := $(TMPDIR)/log.txt @@ -8,15 +10,12 @@ LOG := $(TMPDIR)/log.txt # is correctly detected. ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) # See comment in sanitizer-address/Makefile for why this is here EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic endif all: -ifeq ($(ASAN_SUPPORT),1) $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile index 77f119d889967..b382ff5e7b24f 100644 --- a/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile @@ -1,3 +1,5 @@ +# needs-sanitizer-support + -include ../tools.mk LOG := $(TMPDIR)/log.txt @@ -8,15 +10,11 @@ LOG := $(TMPDIR)/log.txt # is correctly detected. ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) - # See comment in sanitizer-address/Makefile for why this is here EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic endif all: -ifeq ($(ASAN_SUPPORT),1) $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile index ac49e519c7b96..9581ac565ea02 100644 --- a/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile @@ -1,18 +1,16 @@ +# needs-sanitizer-support + -include ../tools.mk # NOTE the address sanitizer only supports x86_64 linux and macOS ifeq ($(TARGET),x86_64-apple-darwin) -ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) EXTRA_RUSTFLAG=-C rpath else ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) EXTRA_RUSTFLAG= endif endif all: -ifeq ($(ASAN_SUPPORT),1) $(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | $(CGREP) '-Z sanitizer' -endif diff --git a/src/test/run-make-fulldeps/sanitizer-leak/Makefile b/src/test/run-make-fulldeps/sanitizer-leak/Makefile index e84e1cbd2b61b..101e8272ab91e 100644 --- a/src/test/run-make-fulldeps/sanitizer-leak/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-leak/Makefile @@ -1,12 +1,11 @@ -include ../tools.mk +# needs-sanitizer-support # only-linux # only-x86_64 # ignore-test # FIXME(#46126) ThinLTO for libstd broke this test all: -ifdef RUSTC_SANITIZER_SUPPORT $(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) librustc_lsan $(TMPDIR)/leak 2>&1 | $(CGREP) 'detected memory leaks' -endif diff --git a/src/test/run-make-fulldeps/sanitizer-memory/Makefile b/src/test/run-make-fulldeps/sanitizer-memory/Makefile index aca3591555cfd..b3376f8a72358 100644 --- a/src/test/run-make-fulldeps/sanitizer-memory/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-memory/Makefile @@ -1,10 +1,9 @@ -include ../tools.mk +# needs-sanitizer-support # only-linux # only-x86_64 all: -ifdef RUSTC_SANITIZER_SUPPORT $(RUSTC) -g -Z sanitizer=memory -Z print-link-args uninit.rs | $(CGREP) librustc_msan $(TMPDIR)/uninit 2>&1 | $(CGREP) use-of-uninitialized-value -endif diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile index 7a1b9509f4f98..8fa08688fdd71 100644 --- a/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile @@ -1,3 +1,5 @@ +# needs-sanitizer-support + -include ../tools.mk # This test builds a staticlib, then an executable that links to it. @@ -5,14 +7,11 @@ # and we assert that a fault in the staticlib is correctly detected. ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT) EXTRA_RUSTFLAG= endif all: -ifeq ($(ASAN_SUPPORT),1) $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif From 08efbac758aa75f710b8018d8974bde5c7a149c1 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Fri, 12 Apr 2019 14:48:41 +0200 Subject: [PATCH 19/24] Implement event filtering for self-profiler. --- src/librustc/session/config.rs | 2 + src/librustc/session/mod.rs | 2 +- src/librustc/util/profiling.rs | 121 +++++++++++++++++++++++++-------- 3 files changed, 97 insertions(+), 28 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index dc1ceaf69f013..97a1c83dbffb6 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1467,6 +1467,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "inject the given attribute in the crate"), self_profile: bool = (false, parse_bool, [UNTRACKED], "run the self profiler and output the raw event data"), + self_profile_events: Option> = (None, parse_opt_comma_list, [UNTRACKED], + "specifies which kinds of events get recorded by the self profiler"), emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], "emits a section containing stack size metadata"), plt: Option = (None, parse_opt_bool, [TRACKED], diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index eed516a438175..eecd5cba6d358 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1138,7 +1138,7 @@ fn build_session_( ) -> Session { let self_profiler = if sopts.debugging_opts.self_profile { - let profiler = SelfProfiler::new(); + let profiler = SelfProfiler::new(&sopts.debugging_opts.self_profile_events); match profiler { Ok(profiler) => { crate::ty::query::QueryName::register_with_profiler(&profiler); diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs index aabf9a401c690..585970e64df8d 100644 --- a/src/librustc/util/profiling.rs +++ b/src/librustc/util/profiling.rs @@ -27,26 +27,42 @@ pub enum ProfileCategory { Other, } -#[derive(Clone, Debug, Eq, PartialEq)] -pub enum ProfilerEvent { - QueryStart { query_name: &'static str, category: ProfileCategory, time: u64 }, - QueryEnd { query_name: &'static str, category: ProfileCategory, time: u64 }, - GenericActivityStart { category: ProfileCategory, label: Cow<'static, str>, time: u64 }, - GenericActivityEnd { category: ProfileCategory, label: Cow<'static, str>, time: u64 }, - IncrementalLoadResultStart { query_name: &'static str, time: u64 }, - IncrementalLoadResultEnd { query_name: &'static str, time: u64 }, - QueryCacheHit { query_name: &'static str, category: ProfileCategory, time: u64 }, - QueryCount { query_name: &'static str, category: ProfileCategory, count: usize, time: u64 }, - QueryBlockedStart { query_name: &'static str, category: ProfileCategory, time: u64 }, - QueryBlockedEnd { query_name: &'static str, category: ProfileCategory, time: u64 }, +bitflags! { + struct EventFilter: u32 { + const GENERIC_ACTIVITIES = 1 << 0; + const QUERY_PROVIDERS = 1 << 1; + const QUERY_CACHE_HITS = 1 << 2; + const QUERY_BLOCKED = 1 << 3; + const INCR_CACHE_LOADS = 1 << 4; + + const DEFAULT = Self::GENERIC_ACTIVITIES.bits | + Self::QUERY_PROVIDERS.bits | + Self::QUERY_BLOCKED.bits | + Self::INCR_CACHE_LOADS.bits; + + // empty() and none() aren't const-fns unfortunately + const NONE = 0; + const ALL = !Self::NONE.bits; + } } +const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[ + ("none", EventFilter::NONE), + ("all", EventFilter::ALL), + ("generic-activity", EventFilter::GENERIC_ACTIVITIES), + ("query-provider", EventFilter::QUERY_PROVIDERS), + ("query-cache-hit", EventFilter::QUERY_CACHE_HITS), + ("query-blocked" , EventFilter::QUERY_BLOCKED), + ("incr-cache-load", EventFilter::INCR_CACHE_LOADS), +]; + fn thread_id_to_u64(tid: ThreadId) -> u64 { unsafe { mem::transmute::(tid) } } pub struct SelfProfiler { profiler: Profiler, + event_filter_mask: EventFilter, query_event_kind: StringId, generic_activity_event_kind: StringId, incremental_load_result_event_kind: StringId, @@ -55,7 +71,7 @@ pub struct SelfProfiler { } impl SelfProfiler { - pub fn new() -> Result> { + pub fn new(event_filters: &Option>) -> Result> { let filename = format!("pid-{}.rustc_profile", process::id()); let path = std::path::Path::new(&filename); let profiler = Profiler::new(path)?; @@ -66,8 +82,38 @@ impl SelfProfiler { let query_blocked_event_kind = profiler.alloc_string("QueryBlocked"); let query_cache_hit_event_kind = profiler.alloc_string("QueryCacheHit"); + let mut event_filter_mask = EventFilter::empty(); + + if let Some(ref event_filters) = *event_filters { + let mut unknown_events = vec![]; + for item in event_filters { + if let Some(&(_, mask)) = EVENT_FILTERS_BY_NAME.iter() + .find(|&(name, _)| name == item) { + event_filter_mask |= mask; + } else { + unknown_events.push(item.clone()); + } + } + + // Warn about any unknown event names + if unknown_events.len() > 0 { + unknown_events.sort(); + unknown_events.dedup(); + + warn!("Unknown self-profiler events specified: {}. Available options are: {}.", + unknown_events.join(", "), + EVENT_FILTERS_BY_NAME.iter() + .map(|&(name, _)| name.to_string()) + .collect::>() + .join(", ")); + } + } else { + event_filter_mask = EventFilter::DEFAULT; + } + Ok(SelfProfiler { profiler, + event_filter_mask, query_event_kind, generic_activity_event_kind, incremental_load_result_event_kind, @@ -86,7 +132,6 @@ impl SelfProfiler { pub fn register_query_name(&self, query_name: QueryName) { let id = SelfProfiler::get_query_name_string_id(query_name); - self.profiler.alloc_string_with_reserved_id(id, query_name.as_str()); } @@ -95,7 +140,9 @@ impl SelfProfiler { &self, label: impl Into>, ) { - self.record(&label.into(), self.generic_activity_event_kind, TimestampKind::Start); + if self.event_filter_mask.contains(EventFilter::GENERIC_ACTIVITIES) { + self.record(&label.into(), self.generic_activity_event_kind, TimestampKind::Start); + } } #[inline] @@ -103,46 +150,66 @@ impl SelfProfiler { &self, label: impl Into>, ) { - self.record(&label.into(), self.generic_activity_event_kind, TimestampKind::End); + if self.event_filter_mask.contains(EventFilter::GENERIC_ACTIVITIES) { + self.record(&label.into(), self.generic_activity_event_kind, TimestampKind::End); + } } #[inline] pub fn record_query_hit(&self, query_name: QueryName) { - self.record_query(query_name, self.query_cache_hit_event_kind, TimestampKind::Instant); + if self.event_filter_mask.contains(EventFilter::QUERY_CACHE_HITS) { + self.record_query(query_name, self.query_cache_hit_event_kind, TimestampKind::Instant); + } } #[inline] pub fn start_query(&self, query_name: QueryName) { - self.record_query(query_name, self.query_event_kind, TimestampKind::Start); + if self.event_filter_mask.contains(EventFilter::QUERY_PROVIDERS) { + self.record_query(query_name, self.query_event_kind, TimestampKind::Start); + } } #[inline] pub fn end_query(&self, query_name: QueryName) { - self.record_query(query_name, self.query_event_kind, TimestampKind::End); + if self.event_filter_mask.contains(EventFilter::QUERY_PROVIDERS) { + self.record_query(query_name, self.query_event_kind, TimestampKind::End); + } } #[inline] pub fn incremental_load_result_start(&self, query_name: QueryName) { - self.record_query( - query_name, - self.incremental_load_result_event_kind, - TimestampKind::Start - ); + if self.event_filter_mask.contains(EventFilter::INCR_CACHE_LOADS) { + self.record_query( + query_name, + self.incremental_load_result_event_kind, + TimestampKind::Start + ); + } } #[inline] pub fn incremental_load_result_end(&self, query_name: QueryName) { - self.record_query(query_name, self.incremental_load_result_event_kind, TimestampKind::End); + if self.event_filter_mask.contains(EventFilter::INCR_CACHE_LOADS) { + self.record_query( + query_name, + self.incremental_load_result_event_kind, + TimestampKind::End + ); + } } #[inline] pub fn query_blocked_start(&self, query_name: QueryName) { - self.record_query(query_name, self.query_blocked_event_kind, TimestampKind::Start); + if self.event_filter_mask.contains(EventFilter::QUERY_BLOCKED) { + self.record_query(query_name, self.query_blocked_event_kind, TimestampKind::Start); + } } #[inline] pub fn query_blocked_end(&self, query_name: QueryName) { - self.record_query(query_name, self.query_blocked_event_kind, TimestampKind::End); + if self.event_filter_mask.contains(EventFilter::QUERY_BLOCKED) { + self.record_query(query_name, self.query_blocked_event_kind, TimestampKind::End); + } } #[inline] From ae1f2b571ad782f1bd80fd776b6c34e057f6625e Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Thu, 18 Apr 2019 18:06:39 +0200 Subject: [PATCH 20/24] Update miri --- src/tools/miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri b/src/tools/miri index ae9e9cb47c7b7..7d7cf4d42e414 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit ae9e9cb47c7b79d8bb29fab90929bd9b3606348a +Subproject commit 7d7cf4d42e41437f5a5b04a6b8dd567f330ae6ee From 048ba28ad1ec2fcf6611e29d388a3becc97f984a Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 17 Apr 2019 22:41:34 +0100 Subject: [PATCH 21/24] Update tests --- src/test/ui/error-codes/E0392.stderr | 2 +- src/test/ui/inner-static-type-parameter.stderr | 2 +- src/test/ui/issues/issue-17904-2.stderr | 2 +- src/test/ui/issues/issue-20413.stderr | 2 +- src/test/ui/issues/issue-36299.stderr | 4 ++-- src/test/ui/issues/issue-36638.stderr | 2 +- src/test/ui/issues/issue-37534.stderr | 2 +- .../region-bounds-on-objects-and-type-parameters.stderr | 2 +- src/test/ui/self/self_type_keyword.stderr | 2 +- src/test/ui/variance/variance-regions-unused-direct.stderr | 4 ++-- .../ui/variance/variance-regions-unused-indirect.stderr | 4 ++-- src/test/ui/variance/variance-unused-region-param.stderr | 4 ++-- src/test/ui/variance/variance-unused-type-param.stderr | 6 +++--- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/test/ui/error-codes/E0392.stderr b/src/test/ui/error-codes/E0392.stderr index 18419572233e9..d0b808df184c4 100644 --- a/src/test/ui/error-codes/E0392.stderr +++ b/src/test/ui/error-codes/E0392.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `T` is never used --> $DIR/E0392.rs:1:10 | LL | enum Foo { Bar } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/inner-static-type-parameter.stderr b/src/test/ui/inner-static-type-parameter.stderr index 3c14e217aeb8e..78514dd93ff0f 100644 --- a/src/test/ui/inner-static-type-parameter.stderr +++ b/src/test/ui/inner-static-type-parameter.stderr @@ -12,7 +12,7 @@ error[E0392]: parameter `T` is never used --> $DIR/inner-static-type-parameter.rs:3:10 | LL | enum Bar { What } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-17904-2.stderr b/src/test/ui/issues/issue-17904-2.stderr index b8fabd3b13f41..930409cc63727 100644 --- a/src/test/ui/issues/issue-17904-2.stderr +++ b/src/test/ui/issues/issue-17904-2.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `T` is never used --> $DIR/issue-17904-2.rs:4:12 | LL | struct Foo where T: Copy; - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index 893f4faab0d58..f331600b03c20 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `T` is never used --> $DIR/issue-20413.rs:5:15 | LL | struct NoData; - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-36299.stderr b/src/test/ui/issues/issue-36299.stderr index dce4bd31ca305..edbe790a0c9f6 100644 --- a/src/test/ui/issues/issue-36299.stderr +++ b/src/test/ui/issues/issue-36299.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/issue-36299.rs:1:12 | LL | struct Foo<'a, A> {} - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `A` is never used --> $DIR/issue-36299.rs:1:16 | LL | struct Foo<'a, A> {} - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `A` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-36638.stderr b/src/test/ui/issues/issue-36638.stderr index 171343090142f..2e44086161110 100644 --- a/src/test/ui/issues/issue-36638.stderr +++ b/src/test/ui/issues/issue-36638.stderr @@ -14,7 +14,7 @@ error[E0392]: parameter `Self` is never used --> $DIR/issue-36638.rs:3:12 | LL | struct Foo(Self); - | ^^^^ unused type parameter + | ^^^^ unused parameter | = help: consider removing `Self` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/issues/issue-37534.stderr b/src/test/ui/issues/issue-37534.stderr index fe143540b735f..7e06d51d97f17 100644 --- a/src/test/ui/issues/issue-37534.stderr +++ b/src/test/ui/issues/issue-37534.stderr @@ -18,7 +18,7 @@ error[E0392]: parameter `T` is never used --> $DIR/issue-37534.rs:1:12 | LL | struct Foo { } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr index ec71d55705e85..394a45a3e49cb 100644 --- a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr +++ b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr @@ -25,7 +25,7 @@ error[E0392]: parameter `'c` is never used --> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:18 | LL | struct Foo<'a,'b,'c> { - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'c` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/self/self_type_keyword.stderr b/src/test/ui/self/self_type_keyword.stderr index f75377a220b49..e0df00ffa9299 100644 --- a/src/test/ui/self/self_type_keyword.stderr +++ b/src/test/ui/self/self_type_keyword.stderr @@ -62,7 +62,7 @@ error[E0392]: parameter `'Self` is never used --> $DIR/self_type_keyword.rs:8:12 | LL | struct Bar<'Self>; - | ^^^^^ unused type parameter + | ^^^^^ unused parameter | = help: consider removing `'Self` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/variance/variance-regions-unused-direct.stderr b/src/test/ui/variance/variance-regions-unused-direct.stderr index ab5dce03fa0a0..21ff475663c6c 100644 --- a/src/test/ui/variance/variance-regions-unused-direct.stderr +++ b/src/test/ui/variance/variance-regions-unused-direct.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-regions-unused-direct.rs:5:18 | LL | struct Bivariant<'a>; - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `'d` is never used --> $DIR/variance-regions-unused-direct.rs:7:19 | LL | struct Struct<'a, 'd> { - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'d` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/variance/variance-regions-unused-indirect.stderr b/src/test/ui/variance/variance-regions-unused-indirect.stderr index 69631b4a504d2..fd66217f692f1 100644 --- a/src/test/ui/variance/variance-regions-unused-indirect.stderr +++ b/src/test/ui/variance/variance-regions-unused-indirect.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-regions-unused-indirect.rs:3:10 | LL | enum Foo<'a> { - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-regions-unused-indirect.rs:7:10 | LL | enum Bar<'a> { - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/variance/variance-unused-region-param.stderr b/src/test/ui/variance/variance-unused-region-param.stderr index 6c103f168f475..a96b2338bf428 100644 --- a/src/test/ui/variance/variance-unused-region-param.stderr +++ b/src/test/ui/variance/variance-unused-region-param.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-unused-region-param.rs:3:19 | LL | struct SomeStruct<'a> { x: u32 } - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `'a` is never used --> $DIR/variance-unused-region-param.rs:4:15 | LL | enum SomeEnum<'a> { Nothing } - | ^^ unused type parameter + | ^^ unused parameter | = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` diff --git a/src/test/ui/variance/variance-unused-type-param.stderr b/src/test/ui/variance/variance-unused-type-param.stderr index 34c430f5498da..883db46298624 100644 --- a/src/test/ui/variance/variance-unused-type-param.stderr +++ b/src/test/ui/variance/variance-unused-type-param.stderr @@ -2,7 +2,7 @@ error[E0392]: parameter `A` is never used --> $DIR/variance-unused-type-param.rs:6:19 | LL | struct SomeStruct { x: u32 } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `A` or using a marker such as `std::marker::PhantomData` @@ -10,7 +10,7 @@ error[E0392]: parameter `A` is never used --> $DIR/variance-unused-type-param.rs:9:15 | LL | enum SomeEnum { Nothing } - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `A` or using a marker such as `std::marker::PhantomData` @@ -18,7 +18,7 @@ error[E0392]: parameter `T` is never used --> $DIR/variance-unused-type-param.rs:13:15 | LL | enum ListCell { - | ^ unused type parameter + | ^ unused parameter | = help: consider removing `T` or using a marker such as `std::marker::PhantomData` From eed3619f8d86e39c67fed33a3acf7a1cb72f3c42 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 18 Apr 2019 15:01:10 -0700 Subject: [PATCH 22/24] Use -mergefunc-use-aliases for any LLVM >= 8 --- src/librustc_codegen_llvm/llvm_util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index 5fea9c8747e0f..8e3bf553fd9bb 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -61,7 +61,7 @@ unsafe fn configure_llvm(sess: &Session) { if sess.opts.debugging_opts.disable_instrumentation_preinliner { add("-disable-preinline"); } - if llvm::LLVMRustIsRustLLVM() { + if get_major_version() >= 8 { match sess.opts.debugging_opts.merge_functions .unwrap_or(sess.target.target.options.merge_functions) { MergeFunctions::Disabled | From a1099ae73ea0fdd9b82329aaf64a977c44a7595e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 18 Apr 2019 15:28:18 -0700 Subject: [PATCH 23/24] Remove the unused LLVMRustIsRustLLVM --- src/librustc_codegen_llvm/llvm/ffi.rs | 1 - src/rustllvm/RustWrapper.cpp | 8 -------- 2 files changed, 9 deletions(-) diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index f6ee8bec16a5a..f88923fc9f1c5 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1382,7 +1382,6 @@ extern "C" { pub fn LLVMRustDebugMetadataVersion() -> u32; pub fn LLVMRustVersionMajor() -> u32; pub fn LLVMRustVersionMinor() -> u32; - pub fn LLVMRustIsRustLLVM() -> bool; pub fn LLVMRustAddModuleFlag(M: &Module, name: *const c_char, value: u32); diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 437e2d482efd6..66453c08a66ef 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -613,14 +613,6 @@ extern "C" uint32_t LLVMRustVersionMinor() { return LLVM_VERSION_MINOR; } extern "C" uint32_t LLVMRustVersionMajor() { return LLVM_VERSION_MAJOR; } -extern "C" bool LLVMRustIsRustLLVM() { -#ifdef LLVM_RUSTLLVM - return 1; -#else - return 0; -#endif -} - extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M, const char *Name, uint32_t Value) { unwrap(M)->addModuleFlag(Module::Warning, Name, Value); From dbfbadeac4f593e31bbcb57bc7c3b1d17ab1cd65 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Fri, 19 Apr 2019 01:37:12 +0200 Subject: [PATCH 24/24] libcore: deny more... --- src/libcore/alloc.rs | 6 +- src/libcore/any.rs | 6 +- src/libcore/array.rs | 4 +- src/libcore/ascii.rs | 2 +- src/libcore/cell.rs | 20 ++--- src/libcore/char/convert.rs | 5 +- src/libcore/char/decode.rs | 2 +- src/libcore/char/mod.rs | 12 +-- src/libcore/ffi.rs | 10 +-- src/libcore/fmt/builders.rs | 2 +- src/libcore/fmt/float.rs | 28 +++--- src/libcore/fmt/mod.rs | 126 +++++++++++++-------------- src/libcore/fmt/num.rs | 10 +-- src/libcore/hash/mod.rs | 2 +- src/libcore/iter/adapters/flatten.rs | 5 +- src/libcore/iter/adapters/mod.rs | 14 +-- src/libcore/iter/sources.rs | 6 +- src/libcore/lib.rs | 1 - src/libcore/mem.rs | 2 +- src/libcore/num/bignum.rs | 2 +- src/libcore/num/dec2flt/mod.rs | 10 +-- src/libcore/num/dec2flt/parse.rs | 2 +- src/libcore/num/mod.rs | 18 ++-- src/libcore/ops/range.rs | 12 +-- src/libcore/option.rs | 4 +- src/libcore/panic.rs | 8 +- src/libcore/panicking.rs | 4 +- src/libcore/pin.rs | 6 +- src/libcore/ptr.rs | 12 +-- src/libcore/result.rs | 4 +- src/libcore/slice/mod.rs | 58 ++++++------ src/libcore/str/lossy.rs | 6 +- src/libcore/str/mod.rs | 42 ++++----- src/libcore/str/pattern.rs | 2 +- src/libcore/sync/atomic.rs | 8 +- src/libcore/task/wake.rs | 4 +- src/libcore/time.rs | 4 +- 37 files changed, 233 insertions(+), 236 deletions(-) diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 18354945a1e51..c124457118cb9 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -338,7 +338,7 @@ pub struct LayoutErr { // (we need this for downstream impl of trait Error) #[stable(feature = "alloc_layout", since = "1.28.0")] impl fmt::Display for LayoutErr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("invalid parameters to Layout::from_size_align") } } @@ -354,7 +354,7 @@ pub struct AllocErr; // (we need this for downstream impl of trait Error) #[unstable(feature = "allocator_api", issue = "32838")] impl fmt::Display for AllocErr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("memory allocation failed") } } @@ -376,7 +376,7 @@ impl CannotReallocInPlace { // (we need this for downstream impl of trait Error) #[unstable(feature = "allocator_api", issue = "32838")] impl fmt::Display for CannotReallocInPlace { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.description()) } } diff --git a/src/libcore/any.rs b/src/libcore/any.rs index a4827aa36edd0..d043ce34effcd 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -107,7 +107,7 @@ impl Any for T { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for dyn Any { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Any") } } @@ -117,14 +117,14 @@ impl fmt::Debug for dyn Any { // dispatch works with upcasting. #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for dyn Any + Send { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Any") } } #[stable(feature = "any_send_sync_methods", since = "1.28.0")] impl fmt::Debug for dyn Any + Send + Sync { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("Any") } } diff --git a/src/libcore/array.rs b/src/libcore/array.rs index 3c445db69bbb4..fb9c99f667df2 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -55,7 +55,7 @@ pub struct TryFromSliceError(()); impl fmt::Display for TryFromSliceError { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self.__description(), f) } } @@ -184,7 +184,7 @@ macro_rules! array_impls { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for [T; $N] { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&&self[..], f) } } diff --git a/src/libcore/ascii.rs b/src/libcore/ascii.rs index 953fe9ca2b9f8..c0ab364380fbd 100644 --- a/src/libcore/ascii.rs +++ b/src/libcore/ascii.rs @@ -131,7 +131,7 @@ impl FusedIterator for EscapeDefault {} #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for EscapeDefault { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("EscapeDefault { .. }") } } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 1c55e62539a85..fcfd80d92660d 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -577,14 +577,14 @@ pub struct BorrowError { #[stable(feature = "try_borrow", since = "1.13.0")] impl Debug for BorrowError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("BorrowError").finish() } } #[stable(feature = "try_borrow", since = "1.13.0")] impl Display for BorrowError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Display::fmt("already mutably borrowed", f) } } @@ -597,14 +597,14 @@ pub struct BorrowMutError { #[stable(feature = "try_borrow", since = "1.13.0")] impl Debug for BorrowMutError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("BorrowMutError").finish() } } #[stable(feature = "try_borrow", since = "1.13.0")] impl Display for BorrowMutError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Display::fmt("already borrowed", f) } } @@ -788,7 +788,7 @@ impl RefCell { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn borrow(&self) -> Ref { + pub fn borrow(&self) -> Ref<'_, T> { self.try_borrow().expect("already mutably borrowed") } @@ -819,7 +819,7 @@ impl RefCell { /// ``` #[stable(feature = "try_borrow", since = "1.13.0")] #[inline] - pub fn try_borrow(&self) -> Result, BorrowError> { + pub fn try_borrow(&self) -> Result, BorrowError> { match BorrowRef::new(&self.borrow) { Some(b) => Ok(Ref { value: unsafe { &*self.value.get() }, @@ -869,7 +869,7 @@ impl RefCell { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn borrow_mut(&self) -> RefMut { + pub fn borrow_mut(&self) -> RefMut<'_, T> { self.try_borrow_mut().expect("already borrowed") } @@ -897,7 +897,7 @@ impl RefCell { /// ``` #[stable(feature = "try_borrow", since = "1.13.0")] #[inline] - pub fn try_borrow_mut(&self) -> Result, BorrowMutError> { + pub fn try_borrow_mut(&self) -> Result, BorrowMutError> { match BorrowRefMut::new(&self.borrow) { Some(b) => Ok(RefMut { value: unsafe { &mut *self.value.get() }, @@ -1245,7 +1245,7 @@ impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for Ref<'b, #[stable(feature = "std_guard_impls", since = "1.20.0")] impl fmt::Display for Ref<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.value.fmt(f) } } @@ -1402,7 +1402,7 @@ impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for RefM #[stable(feature = "std_guard_impls", since = "1.20.0")] impl fmt::Display for RefMut<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.value.fmt(f) } } diff --git a/src/libcore/char/convert.rs b/src/libcore/char/convert.rs index ec273746111ee..ec9ac7ce8b1cb 100644 --- a/src/libcore/char/convert.rs +++ b/src/libcore/char/convert.rs @@ -193,7 +193,7 @@ enum CharErrorKind { #[stable(feature = "char_from_str", since = "1.20.0")] impl fmt::Display for ParseCharError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.__description().fmt(f) } } @@ -240,7 +240,7 @@ pub struct CharTryFromError(()); #[stable(feature = "try_from", since = "1.34.0")] impl fmt::Display for CharTryFromError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "converted integer out of range for `char`".fmt(f) } } @@ -316,4 +316,3 @@ pub fn from_digit(num: u32, radix: u32) -> Option { None } } - diff --git a/src/libcore/char/decode.rs b/src/libcore/char/decode.rs index ed92eca08bf7f..23059243c61d7 100644 --- a/src/libcore/char/decode.rs +++ b/src/libcore/char/decode.rs @@ -128,7 +128,7 @@ impl DecodeUtf16Error { #[stable(feature = "decode_utf16", since = "1.9.0")] impl fmt::Display for DecodeUtf16Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "unpaired surrogate found: {:x}", self.code) } } diff --git a/src/libcore/char/mod.rs b/src/libcore/char/mod.rs index 39186273d62db..dedd2f758b6cb 100644 --- a/src/libcore/char/mod.rs +++ b/src/libcore/char/mod.rs @@ -220,7 +220,7 @@ impl FusedIterator for EscapeUnicode {} #[stable(feature = "char_struct_display", since = "1.16.0")] impl fmt::Display for EscapeUnicode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for c in self.clone() { f.write_char(c)?; } @@ -333,7 +333,7 @@ impl FusedIterator for EscapeDefault {} #[stable(feature = "char_struct_display", since = "1.16.0")] impl fmt::Display for EscapeDefault { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for c in self.clone() { f.write_char(c)?; } @@ -367,7 +367,7 @@ impl FusedIterator for EscapeDebug {} #[stable(feature = "char_escape_debug", since = "1.20.0")] impl fmt::Display for EscapeDebug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.0, f) } } @@ -482,7 +482,7 @@ impl Iterator for CaseMappingIter { } impl fmt::Display for CaseMappingIter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { CaseMappingIter::Three(a, b, c) => { f.write_char(a)?; @@ -503,14 +503,14 @@ impl fmt::Display for CaseMappingIter { #[stable(feature = "char_struct_display", since = "1.16.0")] impl fmt::Display for ToLowercase { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.0, f) } } #[stable(feature = "char_struct_display", since = "1.16.0")] impl fmt::Display for ToUppercase { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.0, f) } } diff --git a/src/libcore/ffi.rs b/src/libcore/ffi.rs index 004fafc5a0b65..2906e5824ae70 100644 --- a/src/libcore/ffi.rs +++ b/src/libcore/ffi.rs @@ -39,7 +39,7 @@ pub enum c_void { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for c_void { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("c_void") } } @@ -62,7 +62,7 @@ extern { all(target_arch = "aarch64", target_os = "ios"), windows))] impl fmt::Debug for VaListImpl { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "va_list* {:p}", self) } } @@ -212,7 +212,7 @@ impl<'a> VaList<'a> { extern "rust-intrinsic" { /// Destroy the arglist `ap` after initialization with `va_start` or /// `va_copy`. - fn va_end(ap: &mut VaList); + fn va_end(ap: &mut VaList<'_>); /// Copies the current location of arglist `src` to the arglist `dst`. #[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), @@ -222,9 +222,9 @@ extern "rust-intrinsic" { fn va_copy<'a>(src: &VaList<'a>) -> VaList<'a>; #[cfg(all(any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"), not(windows), not(all(target_arch = "aarch64", target_os = "ios"))))] - fn va_copy(src: &VaList) -> VaListImpl; + fn va_copy(src: &VaList<'_>) -> VaListImpl; /// Loads an argument of type `T` from the `va_list` `ap` and increment the /// argument `ap` points to. - fn va_arg(ap: &mut VaList) -> T; + fn va_arg(ap: &mut VaList<'_>) -> T; } diff --git a/src/libcore/fmt/builders.rs b/src/libcore/fmt/builders.rs index e78381ba0c482..df86da5fc3906 100644 --- a/src/libcore/fmt/builders.rs +++ b/src/libcore/fmt/builders.rs @@ -6,7 +6,7 @@ struct PadAdapter<'a> { } impl<'a> PadAdapter<'a> { - fn wrap<'b, 'c: 'a+'b>(fmt: &'c mut fmt::Formatter, slot: &'b mut Option) + fn wrap<'b, 'c: 'a+'b>(fmt: &'c mut fmt::Formatter<'_>, slot: &'b mut Option) -> fmt::Formatter<'b> { fmt.wrap_buf(move |buf| { *slot = Some(PadAdapter { diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 5fc2cd4b8d0a3..4bd7d3b4b22e3 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -5,13 +5,13 @@ use crate::num::flt2dec; // Don't inline this so callers don't use the stack space this function // requires unless they have to. #[inline(never)] -fn float_to_decimal_common_exact(fmt: &mut Formatter, num: &T, +fn float_to_decimal_common_exact(fmt: &mut Formatter<'_>, num: &T, sign: flt2dec::Sign, precision: usize) -> Result where T: flt2dec::DecodableFloat { unsafe { let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64 - let mut parts = MaybeUninit::<[flt2dec::Part; 4]>::uninit(); + let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 4]>::uninit(); // FIXME(#53491): Technically, this is calling `get_mut` on an uninitialized // `MaybeUninit` (here and elsewhere in this file). Revisit this once // we decided whether that is valid or not. @@ -26,14 +26,14 @@ fn float_to_decimal_common_exact(fmt: &mut Formatter, num: &T, // Don't inline this so callers that call both this and the above won't wind // up using the combined stack space of both functions in some cases. #[inline(never)] -fn float_to_decimal_common_shortest(fmt: &mut Formatter, num: &T, +fn float_to_decimal_common_shortest(fmt: &mut Formatter<'_>, num: &T, sign: flt2dec::Sign, precision: usize) -> Result where T: flt2dec::DecodableFloat { unsafe { // enough for f32 and f64 let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninit(); - let mut parts = MaybeUninit::<[flt2dec::Part; 4]>::uninit(); + let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 4]>::uninit(); // FIXME(#53491) let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num, sign, precision, false, buf.get_mut(), @@ -43,7 +43,7 @@ fn float_to_decimal_common_shortest(fmt: &mut Formatter, num: &T, } // Common code of floating point Debug and Display. -fn float_to_decimal_common(fmt: &mut Formatter, num: &T, +fn float_to_decimal_common(fmt: &mut Formatter<'_>, num: &T, negative_zero: bool, min_precision: usize) -> Result where T: flt2dec::DecodableFloat { @@ -65,14 +65,14 @@ fn float_to_decimal_common(fmt: &mut Formatter, num: &T, // Don't inline this so callers don't use the stack space this function // requires unless they have to. #[inline(never)] -fn float_to_exponential_common_exact(fmt: &mut Formatter, num: &T, +fn float_to_exponential_common_exact(fmt: &mut Formatter<'_>, num: &T, sign: flt2dec::Sign, precision: usize, upper: bool) -> Result where T: flt2dec::DecodableFloat { unsafe { let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64 - let mut parts = MaybeUninit::<[flt2dec::Part; 6]>::uninit(); + let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 6]>::uninit(); // FIXME(#53491) let formatted = flt2dec::to_exact_exp_str(flt2dec::strategy::grisu::format_exact, *num, sign, precision, @@ -84,7 +84,7 @@ fn float_to_exponential_common_exact(fmt: &mut Formatter, num: &T, // Don't inline this so callers that call both this and the above won't wind // up using the combined stack space of both functions in some cases. #[inline(never)] -fn float_to_exponential_common_shortest(fmt: &mut Formatter, +fn float_to_exponential_common_shortest(fmt: &mut Formatter<'_>, num: &T, sign: flt2dec::Sign, upper: bool) -> Result where T: flt2dec::DecodableFloat @@ -92,7 +92,7 @@ fn float_to_exponential_common_shortest(fmt: &mut Formatter, unsafe { // enough for f32 and f64 let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninit(); - let mut parts = MaybeUninit::<[flt2dec::Part; 6]>::uninit(); + let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 6]>::uninit(); // FIXME(#53491) let formatted = flt2dec::to_shortest_exp_str(flt2dec::strategy::grisu::format_shortest, *num, sign, (0, 0), upper, @@ -102,7 +102,7 @@ fn float_to_exponential_common_shortest(fmt: &mut Formatter, } // Common code of floating point LowerExp and UpperExp. -fn float_to_exponential_common(fmt: &mut Formatter, num: &T, upper: bool) -> Result +fn float_to_exponential_common(fmt: &mut Formatter<'_>, num: &T, upper: bool) -> Result where T: flt2dec::DecodableFloat { let force_sign = fmt.sign_plus(); @@ -123,28 +123,28 @@ macro_rules! floating { ($ty:ident) => ( #[stable(feature = "rust1", since = "1.0.0")] impl Debug for $ty { - fn fmt(&self, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> Result { float_to_decimal_common(fmt, self, true, 1) } } #[stable(feature = "rust1", since = "1.0.0")] impl Display for $ty { - fn fmt(&self, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> Result { float_to_decimal_common(fmt, self, false, 0) } } #[stable(feature = "rust1", since = "1.0.0")] impl LowerExp for $ty { - fn fmt(&self, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> Result { float_to_exponential_common(fmt, self, false) } } #[stable(feature = "rust1", since = "1.0.0")] impl UpperExp for $ty { - fn fmt(&self, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> Result { float_to_exponential_common(fmt, self, true) } } diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 1ccd6ec898f8b..43c1a3b7767ab 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -55,7 +55,7 @@ pub mod rt { /// } /// /// impl fmt::Display for Triangle { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "({}, {}, {})", self.a, self.b, self.c) /// } /// } @@ -191,7 +191,7 @@ pub trait Write { /// assert_eq!(&buf, "world"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - fn write_fmt(mut self: &mut Self, args: Arguments) -> Result { + fn write_fmt(mut self: &mut Self, args: Arguments<'_>) -> Result { write(&mut self, args) } } @@ -206,7 +206,7 @@ impl Write for &mut W { (**self).write_char(c) } - fn write_fmt(&mut self, args: Arguments) -> Result { + fn write_fmt(&mut self, args: Arguments<'_>) -> Result { (**self).write_fmt(args) } } @@ -238,7 +238,7 @@ pub struct Formatter<'a> { } // NB. Argument is essentially an optimized partially applied formatting function, -// equivalent to `exists T.(&T, fn(&T, &mut Formatter) -> Result`. +// equivalent to `exists T.(&T, fn(&T, &mut Formatter<'_>) -> Result`. struct Void { _priv: (), @@ -263,12 +263,12 @@ struct Void { #[doc(hidden)] pub struct ArgumentV1<'a> { value: &'a Void, - formatter: fn(&Void, &mut Formatter) -> Result, + formatter: fn(&Void, &mut Formatter<'_>) -> Result, } impl<'a> ArgumentV1<'a> { #[inline(never)] - fn show_usize(x: &usize, f: &mut Formatter) -> Result { + fn show_usize(x: &usize, f: &mut Formatter<'_>) -> Result { Display::fmt(x, f) } @@ -276,7 +276,7 @@ impl<'a> ArgumentV1<'a> { #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "0")] pub fn new<'b, T>(x: &'b T, - f: fn(&T, &mut Formatter) -> Result) -> ArgumentV1<'b> { + f: fn(&T, &mut Formatter<'_>) -> Result) -> ArgumentV1<'b> { unsafe { ArgumentV1 { formatter: mem::transmute(f), @@ -288,7 +288,7 @@ impl<'a> ArgumentV1<'a> { #[doc(hidden)] #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "0")] - pub fn from_usize(x: &usize) -> ArgumentV1 { + pub fn from_usize(x: &usize) -> ArgumentV1<'_> { ArgumentV1::new(x, ArgumentV1::show_usize) } @@ -406,14 +406,14 @@ pub struct Arguments<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for Arguments<'_> { - fn fmt(&self, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> Result { Display::fmt(self, fmt) } } #[stable(feature = "rust1", since = "1.0.0")] impl Display for Arguments<'_> { - fn fmt(&self, fmt: &mut Formatter) -> Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> Result { write(fmt.buf, *self) } } @@ -463,7 +463,7 @@ impl Display for Arguments<'_> { /// } /// /// impl fmt::Debug for Point { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "Point {{ x: {}, y: {} }}", self.x, self.y) /// } /// } @@ -533,7 +533,7 @@ pub trait Debug { /// } /// /// impl fmt::Debug for Position { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "({:?}, {:?})", self.longitude, self.latitude) /// } /// } @@ -542,7 +542,7 @@ pub trait Debug { /// format!("{:?}", Position { longitude: 1.987, latitude: 2.983, })); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// Format trait for an empty format, `{}`. @@ -569,7 +569,7 @@ pub trait Debug { /// } /// /// impl fmt::Display for Point { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "({}, {})", self.x, self.y) /// } /// } @@ -605,7 +605,7 @@ pub trait Display { /// } /// /// impl fmt::Display for Position { - /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// write!(f, "({}, {})", self.longitude, self.latitude) /// } /// } @@ -614,7 +614,7 @@ pub trait Display { /// format!("{}", Position { longitude: 1.987, latitude: 2.983, })); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// `o` formatting. @@ -651,7 +651,7 @@ pub trait Display { /// struct Length(i32); /// /// impl fmt::Octal for Length { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// let val = self.0; /// /// write!(f, "{:o}", val) // delegate to i32's implementation @@ -666,7 +666,7 @@ pub trait Display { pub trait Octal { /// Formats the value using the given formatter. #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// `b` formatting. @@ -701,7 +701,7 @@ pub trait Octal { /// struct Length(i32); /// /// impl fmt::Binary for Length { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// let val = self.0; /// /// write!(f, "{:b}", val) // delegate to i32's implementation @@ -722,7 +722,7 @@ pub trait Octal { pub trait Binary { /// Formats the value using the given formatter. #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// `x` formatting. @@ -760,7 +760,7 @@ pub trait Binary { /// struct Length(i32); /// /// impl fmt::LowerHex for Length { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// let val = self.0; /// /// write!(f, "{:x}", val) // delegate to i32's implementation @@ -775,7 +775,7 @@ pub trait Binary { pub trait LowerHex { /// Formats the value using the given formatter. #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// `X` formatting. @@ -813,7 +813,7 @@ pub trait LowerHex { /// struct Length(i32); /// /// impl fmt::UpperHex for Length { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// let val = self.0; /// /// write!(f, "{:X}", val) // delegate to i32's implementation @@ -828,7 +828,7 @@ pub trait LowerHex { pub trait UpperHex { /// Formats the value using the given formatter. #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// `p` formatting. @@ -858,7 +858,7 @@ pub trait UpperHex { /// struct Length(i32); /// /// impl fmt::Pointer for Length { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// // use `as` to convert to a `*const T`, which implements Pointer, which we can use /// /// write!(f, "{:p}", self as *const Length) @@ -873,7 +873,7 @@ pub trait UpperHex { pub trait Pointer { /// Formats the value using the given formatter. #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// `e` formatting. @@ -902,7 +902,7 @@ pub trait Pointer { /// struct Length(i32); /// /// impl fmt::LowerExp for Length { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// let val = self.0; /// write!(f, "{}e1", val / 10) /// } @@ -916,7 +916,7 @@ pub trait Pointer { pub trait LowerExp { /// Formats the value using the given formatter. #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// `E` formatting. @@ -945,7 +945,7 @@ pub trait LowerExp { /// struct Length(i32); /// /// impl fmt::UpperExp for Length { -/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// let val = self.0; /// write!(f, "{}E1", val / 10) /// } @@ -959,7 +959,7 @@ pub trait LowerExp { pub trait UpperExp { /// Formats the value using the given formatter. #[stable(feature = "rust1", since = "1.0.0")] - fn fmt(&self, f: &mut Formatter) -> Result; + fn fmt(&self, f: &mut Formatter<'_>) -> Result; } /// The `write` function takes an output stream, and an `Arguments` struct @@ -994,7 +994,7 @@ pub trait UpperExp { /// /// [`write!`]: ../../std/macro.write.html #[stable(feature = "rust1", since = "1.0.0")] -pub fn write(output: &mut dyn Write, args: Arguments) -> Result { +pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result { let mut formatter = Formatter { flags: 0, width: None, @@ -1183,7 +1183,7 @@ impl<'a> Formatter<'a> { // Writes the sign if it exists, and then the prefix if it was requested #[inline(never)] - fn write_prefix(f: &mut Formatter, sign: Option, prefix: Option<&str>) -> Result { + fn write_prefix(f: &mut Formatter<'_>, sign: Option, prefix: Option<&str>) -> Result { if let Some(c) = sign { f.buf.write_char(c)?; } @@ -1331,7 +1331,7 @@ impl<'a> Formatter<'a> { /// Takes the formatted parts and applies the padding. /// Assumes that the caller already has rendered the parts with required precision, /// so that `self.precision` can be ignored. - fn pad_formatted_parts(&mut self, formatted: &flt2dec::Formatted) -> Result { + fn pad_formatted_parts(&mut self, formatted: &flt2dec::Formatted<'_>) -> Result { if let Some(mut width) = self.width { // for the sign-aware zero padding, we render the sign first and // behave as if we had no sign from the beginning. @@ -1370,7 +1370,7 @@ impl<'a> Formatter<'a> { } } - fn write_formatted_parts(&mut self, formatted: &flt2dec::Formatted) -> Result { + fn write_formatted_parts(&mut self, formatted: &flt2dec::Formatted<'_>) -> Result { fn write_bytes(buf: &mut dyn Write, s: &[u8]) -> Result { buf.write_str(unsafe { str::from_utf8_unchecked(s) }) } @@ -1453,7 +1453,7 @@ impl<'a> Formatter<'a> { /// assert_eq!(&format!("{:0>8}", Foo(2)), "Foo 2"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn write_fmt(&mut self, fmt: Arguments) -> Result { + pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result { write(self.buf, fmt) } @@ -1892,14 +1892,14 @@ impl Write for Formatter<'_> { self.buf.write_char(c) } - fn write_fmt(&mut self, args: Arguments) -> Result { + fn write_fmt(&mut self, args: Arguments<'_>) -> Result { write(self.buf, args) } } #[stable(feature = "rust1", since = "1.0.0")] impl Display for Error { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Display::fmt("an error occurred when formatting an argument", f) } } @@ -1911,11 +1911,11 @@ macro_rules! fmt_refs { $( #[stable(feature = "rust1", since = "1.0.0")] impl $tr for &T { - fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) } + fn fmt(&self, f: &mut Formatter<'_>) -> Result { $tr::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl $tr for &mut T { - fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) } + fn fmt(&self, f: &mut Formatter<'_>) -> Result { $tr::fmt(&**self, f) } } )* } @@ -1925,14 +1925,14 @@ fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperEx #[unstable(feature = "never_type", issue = "35121")] impl Debug for ! { - fn fmt(&self, _: &mut Formatter) -> Result { + fn fmt(&self, _: &mut Formatter<'_>) -> Result { *self } } #[unstable(feature = "never_type", issue = "35121")] impl Display for ! { - fn fmt(&self, _: &mut Formatter) -> Result { + fn fmt(&self, _: &mut Formatter<'_>) -> Result { *self } } @@ -1940,21 +1940,21 @@ impl Display for ! { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for bool { #[inline] - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Display::fmt(self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl Display for bool { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Display::fmt(if *self { "true" } else { "false" }, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl Debug for str { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.write_char('"')?; let mut from = 0; for (i, c) in self.char_indices() { @@ -1975,14 +1975,14 @@ impl Debug for str { #[stable(feature = "rust1", since = "1.0.0")] impl Display for str { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.pad(self) } } #[stable(feature = "rust1", since = "1.0.0")] impl Debug for char { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.write_char('\'')?; for c in self.escape_debug() { f.write_char(c)? @@ -1993,7 +1993,7 @@ impl Debug for char { #[stable(feature = "rust1", since = "1.0.0")] impl Display for char { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { if f.width.is_none() && f.precision.is_none() { f.write_char(*self) } else { @@ -2004,7 +2004,7 @@ impl Display for char { #[stable(feature = "rust1", since = "1.0.0")] impl Pointer for *const T { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { let old_width = f.width; let old_flags = f.flags; @@ -2032,21 +2032,21 @@ impl Pointer for *const T { #[stable(feature = "rust1", since = "1.0.0")] impl Pointer for *mut T { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Pointer::fmt(&(*self as *const T), f) } } #[stable(feature = "rust1", since = "1.0.0")] impl Pointer for &T { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Pointer::fmt(&(*self as *const T), f) } } #[stable(feature = "rust1", since = "1.0.0")] impl Pointer for &mut T { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Pointer::fmt(&(&**self as *const T), f) } } @@ -2055,11 +2055,11 @@ impl Pointer for &mut T { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for *const T { - fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) } + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Pointer::fmt(self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl Debug for *mut T { - fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) } + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Pointer::fmt(self, f) } } macro_rules! peel { @@ -2072,7 +2072,7 @@ macro_rules! tuple { #[stable(feature = "rust1", since = "1.0.0")] impl<$($name:Debug),*> Debug for ($($name,)*) where last_type!($($name,)+): ?Sized { #[allow(non_snake_case, unused_assignments)] - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { let mut builder = f.debug_tuple(""); let ($(ref $name,)*) = *self; $( @@ -2095,7 +2095,7 @@ tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } #[stable(feature = "rust1", since = "1.0.0")] impl Debug for [T] { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.debug_list().entries(self.iter()).finish() } } @@ -2103,20 +2103,20 @@ impl Debug for [T] { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for () { #[inline] - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.pad("()") } } #[stable(feature = "rust1", since = "1.0.0")] impl Debug for PhantomData { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.pad("PhantomData") } } #[stable(feature = "rust1", since = "1.0.0")] impl Debug for Cell { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.debug_struct("Cell") .field("value", &self.get()) .finish() @@ -2125,7 +2125,7 @@ impl Debug for Cell { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for RefCell { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { match self.try_borrow() { Ok(borrow) => { f.debug_struct("RefCell") @@ -2138,7 +2138,7 @@ impl Debug for RefCell { struct BorrowedPlaceholder; impl Debug for BorrowedPlaceholder { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.write_str("") } } @@ -2153,21 +2153,21 @@ impl Debug for RefCell { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for Ref<'_, T> { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl Debug for RefMut<'_, T> { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { Debug::fmt(&*(self.deref()), f) } } #[stable(feature = "core_impl_debug", since = "1.9.0")] impl Debug for UnsafeCell { - fn fmt(&self, f: &mut Formatter) -> Result { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.pad("UnsafeCell") } } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 6ad9cc6223953..f9b4c26496cdc 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -46,7 +46,7 @@ trait GenericRadix { fn digit(x: u8) -> u8; /// Format an integer using the radix using a formatter. - fn fmt_int(&self, mut x: T, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt_int(&self, mut x: T, f: &mut fmt::Formatter<'_>) -> fmt::Result { // The radix can be as low as 2, so we need a buffer of at least 128 // characters for a base 2 number. let zero = T::zero(); @@ -131,7 +131,7 @@ macro_rules! int_base { ($Trait:ident for $T:ident as $U:ident -> $Radix:ident) => { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::$Trait for $T { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { $Radix.fmt_int(*self as $U, f) } } @@ -143,7 +143,7 @@ macro_rules! debug { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for $T { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if f.debug_lower_hex() { fmt::LowerHex::fmt(self, f) } else if f.debug_upper_hex() { @@ -188,7 +188,7 @@ static DEC_DIGITS_LUT: &[u8; 200] = macro_rules! impl_Display { ($($t:ident),* as $u:ident via $conv_fn:ident named $name:ident) => { - fn $name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter) -> fmt::Result { + fn $name(mut n: $u, is_nonnegative: bool, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut buf = uninitialized_array![u8; 39]; let mut curr = buf.len() as isize; let buf_ptr = MaybeUninit::first_ptr_mut(&mut buf); @@ -243,7 +243,7 @@ macro_rules! impl_Display { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for $t { #[allow(unused_comparisons)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let is_nonnegative = *self >= 0; let n = if is_nonnegative { self.$conv_fn() diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 46f7f90e4649d..98150fd9f821e 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -500,7 +500,7 @@ pub struct BuildHasherDefault(marker::PhantomData); #[stable(since = "1.9.0", feature = "core_impl_debug")] impl fmt::Debug for BuildHasherDefault { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("BuildHasherDefault") } } diff --git a/src/libcore/iter/adapters/flatten.rs b/src/libcore/iter/adapters/flatten.rs index 8eb81fbb2c6e4..8c2aae477bf2a 100644 --- a/src/libcore/iter/adapters/flatten.rs +++ b/src/libcore/iter/adapters/flatten.rs @@ -34,7 +34,7 @@ impl Clone for FlatMap impl fmt::Debug for FlatMap where U::IntoIter: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("FlatMap").field("inner", &self.inner).finish() } } @@ -120,7 +120,7 @@ impl fmt::Debug for Flatten where I: Iterator + fmt::Debug, U: Iterator + fmt::Debug, I::Item: IntoIterator, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Flatten").field("inner", &self.inner).finish() } } @@ -328,4 +328,3 @@ impl DoubleEndedIterator for FlattenCompat .rfold(init, |acc, iter| iter.rfold(acc, &mut fold)) } } - diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs index ce18b4b97ad66..61e6ab6b48a3f 100644 --- a/src/libcore/iter/adapters/mod.rs +++ b/src/libcore/iter/adapters/mod.rs @@ -553,7 +553,7 @@ impl Map { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for Map { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Map") .field("iter", &self.iter) .finish() @@ -669,7 +669,7 @@ impl Filter { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for Filter { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Filter") .field("iter", &self.iter) .finish() @@ -793,7 +793,7 @@ impl FilterMap { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for FilterMap { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("FilterMap") .field("iter", &self.iter) .finish() @@ -1222,7 +1222,7 @@ impl SkipWhile { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for SkipWhile { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SkipWhile") .field("iter", &self.iter) .field("flag", &self.flag) @@ -1310,7 +1310,7 @@ impl TakeWhile { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for TakeWhile { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("TakeWhile") .field("iter", &self.iter) .field("flag", &self.flag) @@ -1634,7 +1634,7 @@ impl Scan { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for Scan { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Scan") .field("iter", &self.iter) .field("state", &self.state) @@ -1928,7 +1928,7 @@ impl Inspect { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for Inspect { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Inspect") .field("iter", &self.iter) .finish() diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs index c4f6fbf0ff222..70a3b70c180dc 100644 --- a/src/libcore/iter/sources.rs +++ b/src/libcore/iter/sources.rs @@ -200,7 +200,7 @@ pub struct Empty(marker::PhantomData); #[stable(feature = "core_impl_debug", since = "1.9.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") } } @@ -558,7 +558,7 @@ impl Iterator for FromFn #[stable(feature = "iter_from_fn", since = "1.34.0")] impl fmt::Debug for FromFn { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("FromFn").finish() } } @@ -631,7 +631,7 @@ impl FusedIterator for Successors #[stable(feature = "iter_successors", since = "1.34.0")] impl fmt::Debug for Successors { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Successors") .field("next", &self.next) .finish() diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 0d660b002da60..28db55578c3de 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -65,7 +65,6 @@ #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] -#![allow(elided_lifetimes_in_paths)] #![feature(allow_internal_unstable)] #![feature(arbitrary_self_types)] diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index e2bd4b4a39a9d..95480c6bf048d 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -862,7 +862,7 @@ impl hash::Hash for Discriminant { #[stable(feature = "discriminant_value", since = "1.21.0")] impl fmt::Debug for Discriminant { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_tuple("Discriminant") .field(&self.0) .finish() diff --git a/src/libcore/num/bignum.rs b/src/libcore/num/bignum.rs index 64699e85d0c88..342ac69748d92 100644 --- a/src/libcore/num/bignum.rs +++ b/src/libcore/num/bignum.rs @@ -459,7 +459,7 @@ macro_rules! define_bignum { } impl crate::fmt::Debug for $name { - fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result { + fn fmt(&self, f: &mut crate::fmt::Formatter<'_>) -> crate::fmt::Result { use crate::mem; let sz = if self.size < 1 {1} else {self.size}; diff --git a/src/libcore/num/dec2flt/mod.rs b/src/libcore/num/dec2flt/mod.rs index dcfa2d352a818..4536bbc94ad80 100644 --- a/src/libcore/num/dec2flt/mod.rs +++ b/src/libcore/num/dec2flt/mod.rs @@ -196,7 +196,7 @@ impl ParseFloatError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for ParseFloatError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.__description().fmt(f) } } @@ -244,7 +244,7 @@ fn dec2flt(s: &str) -> Result { /// The main workhorse for the decimal-to-float conversion: Orchestrate all the preprocessing /// and figure out which algorithm should do the actual conversion. -fn convert(mut decimal: Decimal) -> Result { +fn convert(mut decimal: Decimal<'_>) -> Result { simplify(&mut decimal); if let Some(x) = trivial_cases(&decimal) { return Ok(x); @@ -281,7 +281,7 @@ fn convert(mut decimal: Decimal) -> Result { /// Strip zeros where possible, even when this requires changing the exponent #[inline(always)] -fn simplify(decimal: &mut Decimal) { +fn simplify(decimal: &mut Decimal<'_>) { let is_zero = &|&&d: &&u8| -> bool { d == b'0' }; // Trimming these zeros does not change anything but may enable the fast path (< 15 digits). let leading_zeros = decimal.integral.iter().take_while(is_zero).count(); @@ -306,7 +306,7 @@ fn simplify(decimal: &mut Decimal) { /// Returns a quick-an-dirty upper bound on the size (log10) of the largest value that Algorithm R /// and Algorithm M will compute while working on the given decimal. -fn bound_intermediate_digits(decimal: &Decimal, e: i64) -> u64 { +fn bound_intermediate_digits(decimal: &Decimal<'_>, e: i64) -> u64 { // We don't need to worry too much about overflow here thanks to trivial_cases() and the // parser, which filter out the most extreme inputs for us. let f_len: u64 = decimal.integral.len() as u64 + decimal.fractional.len() as u64; @@ -325,7 +325,7 @@ fn bound_intermediate_digits(decimal: &Decimal, e: i64) -> u64 { } /// Detects obvious overflows and underflows without even looking at the decimal digits. -fn trivial_cases(decimal: &Decimal) -> Option { +fn trivial_cases(decimal: &Decimal<'_>) -> Option { // There were zeros but they were stripped by simplify() if decimal.integral.is_empty() && decimal.fractional.is_empty() { return Some(T::ZERO); diff --git a/src/libcore/num/dec2flt/parse.rs b/src/libcore/num/dec2flt/parse.rs index f970595452ec9..cf3664a874886 100644 --- a/src/libcore/num/dec2flt/parse.rs +++ b/src/libcore/num/dec2flt/parse.rs @@ -44,7 +44,7 @@ pub enum ParseResult<'a> { /// Checks if the input string is a valid floating point number and if so, locate the integral /// part, the fractional part, and the exponent in it. Does not handle signs. -pub fn parse_decimal(s: &str) -> ParseResult { +pub fn parse_decimal(s: &str) -> ParseResult<'_> { if s.is_empty() { return Invalid; } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 24afc945e9313..c8a4ff7ca61e7 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -15,7 +15,7 @@ macro_rules! impl_nonzero_fmt { #[$stability] impl fmt::$Trait for $Ty { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.get().fmt(f) } } @@ -164,42 +164,42 @@ pub struct Wrapping(#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Wrapping { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } #[stable(feature = "wrapping_display", since = "1.10.0")] impl fmt::Display for Wrapping { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } #[stable(feature = "wrapping_fmt", since = "1.11.0")] impl fmt::Binary for Wrapping { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } #[stable(feature = "wrapping_fmt", since = "1.11.0")] impl fmt::Octal for Wrapping { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } #[stable(feature = "wrapping_fmt", since = "1.11.0")] impl fmt::LowerHex for Wrapping { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } #[stable(feature = "wrapping_fmt", since = "1.11.0")] impl fmt::UpperHex for Wrapping { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -4423,7 +4423,7 @@ impl TryFromIntError { #[stable(feature = "try_from", since = "1.34.0")] impl fmt::Display for TryFromIntError { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { self.__description().fmt(fmt) } } @@ -4820,7 +4820,7 @@ impl ParseIntError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for ParseIntError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.__description().fmt(f) } } diff --git a/src/libcore/ops/range.rs b/src/libcore/ops/range.rs index e13df04c2cedd..a707f0cc0627a 100644 --- a/src/libcore/ops/range.rs +++ b/src/libcore/ops/range.rs @@ -45,7 +45,7 @@ pub struct RangeFull; #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for RangeFull { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "..") } } @@ -84,7 +84,7 @@ pub struct Range { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Range { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { self.start.fmt(fmt)?; write!(fmt, "..")?; self.end.fmt(fmt)?; @@ -186,7 +186,7 @@ pub struct RangeFrom { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for RangeFrom { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { self.start.fmt(fmt)?; write!(fmt, "..")?; Ok(()) @@ -270,7 +270,7 @@ pub struct RangeTo { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for RangeTo { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "..")?; self.end.fmt(fmt)?; Ok(()) @@ -473,7 +473,7 @@ impl RangeInclusive { #[stable(feature = "inclusive_range", since = "1.26.0")] impl fmt::Debug for RangeInclusive { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { self.start.fmt(fmt)?; write!(fmt, "..=")?; self.end.fmt(fmt)?; @@ -611,7 +611,7 @@ pub struct RangeToInclusive { #[stable(feature = "inclusive_range", since = "1.26.0")] impl fmt::Debug for RangeToInclusive { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "..=")?; self.end.fmt(fmt)?; Ok(()) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 7ce9a73a78205..9599491462e92 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -538,7 +538,7 @@ impl Option { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { inner: Item { opt: self.as_ref() } } } @@ -559,7 +559,7 @@ impl Option { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut { inner: Item { opt: self.as_mut() } } } diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs index bcb87bdd098fc..989fc96732a5a 100644 --- a/src/libcore/panic.rs +++ b/src/libcore/panic.rs @@ -86,7 +86,7 @@ impl<'a> PanicInfo<'a> { /// /// [`fmt::write`]: ../fmt/fn.write.html #[unstable(feature = "panic_info_message", issue = "44489")] - pub fn message(&self) -> Option<&fmt::Arguments> { + pub fn message(&self) -> Option<&fmt::Arguments<'_>> { self.message } @@ -115,7 +115,7 @@ impl<'a> PanicInfo<'a> { /// panic!("Normal panic"); /// ``` #[stable(feature = "panic_hooks", since = "1.10.0")] - pub fn location(&self) -> Option<&Location> { + pub fn location(&self) -> Option<&Location<'_>> { // NOTE: If this is changed to sometimes return None, // deal with that case in std::panicking::default_hook and std::panicking::begin_panic_fmt. Some(&self.location) @@ -124,7 +124,7 @@ impl<'a> PanicInfo<'a> { #[stable(feature = "panic_hook_display", since = "1.26.0")] impl fmt::Display for PanicInfo<'_> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("panicked at ")?; if let Some(message) = self.message { write!(formatter, "'{}', ", message)? @@ -249,7 +249,7 @@ impl<'a> Location<'a> { #[stable(feature = "panic_hook_display", since = "1.26.0")] impl fmt::Display for Location<'_> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "{}:{}:{}", self.file, self.line, self.col) } } diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 4b991b8792576..15b7d69c58d24 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -65,7 +65,7 @@ fn panic_bounds_check(file_line_col: &(&'static str, u32, u32), #[cold] #[cfg_attr(not(feature="panic_immediate_abort"),inline(never))] #[cfg_attr( feature="panic_immediate_abort" ,inline)] -pub fn panic_fmt(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32)) -> ! { +pub fn panic_fmt(fmt: fmt::Arguments<'_>, file_line_col: &(&'static str, u32, u32)) -> ! { if cfg!(feature = "panic_immediate_abort") { unsafe { super::intrinsics::abort() } } @@ -74,7 +74,7 @@ pub fn panic_fmt(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32)) #[allow(improper_ctypes)] // PanicInfo contains a trait object which is not FFI safe extern "Rust" { #[lang = "panic_impl"] - fn panic_impl(pi: &PanicInfo) -> !; + fn panic_impl(pi: &PanicInfo<'_>) -> !; } let (file, line, col) = *file_line_col; diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index 538e1aa481cfe..dbf3dcf03a3c0 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -602,21 +602,21 @@ impl Receiver for Pin

{} #[stable(feature = "pin", since = "1.33.0")] impl fmt::Debug for Pin

{ - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.pointer, f) } } #[stable(feature = "pin", since = "1.33.0")] impl fmt::Display for Pin

{ - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.pointer, f) } } #[stable(feature = "pin", since = "1.33.0")] impl fmt::Pointer for Pin

{ - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&self.pointer, f) } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 32dcb5bff3691..f05700a1db285 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2623,14 +2623,14 @@ macro_rules! fnptr_impls_safety_abi { #[stable(feature = "fnptr_impls", since = "1.4.0")] impl fmt::Pointer for $FnTy { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&(*self as *const ()), f) } } #[stable(feature = "fnptr_impls", since = "1.4.0")] impl fmt::Debug for $FnTy { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&(*self as *const ()), f) } } @@ -2776,7 +2776,7 @@ pub struct Unique { #[unstable(feature = "ptr_internals", issue = "0")] impl fmt::Debug for Unique { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } @@ -2876,7 +2876,7 @@ impl DispatchFromDyn> for Unique where T: Uns #[unstable(feature = "ptr_internals", issue = "0")] impl fmt::Pointer for Unique { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } @@ -3049,14 +3049,14 @@ impl DispatchFromDyn> for NonNull where T: U #[stable(feature = "nonnull", since = "1.25.0")] impl fmt::Debug for NonNull { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } #[stable(feature = "nonnull", since = "1.25.0")] impl fmt::Pointer for NonNull { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 0277e52a9a648..bf8fd63b6446f 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -544,7 +544,7 @@ impl Result { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter { inner: self.as_ref().ok() } } @@ -569,7 +569,7 @@ impl Result { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut { inner: self.as_mut().ok() } } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 44d56c60b7899..21c16e65e4ee4 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -524,7 +524,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { unsafe { let ptr = self.as_ptr(); assume(!ptr.is_null()); @@ -556,7 +556,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { unsafe { let ptr = self.as_mut_ptr(); assume(!ptr.is_null()); @@ -603,7 +603,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn windows(&self, size: usize) -> Windows { + pub fn windows(&self, size: usize) -> Windows<'_, T> { assert!(size != 0); Windows { v: self, size } } @@ -637,7 +637,7 @@ impl [T] { /// [`rchunks`]: #method.rchunks #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn chunks(&self, chunk_size: usize) -> Chunks { + pub fn chunks(&self, chunk_size: usize) -> Chunks<'_, T> { assert!(chunk_size != 0); Chunks { v: self, chunk_size } } @@ -675,7 +675,7 @@ impl [T] { /// [`rchunks_mut`]: #method.rchunks_mut #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut { + pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> { assert!(chunk_size != 0); ChunksMut { v: self, chunk_size } } @@ -712,7 +712,7 @@ impl [T] { /// [`rchunks_exact`]: #method.rchunks_exact #[stable(feature = "chunks_exact", since = "1.31.0")] #[inline] - pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact { + pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T> { assert!(chunk_size != 0); let rem = self.len() % chunk_size; let len = self.len() - rem; @@ -757,7 +757,7 @@ impl [T] { /// [`rchunks_exact_mut`]: #method.rchunks_exact_mut #[stable(feature = "chunks_exact", since = "1.31.0")] #[inline] - pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut { + pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T> { assert!(chunk_size != 0); let rem = self.len() % chunk_size; let len = self.len() - rem; @@ -794,7 +794,7 @@ impl [T] { /// [`chunks`]: #method.chunks #[stable(feature = "rchunks", since = "1.31.0")] #[inline] - pub fn rchunks(&self, chunk_size: usize) -> RChunks { + pub fn rchunks(&self, chunk_size: usize) -> RChunks<'_, T> { assert!(chunk_size != 0); RChunks { v: self, chunk_size } } @@ -832,7 +832,7 @@ impl [T] { /// [`chunks_mut`]: #method.chunks_mut #[stable(feature = "rchunks", since = "1.31.0")] #[inline] - pub fn rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut { + pub fn rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut<'_, T> { assert!(chunk_size != 0); RChunksMut { v: self, chunk_size } } @@ -871,7 +871,7 @@ impl [T] { /// [`chunks_exact`]: #method.chunks_exact #[stable(feature = "rchunks", since = "1.31.0")] #[inline] - pub fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact { + pub fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T> { assert!(chunk_size != 0); let rem = self.len() % chunk_size; let (fst, snd) = self.split_at(rem); @@ -916,7 +916,7 @@ impl [T] { /// [`chunks_exact_mut`]: #method.chunks_exact_mut #[stable(feature = "rchunks", since = "1.31.0")] #[inline] - pub fn rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut { + pub fn rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut<'_, T> { assert!(chunk_size != 0); let rem = self.len() % chunk_size; let (fst, snd) = self.split_at_mut(rem); @@ -1042,7 +1042,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn split(&self, pred: F) -> Split + pub fn split(&self, pred: F) -> Split<'_, T, F> where F: FnMut(&T) -> bool { Split { @@ -1067,7 +1067,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn split_mut(&mut self, pred: F) -> SplitMut + pub fn split_mut(&mut self, pred: F) -> SplitMut<'_, T, F> where F: FnMut(&T) -> bool { SplitMut { v: self, pred, finished: false } @@ -1102,7 +1102,7 @@ impl [T] { /// ``` #[stable(feature = "slice_rsplit", since = "1.27.0")] #[inline] - pub fn rsplit(&self, pred: F) -> RSplit + pub fn rsplit(&self, pred: F) -> RSplit<'_, T, F> where F: FnMut(&T) -> bool { RSplit { inner: self.split(pred) } @@ -1127,7 +1127,7 @@ impl [T] { /// #[stable(feature = "slice_rsplit", since = "1.27.0")] #[inline] - pub fn rsplit_mut(&mut self, pred: F) -> RSplitMut + pub fn rsplit_mut(&mut self, pred: F) -> RSplitMut<'_, T, F> where F: FnMut(&T) -> bool { RSplitMut { inner: self.split_mut(pred) } @@ -1154,7 +1154,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn splitn(&self, n: usize, pred: F) -> SplitN + pub fn splitn(&self, n: usize, pred: F) -> SplitN<'_, T, F> where F: FnMut(&T) -> bool { SplitN { @@ -1184,7 +1184,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn splitn_mut(&mut self, n: usize, pred: F) -> SplitNMut + pub fn splitn_mut(&mut self, n: usize, pred: F) -> SplitNMut<'_, T, F> where F: FnMut(&T) -> bool { SplitNMut { @@ -1217,7 +1217,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn rsplitn(&self, n: usize, pred: F) -> RSplitN + pub fn rsplitn(&self, n: usize, pred: F) -> RSplitN<'_, T, F> where F: FnMut(&T) -> bool { RSplitN { @@ -1248,7 +1248,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn rsplitn_mut(&mut self, n: usize, pred: F) -> RSplitNMut + pub fn rsplitn_mut(&mut self, n: usize, pred: F) -> RSplitNMut<'_, T, F> where F: FnMut(&T) -> bool { RSplitNMut { @@ -3284,7 +3284,7 @@ pub struct Iter<'a, T: 'a> { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for Iter<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Iter") .field(&self.as_slice()) .finish() @@ -3386,7 +3386,7 @@ pub struct IterMut<'a, T: 'a> { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for IterMut<'_, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("IterMut") .field(&self.make_slice()) .finish() @@ -3493,7 +3493,7 @@ pub struct Split<'a, T:'a, P> where P: FnMut(&T) -> bool { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for Split<'_, T, P> where P: FnMut(&T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Split") .field("v", &self.v) .field("finished", &self.finished) @@ -3584,7 +3584,7 @@ pub struct SplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for SplitMut<'_, T, P> where P: FnMut(&T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SplitMut") .field("v", &self.v) .field("finished", &self.finished) @@ -3681,7 +3681,7 @@ pub struct RSplit<'a, T:'a, P> where P: FnMut(&T) -> bool { #[stable(feature = "slice_rsplit", since = "1.27.0")] impl fmt::Debug for RSplit<'_, T, P> where P: FnMut(&T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RSplit") .field("v", &self.inner.v) .field("finished", &self.inner.finished) @@ -3737,7 +3737,7 @@ pub struct RSplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool { #[stable(feature = "slice_rsplit", since = "1.27.0")] impl fmt::Debug for RSplitMut<'_, T, P> where P: FnMut(&T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RSplitMut") .field("v", &self.inner.v) .field("finished", &self.inner.finished) @@ -3823,7 +3823,7 @@ pub struct SplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for SplitN<'_, T, P> where P: FnMut(&T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SplitN") .field("inner", &self.inner) .finish() @@ -3845,7 +3845,7 @@ pub struct RSplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for RSplitN<'_, T, P> where P: FnMut(&T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RSplitN") .field("inner", &self.inner) .finish() @@ -3866,7 +3866,7 @@ pub struct SplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for SplitNMut<'_, T, P> where P: FnMut(&T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SplitNMut") .field("inner", &self.inner) .finish() @@ -3888,7 +3888,7 @@ pub struct RSplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for RSplitNMut<'_, T, P> where P: FnMut(&T) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("RSplitNMut") .field("inner", &self.inner) .finish() diff --git a/src/libcore/str/lossy.rs b/src/libcore/str/lossy.rs index 16dd4fe6135be..b291579553a64 100644 --- a/src/libcore/str/lossy.rs +++ b/src/libcore/str/lossy.rs @@ -18,7 +18,7 @@ impl Utf8Lossy { unsafe { mem::transmute(bytes) } } - pub fn chunks(&self) -> Utf8LossyChunksIter { + pub fn chunks(&self) -> Utf8LossyChunksIter<'_> { Utf8LossyChunksIter { source: &self.bytes } } } @@ -138,7 +138,7 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> { impl fmt::Display for Utf8Lossy { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // If we're the empty string then our iterator won't actually yield // anything, so perform the formatting manually if self.bytes.len() == 0 { @@ -164,7 +164,7 @@ impl fmt::Display for Utf8Lossy { } impl fmt::Debug for Utf8Lossy { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_char('"')?; for Utf8LossyChunk { valid, broken } in self.chunks() { diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index f4bb887dd2943..e83581363c866 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -146,7 +146,7 @@ pub struct ParseBoolError { _priv: () } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for ParseBoolError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { "provided string was not `true` or `false`".fmt(f) } } @@ -439,7 +439,7 @@ pub unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Utf8Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(error_len) = self.error_len { write!(f, "invalid utf-8 sequence of {} bytes from index {}", error_len, self.valid_up_to) @@ -914,7 +914,7 @@ macro_rules! generate_pattern_iterators { impl<'a, P: Pattern<'a>> fmt::Debug for $forward_iterator<'a, P> where P::Searcher: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple(stringify!($forward_iterator)) .field(&self.0) .finish() @@ -948,7 +948,7 @@ macro_rules! generate_pattern_iterators { impl<'a, P: Pattern<'a>> fmt::Debug for $reverse_iterator<'a, P> where P::Searcher: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple(stringify!($reverse_iterator)) .field(&self.0) .finish() @@ -1033,7 +1033,7 @@ struct SplitInternal<'a, P: Pattern<'a>> { } impl<'a, P: Pattern<'a>> fmt::Debug for SplitInternal<'a, P> where P::Searcher: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SplitInternal") .field("start", &self.start) .field("end", &self.end) @@ -1150,7 +1150,7 @@ struct SplitNInternal<'a, P: Pattern<'a>> { } impl<'a, P: Pattern<'a>> fmt::Debug for SplitNInternal<'a, P> where P::Searcher: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SplitNInternal") .field("iter", &self.iter) .field("count", &self.count) @@ -1206,7 +1206,7 @@ derive_pattern_clone!{ struct MatchIndicesInternal<'a, P: Pattern<'a>>(P::Searcher); impl<'a, P: Pattern<'a>> fmt::Debug for MatchIndicesInternal<'a, P> where P::Searcher: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("MatchIndicesInternal") .field(&self.0) .finish() @@ -1257,7 +1257,7 @@ derive_pattern_clone!{ struct MatchesInternal<'a, P: Pattern<'a>>(P::Searcher); impl<'a, P: Pattern<'a>> fmt::Debug for MatchesInternal<'a, P> where P::Searcher: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("MatchesInternal") .field(&self.0) .finish() @@ -2559,7 +2559,7 @@ impl str { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn chars(&self) -> Chars { + pub fn chars(&self) -> Chars<'_> { Chars{iter: self.as_bytes().iter()} } @@ -2614,7 +2614,7 @@ impl str { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn char_indices(&self) -> CharIndices { + pub fn char_indices(&self) -> CharIndices<'_> { CharIndices { front_offset: 0, iter: self.chars() } } @@ -2639,7 +2639,7 @@ impl str { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn bytes(&self) -> Bytes { + pub fn bytes(&self) -> Bytes<'_> { Bytes(self.as_bytes().iter().cloned()) } @@ -2682,7 +2682,7 @@ impl str { /// ``` #[stable(feature = "split_whitespace", since = "1.1.0")] #[inline] - pub fn split_whitespace(&self) -> SplitWhitespace { + pub fn split_whitespace(&self) -> SplitWhitespace<'_> { SplitWhitespace { inner: self.split(IsWhitespace).filter(IsNotEmpty) } } @@ -2723,7 +2723,7 @@ impl str { /// ``` #[stable(feature = "split_ascii_whitespace", since = "1.34.0")] #[inline] - pub fn split_ascii_whitespace(&self) -> SplitAsciiWhitespace { + pub fn split_ascii_whitespace(&self) -> SplitAsciiWhitespace<'_> { let inner = self .as_bytes() .split(IsAsciiWhitespace) @@ -2770,7 +2770,7 @@ impl str { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn lines(&self) -> Lines { + pub fn lines(&self) -> Lines<'_> { Lines(self.split_terminator('\n').map(LinesAnyMap)) } @@ -2779,7 +2779,7 @@ impl str { #[rustc_deprecated(since = "1.4.0", reason = "use lines() instead now")] #[inline] #[allow(deprecated)] - pub fn lines_any(&self) -> LinesAny { + pub fn lines_any(&self) -> LinesAny<'_> { LinesAny(self.lines()) } @@ -2798,7 +2798,7 @@ impl str { /// assert!(utf16_len <= utf8_len); /// ``` #[stable(feature = "encode_utf16", since = "1.8.0")] - pub fn encode_utf16(&self) -> EncodeUtf16 { + pub fn encode_utf16(&self) -> EncodeUtf16<'_> { EncodeUtf16 { chars: self.chars(), extra: 0 } } @@ -4018,7 +4018,7 @@ impl str { /// assert_eq!("❤\n!".escape_debug().to_string(), "❤\\n!"); /// ``` #[stable(feature = "str_escape", since = "1.34.0")] - pub fn escape_debug(&self) -> EscapeDebug { + pub fn escape_debug(&self) -> EscapeDebug<'_> { let mut chars = self.chars(); EscapeDebug { inner: chars.next() @@ -4063,7 +4063,7 @@ impl str { /// assert_eq!("❤\n!".escape_default().to_string(), "\\u{2764}\\n!"); /// ``` #[stable(feature = "str_escape", since = "1.34.0")] - pub fn escape_default(&self) -> EscapeDefault { + pub fn escape_default(&self) -> EscapeDefault<'_> { EscapeDefault { inner: self.chars().flat_map(CharEscapeDefault) } } @@ -4101,7 +4101,7 @@ impl str { /// assert_eq!("❤\n!".escape_unicode().to_string(), "\\u{2764}\\u{a}\\u{21}"); /// ``` #[stable(feature = "str_escape", since = "1.34.0")] - pub fn escape_unicode(&self) -> EscapeUnicode { + pub fn escape_unicode(&self) -> EscapeUnicode<'_> { EscapeUnicode { inner: self.chars().flat_map(CharEscapeUnicode) } } } @@ -4267,7 +4267,7 @@ pub struct EncodeUtf16<'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for EncodeUtf16<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pad("EncodeUtf16 { .. }") } } @@ -4341,7 +4341,7 @@ macro_rules! escape_types_impls { ($( $Name: ident ),+) => {$( #[stable(feature = "str_escape", since = "1.34.0")] impl<'a> fmt::Display for $Name<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.clone().try_for_each(|c| f.write_char(c)) } } diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 5dd4aec5e5a57..ad9d956fda1c8 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -658,7 +658,7 @@ pub struct CharPredicateSearcher<'a, F>( as Pattern<'a>>:: impl fmt::Debug for CharPredicateSearcher<'_, F> where F: FnMut(char) -> bool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("CharPredicateSearcher") .field("haystack", &self.0.haystack) .field("char_indices", &self.0.char_indices) diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 7ae91b3049814..12414980d76b1 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -1193,7 +1193,7 @@ macro_rules! atomic_int { #[$stable_debug] impl fmt::Debug for $atomic_type { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) } } @@ -2506,7 +2506,7 @@ pub fn compiler_fence(order: Ordering) { #[cfg(target_has_atomic = "8")] #[stable(feature = "atomic_debug", since = "1.3.0")] impl fmt::Debug for AtomicBool { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) } } @@ -2514,7 +2514,7 @@ impl fmt::Debug for AtomicBool { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "atomic_debug", since = "1.3.0")] impl fmt::Debug for AtomicPtr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) } } @@ -2522,7 +2522,7 @@ impl fmt::Debug for AtomicPtr { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "atomic_pointer", since = "1.24.0")] impl fmt::Pointer for AtomicPtr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Pointer::fmt(&self.load(Ordering::SeqCst), f) } } diff --git a/src/libcore/task/wake.rs b/src/libcore/task/wake.rs index 1d3140070f351..94e31054a5812 100644 --- a/src/libcore/task/wake.rs +++ b/src/libcore/task/wake.rs @@ -180,7 +180,7 @@ impl<'a> Context<'a> { } impl fmt::Debug for Context<'_> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Context") .field("waker", &self.waker) .finish() @@ -283,7 +283,7 @@ impl Drop for Waker { } impl fmt::Debug for Waker { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let vtable_ptr = self.waker.vtable as *const RawWakerVTable; f.debug_struct("Waker") .field("data", &self.waker.data) diff --git a/src/libcore/time.rs b/src/libcore/time.rs index 9bb187e7de9f6..0f5f91f41a8cd 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -847,7 +847,7 @@ impl<'a> Sum<&'a Duration> for Duration { #[stable(feature = "duration_debug_impl", since = "1.27.0")] impl fmt::Debug for Duration { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// Formats a floating point number in decimal notation. /// /// The number is given as the `integer_part` and a fractional part. @@ -859,7 +859,7 @@ impl fmt::Debug for Duration { /// of 10, everything else doesn't make sense. `fractional_part` has /// to be less than `10 * divisor`! fn fmt_decimal( - f: &mut fmt::Formatter, + f: &mut fmt::Formatter<'_>, mut integer_part: u64, mut fractional_part: u32, mut divisor: u32,