From a1f81ff0ad112d1d8e1ce86df1feb8abcdac76b6 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 29 Apr 2020 11:52:02 -0400 Subject: [PATCH 01/17] rustdoc supports const re-exports --- .../{issue-27362.rs => issue-27362-aux.rs} | 0 src/test/rustdoc/issue-27362.rs | 14 +++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) rename src/test/rustdoc/auxiliary/{issue-27362.rs => issue-27362-aux.rs} (100%) diff --git a/src/test/rustdoc/auxiliary/issue-27362.rs b/src/test/rustdoc/auxiliary/issue-27362-aux.rs similarity index 100% rename from src/test/rustdoc/auxiliary/issue-27362.rs rename to src/test/rustdoc/auxiliary/issue-27362-aux.rs diff --git a/src/test/rustdoc/issue-27362.rs b/src/test/rustdoc/issue-27362.rs index 3f3878350d515..1cbba4b663df8 100644 --- a/src/test/rustdoc/issue-27362.rs +++ b/src/test/rustdoc/issue-27362.rs @@ -1,10 +1,10 @@ -// aux-build:issue-27362.rs +// aux-build:issue-27362-aux.rs // ignore-cross-compile -// ignore-test This test fails on beta/stable #32019 -extern crate issue_27362; -pub use issue_27362 as quux; +extern crate issue_27362_aux; -// @matches issue_27362/quux/fn.foo.html '//pre' "pub const fn foo()" -// @matches issue_27362/quux/fn.bar.html '//pre' "pub const unsafe fn bar()" -// @matches issue_27362/quux/struct.Foo.html '//code' "const unsafe fn baz()" +pub use issue_27362_aux::*; + +// @matches issue_27362/fn.foo.html '//pre' "pub const fn foo()" +// @matches issue_27362/fn.bar.html '//pre' "pub const unsafe fn bar()" +// @matches issue_27362/struct.Foo.html '//code' "const unsafe fn baz()" From 70fafed3c8c48062617a2811d0cd3e0fafcf3319 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 30 Apr 2020 09:55:15 -0400 Subject: [PATCH 02/17] Remove unsized enum test This was already tested (at least) by src/test/ui/unsized/unsized-enum2.rs --- src/test/ui/issues/issue-17025.rs | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 src/test/ui/issues/issue-17025.rs diff --git a/src/test/ui/issues/issue-17025.rs b/src/test/ui/issues/issue-17025.rs deleted file mode 100644 index 6b7b6d010aa22..0000000000000 --- a/src/test/ui/issues/issue-17025.rs +++ /dev/null @@ -1,13 +0,0 @@ -// ignore-test the unsized enum no longer compiles - -enum A { - B(char), - C([Box]), -} - -fn c(c:char) { - A::B(c); - //~^ ERROR cannot move a value of type A: the size of A cannot be statically determined -} - -pub fn main() {} From bfed215cedceecb4e4c45ccf48d86b4a8df3ae38 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 30 Apr 2020 10:23:45 -0400 Subject: [PATCH 03/17] Remove ignored type alias test This is tracked by a GH issue 17164, and having an ignored test for it isn't helpful. --- .../fully-qualified-type-name3.rs | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/test/ui/fully-qualified-type/fully-qualified-type-name3.rs diff --git a/src/test/ui/fully-qualified-type/fully-qualified-type-name3.rs b/src/test/ui/fully-qualified-type/fully-qualified-type-name3.rs deleted file mode 100644 index 22faa66d9fb03..0000000000000 --- a/src/test/ui/fully-qualified-type/fully-qualified-type-name3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Test that we use fully-qualified type names in error messages. - -// ignore-test - -type T1 = usize; -type T2 = isize; - -fn bar(x: T1) -> T2 { - return x; - //~^ ERROR mismatched types: expected `T2`, found `T1` -} - -fn main() { -} From 34eb2c1d4ff61693ab45863ee0f9ee298148a1ab Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Wed, 22 Apr 2020 21:40:18 +0100 Subject: [PATCH 04/17] Report cannot move errors in promoted MIR --- src/librustc_mir/borrow_check/mod.rs | 48 ++++++++++++++++--- .../ui/borrowck/move-error-in-promoted-2.rs | 10 ++++ .../borrowck/move-error-in-promoted-2.stderr | 12 +++++ .../ui/borrowck/move-error-in-promoted.rs | 17 +++++++ .../ui/borrowck/move-error-in-promoted.stderr | 12 +++++ 5 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/borrowck/move-error-in-promoted-2.rs create mode 100644 src/test/ui/borrowck/move-error-in-promoted-2.stderr create mode 100644 src/test/ui/borrowck/move-error-in-promoted.rs create mode 100644 src/test/ui/borrowck/move-error-in-promoted.stderr diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 7c7251c913492..a548b6b4c37cd 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -180,11 +180,14 @@ fn do_mir_borrowck<'a, 'tcx>( let location_table = &LocationTable::new(&body); let mut errors_buffer = Vec::new(); - let (move_data, move_errors): (MoveData<'tcx>, Option, MoveError<'tcx>)>>) = + let (move_data, move_errors): (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>) = match MoveData::gather_moves(&body, tcx, param_env) { - Ok(move_data) => (move_data, None), - Err((move_data, move_errors)) => (move_data, Some(move_errors)), + Ok(move_data) => (move_data, Vec::new()), + Err((move_data, move_errors)) => (move_data, move_errors), }; + let promoted_errors = promoted + .iter_enumerated() + .map(|(idx, body)| (idx, MoveData::gather_moves(&body, tcx, param_env))); let mdpe = MoveDataParamEnv { move_data, param_env }; @@ -264,6 +267,41 @@ fn do_mir_borrowck<'a, 'tcx>( _ => true, }; + for (idx, move_data_results) in promoted_errors { + let promoted_body = &promoted[idx]; + let dominators = promoted_body.dominators(); + + if let Err((move_data, move_errors)) = move_data_results { + let mut promoted_mbcx = MirBorrowckCtxt { + infcx, + body: promoted_body, + mir_def_id: def_id.to_def_id(), + move_data: &move_data, + location_table: &LocationTable::new(promoted_body), + movable_generator, + locals_are_invalidated_at_exit, + access_place_error_reported: Default::default(), + reservation_error_reported: Default::default(), + reservation_warnings: Default::default(), + move_error_reported: BTreeMap::new(), + uninitialized_error_reported: Default::default(), + errors_buffer, + regioncx: regioncx.clone(), + used_mut: Default::default(), + used_mut_upvars: SmallVec::new(), + borrow_set: borrow_set.clone(), + dominators, + upvars: Vec::new(), + local_names: IndexVec::from_elem(None, &promoted_body.local_decls), + region_names: RefCell::default(), + next_region_name: RefCell::new(1), + polonius_output: None, + }; + promoted_mbcx.report_move_errors(move_errors); + errors_buffer = promoted_mbcx.errors_buffer; + }; + } + let dominators = body.dominators(); let mut mbcx = MirBorrowckCtxt { @@ -301,9 +339,7 @@ fn do_mir_borrowck<'a, 'tcx>( borrows: flow_borrows, }; - if let Some(errors) = move_errors { - mbcx.report_move_errors(errors); - } + mbcx.report_move_errors(move_errors); dataflow::visit_results( &body, diff --git a/src/test/ui/borrowck/move-error-in-promoted-2.rs b/src/test/ui/borrowck/move-error-in-promoted-2.rs new file mode 100644 index 0000000000000..13da34f3922c2 --- /dev/null +++ b/src/test/ui/borrowck/move-error-in-promoted-2.rs @@ -0,0 +1,10 @@ +// Regression test for #70934 + +struct S; + +fn foo() { + &([S][0],); + //~^ ERROR cannot move out of type `[S; 1]` +} + +fn main() {} diff --git a/src/test/ui/borrowck/move-error-in-promoted-2.stderr b/src/test/ui/borrowck/move-error-in-promoted-2.stderr new file mode 100644 index 0000000000000..38dba94bdd41b --- /dev/null +++ b/src/test/ui/borrowck/move-error-in-promoted-2.stderr @@ -0,0 +1,12 @@ +error[E0508]: cannot move out of type `[S; 1]`, a non-copy array + --> $DIR/move-error-in-promoted-2.rs:6:7 + | +LL | &([S][0],); + | ^^^^^^ + | | + | cannot move out of here + | move occurs because value has type `S`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/borrowck/move-error-in-promoted.rs b/src/test/ui/borrowck/move-error-in-promoted.rs new file mode 100644 index 0000000000000..b94db64513123 --- /dev/null +++ b/src/test/ui/borrowck/move-error-in-promoted.rs @@ -0,0 +1,17 @@ +// Regression test for #70934 + +fn f() { + const C: [S2; 1] = [S2]; + let _ = S1(C[0]).clone(); + //~^ ERROR cannot move out of type `[S2; 1]` +} + +#[derive(Clone)] +struct S1(S2); + +#[derive(Clone)] +struct S2; + +fn main() { + f(); +} diff --git a/src/test/ui/borrowck/move-error-in-promoted.stderr b/src/test/ui/borrowck/move-error-in-promoted.stderr new file mode 100644 index 0000000000000..a4432e38da0e4 --- /dev/null +++ b/src/test/ui/borrowck/move-error-in-promoted.stderr @@ -0,0 +1,12 @@ +error[E0508]: cannot move out of type `[S2; 1]`, a non-copy array + --> $DIR/move-error-in-promoted.rs:5:16 + | +LL | let _ = S1(C[0]).clone(); + | ^^^^ + | | + | cannot move out of here + | move occurs because value has type `S2`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. From a992f95e34cd9ccc514c4706812f0f14b130332c Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 3 May 2020 09:01:14 -0500 Subject: [PATCH 05/17] Add examples for std::f32 constants. And also point people to use the associated constants of f32 instead. --- src/libcore/num/f32.rs | 140 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 32f4956328975..cdbdd70d6a1ed 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -18,15 +18,45 @@ use crate::num::FpCategory; /// The radix or base of the internal representation of `f32`. /// Use [`f32::RADIX`](../../std/primitive.f32.html#associatedconstant.RADIX) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let r = std::f32::RADIX; +/// +/// // correct way +/// let r = f32::RADIX; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const RADIX: u32 = f32::RADIX; /// Number of significant digits in base 2. /// Use [`f32::MANTISSA_DIGITS`](../../std/primitive.f32.html#associatedconstant.MANTISSA_DIGITS) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let d = std::f32::MANTISSA_DIGITS; +/// +/// // correct way +/// let d = f32::MANTISSA_DIGITS; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS; /// Approximate number of significant digits in base 10. /// Use [`f32::DIGITS`](../../std/primitive.f32.html#associatedconstant.DIGITS) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let d = std::f32::DIGITS; +/// +/// // correct way +/// let d = f32::DIGITS; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const DIGITS: u32 = f32::DIGITS; @@ -36,50 +66,160 @@ pub const DIGITS: u32 = f32::DIGITS; /// This is the difference between `1.0` and the next larger representable number. /// /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let e = std::f32::EPSILON; +/// +/// // correct way +/// let e = f32::EPSILON; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const EPSILON: f32 = f32::EPSILON; /// Smallest finite `f32` value. /// Use [`f32::MIN`](../../std/primitive.f32.html#associatedconstant.MIN) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let min = std::f32::MIN; +/// +/// // correct way +/// let min = f32::MIN; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN: f32 = f32::MIN; /// Smallest positive normal `f32` value. /// Use [`f32::MIN_POSITIVE`](../../std/primitive.f32.html#associatedconstant.MIN_POSITIVE) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let min = std::f32::MIN_POSITIVE; +/// +/// // correct way +/// let min = f32::MIN_POSITIVE; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE; /// Largest finite `f32` value. /// Use [`f32::MAX`](../../std/primitive.f32.html#associatedconstant.MAX) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let max = std::f32::MAX; +/// +/// // correct way +/// let max = f32::MAX; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MAX: f32 = f32::MAX; /// One greater than the minimum possible normal power of 2 exponent. /// Use [`f32::MIN_EXP`](../../std/primitive.f32.html#associatedconstant.MIN_EXP) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let min = std::f32::MIN_EXP; +/// +/// // correct way +/// let min = f32::MIN_EXP; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_EXP: i32 = f32::MIN_EXP; /// Maximum possible power of 2 exponent. /// Use [`f32::MAX_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_EXP) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let max = std::f32::MAX_EXP; +/// +/// // correct way +/// let max = f32::MAX_EXP; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MAX_EXP: i32 = f32::MAX_EXP; /// Minimum possible normal power of 10 exponent. /// Use [`f32::MIN_10_EXP`](../../std/primitive.f32.html#associatedconstant.MIN_10_EXP) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let min = std::f32::MIN_10_EXP; +/// +/// // correct way +/// let min = f32::MIN_10_EXP; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_10_EXP: i32 = f32::MIN_10_EXP; /// Maximum possible power of 10 exponent. /// Use [`f32::MAX_10_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_10_EXP) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let max = std::f32::MAX_10_EXP; +/// +/// // correct way +/// let max = f32::MAX_10_EXP; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MAX_10_EXP: i32 = f32::MAX_10_EXP; /// Not a Number (NaN). /// Use [`f32::NAN`](../../std/primitive.f32.html#associatedconstant.NAN) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let nan = std::f32::NAN; +/// +/// // correct way +/// let nan = f32::NAN; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const NAN: f32 = f32::NAN; /// Infinity (∞). /// Use [`f32::INFINITY`](../../std/primitive.f32.html#associatedconstant.INFINITY) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let inf = std::f32::INFINITY; +/// +/// // correct way +/// let inf = f32::INFINITY; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const INFINITY: f32 = f32::INFINITY; /// Negative infinity (−∞). /// Use [`f32::NEG_INFINITY`](../../std/primitive.f32.html#associatedconstant.NEG_INFINITY) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let ninf = std::f32::NEG_INFINITY; +/// +/// // correct way +/// let ninf = f32::NEG_INFINITY; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const NEG_INFINITY: f32 = f32::NEG_INFINITY; From 0768fa461c8491aa97185f3d512c462a8b38bbb2 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 3 May 2020 09:02:58 -0500 Subject: [PATCH 06/17] add some whitespace --- src/libcore/num/f32.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index cdbdd70d6a1ed..25b2c7c5ef4ea 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -45,6 +45,7 @@ pub const RADIX: u32 = f32::RADIX; /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS; + /// Approximate number of significant digits in base 10. /// Use [`f32::DIGITS`](../../std/primitive.f32.html#associatedconstant.DIGITS) instead. /// @@ -93,6 +94,7 @@ pub const EPSILON: f32 = f32::EPSILON; /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN: f32 = f32::MIN; + /// Smallest positive normal `f32` value. /// Use [`f32::MIN_POSITIVE`](../../std/primitive.f32.html#associatedconstant.MIN_POSITIVE) instead. /// @@ -107,6 +109,7 @@ pub const MIN: f32 = f32::MIN; /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE; + /// Largest finite `f32` value. /// Use [`f32::MAX`](../../std/primitive.f32.html#associatedconstant.MAX) instead. /// @@ -136,6 +139,7 @@ pub const MAX: f32 = f32::MAX; /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_EXP: i32 = f32::MIN_EXP; + /// Maximum possible power of 2 exponent. /// Use [`f32::MAX_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_EXP) instead. /// @@ -165,6 +169,7 @@ pub const MAX_EXP: i32 = f32::MAX_EXP; /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_10_EXP: i32 = f32::MIN_10_EXP; + /// Maximum possible power of 10 exponent. /// Use [`f32::MAX_10_EXP`](../../std/primitive.f32.html#associatedconstant.MAX_10_EXP) instead. /// @@ -194,6 +199,7 @@ pub const MAX_10_EXP: i32 = f32::MAX_10_EXP; /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const NAN: f32 = f32::NAN; + /// Infinity (∞). /// Use [`f32::INFINITY`](../../std/primitive.f32.html#associatedconstant.INFINITY) instead. /// @@ -208,6 +214,7 @@ pub const NAN: f32 = f32::NAN; /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const INFINITY: f32 = f32::INFINITY; + /// Negative infinity (−∞). /// Use [`f32::NEG_INFINITY`](../../std/primitive.f32.html#associatedconstant.NEG_INFINITY) instead. /// From d38d429be74c8bad84d330ccdae95fcaf6f7c30a Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 4 May 2020 08:07:20 -0500 Subject: [PATCH 07/17] correct -> intended --- src/libcore/num/f32.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 25b2c7c5ef4ea..4483940c9a771 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -25,7 +25,7 @@ use crate::num::FpCategory; /// // deprecated way /// let r = std::f32::RADIX; /// -/// // correct way +/// // intended way /// let r = f32::RADIX; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -40,7 +40,7 @@ pub const RADIX: u32 = f32::RADIX; /// // deprecated way /// let d = std::f32::MANTISSA_DIGITS; /// -/// // correct way +/// // intended way /// let d = f32::MANTISSA_DIGITS; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -55,7 +55,7 @@ pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS; /// // deprecated way /// let d = std::f32::DIGITS; /// -/// // correct way +/// // intended way /// let d = f32::DIGITS; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -74,7 +74,7 @@ pub const DIGITS: u32 = f32::DIGITS; /// // deprecated way /// let e = std::f32::EPSILON; /// -/// // correct way +/// // intended way /// let e = f32::EPSILON; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -89,7 +89,7 @@ pub const EPSILON: f32 = f32::EPSILON; /// // deprecated way /// let min = std::f32::MIN; /// -/// // correct way +/// // intended way /// let min = f32::MIN; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -104,7 +104,7 @@ pub const MIN: f32 = f32::MIN; /// // deprecated way /// let min = std::f32::MIN_POSITIVE; /// -/// // correct way +/// // intended way /// let min = f32::MIN_POSITIVE; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -119,7 +119,7 @@ pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE; /// // deprecated way /// let max = std::f32::MAX; /// -/// // correct way +/// // intended way /// let max = f32::MAX; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -134,7 +134,7 @@ pub const MAX: f32 = f32::MAX; /// // deprecated way /// let min = std::f32::MIN_EXP; /// -/// // correct way +/// // intended way /// let min = f32::MIN_EXP; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -149,7 +149,7 @@ pub const MIN_EXP: i32 = f32::MIN_EXP; /// // deprecated way /// let max = std::f32::MAX_EXP; /// -/// // correct way +/// // intended way /// let max = f32::MAX_EXP; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -164,7 +164,7 @@ pub const MAX_EXP: i32 = f32::MAX_EXP; /// // deprecated way /// let min = std::f32::MIN_10_EXP; /// -/// // correct way +/// // intended way /// let min = f32::MIN_10_EXP; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -179,7 +179,7 @@ pub const MIN_10_EXP: i32 = f32::MIN_10_EXP; /// // deprecated way /// let max = std::f32::MAX_10_EXP; /// -/// // correct way +/// // intended way /// let max = f32::MAX_10_EXP; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -194,7 +194,7 @@ pub const MAX_10_EXP: i32 = f32::MAX_10_EXP; /// // deprecated way /// let nan = std::f32::NAN; /// -/// // correct way +/// // intended way /// let nan = f32::NAN; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -209,7 +209,7 @@ pub const NAN: f32 = f32::NAN; /// // deprecated way /// let inf = std::f32::INFINITY; /// -/// // correct way +/// // intended way /// let inf = f32::INFINITY; /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -224,7 +224,7 @@ pub const INFINITY: f32 = f32::INFINITY; /// // deprecated way /// let ninf = std::f32::NEG_INFINITY; /// -/// // correct way +/// // intended way /// let ninf = f32::NEG_INFINITY; /// ``` #[stable(feature = "rust1", since = "1.0.0")] From 8bef0a3683c0a5dad40ee5889364ba206fc3af1f Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 4 May 2020 08:14:38 -0500 Subject: [PATCH 08/17] f64 examples --- src/libcore/num/f64.rs | 147 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index b38fd804ee80f..587f069312f72 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -18,15 +18,46 @@ use crate::num::FpCategory; /// The radix or base of the internal representation of `f64`. /// Use [`f64::RADIX`](../../std/primitive.f64.html#associatedconstant.RADIX) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let r = std::f64::RADIX; +/// +/// // intended way +/// let r = f64::RADIX; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const RADIX: u32 = f64::RADIX; /// Number of significant digits in base 2. /// Use [`f64::MANTISSA_DIGITS`](../../std/primitive.f64.html#associatedconstant.MANTISSA_DIGITS) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let d = std::f64::MANTISSA_DIGITS; +/// +/// // intended way +/// let d = f64::MANTISSA_DIGITS; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MANTISSA_DIGITS: u32 = f64::MANTISSA_DIGITS; + /// Approximate number of significant digits in base 10. /// Use [`f64::DIGITS`](../../std/primitive.f64.html#associatedconstant.DIGITS) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let d = std::f64::DIGITS; +/// +/// // intended way +/// let d = f64::DIGITS; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const DIGITS: u32 = f64::DIGITS; @@ -36,50 +67,166 @@ pub const DIGITS: u32 = f64::DIGITS; /// This is the difference between `1.0` and the next larger representable number. /// /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let e = std::f64::EPSILON; +/// +/// // intended way +/// let e = f64::EPSILON; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const EPSILON: f64 = f64::EPSILON; /// Smallest finite `f64` value. /// Use [`f64::MIN`](../../std/primitive.f64.html#associatedconstant.MIN) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let min = std::f64::MIN; +/// +/// // intended way +/// let min = f64::MIN; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN: f64 = f64::MIN; + /// Smallest positive normal `f64` value. /// Use [`f64::MIN_POSITIVE`](../../std/primitive.f64.html#associatedconstant.MIN_POSITIVE) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let min = std::f64::MIN_POSITIVE; +/// +/// // intended way +/// let min = f64::MIN_POSITIVE; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_POSITIVE: f64 = f64::MIN_POSITIVE; + /// Largest finite `f64` value. /// Use [`f64::MAX`](../../std/primitive.f64.html#associatedconstant.MAX) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let max = std::f64::MAX; +/// +/// // intended way +/// let max = f64::MAX; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MAX: f64 = f64::MAX; /// One greater than the minimum possible normal power of 2 exponent. /// Use [`f64::MIN_EXP`](../../std/primitive.f64.html#associatedconstant.MIN_EXP) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let min = std::f64::MIN_EXP; +/// +/// // intended way +/// let min = f64::MIN_EXP; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_EXP: i32 = f64::MIN_EXP; + /// Maximum possible power of 2 exponent. /// Use [`f64::MAX_EXP`](../../std/primitive.f64.html#associatedconstant.MAX_EXP) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let max = std::f64::MAX_EXP; +/// +/// // intended way +/// let max = f64::MAX_EXP; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MAX_EXP: i32 = f64::MAX_EXP; /// Minimum possible normal power of 10 exponent. /// Use [`f64::MIN_10_EXP`](../../std/primitive.f64.html#associatedconstant.MIN_10_EXP) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let min = std::f64::MIN_10_EXP; +/// +/// // intended way +/// let min = f64::MIN_10_EXP; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MIN_10_EXP: i32 = f64::MIN_10_EXP; + /// Maximum possible power of 10 exponent. /// Use [`f64::MAX_10_EXP`](../../std/primitive.f64.html#associatedconstant.MAX_10_EXP) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let max = std::f64::MAX_10_EXP; +/// +/// // intended way +/// let max = f64::MAX_10_EXP; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const MAX_10_EXP: i32 = f64::MAX_10_EXP; /// Not a Number (NaN). /// Use [`f64::NAN`](../../std/primitive.f64.html#associatedconstant.NAN) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let nan = std::f64::NAN; +/// +/// // intended way +/// let nan = f64::NAN; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const NAN: f64 = f64::NAN; + /// Infinity (∞). /// Use [`f64::INFINITY`](../../std/primitive.f64.html#associatedconstant.INFINITY) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let inf = std::f64::INFINITY; +/// +/// // intended way +/// let inf = f64::INFINITY; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const INFINITY: f64 = f64::INFINITY; + /// Negative infinity (−∞). /// Use [`f64::NEG_INFINITY`](../../std/primitive.f64.html#associatedconstant.NEG_INFINITY) instead. +/// +/// # Examples +/// +/// ```rust +/// // deprecated way +/// let ninf = std::f64::NEG_INFINITY; +/// +/// // intended way +/// let ninf = f64::NEG_INFINITY; +/// ``` #[stable(feature = "rust1", since = "1.0.0")] pub const NEG_INFINITY: f64 = f64::NEG_INFINITY; From 55e37f9f02af4eec5c52413e3219bef838beadab Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 4 May 2020 08:26:39 -0500 Subject: [PATCH 09/17] Add examples to int macros --- src/libcore/num/int_macros.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs index 5035445ba939f..ffd30b03f2109 100644 --- a/src/libcore/num/int_macros.rs +++ b/src/libcore/num/int_macros.rs @@ -12,14 +12,36 @@ macro_rules! int_module { ($T:ident, #[$attr:meta]) => ( doc_comment! { concat!("The smallest value that can be represented by this integer type. -Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead."), +Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead. + +# Examples + +```rust +// deprecated way +let min = std::", stringify!($T), "::MIN; + +// intended way +let min = ", stringify!($T), "::MIN; +``` +"), #[$attr] pub const MIN: $T = $T::MIN; } doc_comment! { concat!("The largest value that can be represented by this integer type. -Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead."), +Use [`", stringify!($T), "::MAX", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MAX) instead. + +# Examples + +```rust +// deprecated way +let max = std::", stringify!($T), "::MAX; + +// intended way +let max = ", stringify!($T), "::MAX; +``` +"), #[$attr] pub const MAX: $T = $T::MAX; } From 1593e2b7df05da71162b9ad0e3f12d577aec3131 Mon Sep 17 00:00:00 2001 From: "main()" Date: Mon, 4 May 2020 15:53:02 +0200 Subject: [PATCH 10/17] Add remove_current_as_list to LinkedList's CursorMut The `remove_current` method only returns the inner `T` and deallocates the list node. This is unnecessary for move operations, where the element is going to be linked back into this (or even a different) `LinkedList`. The `remove_current_as_list` method avoids this by returning the unlinked list node as a new single-element `LinkedList` structure . --- src/liballoc/collections/linked_list.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index bfa4045787f5b..952e5317840a1 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -1496,6 +1496,31 @@ impl<'a, T> CursorMut<'a, T> { } } + /// Removes the current element from the `LinkedList` without deallocating the list node. + /// + /// The node that was removed is returned as a new `LinkedList` containing only this node. + /// The cursor is moved to point to the next element in the current `LinkedList`. + /// + /// If the cursor is currently pointing to the "ghost" non-element then no element + /// is removed and `None` is returned. + #[unstable(feature = "linked_list_cursors", issue = "58533")] + pub fn remove_current_as_list(&mut self) -> Option> { + let unlinked_node = self.current?; + unsafe { + self.current = unlinked_node.as_ref().next; + self.list.unlink_node(unlinked_node); + + unlinked_node.as_mut().prev = None; + unlinked_node.as_mut().next = None; + Some(LinkedList { + head: Some(unlinked_node), + tail: Some(unlinked_node), + len: 1, + marker: PhantomData, + }) + } + } + /// Inserts the elements from the given `LinkedList` after the current one. /// /// If the cursor is pointing at the "ghost" non-element then the new elements are From c5cdf7fe920c8cb3b60f5a6e257f6cdfb51102d3 Mon Sep 17 00:00:00 2001 From: "main()" Date: Mon, 4 May 2020 16:10:59 +0200 Subject: [PATCH 11/17] whoops --- src/liballoc/collections/linked_list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index 952e5317840a1..cc0f07b822741 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -1505,7 +1505,7 @@ impl<'a, T> CursorMut<'a, T> { /// is removed and `None` is returned. #[unstable(feature = "linked_list_cursors", issue = "58533")] pub fn remove_current_as_list(&mut self) -> Option> { - let unlinked_node = self.current?; + let mut unlinked_node = self.current?; unsafe { self.current = unlinked_node.as_ref().next; self.list.unlink_node(unlinked_node); From 6e77729ed5af41f87ffe8c8b7bd949b8b1d44f83 Mon Sep 17 00:00:00 2001 From: Isaac Woods Date: Mon, 4 May 2020 16:27:46 +0100 Subject: [PATCH 12/17] Correctly handle UEFI targets as Windows-like when emitting sections for LLVM bitcode --- src/librustc_codegen_llvm/back/write.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 6d175fda45f5c..394e2f332cb21 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -853,7 +853,9 @@ unsafe fn embed_bitcode( || cgcx.opts.target_triple.triple().starts_with("asmjs") { // nothing to do here - } else if cgcx.opts.target_triple.triple().contains("windows") { + } else if cgcx.opts.target_triple.triple().contains("windows") + || cgcx.opts.target_triple.triple().contains("uefi") + { let asm = " .section .llvmbc,\"n\" .section .llvmcmd,\"n\" From 4a8fa189776e028d869a511962c13a2e0425025c Mon Sep 17 00:00:00 2001 From: Dante Broggi <34220985+Dante-Broggi@users.noreply.github.com> Date: Mon, 4 May 2020 11:42:57 -0400 Subject: [PATCH 13/17] add a missing word --- src/librustc_middle/ty/layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_middle/ty/layout.rs b/src/librustc_middle/ty/layout.rs index 4cdcd5320e761..ade89ab39d472 100644 --- a/src/librustc_middle/ty/layout.rs +++ b/src/librustc_middle/ty/layout.rs @@ -2607,7 +2607,7 @@ where // `Box` (`UniqueBorrowed`) are not necessarily dereferenceable // for the entire duration of the function as they can be deallocated - // any time. Set their valid size to 0. + // at any time. Set their valid size to 0. attrs.pointee_size = match kind { PointerKind::UniqueOwned => Size::ZERO, _ => pointee.size, From a9b6af98d182e1a40d97c48bbab27916224847ff Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Mon, 4 May 2020 21:04:11 +0200 Subject: [PATCH 14/17] double neg --- src/librustc_typeck/astconv.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 39fcd07564516..cd6cd94b14356 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1753,7 +1753,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { potential_assoc_types: Vec, trait_bounds: &[hir::PolyTraitRef<'_>], ) { - if !associated_types.values().any(|v| !v.is_empty()) { + if associated_types.values().all(|v| v.is_empty()) { return; } let tcx = self.tcx(); From d02128f92f5e7ce4911ee9ce77fc969e19aad5ad Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 4 May 2020 15:49:11 -0400 Subject: [PATCH 15/17] Update btree_map::VacantEntry::insert docs to actually call insert It looks like they were copied from the `or_insert` docs. This change makes the example more like the hash_map::VacantEntry::insert docs. --- src/liballoc/collections/btree/map.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index c0b976565e41d..b8f1a4199c64f 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -2499,15 +2499,14 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> { /// /// ``` /// use std::collections::BTreeMap; + /// use std::collections::btree_map::Entry; /// - /// let mut count: BTreeMap<&str, usize> = BTreeMap::new(); + /// let mut map: BTreeMap<&str, u32> = BTreeMap::new(); /// - /// // count the number of occurrences of letters in the vec - /// for x in vec!["a","b","a","c","a","b"] { - /// *count.entry(x).or_insert(0) += 1; + /// if let Entry::Vacant(o) = map.entry("poneyland") { + /// o.insert(37); /// } - /// - /// assert_eq!(count["a"], 3); + /// assert_eq!(map["poneyland"], 37); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn insert(self, value: V) -> &'a mut V { From 73867365a8dbeb5a2ad8c2de61b4f74faeb34ece Mon Sep 17 00:00:00 2001 From: mibac138 <5672750+mibac138@users.noreply.github.com> Date: Mon, 4 May 2020 23:33:10 +0200 Subject: [PATCH 16/17] Suggest to add missing feature when using gated const features --- .../transform/check_consts/ops.rs | 3 +++ .../ui/check-static-values-constraints.stderr | 14 +++++++++++++ src/test/ui/const-suggest-feature.rs | 9 ++++++++ src/test/ui/const-suggest-feature.stderr | 21 +++++++++++++++++++ ...ign-to-static-within-other-static-2.stderr | 2 ++ .../mod-static-with-const-fn.stderr | 2 ++ src/test/ui/consts/const_let_assign3.stderr | 4 ++++ .../ui/consts/projection_qualif.stock.stderr | 2 ++ ...tatic_mut_containing_mut_ref2.stock.stderr | 2 ++ src/test/ui/error-codes/E0010-teach.stderr | 1 + src/test/ui/error-codes/E0010.stderr | 2 ++ src/test/ui/error-codes/E0017.stderr | 2 ++ src/test/ui/error-codes/E0388.stderr | 2 ++ src/test/ui/issues/issue-7364.stderr | 2 ++ .../ui/static/static-mut-not-constant.stderr | 2 ++ 15 files changed, 70 insertions(+) create mode 100644 src/test/ui/const-suggest-feature.rs create mode 100644 src/test/ui/const-suggest-feature.stderr diff --git a/src/librustc_mir/transform/check_consts/ops.rs b/src/librustc_mir/transform/check_consts/ops.rs index fe20ceb47ee37..bb6e3681cc3c1 100644 --- a/src/librustc_mir/transform/check_consts/ops.rs +++ b/src/librustc_mir/transform/check_consts/ops.rs @@ -39,6 +39,9 @@ pub trait NonConstOp: std::fmt::Debug { "{} contains unimplemented expression type", ccx.const_kind() ); + if let Some(feat) = Self::feature_gate() { + err.help(&format!("add `#![feature({})]` to the crate attributes to enable", feat)); + } if ccx.tcx.sess.teach(&err.get_code().unwrap()) { err.note( "A function call isn't allowed in the const's initialization expression \ diff --git a/src/test/ui/check-static-values-constraints.stderr b/src/test/ui/check-static-values-constraints.stderr index 7d7ecbd1a26a5..6b5a739899cac 100644 --- a/src/test/ui/check-static-values-constraints.stderr +++ b/src/test/ui/check-static-values-constraints.stderr @@ -18,6 +18,8 @@ error[E0019]: static contains unimplemented expression type | LL | static STATIC11: Box = box MyOwned; | ^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants --> $DIR/check-static-values-constraints.rs:90:32 @@ -36,6 +38,8 @@ error[E0019]: static contains unimplemented expression type | LL | box MyOwned, | ^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0010]: allocations are not allowed in statics --> $DIR/check-static-values-constraints.rs:97:5 @@ -48,6 +52,8 @@ error[E0019]: static contains unimplemented expression type | LL | box MyOwned, | ^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0010]: allocations are not allowed in statics --> $DIR/check-static-values-constraints.rs:102:6 @@ -60,6 +66,8 @@ error[E0019]: static contains unimplemented expression type | LL | &box MyOwned, | ^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0010]: allocations are not allowed in statics --> $DIR/check-static-values-constraints.rs:104:6 @@ -72,6 +80,8 @@ error[E0019]: static contains unimplemented expression type | LL | &box MyOwned, | ^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0010]: allocations are not allowed in statics --> $DIR/check-static-values-constraints.rs:111:5 @@ -84,6 +94,8 @@ error[E0019]: static contains unimplemented expression type | LL | box 3; | ^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0507]: cannot move out of static item `x` --> $DIR/check-static-values-constraints.rs:116:45 @@ -105,6 +117,8 @@ error[E0019]: static contains unimplemented expression type | LL | let y = { static x: Box = box 3; x }; | ^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 17 previous errors diff --git a/src/test/ui/const-suggest-feature.rs b/src/test/ui/const-suggest-feature.rs new file mode 100644 index 0000000000000..89fafbbe6f044 --- /dev/null +++ b/src/test/ui/const-suggest-feature.rs @@ -0,0 +1,9 @@ +const WRITE: () = unsafe { + *std::ptr::null_mut() = 0; + //~^ ERROR dereferencing raw pointers in constants is unstable + //~| HELP add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + //~| ERROR constant contains unimplemented expression type + //~| HELP add `#![feature(const_mut_refs)]` to the crate attributes to enable +}; + +fn main() {} diff --git a/src/test/ui/const-suggest-feature.stderr b/src/test/ui/const-suggest-feature.stderr new file mode 100644 index 0000000000000..6b91df6b42d91 --- /dev/null +++ b/src/test/ui/const-suggest-feature.stderr @@ -0,0 +1,21 @@ +error[E0658]: dereferencing raw pointers in constants is unstable + --> $DIR/const-suggest-feature.rs:2:5 + | +LL | *std::ptr::null_mut() = 0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #51911 for more information + = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + +error[E0019]: constant contains unimplemented expression type + --> $DIR/const-suggest-feature.rs:2:5 + | +LL | *std::ptr::null_mut() = 0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0019, E0658. +For more information about an error, try `rustc --explain E0019`. diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr b/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr index 148b1210d39e1..14dcc074639e5 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr @@ -3,6 +3,8 @@ error[E0019]: static contains unimplemented expression type | LL | *FOO.0.get() = 5; | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr b/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr index 50cd3214507a3..44ae1ecf04718 100644 --- a/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr +++ b/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr @@ -3,6 +3,8 @@ error[E0019]: static contains unimplemented expression type | LL | *FOO.0.get() = 5; | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants --> $DIR/mod-static-with-const-fn.rs:21:5 diff --git a/src/test/ui/consts/const_let_assign3.stderr b/src/test/ui/consts/const_let_assign3.stderr index 5e2a85cc03d9f..62fd04ea522c3 100644 --- a/src/test/ui/consts/const_let_assign3.stderr +++ b/src/test/ui/consts/const_let_assign3.stderr @@ -3,6 +3,8 @@ error[E0019]: constant function contains unimplemented expression type | LL | self.state = x; | ^^^^^^^^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0658]: references in constants may only refer to immutable values --> $DIR/const_let_assign3.rs:16:5 @@ -27,6 +29,8 @@ error[E0019]: constant contains unimplemented expression type | LL | *y = 42; | ^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/projection_qualif.stock.stderr b/src/test/ui/consts/projection_qualif.stock.stderr index 75625a4bd1bc3..cfa48d947c992 100644 --- a/src/test/ui/consts/projection_qualif.stock.stderr +++ b/src/test/ui/consts/projection_qualif.stock.stderr @@ -21,6 +21,8 @@ error[E0019]: constant contains unimplemented expression type | LL | unsafe { *b = 5; } | ^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr b/src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr index c70431886e868..cc169351bf268 100644 --- a/src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr +++ b/src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr @@ -12,6 +12,8 @@ error[E0019]: static contains unimplemented expression type | LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0010-teach.stderr b/src/test/ui/error-codes/E0010-teach.stderr index 4c9d140692ad0..c15ab5c655a46 100644 --- a/src/test/ui/error-codes/E0010-teach.stderr +++ b/src/test/ui/error-codes/E0010-teach.stderr @@ -12,6 +12,7 @@ error[E0019]: constant contains unimplemented expression type LL | const CON : Box = box 0; | ^ | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = note: A function call isn't allowed in the const's initialization expression because the expression's value must be known at compile-time. = note: Remember: you can't use a function call inside a const's initialization expression! However, you can use it anywhere else. diff --git a/src/test/ui/error-codes/E0010.stderr b/src/test/ui/error-codes/E0010.stderr index 48472d8acda38..f49fb9c46326b 100644 --- a/src/test/ui/error-codes/E0010.stderr +++ b/src/test/ui/error-codes/E0010.stderr @@ -9,6 +9,8 @@ error[E0019]: constant contains unimplemented expression type | LL | const CON : Box = box 0; | ^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0017.stderr b/src/test/ui/error-codes/E0017.stderr index 2e687c18ed3ff..f959ad0d00887 100644 --- a/src/test/ui/error-codes/E0017.stderr +++ b/src/test/ui/error-codes/E0017.stderr @@ -12,6 +12,8 @@ error[E0019]: static contains unimplemented expression type | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0658]: references in statics may only refer to immutable values --> $DIR/E0017.rs:6:39 diff --git a/src/test/ui/error-codes/E0388.stderr b/src/test/ui/error-codes/E0388.stderr index 52822ebdd9e67..8bdfbac36816b 100644 --- a/src/test/ui/error-codes/E0388.stderr +++ b/src/test/ui/error-codes/E0388.stderr @@ -12,6 +12,8 @@ error[E0019]: static contains unimplemented expression type | LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0658]: references in statics may only refer to immutable values --> $DIR/E0388.rs:5:39 diff --git a/src/test/ui/issues/issue-7364.stderr b/src/test/ui/issues/issue-7364.stderr index 1f1079555a91f..efff2c24525e8 100644 --- a/src/test/ui/issues/issue-7364.stderr +++ b/src/test/ui/issues/issue-7364.stderr @@ -9,6 +9,8 @@ error[E0019]: static contains unimplemented expression type | LL | static boxed: Box> = box RefCell::new(0); | ^^^^^^^^^^^^^^^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error[E0277]: `std::cell::RefCell` cannot be shared between threads safely --> $DIR/issue-7364.rs:6:1 diff --git a/src/test/ui/static/static-mut-not-constant.stderr b/src/test/ui/static/static-mut-not-constant.stderr index 3560be0e29e43..a618b49d1089e 100644 --- a/src/test/ui/static/static-mut-not-constant.stderr +++ b/src/test/ui/static/static-mut-not-constant.stderr @@ -9,6 +9,8 @@ error[E0019]: static contains unimplemented expression type | LL | static mut a: Box = box 3; | ^ + | + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable error: aborting due to 2 previous errors From 36f51f97c732a95d90eb8170f5e2c46e505fb9b5 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Mon, 4 May 2020 18:27:23 -0400 Subject: [PATCH 17/17] fix typo in function name --- src/librustc_builtin_macros/deriving/debug.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_builtin_macros/deriving/debug.rs b/src/librustc_builtin_macros/deriving/debug.rs index 71f6eb4485845..cea7e8176b67f 100644 --- a/src/librustc_builtin_macros/deriving/debug.rs +++ b/src/librustc_builtin_macros/deriving/debug.rs @@ -88,7 +88,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_> // Use `let _ = expr;` to avoid triggering the // unused_results lint. - stmts.push(stmt_let_undescore(cx, span, expr)); + stmts.push(stmt_let_underscore(cx, span, expr)); } } ast::VariantData::Struct(..) => { @@ -112,7 +112,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_> Ident::new(sym::field, span), vec![name, field], ); - stmts.push(stmt_let_undescore(cx, span, expr)); + stmts.push(stmt_let_underscore(cx, span, expr)); } } } @@ -124,7 +124,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_> cx.expr_block(block) } -fn stmt_let_undescore(cx: &mut ExtCtxt<'_>, sp: Span, expr: P) -> ast::Stmt { +fn stmt_let_underscore(cx: &mut ExtCtxt<'_>, sp: Span, expr: P) -> ast::Stmt { let local = P(ast::Local { pat: cx.pat_wild(sp), ty: None,