From abbc7365a726269e13b7ee2864bb6086dfc41d69 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 8 May 2020 15:19:14 +0200 Subject: [PATCH 1/6] Add emoji for deprecated messages --- src/librustdoc/html/render.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 666e59b9a045e..82f91e232df3b 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2281,7 +2281,10 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec { ); message.push_str(&format!(": {}", html.to_string())); } - stability.push(format!("
{}
", message)); + stability.push(format!( + "
👎 {}
", + message, + )); } if let Some(stab) = item.stability.as_ref().filter(|stab| stab.level == stability::Unstable) { From 9d8310856b3a42aa99d6591244a6679284011dc9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 8 May 2020 15:27:08 +0200 Subject: [PATCH 2/6] Add test for deprecated emoji --- src/test/rustdoc/issue-32374.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/rustdoc/issue-32374.rs b/src/test/rustdoc/issue-32374.rs index 7babfaf6060f4..11caa34d4b114 100644 --- a/src/test/rustdoc/issue-32374.rs +++ b/src/test/rustdoc/issue-32374.rs @@ -10,7 +10,7 @@ // @matches issue_32374/index.html '//*[@class="docblock-short"]/text()' 'Docs' // @has issue_32374/struct.T.html '//*[@class="stab deprecated"]' \ -// 'Deprecated since 1.0.0: text' +// '👎 Deprecated since 1.0.0: text' // @has - 'test #32374' // @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ // '🔬 This is a nightly-only experimental API. \(test\s#32374\)$' @@ -20,7 +20,7 @@ pub struct T; // @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \ -// 'Deprecated since 1.0.0: deprecated' +// '👎 Deprecated since 1.0.0: deprecated' // @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \ // '🔬 This is a nightly-only experimental API. (test #32374)' // @has issue_32374/struct.U.html '//details' \ From 0db2aec14a93fd9c5b084aa5f973d3609e625bf6 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Sat, 9 May 2020 17:10:40 +0200 Subject: [PATCH 3/6] display `ConstKind::Param` --- src/librustc_middle/ty/print/pretty.rs | 4 +++- src/test/ui/array-slice-vec/match_arr_unknown_len.stderr | 2 +- .../array-impls/alloc-types-no-impls-length-33.stderr | 6 +++--- .../array-impls/core-traits-no-impls-length-33.stderr | 4 ++-- src/test/ui/const-generics/broken-mir-2.stderr | 6 +++--- .../ui/const-generics/derive-debug-array-wrapper.stderr | 6 +++--- src/test/ui/const-generics/issues/issue-62504.stderr | 2 +- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index 2d2704fc2bd89..8ec81fb3c570d 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -701,12 +701,14 @@ pub trait PrettyPrinter<'tcx>: if self.tcx().sess.verbose() { p!(write("{:?}", sz)); } else if let ty::ConstKind::Unevaluated(..) = sz.val { - // do not try to evaluate unevaluated constants. If we are const evaluating an + // Do not try to evaluate unevaluated constants. If we are const evaluating an // array length anon const, rustc will (with debug assertions) print the // constant's path. Which will end up here again. p!(write("_")); } else if let Some(n) = sz.val.try_to_bits(self.tcx().data_layout.pointer_size) { p!(write("{}", n)); + } else if let ty::ConstKind::Param(param) = sz.val { + p!(write("{}", param)); } else { p!(write("_")); } diff --git a/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr b/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr index 09f65f6acd069..ed29443332f62 100644 --- a/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr +++ b/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr @@ -13,7 +13,7 @@ LL | [1, 2] => true, | ^^^^^^ expected `2usize`, found `N` | = note: expected array `[u32; 2]` - found array `[u32; _]` + found array `[u32; N]` error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr b/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr index d795840551c50..bd26c08a8e5da 100644 --- a/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr +++ b/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr @@ -29,7 +29,7 @@ LL | let boxed_array = >::try_from(boxed_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::boxed::Box<[i32; 33]>` | = help: the following implementations were found: - as std::convert::TryFrom>> + as std::convert::TryFrom>> error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From>` is not satisfied --> $DIR/alloc-types-no-impls-length-33.rs:19:23 @@ -53,7 +53,7 @@ LL | let boxed_array = >::try_from(boxed_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::rc::Rc<[i32; 33]>` | = help: the following implementations were found: - as std::convert::TryFrom>> + as std::convert::TryFrom>> error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From>` is not satisfied --> $DIR/alloc-types-no-impls-length-33.rs:26:23 @@ -77,7 +77,7 @@ LL | let boxed_array = >::try_from(boxed_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::sync::Arc<[i32; 33]>` | = help: the following implementations were found: - as std::convert::TryFrom>> + as std::convert::TryFrom>> error: aborting due to 7 previous errors diff --git a/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr b/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr index c03377d74e9b7..76ccc48c32ac1 100644 --- a/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr +++ b/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr @@ -39,9 +39,9 @@ LL | for _ in &[0_usize; 33] { | ^^^^^^^^^^^^^^ the trait `std::iter::IntoIterator` is not implemented for `&[usize; 33]` | = help: the following implementations were found: - <&'a [T; _] as std::iter::IntoIterator> + <&'a [T; N] as std::iter::IntoIterator> <&'a [T] as std::iter::IntoIterator> - <&'a mut [T; _] as std::iter::IntoIterator> + <&'a mut [T; N] as std::iter::IntoIterator> <&'a mut [T] as std::iter::IntoIterator> = note: required by `std::iter::IntoIterator::into_iter` diff --git a/src/test/ui/const-generics/broken-mir-2.stderr b/src/test/ui/const-generics/broken-mir-2.stderr index cbb8159e9b5df..d48524f66dd99 100644 --- a/src/test/ui/const-generics/broken-mir-2.stderr +++ b/src/test/ui/const-generics/broken-mir-2.stderr @@ -10,10 +10,10 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32 --> $DIR/broken-mir-2.rs:7:36 | LL | struct S([T; N]); - | ^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[T; _]` + | ^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[T; N]` | - = note: required because of the requirements on the impl of `std::fmt::Debug` for `[T; _]` - = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[T; _]` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `[T; N]` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[T; N]` = note: required for the cast to the object type `dyn std::fmt::Debug` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/const-generics/derive-debug-array-wrapper.stderr b/src/test/ui/const-generics/derive-debug-array-wrapper.stderr index 672586fd3fe00..35ecc49cfb3ab 100644 --- a/src/test/ui/const-generics/derive-debug-array-wrapper.stderr +++ b/src/test/ui/const-generics/derive-debug-array-wrapper.stderr @@ -10,10 +10,10 @@ error[E0277]: arrays only have std trait implementations for lengths 0..=32 --> $DIR/derive-debug-array-wrapper.rs:6:5 | LL | a: [u32; N], - | ^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[u32; _]` + | ^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[u32; N]` | - = note: required because of the requirements on the impl of `std::fmt::Debug` for `[u32; _]` - = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[u32; _]` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `[u32; N]` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[u32; N]` = note: required for the cast to the object type `dyn std::fmt::Debug` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/const-generics/issues/issue-62504.stderr b/src/test/ui/const-generics/issues/issue-62504.stderr index a3a864f770cb8..5d45e302888d4 100644 --- a/src/test/ui/const-generics/issues/issue-62504.stderr +++ b/src/test/ui/const-generics/issues/issue-62504.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | ArrayHolder([0; Self::SIZE]) | ^^^^^^^^^^^^^^^ expected `X`, found `Self::SIZE` | - = note: expected array `[u32; _]` + = note: expected array `[u32; X]` found array `[u32; _]` error: constant expression depends on a generic parameter From 0ceacd022c326dadfc65e5cffcde28449c3d735a Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Sun, 10 May 2020 11:24:06 +0200 Subject: [PATCH 4/6] doc: minus (U+2212) instead of dash (U+002D) for negative infinity --- src/libcore/num/f32.rs | 2 +- src/libcore/num/f64.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 4483940c9a771..434569020d2a8 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -367,7 +367,7 @@ impl f32 { /// Infinity (∞). #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const INFINITY: f32 = 1.0_f32 / 0.0_f32; - /// Negative infinity (-∞). + /// Negative infinity (−∞). #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const NEG_INFINITY: f32 = -1.0_f32 / 0.0_f32; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index df45e588369fe..6476ddb4541ff 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -366,7 +366,7 @@ impl f64 { /// Infinity (∞). #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const INFINITY: f64 = 1.0_f64 / 0.0_f64; - /// Negative infinity (-∞). + /// Negative infinity (−∞). #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64; From 0aaff14ae38aa24729fe2fc056ce9fc79b5dda57 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 10 May 2020 12:40:11 +0200 Subject: [PATCH 5/6] Improve E0571 wording --- src/librustc_error_codes/error_codes/E0571.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0571.md b/src/librustc_error_codes/error_codes/E0571.md index c2a3a8d758881..eadae05aa304c 100644 --- a/src/librustc_error_codes/error_codes/E0571.md +++ b/src/librustc_error_codes/error_codes/E0571.md @@ -7,7 +7,7 @@ Example of erroneous code: # fn satisfied(n: usize) -> bool { n % 23 == 0 } let result = while true { if satisfied(i) { - break 2*i; // error: `break` with value from a `while` loop + break 2 * i; // error: `break` with value from a `while` loop } i += 1; }; @@ -22,9 +22,9 @@ Make sure `break value;` statements only occur in `loop` loops: ``` # let mut i = 1; # fn satisfied(n: usize) -> bool { n % 23 == 0 } -let result = loop { // ok! +let result = loop { // This is now a "loop" loop. if satisfied(i) { - break 2*i; + break 2 * i; // ok! } i += 1; }; From 62116c31cd863c8aab35e5c7acfb8ded41ca28a1 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 10 May 2020 00:33:08 +0200 Subject: [PATCH 6/6] Emit a warning when optimization fuel runs out `eprintln!` gets swallowed by Cargo too easily. --- src/librustc_session/session.rs | 2 +- src/test/ui/optimization-fuel-0.rs | 3 +-- src/test/ui/optimization-fuel-0.stderr | 5 ++++- src/test/ui/optimization-fuel-1.rs | 3 +-- src/test/ui/optimization-fuel-1.stderr | 5 ++++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs index 48e36fdb3d499..15bd87d5ffdb1 100644 --- a/src/librustc_session/session.rs +++ b/src/librustc_session/session.rs @@ -813,7 +813,7 @@ impl Session { let mut fuel = self.optimization_fuel.lock(); ret = fuel.remaining != 0; if fuel.remaining == 0 && !fuel.out_of_fuel { - eprintln!("optimization-fuel-exhausted: {}", msg()); + self.warn(&format!("optimization-fuel-exhausted: {}", msg())); fuel.out_of_fuel = true; } else if fuel.remaining > 0 { fuel.remaining -= 1; diff --git a/src/test/ui/optimization-fuel-0.rs b/src/test/ui/optimization-fuel-0.rs index f86972b734826..a97c5750f94c3 100644 --- a/src/test/ui/optimization-fuel-0.rs +++ b/src/test/ui/optimization-fuel-0.rs @@ -4,8 +4,7 @@ use std::mem::size_of; -// (#55495: The --error-format is to sidestep an issue in our test harness) -// compile-flags: --error-format human -Z fuel=foo=0 +// compile-flags: -Z fuel=foo=0 struct S1(u8, u16, u8); struct S2(u8, u16, u8); diff --git a/src/test/ui/optimization-fuel-0.stderr b/src/test/ui/optimization-fuel-0.stderr index 3ad405b2b50ff..f0e2ebfc37a37 100644 --- a/src/test/ui/optimization-fuel-0.stderr +++ b/src/test/ui/optimization-fuel-0.stderr @@ -1 +1,4 @@ -optimization-fuel-exhausted: Reorder fields of "S1" +warning: optimization-fuel-exhausted: Reorder fields of "S1" + +warning: 1 warning emitted + diff --git a/src/test/ui/optimization-fuel-1.rs b/src/test/ui/optimization-fuel-1.rs index 98283066361c2..a09f91c68abe7 100644 --- a/src/test/ui/optimization-fuel-1.rs +++ b/src/test/ui/optimization-fuel-1.rs @@ -4,8 +4,7 @@ use std::mem::size_of; -// (#55495: The --error-format is to sidestep an issue in our test harness) -// compile-flags: --error-format human -Z fuel=foo=1 +// compile-flags: -Z fuel=foo=1 struct S1(u8, u16, u8); struct S2(u8, u16, u8); diff --git a/src/test/ui/optimization-fuel-1.stderr b/src/test/ui/optimization-fuel-1.stderr index 197e45219c3f8..53eafb05830cb 100644 --- a/src/test/ui/optimization-fuel-1.stderr +++ b/src/test/ui/optimization-fuel-1.stderr @@ -1 +1,4 @@ -optimization-fuel-exhausted: Reorder fields of "S2" +warning: optimization-fuel-exhausted: Reorder fields of "S2" + +warning: 1 warning emitted +