From f1c1fc2dbe442bedf214219d281b0d83b42cff67 Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Wed, 14 Feb 2018 09:19:01 +0200 Subject: [PATCH 01/24] rephrase UnsafeCell doc Make UnsafeCell doc easier to follow --- src/libcore/cell.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index ec0d1b704dceb..6270e87c9cce9 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1164,11 +1164,12 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// The compiler makes optimizations based on the knowledge that `&T` is not mutably aliased or /// mutated, and that `&mut T` is unique. When building abstractions like `Cell`, `RefCell`, /// `Mutex`, etc, you need to turn these optimizations off. `UnsafeCell` is the only legal way -/// to do this. When `UnsafeCell` is immutably aliased, it is still safe to obtain a mutable -/// reference to its interior and/or to mutate it. However, it is up to the abstraction designer -/// to ensure that no two mutable references obtained this way are active at the same time, and -/// that there are no active mutable references or mutations when an immutable reference is obtained -/// from the cell. This is often done via runtime checks. +/// to do this. When `UnsafeCell` _itself_ is immutably aliased, it is still safe to obtain +/// a mutable reference to its _interior_ and/or to mutate the interior. However, it is up to +/// the abstraction designer to ensure that no two mutable references obtained this way are active +/// at the same time, there are no active immutable reference when a mutable reference is obtained +/// from the cell, and that there are no active mutable references or mutations when an immutable +/// reference is obtained. This is often done via runtime checks. /// /// Note that while mutating or mutably aliasing the contents of an `& UnsafeCell` is /// okay (provided you enforce the invariants some other way); it is still undefined behavior @@ -1240,9 +1241,9 @@ impl UnsafeCell { /// Gets a mutable pointer to the wrapped value. /// /// This can be cast to a pointer of any kind. - /// Ensure that the access is unique when casting to - /// `&mut T`, and ensure that there are no mutations or mutable - /// aliases going on when casting to `&T` + /// Ensure that the access is unique (no active references, mutable or not) + /// when casting to `&mut T`, and ensure that there are no mutations + /// or mutable aliases going on when casting to `&T` /// /// # Examples /// From b9b82490206fc41eb10662d6847a1ad28618ee59 Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Wed, 14 Feb 2018 10:11:37 +0200 Subject: [PATCH 02/24] fix tidy checks --- src/libcore/cell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 6270e87c9cce9..6f91e743999b1 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1165,7 +1165,7 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// mutated, and that `&mut T` is unique. When building abstractions like `Cell`, `RefCell`, /// `Mutex`, etc, you need to turn these optimizations off. `UnsafeCell` is the only legal way /// to do this. When `UnsafeCell` _itself_ is immutably aliased, it is still safe to obtain -/// a mutable reference to its _interior_ and/or to mutate the interior. However, it is up to +/// a mutable reference to its _interior_ and/or to mutate the interior. However, it is up to /// the abstraction designer to ensure that no two mutable references obtained this way are active /// at the same time, there are no active immutable reference when a mutable reference is obtained /// from the cell, and that there are no active mutable references or mutations when an immutable @@ -1243,7 +1243,7 @@ impl UnsafeCell { /// This can be cast to a pointer of any kind. /// Ensure that the access is unique (no active references, mutable or not) /// when casting to `&mut T`, and ensure that there are no mutations - /// or mutable aliases going on when casting to `&T` + /// or mutable aliases going on when casting to `&T` /// /// # Examples /// From cfad25ee8fb9866d0cbdc43e3a89a00aed13e12c Mon Sep 17 00:00:00 2001 From: jethrogb Date: Fri, 23 Feb 2018 11:57:38 -0800 Subject: [PATCH 03/24] Clarify interfaction between File::set_len and file cursor --- src/libstd/fs.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 292a78278ab0a..db52ed67d3a85 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -453,6 +453,10 @@ impl File { /// will be extended to `size` and have all of the intermediate data filled /// in with 0s. /// + /// The file's cursor isn't changed. In particular, if the cursor was at the + /// end and the file is shrunk using this operation, the cursor will now be + /// past the end. + /// /// # Errors /// /// This function will return an error if the file is not opened for writing. From 273166e7655dc736f444de43505c3ddda5c742f7 Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Tue, 27 Feb 2018 16:41:28 +0200 Subject: [PATCH 04/24] remove italic remove italic as per @GuillaumeGomez suggestion --- src/libcore/cell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 6f91e743999b1..4a1d68efc99b0 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1164,8 +1164,8 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// The compiler makes optimizations based on the knowledge that `&T` is not mutably aliased or /// mutated, and that `&mut T` is unique. When building abstractions like `Cell`, `RefCell`, /// `Mutex`, etc, you need to turn these optimizations off. `UnsafeCell` is the only legal way -/// to do this. When `UnsafeCell` _itself_ is immutably aliased, it is still safe to obtain -/// a mutable reference to its _interior_ and/or to mutate the interior. However, it is up to +/// to do this. When `UnsafeCell` itself is immutably aliased, it is still safe to obtain +/// a mutable reference to its interior and/or to mutate the interior. However, it is up to /// the abstraction designer to ensure that no two mutable references obtained this way are active /// at the same time, there are no active immutable reference when a mutable reference is obtained /// from the cell, and that there are no active mutable references or mutations when an immutable From d9b8724a8072d51c014d2d8c6852e5a398c757d3 Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Tue, 27 Feb 2018 23:21:04 +0200 Subject: [PATCH 05/24] style fix --- src/libcore/cell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 4a1d68efc99b0..01e618421cc53 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1172,7 +1172,7 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// reference is obtained. This is often done via runtime checks. /// /// Note that while mutating or mutably aliasing the contents of an `& UnsafeCell` is -/// okay (provided you enforce the invariants some other way); it is still undefined behavior +/// okay (provided you enforce the invariants some other way), it is still undefined behavior /// to have multiple `&mut UnsafeCell` aliases. /// /// From 50f5ea919231b41b7d8ccb1023b4dc0fd6e6730d Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Tue, 27 Feb 2018 23:23:19 +0200 Subject: [PATCH 06/24] Simplify Merge three rules into one following @cramertj --- src/libcore/cell.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 01e618421cc53..b57667df99169 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1165,11 +1165,15 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// mutated, and that `&mut T` is unique. When building abstractions like `Cell`, `RefCell`, /// `Mutex`, etc, you need to turn these optimizations off. `UnsafeCell` is the only legal way /// to do this. When `UnsafeCell` itself is immutably aliased, it is still safe to obtain -/// a mutable reference to its interior and/or to mutate the interior. However, it is up to -/// the abstraction designer to ensure that no two mutable references obtained this way are active -/// at the same time, there are no active immutable reference when a mutable reference is obtained -/// from the cell, and that there are no active mutable references or mutations when an immutable -/// reference is obtained. This is often done via runtime checks. +/// a mutable reference to its interior and/or to mutate the interior. However, the abstraction +/// designer must ensure that any active mutable references to the interior obtained this way does +/// not co-exist with other active references to the interior, either mutable or not. This is often +/// done via runtime checks. Naturally, several active immutable references to the interior can +/// co-exits with each other (but not with a mutable reference). +/// +/// To put it in other words, if a mutable reference to the contents is active, no other references +/// can be active at the same time, and if an immutable reference to the contents is active, then +/// only other immutable reference may be active. /// /// Note that while mutating or mutably aliasing the contents of an `& UnsafeCell` is /// okay (provided you enforce the invariants some other way), it is still undefined behavior From ff6754c68ec293d46eb294f3b7efeca8300b2251 Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Tue, 27 Feb 2018 23:34:38 +0200 Subject: [PATCH 07/24] fix tidy checks --- src/libcore/cell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index b57667df99169..6f18b8466a665 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1166,12 +1166,12 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// `Mutex`, etc, you need to turn these optimizations off. `UnsafeCell` is the only legal way /// to do this. When `UnsafeCell` itself is immutably aliased, it is still safe to obtain /// a mutable reference to its interior and/or to mutate the interior. However, the abstraction -/// designer must ensure that any active mutable references to the interior obtained this way does -/// not co-exist with other active references to the interior, either mutable or not. This is often +/// designer must ensure that any active mutable references to the interior obtained this way does +/// not co-exist with other active references to the interior, either mutable or not. This is often /// done via runtime checks. Naturally, several active immutable references to the interior can /// co-exits with each other (but not with a mutable reference). /// -/// To put it in other words, if a mutable reference to the contents is active, no other references +/// To put it in other words, if a mutable reference to the contents is active, no other references /// can be active at the same time, and if an immutable reference to the contents is active, then /// only other immutable reference may be active. /// From 78789add6c4ab8a4b81e717803be63c384438595 Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Tue, 27 Feb 2018 23:52:47 +0200 Subject: [PATCH 08/24] and some more tidy checks --- src/libcore/cell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 6f18b8466a665..8accbc204c1d7 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1168,12 +1168,12 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// a mutable reference to its interior and/or to mutate the interior. However, the abstraction /// designer must ensure that any active mutable references to the interior obtained this way does /// not co-exist with other active references to the interior, either mutable or not. This is often -/// done via runtime checks. Naturally, several active immutable references to the interior can +/// done via runtime checks. Naturally, several active immutable references to the interior can /// co-exits with each other (but not with a mutable reference). /// /// To put it in other words, if a mutable reference to the contents is active, no other references /// can be active at the same time, and if an immutable reference to the contents is active, then -/// only other immutable reference may be active. +/// only other immutable reference may be active. /// /// Note that while mutating or mutably aliasing the contents of an `& UnsafeCell` is /// okay (provided you enforce the invariants some other way), it is still undefined behavior From 55cc9a43368aae6e6ed3a0c75ee8fd47ac4f3bcd Mon Sep 17 00:00:00 2001 From: Peter Lyons Date: Wed, 28 Feb 2018 20:51:40 -0700 Subject: [PATCH 09/24] Remember state of top-level collapse toggle widget --- src/librustdoc/html/static/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 960f2f198d8b0..4f90b86a3f7ac 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1623,6 +1623,7 @@ function toggleAllDocs() { var toggle = document.getElementById("toggle-all-docs"); if (hasClass(toggle, "will-expand")) { + updateLocalStorage("collapse", "false"); removeClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(false); @@ -1632,6 +1633,7 @@ collapseDocs(e, "show"); }); } else { + updateLocalStorage("collapse", "true"); addClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(true); @@ -1972,6 +1974,10 @@ window.onresize = function() { hideSidebar(); }; + + if (getCurrentValue("collapse") === "true") { + toggleAllDocs(); + } }()); // Sets the focus on the search bar at the top of the page From 2dd81c86c51435ed57d7a2b16f1b66c254a64cc8 Mon Sep 17 00:00:00 2001 From: Peter Lyons Date: Thu, 1 Mar 2018 02:50:32 -0700 Subject: [PATCH 10/24] Rename doc collapse sentinal to rustdoc-collapse --- src/librustdoc/html/static/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 4f90b86a3f7ac..c5c31d109fbf3 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1623,7 +1623,7 @@ function toggleAllDocs() { var toggle = document.getElementById("toggle-all-docs"); if (hasClass(toggle, "will-expand")) { - updateLocalStorage("collapse", "false"); + updateLocalStorage("rustdoc-collapse", "false"); removeClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(false); @@ -1633,7 +1633,7 @@ collapseDocs(e, "show"); }); } else { - updateLocalStorage("collapse", "true"); + updateLocalStorage("rustdoc-collapse", "true"); addClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(true); @@ -1975,7 +1975,7 @@ hideSidebar(); }; - if (getCurrentValue("collapse") === "true") { + if (getCurrentValue("rustdoc-collapse") === "true") { toggleAllDocs(); } }()); From f9c5b1f8e8fbc9c6d8e4b69ecbef6345a73ce515 Mon Sep 17 00:00:00 2001 From: Kurtis Nusbaum Date: Sat, 3 Mar 2018 11:12:09 -0800 Subject: [PATCH 11/24] Update Feature Request instructions --- CONTRIBUTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 552961b9b66c1..2b389888e5185 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,10 +26,10 @@ As a reminder, all contributors are expected to follow our [Code of Conduct][coc ## Feature Requests [feature-requests]: #feature-requests -To request a change to the way that the Rust language works, please open an -issue in the [RFCs repository](https://github.com/rust-lang/rfcs/issues/new) -rather than this one. New features and other significant language changes -must go through the RFC process. +To request a change to the way the Rust language works, please head over +to the [RFCs repository](https://github.com/rust-lang/rfcs) and view the +[README](https://github.com/rust-lang/rfcs/blob/master/README.md) +for instructions. ## Bug Reports [bug-reports]: #bug-reports From ca1c91bc653caa2c51d70a0f9ed81dd364da1a5f Mon Sep 17 00:00:00 2001 From: David Alber Date: Wed, 7 Mar 2018 08:57:26 -0800 Subject: [PATCH 12/24] Synchronizing with code of conduct in rust-www This is propagated from rust-lang/rust-www#1062. --- CODE_OF_CONDUCT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index e9b39717c7008..d70b2b52aca1b 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -11,9 +11,9 @@ A version of this document [can be found online](https://www.rust-lang.org/condu * Please be kind and courteous. There's no need to be mean or rude. * Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer. * Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works. -* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behaviour. We interpret the term "harassment" as including the definition in the Citizen Code of Conduct; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups. +* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We interpret the term "harassment" as including the definition in the Citizen Code of Conduct; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups. * Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation team][mod_team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back. -* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behaviour is not welcome. +* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome. ## Moderation From fe557eee7de236e767a81a123c5de9b52d5e9a2a Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Thu, 8 Mar 2018 23:15:39 +0200 Subject: [PATCH 13/24] another rewrite based on @nikomatsakis texthg --- src/libcore/cell.rs | 46 ++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 8accbc204c1d7..61b0aead22f20 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1161,27 +1161,43 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// The `UnsafeCell` type is the only legal way to obtain aliasable data that is considered /// mutable. In general, transmuting an `&T` type into an `&mut T` is considered undefined behavior. /// -/// The compiler makes optimizations based on the knowledge that `&T` is not mutably aliased or -/// mutated, and that `&mut T` is unique. When building abstractions like `Cell`, `RefCell`, -/// `Mutex`, etc, you need to turn these optimizations off. `UnsafeCell` is the only legal way -/// to do this. When `UnsafeCell` itself is immutably aliased, it is still safe to obtain -/// a mutable reference to its interior and/or to mutate the interior. However, the abstraction -/// designer must ensure that any active mutable references to the interior obtained this way does -/// not co-exist with other active references to the interior, either mutable or not. This is often -/// done via runtime checks. Naturally, several active immutable references to the interior can -/// co-exits with each other (but not with a mutable reference). +/// If you have a reference `&SomeStruct`, then normally in Rust all fields of `SomeStruct` are +/// immutable. The compiler makes optimizations based on the knowledge that `&T` is not mutably +/// aliased or mutated, and that `&mut T` is unique. `UnsafeCel` is the only core language +/// feature to work around this restriction. All other types that allow internal mutability, such as +/// `Cell` and `RefCell` use `UnsafeCell` to wrap their internal data. /// -/// To put it in other words, if a mutable reference to the contents is active, no other references -/// can be active at the same time, and if an immutable reference to the contents is active, then -/// only other immutable reference may be active. +/// The `UnsafeCell` API itself is technically very simple: it gives you a raw pointer `*mut T` to +/// its contents. It is up to _you_ as the abstraction designer to use that raw pointer correctly. +/// +/// The precise Rust aliasing rules are somewhat in flux, but the main points are not contentious: +/// +/// - If you create a safe reference with lifetime `'a` (either a `&T` or `&mut T` reference) that +/// is accessible by safe code (for example, because you returned it), then you must not access +/// the data in any way that contradicts that reference for the remainder of `'a`. For example, that +/// means that if you take the `*mut T` from an `UnsafeCell` and case it to an `&T`, then until +/// that reference's lifetime expires, the data in `T` must remain immutable (modulo any +/// `UnsafeCell` data found within `T`, of course). Similarly, if you create an `&mut T` reference +/// that is released to safe code, then you must not access the data within the `UnsafeCell` until +/// that reference expires. +/// +/// - At all times, you must avoid data races, meaning that if multiple threads have access to +/// the same `UnsafeCell`, then any writes must have a proper happens-before relation to all other +/// accesses (or use atomics). +/// +/// To assist with proper design, the following scenarios are explicitly declared legal +/// for single-threaded code: +/// +/// 1. A `&T` reference can be released to safe code and there it can co-exit with other `&T` +/// references, but not with a `&mut T` +/// +/// 2. A `&mut T` reference may be released to safe code, provided neither other `&mut T` nor `&T` +/// co-exist with it. A `&mut T` must always be unique. /// /// Note that while mutating or mutably aliasing the contents of an `& UnsafeCell` is /// okay (provided you enforce the invariants some other way), it is still undefined behavior /// to have multiple `&mut UnsafeCell` aliases. /// -/// -/// Types like `Cell` and `RefCell` use this type to wrap their internal data. -/// /// # Examples /// /// ``` From fbcd2f5a6a23c48416e6a948d8733f1c225acab3 Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Thu, 8 Mar 2018 23:16:31 +0200 Subject: [PATCH 14/24] tidy. Again --- src/libcore/cell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 61b0aead22f20..98f08676722ea 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1167,7 +1167,7 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// feature to work around this restriction. All other types that allow internal mutability, such as /// `Cell` and `RefCell` use `UnsafeCell` to wrap their internal data. /// -/// The `UnsafeCell` API itself is technically very simple: it gives you a raw pointer `*mut T` to +/// The `UnsafeCell` API itself is technically very simple: it gives you a raw pointer `*mut T` to /// its contents. It is up to _you_ as the abstraction designer to use that raw pointer correctly. /// /// The precise Rust aliasing rules are somewhat in flux, but the main points are not contentious: @@ -1182,7 +1182,7 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// that reference expires. /// /// - At all times, you must avoid data races, meaning that if multiple threads have access to -/// the same `UnsafeCell`, then any writes must have a proper happens-before relation to all other +/// the same `UnsafeCell`, then any writes must have a proper happens-before relation to all other /// accesses (or use atomics). /// /// To assist with proper design, the following scenarios are explicitly declared legal From 55be28367413e01262e4fb72d4af36cee368b65d Mon Sep 17 00:00:00 2001 From: Maxim Nazarenko Date: Thu, 8 Mar 2018 23:26:27 +0200 Subject: [PATCH 15/24] and again :( --- src/libcore/cell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 98f08676722ea..4cfc34b86d09b 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1176,10 +1176,10 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// is accessible by safe code (for example, because you returned it), then you must not access /// the data in any way that contradicts that reference for the remainder of `'a`. For example, that /// means that if you take the `*mut T` from an `UnsafeCell` and case it to an `&T`, then until -/// that reference's lifetime expires, the data in `T` must remain immutable (modulo any +/// that reference's lifetime expires, the data in `T` must remain immutable (modulo any /// `UnsafeCell` data found within `T`, of course). Similarly, if you create an `&mut T` reference /// that is released to safe code, then you must not access the data within the `UnsafeCell` until -/// that reference expires. +/// that reference expires. /// /// - At all times, you must avoid data races, meaning that if multiple threads have access to /// the same `UnsafeCell`, then any writes must have a proper happens-before relation to all other @@ -1189,7 +1189,7 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { /// for single-threaded code: /// /// 1. A `&T` reference can be released to safe code and there it can co-exit with other `&T` -/// references, but not with a `&mut T` +/// references, but not with a `&mut T` /// /// 2. A `&mut T` reference may be released to safe code, provided neither other `&mut T` nor `&T` /// co-exist with it. A `&mut T` must always be unique. From a63bf3bb10117af94cc8189e9f228a81da5b432d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 9 Mar 2018 14:08:59 +0100 Subject: [PATCH 16/24] Add missing urls --- src/liballoc/vec.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 2f57c53a6d834..1bb2bed463b09 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1212,8 +1212,9 @@ impl Vec { /// difference, with each additional slot filled with `value`. /// If `new_len` is less than `len`, the `Vec` is simply truncated. /// - /// This method requires `Clone` to clone the passed value. If you'd - /// rather create a value with `Default` instead, see [`resize_default`]. + /// This method requires [`Clone`] to be able clone the passed value. If + /// you'd rather create a value with [`Default`] instead, see + /// [`resize_default`]. /// /// # Examples /// @@ -1227,6 +1228,8 @@ impl Vec { /// assert_eq!(vec, [1, 2]); /// ``` /// + /// [`Clone`]: ../../std/clone/trait.Clone.html + /// [`Default`]: ../../std/default/trait.Default.html /// [`resize_default`]: #method.resize_default #[stable(feature = "vec_resize", since = "1.5.0")] pub fn resize(&mut self, new_len: usize, value: T) { @@ -1244,7 +1247,7 @@ impl Vec { /// Iterates over the slice `other`, clones each element, and then appends /// it to this `Vec`. The `other` vector is traversed in-order. /// - /// Note that this function is same as `extend` except that it is + /// Note that this function is same as [`extend`] except that it is /// specialized to work with slices instead. If and when Rust gets /// specialization this function will likely be deprecated (but still /// available). @@ -1256,6 +1259,8 @@ impl Vec { /// vec.extend_from_slice(&[2, 3, 4]); /// assert_eq!(vec, [1, 2, 3, 4]); /// ``` + /// + /// [`extend`]: #method.extend #[stable(feature = "vec_extend_from_slice", since = "1.6.0")] pub fn extend_from_slice(&mut self, other: &[T]) { self.spec_extend(other.iter()) @@ -1266,12 +1271,11 @@ impl Vec { /// Resizes the `Vec` in-place so that `len` is equal to `new_len`. /// /// If `new_len` is greater than `len`, the `Vec` is extended by the - /// difference, with each additional slot filled with `Default::default()`. + /// difference, with each additional slot filled with [`Default::default()`]. /// If `new_len` is less than `len`, the `Vec` is simply truncated. /// - /// This method uses `Default` to create new values on every push. If - /// you'd rather `Clone` a given value, use [`resize`]. - /// + /// This method uses [`Default`] to create new values on every push. If + /// you'd rather [`Clone`] a given value, use [`resize`]. /// /// # Examples /// @@ -1288,6 +1292,9 @@ impl Vec { /// ``` /// /// [`resize`]: #method.resize + /// [`Default::default()`]: ../../std/default/trait.Default.html#tymethod.default + /// [`Default`]: ../../std/default/trait.Default.html + /// [`Clone`]: ../../std/clone/trait.Clone.html #[unstable(feature = "vec_resize_default", issue = "41758")] pub fn resize_default(&mut self, new_len: usize) { let len = self.len(); From c1a73d2f4a8ef0003b93c4307930438be4aae9a5 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 9 Mar 2018 17:11:06 +0300 Subject: [PATCH 17/24] tidy: Add a check for stray `.stderr` and `.stdout` files in UI test directories --- .../ex3-both-anon-regions-4.stderr | 19 ------ .../propagate-approximated-to-empty.stderr | 45 -------------- src/test/ui/resolve-error.stderr | 62 ------------------- src/test/ui/span/loan-extend.stderr | 14 ----- src/tools/tidy/src/lib.rs | 1 + src/tools/tidy/src/main.rs | 1 + src/tools/tidy/src/ui_tests.rs | 26 ++++++++ 7 files changed, 28 insertions(+), 140 deletions(-) delete mode 100644 src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr delete mode 100644 src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr delete mode 100644 src/test/ui/resolve-error.stderr delete mode 100644 src/test/ui/span/loan-extend.stderr create mode 100644 src/tools/tidy/src/ui_tests.rs diff --git a/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr b/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr deleted file mode 100644 index 19339800a7a98..0000000000000 --- a/src/test/ui/lifetime-errors/ex3-both-anon-regions-4.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-4.rs:12:13 - | -11 | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { - | --- --- these references are declared with different lifetimes... -12 | z.push((x,y)); - | ^ ...but data flows into `z` here - -error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-4.rs:12:15 - | -11 | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { - | --- --- these references are declared with different lifetimes... -12 | z.push((x,y)); - | ^ ...but data flows into `z` here - -error: aborting due to 2 previous errors - -If you want more information on this error, try using "rustc --explain E0623" diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr deleted file mode 100644 index 502b344c89e44..0000000000000 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-to-empty.stderr +++ /dev/null @@ -1,45 +0,0 @@ -warning: not reporting region error due to -Znll - --> $DIR/propagate-approximated-to-empty.rs:41:9 - | -41 | demand_y(x, y, x.get()) - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: free region `'_#6r` does not outlive free region `'_#4r` - --> $DIR/propagate-approximated-to-empty.rs:41:18 - | -41 | demand_y(x, y, x.get()) - | ^ - -note: No external requirements - --> $DIR/propagate-approximated-to-empty.rs:39:47 - | -39 | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | _______________________________________________^ -40 | | // Only works if 'x: 'y: -41 | | demand_y(x, y, x.get()) -42 | | //~^ WARN not reporting region error due to -Znll -43 | | //~| ERROR free region `'_#6r` does not outlive free region `'_#4r` -44 | | }); - | |_____^ - | - = note: defining type: DefId(0/1:18 ~ propagate_approximated_to_empty[317d]::supply[0]::{{closure}}[0]) with closure substs [ - i16, - for<'r, 's, 't0, 't1, 't2> extern "rust-call" fn((&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 'r)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) &'_#1r u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't0)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't1)) u32>, &ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 't2)) std::cell::Cell<&ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(crate0:DefIndex(0:0), 's)) u32>)) - ] - -note: No external requirements - --> $DIR/propagate-approximated-to-empty.rs:38:1 - | -38 | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { -39 | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { -40 | | // Only works if 'x: 'y: -41 | | demand_y(x, y, x.get()) -... | -44 | | }); -45 | | } - | |_^ - | - = note: defining type: DefId(0/0:6 ~ propagate_approximated_to_empty[317d]::supply[0]) with substs [] - -error: aborting due to previous error - diff --git a/src/test/ui/resolve-error.stderr b/src/test/ui/resolve-error.stderr deleted file mode 100644 index 27f93939246c0..0000000000000 --- a/src/test/ui/resolve-error.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error: cannot find derive macro `FooWithLongNan` in this scope - --> $DIR/resolve-error.rs:37:10 - | -37 | #[derive(FooWithLongNan)] - | ^^^^^^^^^^^^^^ help: try: `FooWithLongName` - -error: cannot find attribute macro `attr_proc_macra` in this scope - --> $DIR/resolve-error.rs:40:3 - | -40 | #[attr_proc_macra] - | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro` - -error: cannot find attribute macro `FooWithLongNan` in this scope - --> $DIR/resolve-error.rs:43:3 - | -43 | #[FooWithLongNan] - | ^^^^^^^^^^^^^^ - -error: cannot find derive macro `Dlone` in this scope - --> $DIR/resolve-error.rs:46:10 - | -46 | #[derive(Dlone)] - | ^^^^^ help: try: `Clone` - -error: cannot find derive macro `Dlona` in this scope - --> $DIR/resolve-error.rs:49:10 - | -49 | #[derive(Dlona)] - | ^^^^^ help: try: `Clona` - -error: cannot find derive macro `attr_proc_macra` in this scope - --> $DIR/resolve-error.rs:52:10 - | -52 | #[derive(attr_proc_macra)] - | ^^^^^^^^^^^^^^^ - -error: cannot find macro `FooWithLongNama!` in this scope - --> $DIR/resolve-error.rs:56:5 - | -56 | FooWithLongNama!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam!` - -error: cannot find macro `attr_proc_macra!` in this scope - --> $DIR/resolve-error.rs:58:5 - | -58 | attr_proc_macra!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac!` - -error: cannot find macro `Dlona!` in this scope - --> $DIR/resolve-error.rs:60:5 - | -60 | Dlona!(); - | ^^^^^ - -error: cannot find macro `bang_proc_macrp!` in this scope - --> $DIR/resolve-error.rs:62:5 - | -62 | bang_proc_macrp!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro!` - -error: aborting due to previous error(s) - diff --git a/src/test/ui/span/loan-extend.stderr b/src/test/ui/span/loan-extend.stderr deleted file mode 100644 index af498129fc440..0000000000000 --- a/src/test/ui/span/loan-extend.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `short` does not live long enough - --> $DIR/loan-extend.rs:21:1 - | -19 | long = borrow(&mut short); - | ----- borrow occurs here -20 | -21 | } - | ^ `short` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to previous error - -If you want more information on this error, try using "rustc --explain E0597" diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index c927ff19b279b..06eb055f68e06 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -51,6 +51,7 @@ pub mod features; pub mod cargo; pub mod pal; pub mod deps; +pub mod ui_tests; pub mod unstable_book; fn filter_dirs(path: &Path) -> bool { diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index afa3ebd198319..2497419279560 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -45,6 +45,7 @@ fn main() { deps::check(&path, &mut bad); } deps::check_whitelist(&path, &cargo, &mut bad); + ui_tests::check(&path, &mut bad); if bad { eprintln!("some tidy checks failed"); diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs new file mode 100644 index 0000000000000..f7fec2e667ab9 --- /dev/null +++ b/src/tools/tidy/src/ui_tests.rs @@ -0,0 +1,26 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Tidy check to ensure that there are no stray `.stderr` files in UI test directories. + +use std::path::Path; + +pub fn check(path: &Path, bad: &mut bool) { + super::walk_many(&[&path.join("test/ui"), &path.join("test/ui-fulldeps")], + &mut |_| false, + &mut |file_path| { + if let Some(ext) = file_path.extension() { + if (ext == "stderr" || ext == "stdout") && !file_path.with_extension("rs").exists() { + println!("Stray file with UI testing output: {:?}", file_path); + *bad = true; + } + } + }); +} From 7dc71ec009ffce75142b2987374401b50a3a194c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 9 Mar 2018 22:18:08 +0100 Subject: [PATCH 18/24] Remove auto trait implementation section when empty --- src/librustdoc/html/render.rs | 18 ++++++++++-------- src/test/rustdoc/empty-section.rs | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 src/test/rustdoc/empty-section.rs diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 6945a6f3724d5..84f693a3be5f9 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3181,14 +3181,16 @@ fn render_assoc_items(w: &mut fmt::Formatter, render_impls(cx, w, concrete, containing_item)?; write!(w, "")?; - write!(w, " -

- Auto Trait Implementations -

-
- ")?; - render_impls(cx, w, synthetic, containing_item)?; - write!(w, "
")?; + if !synthetic.is_empty() { + write!(w, " +

+ Auto Trait Implementations +

+
+ ")?; + render_impls(cx, w, synthetic, containing_item)?; + write!(w, "
")?; + } } Ok(()) } diff --git a/src/test/rustdoc/empty-section.rs b/src/test/rustdoc/empty-section.rs new file mode 100644 index 0000000000000..3748313593fc2 --- /dev/null +++ b/src/test/rustdoc/empty-section.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +#![feature(optin_builtin_traits)] + +pub struct Foo; + +// @has foo/struct.Foo.html +// @!has - '//*[@class="synthetic-implementations"]' 'Auto Trait Implementations' +impl !Send for Foo {} +impl !Sync for Foo {} From 933417549c0e3fab110d8f435eb8e80303c35bde Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Sat, 10 Mar 2018 15:00:26 +0100 Subject: [PATCH 19/24] remove linker arguments from L4Re target These change from release to release and are impossible to get right, since they are generated by Make magic. --- src/librustc_back/target/l4re_base.rs | 71 +++++-------------- .../target/x86_64_unknown_l4re_uclibc.rs | 2 +- 2 files changed, 17 insertions(+), 56 deletions(-) diff --git a/src/librustc_back/target/l4re_base.rs b/src/librustc_back/target/l4re_base.rs index 7cb7f8d613dee..bff91e8f9952a 100644 --- a/src/librustc_back/target/l4re_base.rs +++ b/src/librustc_back/target/l4re_base.rs @@ -8,74 +8,35 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use PanicStrategy; use LinkerFlavor; +use PanicStrategy; use target::{LinkArgs, TargetOptions}; use std::default::Default; -use std::env; -use std::process::Command; +//use std::process::Command; // Use GCC to locate code for crt* libraries from the host, not from L4Re. Note // that a few files also come from L4Re, for these, the function shouldn't be // used. This uses GCC for the location of the file, but GCC is required for L4Re anyway. -fn get_path_or(filename: &str) -> String { - let child = Command::new("gcc") - .arg(format!("-print-file-name={}", filename)).output() - .expect("Failed to execute GCC"); - String::from_utf8(child.stdout) - .expect("Couldn't read path from GCC").trim().into() -} +//fn get_path_or(filename: &str) -> String { +// let child = Command::new("gcc") +// .arg(format!("-print-file-name={}", filename)).output() +// .expect("Failed to execute GCC"); +// String::from_utf8(child.stdout) +// .expect("Couldn't read path from GCC").trim().into() +//} -pub fn opts() -> Result { - let l4re_lib_path = env::var_os("L4RE_LIBDIR").ok_or("Unable to find L4Re \ - library directory: L4RE_LIBDIR not set.")?.into_string().unwrap(); - let mut pre_link_args = LinkArgs::new(); - pre_link_args.insert(LinkerFlavor::Ld, vec![ - format!("-T{}/main_stat.ld", l4re_lib_path), - "--defsym=__executable_start=0x01000000".to_string(), - "--defsym=__L4_KIP_ADDR__=0x6ffff000".to_string(), - format!("{}/crt1.o", l4re_lib_path), - format!("{}/crti.o", l4re_lib_path), - get_path_or("crtbeginT.o"), - ]); - let mut post_link_args = LinkArgs::new(); - post_link_args.insert(LinkerFlavor::Ld, vec![ - format!("{}/l4f/libpthread.a", l4re_lib_path), - format!("{}/l4f/libc_be_sig.a", l4re_lib_path), - format!("{}/l4f/libc_be_sig_noop.a", l4re_lib_path), - format!("{}/l4f/libc_be_socket_noop.a", l4re_lib_path), - format!("{}/l4f/libc_be_fs_noop.a", l4re_lib_path), - format!("{}/l4f/libc_be_sem_noop.a", l4re_lib_path), - format!("{}/l4f/libl4re-vfs.o.a", l4re_lib_path), - format!("{}/l4f/lib4re.a", l4re_lib_path), - format!("{}/l4f/lib4re-util.a", l4re_lib_path), - format!("{}/l4f/libc_support_misc.a", l4re_lib_path), - format!("{}/l4f/libsupc++.a", l4re_lib_path), - format!("{}/l4f/lib4shmc.a", l4re_lib_path), - format!("{}/l4f/lib4re-c.a", l4re_lib_path), - format!("{}/l4f/lib4re-c-util.a", l4re_lib_path), - get_path_or("libgcc_eh.a"), - format!("{}/l4f/libdl.a", l4re_lib_path), - "--start-group".to_string(), - format!("{}/l4f/libl4util.a", l4re_lib_path), - format!("{}/l4f/libc_be_l4re.a", l4re_lib_path), - format!("{}/l4f/libuc_c.a", l4re_lib_path), - format!("{}/l4f/libc_be_l4refile.a", l4re_lib_path), - "--end-group".to_string(), - format!("{}/l4f/libl4sys.a", l4re_lib_path), - "-gc-sections".to_string(), - get_path_or("crtend.o"), - format!("{}/crtn.o", l4re_lib_path), - ]); +pub fn opts() -> TargetOptions { + let mut args = LinkArgs::new(); + args.insert(LinkerFlavor::Gcc, vec![]); - Ok(TargetOptions { + TargetOptions { executables: true, has_elf_tls: false, exe_allocation_crate: None, panic_strategy: PanicStrategy::Abort, - pre_link_args, - post_link_args, + linker: "ld".to_string(), + pre_link_args: args, target_family: Some("unix".to_string()), .. Default::default() - }) + } } diff --git a/src/librustc_back/target/x86_64_unknown_l4re_uclibc.rs b/src/librustc_back/target/x86_64_unknown_l4re_uclibc.rs index 6e849f19cf20f..821a77f52f511 100644 --- a/src/librustc_back/target/x86_64_unknown_l4re_uclibc.rs +++ b/src/librustc_back/target/x86_64_unknown_l4re_uclibc.rs @@ -12,7 +12,7 @@ use LinkerFlavor; use target::{Target, TargetResult}; pub fn target() -> TargetResult { - let mut base = super::l4re_base::opts()?; + let mut base = super::l4re_base::opts(); base.cpu = "x86-64".to_string(); base.max_atomic_width = Some(64); From 9fd941e847fd02c0a74059df78e9040b8e0ada2c Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Sat, 10 Mar 2018 15:01:51 +0100 Subject: [PATCH 20/24] add stub for retrieving number of CPUs --- src/librustc_back/target/l4re_base.rs | 2 +- src/libtest/lib.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc_back/target/l4re_base.rs b/src/librustc_back/target/l4re_base.rs index bff91e8f9952a..3b13ef0150064 100644 --- a/src/librustc_back/target/l4re_base.rs +++ b/src/librustc_back/target/l4re_base.rs @@ -34,7 +34,7 @@ pub fn opts() -> TargetOptions { has_elf_tls: false, exe_allocation_crate: None, panic_strategy: PanicStrategy::Abort, - linker: "ld".to_string(), + linker: Some("ld".to_string()), pre_link_args: args, target_family: Some("unix".to_string()), .. Default::default() diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 82077bc4cd482..59d701dd0fbc8 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1294,6 +1294,12 @@ fn get_concurrency() -> usize { // FIXME: implement 1 } + + #[cfg(target_os = "l4re")] + fn num_cpus() -> usize { + // FIXME: implement + 1 + } } pub fn filter_tests(opts: &TestOpts, tests: Vec) -> Vec { From 9b599856a4b7e375e4e54eb759c250be969f5562 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Sun, 11 Mar 2018 00:04:15 -0800 Subject: [PATCH 21/24] in which some labels and notes are upgraded to structured suggestions (Meanwhile, a couple of parse-fail tests are moved to UI tests so that the reader can see the new output, and an existing UI test is given a more evocative name.) --- src/librustc_typeck/check/mod.rs | 8 ++++---- src/libsyntax/parse/parser.rs | 13 ++++++++----- ...> issue-41679-tilde-bitwise-negation-attempt.rs} | 2 +- ...ssue-41679-tilde-bitwise-negation-attempt.stderr | 8 ++++++++ src/test/ui/did_you_mean/issue-41679.stderr | 10 ---------- .../did_you_mean}/match-refactor-to-expr.rs | 2 +- .../ui/did_you_mean/match-refactor-to-expr.stderr | 13 +++++++++++++ .../did_you_mean}/pub-macro-rules.rs | 3 +-- src/test/ui/did_you_mean/pub-macro-rules.stderr | 8 ++++++++ src/test/ui/issue-11004.stderr | 8 ++------ 10 files changed, 46 insertions(+), 29 deletions(-) rename src/test/ui/did_you_mean/{issue-41679.rs => issue-41679-tilde-bitwise-negation-attempt.rs} (88%) create mode 100644 src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr delete mode 100644 src/test/ui/did_you_mean/issue-41679.stderr rename src/test/{parse-fail => ui/did_you_mean}/match-refactor-to-expr.rs (91%) create mode 100644 src/test/ui/did_you_mean/match-refactor-to-expr.stderr rename src/test/{parse-fail => ui/did_you_mean}/pub-macro-rules.rs (91%) create mode 100644 src/test/ui/did_you_mean/pub-macro-rules.stderr diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 19085ff039ec5..1ea1ff1fae24d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3096,10 +3096,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; } ty::TyRawPtr(..) => { - err.note(&format!("`{0}` is a native pointer; perhaps you need to deref \ - with `(*{0}).{1}`", - self.tcx.hir.node_to_pretty_string(base.id), - field.node)); + let base = self.tcx.hir.node_to_pretty_string(base.id); + let msg = format!("`{}` is a native pointer; try dereferencing it", base); + let suggestion = format!("(*{}).{}", base, field.node); + err.span_suggestion(field.span, &msg, suggestion); } _ => {} } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f5aa01fb03459..bd0ca0e670487 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2831,9 +2831,10 @@ impl<'a> Parser<'a> { let (span, e) = self.interpolated_or_expr_span(e)?; let span_of_tilde = lo; let mut err = self.diagnostic().struct_span_err(span_of_tilde, - "`~` can not be used as a unary operator"); - err.span_label(span_of_tilde, "did you mean `!`?"); - err.help("use `!` instead of `~` if you meant to perform bitwise negation"); + "`~` cannot be used as a unary operator"); + err.span_suggestion_short(span_of_tilde, + "use `!` to perform bitwise negation", + "!".to_owned()); err.emit(); (lo.to(span), self.mk_unary(UnOp::Not, e)) } @@ -3389,7 +3390,7 @@ impl<'a> Parser<'a> { None)?; if let Err(mut e) = self.expect(&token::OpenDelim(token::Brace)) { if self.token == token::Token::Semi { - e.span_note(match_span, "did you mean to remove this `match` keyword?"); + e.span_suggestion_short(match_span, "try removing this `match`", "".to_owned()); } return Err(e) } @@ -5361,7 +5362,9 @@ impl<'a> Parser<'a> { if is_macro_rules { let mut err = self.diagnostic() .struct_span_err(sp, "can't qualify macro_rules invocation with `pub`"); - err.help("did you mean #[macro_export]?"); + err.span_suggestion(sp, + "try exporting the macro", + "#[macro_export]".to_owned()); Err(err) } else { let mut err = self.diagnostic() diff --git a/src/test/ui/did_you_mean/issue-41679.rs b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs similarity index 88% rename from src/test/ui/did_you_mean/issue-41679.rs rename to src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs index 98c909e212fdd..e8fd248011cb8 100644 --- a/src/test/ui/did_you_mean/issue-41679.rs +++ b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let x = ~1; //~ ERROR can not be used as a unary operator + let x = ~1; //~ ERROR cannot be used as a unary operator } diff --git a/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr new file mode 100644 index 0000000000000..f13f15f63771d --- /dev/null +++ b/src/test/ui/did_you_mean/issue-41679-tilde-bitwise-negation-attempt.stderr @@ -0,0 +1,8 @@ +error: `~` cannot be used as a unary operator + --> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:12:13 + | +LL | let x = ~1; //~ ERROR cannot be used as a unary operator + | ^ help: use `!` to perform bitwise negation + +error: aborting due to previous error + diff --git a/src/test/ui/did_you_mean/issue-41679.stderr b/src/test/ui/did_you_mean/issue-41679.stderr deleted file mode 100644 index c17812fc0cb9d..0000000000000 --- a/src/test/ui/did_you_mean/issue-41679.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `~` can not be used as a unary operator - --> $DIR/issue-41679.rs:12:13 - | -LL | let x = ~1; //~ ERROR can not be used as a unary operator - | ^ did you mean `!`? - | - = help: use `!` instead of `~` if you meant to perform bitwise negation - -error: aborting due to previous error - diff --git a/src/test/parse-fail/match-refactor-to-expr.rs b/src/test/ui/did_you_mean/match-refactor-to-expr.rs similarity index 91% rename from src/test/parse-fail/match-refactor-to-expr.rs rename to src/test/ui/did_you_mean/match-refactor-to-expr.rs index e2fee1d189591..3c88608697aad 100644 --- a/src/test/parse-fail/match-refactor-to-expr.rs +++ b/src/test/ui/did_you_mean/match-refactor-to-expr.rs @@ -12,7 +12,7 @@ fn main() { let foo = - match //~ NOTE did you mean to remove this `match` keyword? + match Some(4).unwrap_or_else(5) //~^ NOTE expected one of `.`, `?`, `{`, or an operator here ; //~ NOTE unexpected token diff --git a/src/test/ui/did_you_mean/match-refactor-to-expr.stderr b/src/test/ui/did_you_mean/match-refactor-to-expr.stderr new file mode 100644 index 0000000000000..ecca781684cec --- /dev/null +++ b/src/test/ui/did_you_mean/match-refactor-to-expr.stderr @@ -0,0 +1,13 @@ +error: expected one of `.`, `?`, `{`, or an operator, found `;` + --> $DIR/match-refactor-to-expr.rs:18:9 + | +LL | match + | ----- help: try removing this `match` +LL | Some(4).unwrap_or_else(5) + | - expected one of `.`, `?`, `{`, or an operator here +LL | //~^ NOTE expected one of `.`, `?`, `{`, or an operator here +LL | ; //~ NOTE unexpected token + | ^ unexpected token + +error: aborting due to previous error + diff --git a/src/test/parse-fail/pub-macro-rules.rs b/src/test/ui/did_you_mean/pub-macro-rules.rs similarity index 91% rename from src/test/parse-fail/pub-macro-rules.rs rename to src/test/ui/did_you_mean/pub-macro-rules.rs index 93b992f2f8af2..65a0d642cd7d1 100644 --- a/src/test/parse-fail/pub-macro-rules.rs +++ b/src/test/ui/did_you_mean/pub-macro-rules.rs @@ -9,8 +9,7 @@ // except according to those terms. #[macro_use] mod bleh { - pub macro_rules! foo { //~ ERROR can't qualify macro_rules invocation with `pub` - //~^ HELP did you mean #[macro_export]? + pub macro_rules! foo { //~ ERROR can't qualify macro_rules invocation ($n:ident) => ( fn $n () -> i32 { 1 diff --git a/src/test/ui/did_you_mean/pub-macro-rules.stderr b/src/test/ui/did_you_mean/pub-macro-rules.stderr new file mode 100644 index 0000000000000..dfeab75525ba3 --- /dev/null +++ b/src/test/ui/did_you_mean/pub-macro-rules.stderr @@ -0,0 +1,8 @@ +error: can't qualify macro_rules invocation with `pub` + --> $DIR/pub-macro-rules.rs:12:5 + | +LL | pub macro_rules! foo { //~ ERROR can't qualify macro_rules invocation + | ^^^ help: try exporting the macro: `#[macro_export]` + +error: aborting due to previous error + diff --git a/src/test/ui/issue-11004.stderr b/src/test/ui/issue-11004.stderr index 4cfc7d23bd0b9..268c3cd6d2afd 100644 --- a/src/test/ui/issue-11004.stderr +++ b/src/test/ui/issue-11004.stderr @@ -2,17 +2,13 @@ error[E0609]: no field `x` on type `*mut A` --> $DIR/issue-11004.rs:17:21 | LL | let x : i32 = n.x; //~ no field `x` on type `*mut A` - | ^ - | - = note: `n` is a native pointer; perhaps you need to deref with `(*n).x` + | ^ help: `n` is a native pointer; try dereferencing it: `(*n).x` error[E0609]: no field `y` on type `*mut A` --> $DIR/issue-11004.rs:18:21 | LL | let y : f64 = n.y; //~ no field `y` on type `*mut A` - | ^ - | - = note: `n` is a native pointer; perhaps you need to deref with `(*n).y` + | ^ help: `n` is a native pointer; try dereferencing it: `(*n).y` error: aborting due to 2 previous errors From c033c6e47c1a84e2902c75a1b5ec161362f34f18 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Sun, 11 Mar 2018 10:03:23 -0400 Subject: [PATCH 22/24] Fix hygene issue when deriving Debug The code for several of the core traits doesn't use hygenic macros. This isn't a problem, except for the Debug trait, which is the only one that uses a variable, named "builder". Variables can't share names with unit structs, so attempting to [derive(Debug)] on any type while a unit struct with the name "builder" was in scope would result in an error. This commit just changes the name of the variable to "__debug_trait_builder", because I couldn't figure out how to get a list of all unit structs in-scope from within the derive expansion function. If someone wants to have a unit struct with the exact name "__debug_trait_builder", they'll just have to do it without a [derive(Debug)]. --- src/libsyntax_ext/deriving/debug.rs | 2 +- src/test/run-pass/issue-42453.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/issue-42453.rs diff --git a/src/libsyntax_ext/deriving/debug.rs b/src/libsyntax_ext/deriving/debug.rs index 82fc09fca69af..7b23de582a79a 100644 --- a/src/libsyntax_ext/deriving/debug.rs +++ b/src/libsyntax_ext/deriving/debug.rs @@ -70,7 +70,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug)] +struct builder; + +fn main() { + +} + From f2a8556df455c37b64d7e7df1454fc156f6be342 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 9 Mar 2018 11:31:04 -0800 Subject: [PATCH 23/24] Update stdsimd module Pulls in a redesigned `std::simd` module as well as a replacement for the `is_target_feature_detected!` macro --- src/libcore/lib.rs | 2 ++ src/stdsimd | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 1efd605112dc2..448e49ffebda8 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -74,7 +74,9 @@ #![feature(concat_idents)] #![feature(const_fn)] #![feature(custom_attribute)] +#![feature(doc_cfg)] #![feature(doc_spotlight)] +#![feature(fn_must_use)] #![feature(fundamental)] #![feature(i128_type)] #![feature(inclusive_range_syntax)] diff --git a/src/stdsimd b/src/stdsimd index 678cbd325c840..ab9356f2af650 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 678cbd325c84070c9dbe4303969fbd2734c0b4ee +Subproject commit ab9356f2af650815d339d77306f0d09c44d531ad From bda5a45793b7bf98290b815f80db6ae2e1f867ae Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 12 Mar 2018 16:01:28 +0100 Subject: [PATCH 24/24] Add missing links --- src/libcore/fmt/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 8ad5a9861a02f..213b317f632eb 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -684,18 +684,16 @@ pub trait Octal { /// /// The `Binary` trait should format its output as a number in binary. /// -/// For primitive signed integers (`i8` to `i128`, and `isize`), +/// For primitive signed integers ([`i8`] to [`i128`], and [`isize`]), /// negative values are formatted as the two’s complement representation. /// /// The alternate flag, `#`, adds a `0b` in front of the output. /// /// For more information on formatters, see [the module-level documentation][module]. /// -/// [module]: ../../std/fmt/index.html -/// /// # Examples /// -/// Basic usage with `i32`: +/// Basic usage with [`i32`]: /// /// ``` /// let x = 42; // 42 is '101010' in binary @@ -725,6 +723,12 @@ pub trait Octal { /// /// println!("l as binary is: {:b}", l); /// ``` +/// +/// [module]: ../../std/fmt/index.html +/// [`i8`]: ../../std/primitive.i8.html +/// [`i128`]: ../../std/primitive.i128.html +/// [`isize`]: ../../std/primitive.isize.html +/// [`i32`]: ../../std/primitive.i32.html #[stable(feature = "rust1", since = "1.0.0")] pub trait Binary { /// Formats the value using the given formatter.