From 0591ff7525d3d468244e102c4002b6663db5f5ad Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Sat, 10 Nov 2018 06:59:42 +0000 Subject: [PATCH 01/18] OsString: mention storage form in discussion Helps users to understand capacity related values, which may surpise on Windows. Also is a step towards clarifying understanding of `OsStr`'s len() return value. --- src/libstd/ffi/os_str.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index e9390630445a1..d5a51c02a4778 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -42,6 +42,13 @@ use sys_common::{AsInner, IntoInner, FromInner}; /// in each pair are owned strings; the latter are borrowed /// references. /// +/// Note, `OsString` and `OsStr` internally do not necessarily hold strings in +/// the form native to the platform; While on Unix, strings are stored as a +/// sequence of 8-bit values, on Windows, where strings are 16-bit value based +/// as just discussed, strings are also actually stored as a sequence of 8-bit +/// values, encoded in a less-strict variant of UTF-8. This is useful to +/// understand when handling capacity and length values. +/// /// # Creating an `OsString` /// /// **From a Rust string**: `OsString` implements From a1e9c7fc2e4806fe72c84178bf1116f645d18c43 Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Sat, 10 Nov 2018 07:35:15 +0000 Subject: [PATCH 02/18] OsStr: clarify `len()` method documentation --- src/libstd/ffi/os_str.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index d5a51c02a4778..0edfd122ceff9 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -590,14 +590,19 @@ impl OsStr { /// Returns the length of this `OsStr`. /// - /// Note that this does **not** return the number of bytes in this string - /// as, for example, OS strings on Windows are encoded as a list of [`u16`] - /// rather than a list of bytes. This number is simply useful for passing to - /// other methods like [`OsString::with_capacity`] to avoid reallocations. + /// Note that this does **not** return the number of bytes in the string in + /// OS string form. /// - /// See `OsStr` introduction for more information about encoding. + /// The length returned is that of the underlying storage used by `OsStr`; + /// As discussed in the [`OsString`] introduction, [`OsString`] and `OsStr` + /// store strings in a form best suited for cheap inter-conversion between + /// native-platform and Rust string forms, which may differ significantly + /// from both of them, including in storage size and encoding. /// - /// [`u16`]: ../primitive.u16.html + /// This number is simply useful for passing to other methods, like + /// [`OsString::with_capacity`] to avoid reallocations. + /// + /// [`OsString`]: struct.OsString.html /// [`OsString::with_capacity`]: struct.OsString.html#method.with_capacity /// /// # Examples From aa5a4ef59d51dcea98fe6750a5fdb36bed6b9b55 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Fri, 30 Nov 2018 03:55:26 +0000 Subject: [PATCH 03/18] Removed feature gate. --- src/librustc_resolve/lib.rs | 20 ++++--------------- src/libsyntax/feature_gate.rs | 11 +++++----- src/test/run-pass/self/self-in-typedefs.rs | 3 +-- .../feature-gate-self_in_typedefs.rs | 18 ----------------- .../feature-gate-self_in_typedefs.stderr | 11 ---------- 5 files changed, 10 insertions(+), 53 deletions(-) delete mode 100644 src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c1d4643c2403e..fdac1e3b81652 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2373,13 +2373,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { self.with_current_self_item(item, |this| { this.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| { let item_def_id = this.definitions.local_def_id(item.id); - if this.session.features_untracked().self_in_typedefs { - this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| { - visit::walk_item(this, item); - }); - } else { + this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| { visit::walk_item(this, item); - } + }); }); }); } @@ -3185,16 +3181,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { if is_self_type(path, ns) { __diagnostic_used!(E0411); err.code(DiagnosticId::Error("E0411".into())); - let available_in = if this.session.features_untracked().self_in_typedefs { - "impls, traits, and type definitions" - } else { - "traits and impls" - }; - err.span_label(span, format!("`Self` is only available in {}", available_in)); - if this.current_self_item.is_some() && nightly_options::is_nightly_build() { - err.help("add #![feature(self_in_typedefs)] to the crate attributes \ - to enable"); - } + err.span_label(span, format!("`Self` is only available in impls, traits, \ + and type definitions")); return (err, Vec::new()); } if is_self_value(path, ns) { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2402de5a816b7..dd61fd6826f13 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -462,9 +462,6 @@ declare_features! ( // Allows `use x::y;` to resolve through `self::x`, not just `::x` (active, uniform_paths, "1.30.0", Some(53130), None), - // Allows `Self` in type definitions - (active, self_in_typedefs, "1.30.0", Some(49303), None), - // Allows unsized rvalues at arguments and parameters (active, unsized_locals, "1.30.0", Some(48055), None), @@ -672,21 +669,23 @@ declare_features! ( (accepted, extern_prelude, "1.30.0", Some(44660), None), // Parentheses in patterns (accepted, pattern_parentheses, "1.31.0", Some(51087), None), - // Allows the definition of `const fn` functions. + // Allows the definition of `const fn` functions (accepted, min_const_fn, "1.31.0", Some(53555), None), // Scoped lints (accepted, tool_lints, "1.31.0", Some(44690), None), // impl Iterator for &mut Iterator // impl Debug for Foo<'_> (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None), - // `extern crate foo as bar;` puts `bar` into extern prelude. + // `extern crate foo as bar;` puts `bar` into extern prelude (accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None), // Allows use of the :literal macro fragment specifier (RFC 1576) (accepted, macro_literal_matcher, "1.31.0", Some(35625), None), // Use `?` as the Kleene "at most one" operator (accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None), - // Self struct constructor (RFC 2302) + // `Self` struct constructor (RFC 2302) (accepted, self_struct_ctor, "1.32.0", Some(51994), None), + // `Self` in type definitions (RFC 2300) + (accepted, self_in_typedefs, "1.32.0", Some(49303), None), ); // If you change this, please modify `src/doc/unstable-book` as well. You must diff --git a/src/test/run-pass/self/self-in-typedefs.rs b/src/test/run-pass/self/self-in-typedefs.rs index 92eccb47e1894..84a7e18f91ad2 100644 --- a/src/test/run-pass/self/self-in-typedefs.rs +++ b/src/test/run-pass/self/self-in-typedefs.rs @@ -9,12 +9,11 @@ // except according to those terms. // run-pass -#![allow(unions_with_drop_fields)] -#![feature(self_in_typedefs)] #![feature(untagged_unions)] #![allow(dead_code)] +#![allow(unions_with_drop_fields)] enum A<'a, T: 'a> where diff --git a/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs b/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs deleted file mode 100644 index 4b476a0a645b1..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -enum StackList<'a, T: 'a> { - Nil, - Cons(T, &'a Self) - //~^ ERROR cannot find type `Self` in this scope - //~| `Self` is only available in traits and impls -} - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr b/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr deleted file mode 100644 index ab04953f3e50c..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0411]: cannot find type `Self` in this scope - --> $DIR/feature-gate-self_in_typedefs.rs:13:17 - | -LL | Cons(T, &'a Self) - | ^^^^ `Self` is only available in traits and impls - | - = help: add #![feature(self_in_typedefs)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0411`. From 7bc1255955a14e668b119ac3ccd895509be2656b Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Fri, 30 Nov 2018 04:14:51 +0000 Subject: [PATCH 04/18] Removed chapter from Unstable Book. --- .../src/language-features/self-in-typedefs.md | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/self-in-typedefs.md diff --git a/src/doc/unstable-book/src/language-features/self-in-typedefs.md b/src/doc/unstable-book/src/language-features/self-in-typedefs.md deleted file mode 100644 index 2416e85c17d1f..0000000000000 --- a/src/doc/unstable-book/src/language-features/self-in-typedefs.md +++ /dev/null @@ -1,24 +0,0 @@ -# `self_in_typedefs` - -The tracking issue for this feature is: [#49303] - -[#49303]: https://github.com/rust-lang/rust/issues/49303 - ------------------------- - -The `self_in_typedefs` feature gate lets you use the special `Self` identifier -in `struct`, `enum`, and `union` type definitions. - -A simple example is: - -```rust -#![feature(self_in_typedefs)] - -enum List -where - Self: PartialOrd // can write `Self` instead of `List` -{ - Nil, - Cons(T, Box) // likewise here -} -``` From d609fdf775f2789066cc92ba30f6de2875c10903 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Fri, 30 Nov 2018 15:41:32 +0000 Subject: [PATCH 05/18] Updated ui tests. --- src/test/ui/error-codes/E0411.stderr | 2 +- src/test/ui/issues/issue-36638.rs | 1 + src/test/ui/issues/issue-36638.stderr | 13 +++++++++++-- src/test/ui/resolve/issue-24968.stderr | 2 +- src/test/ui/resolve/resolve-self-in-impl-2.stderr | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/test/ui/error-codes/E0411.stderr b/src/test/ui/error-codes/E0411.stderr index a5f2e3a7b93de..4e85f651b5533 100644 --- a/src/test/ui/error-codes/E0411.stderr +++ b/src/test/ui/error-codes/E0411.stderr @@ -2,7 +2,7 @@ error[E0411]: cannot find type `Self` in this scope --> $DIR/E0411.rs:12:6 | LL | ::foo; //~ ERROR E0411 - | ^^^^ `Self` is only available in traits and impls + | ^^^^ `Self` is only available in impls, traits, and type definitions error: aborting due to previous error diff --git a/src/test/ui/issues/issue-36638.rs b/src/test/ui/issues/issue-36638.rs index 5e43536ef3f90..acb501c29fceb 100644 --- a/src/test/ui/issues/issue-36638.rs +++ b/src/test/ui/issues/issue-36638.rs @@ -12,6 +12,7 @@ struct Foo(Self); //~^ ERROR expected identifier, found keyword `Self` +//~^^ ERROR E0392 trait Bar {} //~^ ERROR expected identifier, found keyword `Self` diff --git a/src/test/ui/issues/issue-36638.stderr b/src/test/ui/issues/issue-36638.stderr index d111fb469bfe1..155eb170b091f 100644 --- a/src/test/ui/issues/issue-36638.stderr +++ b/src/test/ui/issues/issue-36638.stderr @@ -5,10 +5,19 @@ LL | struct Foo(Self); | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/issue-36638.rs:16:11 + --> $DIR/issue-36638.rs:17:11 | LL | trait Bar {} | ^^^^ expected identifier, found keyword -error: aborting due to 2 previous errors +error[E0392]: parameter `Self` is never used + --> $DIR/issue-36638.rs:13:12 + | +LL | struct Foo(Self); + | ^^^^ unused type parameter + | + = help: consider removing `Self` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/resolve/issue-24968.stderr b/src/test/ui/resolve/issue-24968.stderr index 9a1d5ea170e65..cfb2034050485 100644 --- a/src/test/ui/resolve/issue-24968.stderr +++ b/src/test/ui/resolve/issue-24968.stderr @@ -2,7 +2,7 @@ error[E0411]: cannot find type `Self` in this scope --> $DIR/issue-24968.rs:11:11 | LL | fn foo(_: Self) { - | ^^^^ `Self` is only available in traits and impls + | ^^^^ `Self` is only available in impls, traits, and type definitions error: aborting due to previous error diff --git a/src/test/ui/resolve/resolve-self-in-impl-2.stderr b/src/test/ui/resolve/resolve-self-in-impl-2.stderr index 183b9b66327b4..b3a8261bcfc74 100644 --- a/src/test/ui/resolve/resolve-self-in-impl-2.stderr +++ b/src/test/ui/resolve/resolve-self-in-impl-2.stderr @@ -2,7 +2,7 @@ error[E0411]: expected trait, found self type `Self` --> $DIR/resolve-self-in-impl-2.rs:14:6 | LL | impl Self for S {} //~ ERROR expected trait, found self type `Self` - | ^^^^ `Self` is only available in traits and impls + | ^^^^ `Self` is only available in impls, traits, and type definitions error[E0405]: cannot find trait `N` in `Self` --> $DIR/resolve-self-in-impl-2.rs:15:12 From f4cde5bc4e17198670d49c21aa8ce4c199c5489c Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 1 Dec 2018 02:54:09 +0100 Subject: [PATCH 06/18] stabilize std::dbg!(...) --- src/libstd/macros.rs | 12 ++---------- .../dbg-macro-expected-behavior.rs | 18 ++++++++---------- .../dbg-macro-feature-gate.rs | 5 ----- .../dbg-macro-feature-gate.stderr | 11 ----------- .../dbg-macro-move-semantics.nll.stderr | 2 +- .../dbg-macro-move-semantics.rs | 2 -- .../dbg-macro-move-semantics.stderr | 4 ++-- .../dbg-macro-requires-debug.rs | 2 -- .../dbg-macro-requires-debug.stderr | 2 +- 9 files changed, 14 insertions(+), 44 deletions(-) delete mode 100644 src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs delete mode 100644 src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 0995ab3c373ca..94827d2a0355f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -224,11 +224,9 @@ macro_rules! eprintln { /// the value of a given expression. An example: /// /// ```rust -/// #![feature(dbg_macro)] -/// /// let a = 2; /// let b = dbg!(a * 2) + 1; -/// // ^-- prints: [src/main.rs:4] a * 2 = 4 +/// // ^-- prints: [src/main.rs:2] a * 2 = 4 /// assert_eq!(b, 5); /// ``` /// @@ -262,8 +260,6 @@ macro_rules! eprintln { /// With a method call: /// /// ```rust -/// #![feature(dbg_macro)] -/// /// fn foo(n: usize) { /// if let Some(_) = dbg!(n.checked_sub(4)) { /// // ... @@ -282,8 +278,6 @@ macro_rules! eprintln { /// Naive factorial implementation: /// /// ```rust -/// #![feature(dbg_macro)] -/// /// fn factorial(n: u32) -> u32 { /// if dbg!(n <= 1) { /// dbg!(1) @@ -312,8 +306,6 @@ macro_rules! eprintln { /// The `dbg!(..)` macro moves the input: /// /// ```compile_fail -/// #![feature(dbg_macro)] -/// /// /// A wrapper around `usize` which importantly is not Copyable. /// #[derive(Debug)] /// struct NoCopy(usize); @@ -325,7 +317,7 @@ macro_rules! eprintln { /// /// [stderr]: https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr) #[macro_export] -#[unstable(feature = "dbg_macro", issue = "54306")] +#[stable(feature = "dbg_macro", since = "1.32.0")] macro_rules! dbg { ($val:expr) => { // Use of `match` here is intentional because it affects the lifetimes diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs index f7216c57e42b8..3d24f49ad7509 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs @@ -5,8 +5,6 @@ // Tests ensuring that `dbg!(expr)` has the expected run-time behavior. // as well as some compile time properties we expect. -#![feature(dbg_macro)] - #[derive(Copy, Clone, Debug)] struct Unit; @@ -57,31 +55,31 @@ fn test() { fn validate_stderr(stderr: Vec) { assert_eq!(stderr, &[ - ":23] Unit = Unit", + ":21] Unit = Unit", - ":24] a = Unit", + ":22] a = Unit", - ":30] Point{x: 42, y: 24,} = Point {", + ":28] Point{x: 42, y: 24,} = Point {", " x: 42,", " y: 24", "}", - ":31] b = Point {", + ":29] b = Point {", " x: 42,", " y: 24", "}", - ":40] &a = NoCopy(", + ":38] &a = NoCopy(", " 1337", ")", - ":40] dbg!(& a) = NoCopy(", + ":38] dbg!(& a) = NoCopy(", " 1337", ")", - ":45] f(&42) = 42", + ":43] f(&42) = 42", "before", - ":50] { foo += 1; eprintln!(\"before\"); 7331 } = 7331", + ":48] { foo += 1; eprintln!(\"before\"); 7331 } = 7331", ]); } diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs deleted file mode 100644 index b237c6f147bf7..0000000000000 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Feature gate test for `dbg!(..)`. - -fn main() { - dbg!(1); -} diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr deleted file mode 100644 index 64df1e196d285..0000000000000 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: macro dbg! is unstable (see issue #54306) - --> $DIR/dbg-macro-feature-gate.rs:4:5 - | -LL | dbg!(1); - | ^^^^^^^^ - | - = help: add #![feature(dbg_macro)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr index bf99fef3bbd2f..218a1d5b5fd12 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:11:18 + --> $DIR/dbg-macro-move-semantics.rs:9:18 | LL | let _ = dbg!(a); | ------- value moved here diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs index bcf508d9af5d7..06a23ea1767b0 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs @@ -1,7 +1,5 @@ // Test ensuring that `dbg!(expr)` will take ownership of the argument. -#![feature(dbg_macro)] - #[derive(Debug)] struct NoCopy(usize); diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr index 1064317438515..cfc318c1cd0f3 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:11:18 + --> $DIR/dbg-macro-move-semantics.rs:9:18 | LL | let _ = dbg!(a); | ------- value moved here @@ -10,7 +10,7 @@ LL | let _ = dbg!(a); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:11:13 + --> $DIR/dbg-macro-move-semantics.rs:9:13 | LL | let _ = dbg!(a); | ------- value moved here diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs index 8e6f3b226fc1e..365e62c808673 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs @@ -1,7 +1,5 @@ // Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`. -#![feature(dbg_macro)] - struct NotDebug; fn main() { diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr index a3b6a1761b991..ecab673953d6d 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -1,5 +1,5 @@ error[E0277]: `NotDebug` doesn't implement `std::fmt::Debug` - --> $DIR/dbg-macro-requires-debug.rs:8:23 + --> $DIR/dbg-macro-requires-debug.rs:6:23 | LL | let _: NotDebug = dbg!(NotDebug); | ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}` From 4c2c523a0546480fe2ee1895802d80cfdcf4ad64 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Fri, 30 Nov 2018 23:38:05 -0800 Subject: [PATCH 07/18] Move VecDeque::resize_with out of the impl block --- src/liballoc/collections/vec_deque.rs | 60 ++++++++++++--------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index cbf104a8fcde9..b52e93f85d94f 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -19,7 +19,7 @@ use core::cmp::Ordering; use core::fmt; -use core::iter::{repeat, repeat_with, FromIterator, FusedIterator}; +use core::iter::{repeat_with, FromIterator, FusedIterator}; use core::mem; use core::ops::Bound::{Excluded, Included, Unbounded}; use core::ops::{Index, IndexMut, RangeBounds}; @@ -1886,16 +1886,16 @@ impl VecDeque { debug_assert!(!self.is_full()); } } -} -impl VecDeque { - /// Modifies the `VecDeque` in-place so that `len()` is equal to new_len, - /// either by removing excess elements from the back or by appending clones of `value` - /// to the back. + /// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`, + /// either by removing excess elements from the back or by appending + /// elements generated by calling `generator` to the back. /// /// # Examples /// /// ``` + /// #![feature(vec_resize_with)] + /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); @@ -1904,32 +1904,36 @@ impl VecDeque { /// buf.push_back(15); /// assert_eq!(buf, [5, 10, 15]); /// - /// buf.resize(2, 0); + /// buf.resize_with(5, Default::default); + /// assert_eq!(buf, [5, 10, 15, 0, 0]); + /// + /// buf.resize_with(2, || unreachable!()); /// assert_eq!(buf, [5, 10]); /// - /// buf.resize(5, 20); - /// assert_eq!(buf, [5, 10, 20, 20, 20]); + /// let mut state = 100; + /// buf.resize_with(5, || { state += 1; state }); + /// assert_eq!(buf, [5, 10, 101, 102, 103]); /// ``` - #[stable(feature = "deque_extras", since = "1.16.0")] - pub fn resize(&mut self, new_len: usize, value: T) { + #[unstable(feature = "vec_resize_with", issue = "41758")] + pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut()->T) { let len = self.len(); if new_len > len { - self.extend(repeat(value).take(new_len - len)) + self.extend(repeat_with(generator).take(new_len - len)) } else { self.truncate(new_len); } } +} - /// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`, - /// either by removing excess elements from the back or by appending - /// elements generated by calling `generator` to the back. +impl VecDeque { + /// Modifies the `VecDeque` in-place so that `len()` is equal to new_len, + /// either by removing excess elements from the back or by appending clones of `value` + /// to the back. /// /// # Examples /// /// ``` - /// #![feature(vec_resize_with)] - /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); @@ -1938,25 +1942,15 @@ impl VecDeque { /// buf.push_back(15); /// assert_eq!(buf, [5, 10, 15]); /// - /// buf.resize_with(5, Default::default); - /// assert_eq!(buf, [5, 10, 15, 0, 0]); - /// - /// buf.resize_with(2, || unreachable!()); + /// buf.resize(2, 0); /// assert_eq!(buf, [5, 10]); /// - /// let mut state = 100; - /// buf.resize_with(5, || { state += 1; state }); - /// assert_eq!(buf, [5, 10, 101, 102, 103]); + /// buf.resize(5, 20); + /// assert_eq!(buf, [5, 10, 20, 20, 20]); /// ``` - #[unstable(feature = "vec_resize_with", issue = "41758")] - pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut()->T) { - let len = self.len(); - - if new_len > len { - self.extend(repeat_with(generator).take(new_len - len)) - } else { - self.truncate(new_len); - } + #[stable(feature = "deque_extras", since = "1.16.0")] + pub fn resize(&mut self, new_len: usize, value: T) { + self.resize_with(new_len, || value.clone()); } } From a3b7a21268edecc69267fd2b641b22d5bb7844b2 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 1 Dec 2018 02:07:50 -0800 Subject: [PATCH 08/18] Improve the unstable book example for `#[marker]` The previous one didn't actually use the Display&Debug bounds in any way, so I think this one is a bit more meaningful. --- .../src/language-features/marker-trait-attr.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/doc/unstable-book/src/language-features/marker-trait-attr.md b/src/doc/unstable-book/src/language-features/marker-trait-attr.md index 9dd7b6fae9bc6..dedc7d3015d4d 100644 --- a/src/doc/unstable-book/src/language-features/marker-trait-attr.md +++ b/src/doc/unstable-book/src/language-features/marker-trait-attr.md @@ -17,15 +17,17 @@ when they'd need to do the same thing for every type anyway). ```rust #![feature(marker_trait_attr)] -use std::fmt::{Debug, Display}; +#[marker] trait CheapToClone: Clone {} -#[marker] trait MyMarker {} +impl CheapToClone for T {} -impl MyMarker for T {} -impl MyMarker for T {} +// These could potentally overlap with the blanket implementation above, +// so are only allowed because CheapToClone is a marker trait. +impl CheapToClone for (T, U) {} +impl CheapToClone for std::ops::Range {} -fn foo(t: T) -> T { - t +fn cheap_clone(t: T) -> T { + t.clone() } ``` From df0ab06073165e5c66bf28a80c729b4d77397ab2 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 1 Dec 2018 18:58:43 +0300 Subject: [PATCH 09/18] Update tracking issue for `extern_crate_self` --- src/libsyntax/feature_gate.rs | 2 +- src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index d0c4d1c7dce0a..34187d1854dcb 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -494,7 +494,7 @@ declare_features! ( (active, lint_reasons, "1.31.0", Some(54503), None), // `extern crate self as foo;` puts local crate root into extern prelude under name `foo`. - (active, extern_crate_self, "1.31.0", Some(54658), None), + (active, extern_crate_self, "1.31.0", Some(56409), None), ); declare_features! ( diff --git a/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr b/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr index 61cc68477830d..530015b2cb712 100644 --- a/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr +++ b/src/test/ui/feature-gates/feature-gate-extern_crate_self.stderr @@ -1,4 +1,4 @@ -error[E0658]: `extern crate self` is unstable (see issue #54658) +error[E0658]: `extern crate self` is unstable (see issue #56409) --> $DIR/feature-gate-extern_crate_self.rs:1:1 | LL | extern crate self as foo; //~ ERROR `extern crate self` is unstable From 08a6cf30f0a4c4e76f6b529af50d28e9e9014345 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 1 Dec 2018 18:20:43 +0100 Subject: [PATCH 10/18] Remove unneeded body class selector --- src/librustdoc/html/static/rustdoc.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 1ae3b0b88c6dd..ad5bc021408c0 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -282,7 +282,7 @@ nav.sub { padding-left: 0; } -body:not(.source) .example-wrap { +:not(.source) .example-wrap { display: inline-flex; } @@ -299,7 +299,7 @@ body:not(.source) .example-wrap { text-align: right; } -body:not(.source) .example-wrap > pre.rust { +:not(.source) .example-wrap > pre.rust { width: 100%; } From 12c9b79b68ab9c8add6e8ffaab411a2d40b2fd3f Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 2 Dec 2018 00:19:06 +0300 Subject: [PATCH 11/18] Fix failing tidy (line endings on Windows) --- src/doc/edition-guide | 2 +- src/doc/rustc-guide | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/edition-guide b/src/doc/edition-guide index ad895867b6751..850ea159d0fcf 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit ad895867b675199a7f597ce7045a56875a7e516a +Subproject commit 850ea159d0fcf44dfbff16148faf9b5162481f89 diff --git a/src/doc/rustc-guide b/src/doc/rustc-guide index 3a804956e3c28..344c4e437ba4c 160000 --- a/src/doc/rustc-guide +++ b/src/doc/rustc-guide @@ -1 +1 @@ -Subproject commit 3a804956e3c28d7e44e38804207a00013594e1d3 +Subproject commit 344c4e437ba4cfa5c14db643ec4d6b68dcd164c5 From e7e96921c28ab8d29b6ee61053152eead822f09a Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Sat, 1 Dec 2018 15:48:55 -0600 Subject: [PATCH 12/18] remove some uses of try! --- src/bootstrap/doc.rs | 6 +++--- src/bootstrap/util.rs | 6 +++--- src/libcore/macros.rs | 10 +++++----- src/librustc_incremental/persist/fs.rs | 6 +++--- src/librustc_mir/dataflow/move_paths/builder.rs | 2 +- src/librustc_target/spec/mod.rs | 6 +++--- src/libstd/fs.rs | 2 +- src/libstd/sys/windows/stdio.rs | 4 ++-- src/libsyntax/parse/parser.rs | 6 ++---- src/libsyntax/print/pprust.rs | 2 +- src/libsyntax_ext/format_foreign.rs | 2 +- 11 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index f9b19ffb10d69..d5d6f3342c6c1 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -914,13 +914,13 @@ fn symlink_dir_force(config: &Config, src: &Path, dst: &Path) -> io::Result<()> } if let Ok(m) = fs::symlink_metadata(dst) { if m.file_type().is_dir() { - try!(fs::remove_dir_all(dst)); + fs::remove_dir_all(dst)?; } else { // handle directory junctions on windows by falling back to // `remove_dir`. - try!(fs::remove_file(dst).or_else(|_| { + fs::remove_file(dst).or_else(|_| { fs::remove_dir(dst) - })); + })?; } } diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 8ce8f20add3ad..be24ae0ce6648 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -203,11 +203,11 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> { // We're using low-level APIs to create the junction, and these are more // picky about paths. For example, forward slashes cannot be used as a // path separator, so we should try to canonicalize the path first. - let target = try!(fs::canonicalize(target)); + let target = fs::canonicalize(target)?; - try!(fs::create_dir(junction)); + fs::create_dir(junction)?; - let path = try!(to_u16s(junction)); + let path = to_u16s(junction)?; unsafe { let h = CreateFileW(path.as_ptr(), diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index c008b78e45092..8b1855800c2fd 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -278,14 +278,14 @@ macro_rules! debug_assert_ne { /// /// // The previous method of quick returning Errors /// fn write_to_file_using_try() -> Result<(), MyError> { -/// let mut file = try!(File::create("my_best_friends.txt")); -/// try!(file.write_all(b"This is a list of my best friends.")); +/// let mut file = r#try!(File::create("my_best_friends.txt")); +/// r#try!(file.write_all(b"This is a list of my best friends.")); /// Ok(()) /// } /// /// // This is equivalent to: /// fn write_to_file_using_match() -> Result<(), MyError> { -/// let mut file = try!(File::create("my_best_friends.txt")); +/// let mut file = r#try!(File::create("my_best_friends.txt")); /// match file.write_all(b"This is a list of my best friends.") { /// Ok(v) => v, /// Err(e) => return Err(From::from(e)), @@ -296,14 +296,14 @@ macro_rules! debug_assert_ne { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] #[doc(alias = "?")] -macro_rules! try { +macro_rules! r#try { ($expr:expr) => (match $expr { $crate::result::Result::Ok(val) => val, $crate::result::Result::Err(err) => { return $crate::result::Result::Err($crate::convert::From::from(err)) } }); - ($expr:expr,) => (try!($expr)); + ($expr:expr,) => (r#try!($expr)); } /// Write formatted data into a buffer. diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index 2a8a0baf571b0..75cdefaf49f00 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -659,7 +659,7 @@ pub fn garbage_collect_session_directories(sess: &Session) -> io::Result<()> { let mut session_directories = FxHashSet::default(); let mut lock_files = FxHashSet::default(); - for dir_entry in try!(crate_directory.read_dir()) { + for dir_entry in crate_directory.read_dir()? { let dir_entry = match dir_entry { Ok(dir_entry) => dir_entry, _ => { @@ -887,7 +887,7 @@ fn all_except_most_recent(deletion_candidates: Vec<(SystemTime, PathBuf, Option< /// into the '\\?\' format, which supports much longer paths. fn safe_remove_dir_all(p: &Path) -> io::Result<()> { if p.exists() { - let canonicalized = try!(p.canonicalize()); + let canonicalized = p.canonicalize()?; std_fs::remove_dir_all(canonicalized) } else { Ok(()) @@ -896,7 +896,7 @@ fn safe_remove_dir_all(p: &Path) -> io::Result<()> { fn safe_remove_file(p: &Path) -> io::Result<()> { if p.exists() { - let canonicalized = try!(p.canonicalize()); + let canonicalized = p.canonicalize()?; std_fs::remove_file(canonicalized) } else { Ok(()) diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 3796b1cc4b0c8..7fe27e97d3d3b 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -128,7 +128,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { proj: &PlaceProjection<'tcx>) -> Result> { - let base = try!(self.move_path_for(&proj.base)); + let base = self.move_path_for(&proj.base)?; let mir = self.builder.mir; let tcx = self.builder.tcx; let place_ty = proj.base.ty(mir, tcx).to_ty(tcx); diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 3285ccfd6c12d..1c654bf91925e 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -995,7 +995,7 @@ impl Target { key!(is_builtin, bool); key!(linker, optional); - try!(key!(lld_flavor, LldFlavor)); + key!(lld_flavor, LldFlavor)?; key!(pre_link_args, link_args); key!(pre_link_args_crt, link_args); key!(pre_link_objects_exe, list); @@ -1038,7 +1038,7 @@ impl Target { key!(no_default_libraries, bool); key!(position_independent_executables, bool); key!(needs_plt, bool); - try!(key!(relro_level, RelroLevel)); + key!(relro_level, RelroLevel)?; key!(archive_format); key!(allow_asm, bool); key!(custom_unwind_resume, bool); @@ -1048,7 +1048,7 @@ impl Target { key!(max_atomic_width, Option); key!(min_atomic_width, Option); key!(atomic_cas, bool); - try!(key!(panic_strategy, PanicStrategy)); + key!(panic_strategy, PanicStrategy)?; key!(crt_static_allows_dylibs, bool); key!(crt_static_default, bool); key!(crt_static_respected, bool); diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 92678dd5cede0..7d054a347f4c3 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -2065,7 +2065,7 @@ impl DirBuilder { Err(e) => return Err(e), } match path.parent() { - Some(p) => try!(self.create_dir_all(p)), + Some(p) => self.create_dir_all(p)?, None => return Err(io::Error::new(io::ErrorKind::Other, "failed to create whole tree")), } match self.inner.mkdir(path) { diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs index 81b89da21d3c6..c3a94698a0f36 100644 --- a/src/libstd/sys/windows/stdio.rs +++ b/src/libstd/sys/windows/stdio.rs @@ -48,7 +48,7 @@ pub fn get(handle: c::DWORD) -> io::Result { } fn write(handle: c::DWORD, data: &[u8]) -> io::Result { - let handle = match try!(get(handle)) { + let handle = match get(handle)? { Output::Console(c) => c, Output::Pipe(p) => { let handle = Handle::new(p); @@ -99,7 +99,7 @@ impl Stdin { } pub fn read(&self, buf: &mut [u8]) -> io::Result { - let handle = match try!(get(c::STD_INPUT_HANDLE)) { + let handle = match get(c::STD_INPUT_HANDLE)? { Output::Console(c) => c, Output::Pipe(p) => { let handle = Handle::new(p); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 506199b60adb6..48f15f5298bec 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3145,7 +3145,7 @@ impl<'a> Parser<'a> { RangeLimits::Closed }; - let r = try!(self.mk_range(Some(lhs), rhs, limits)); + let r = self.mk_range(Some(lhs), rhs, limits)?; lhs = self.mk_expr(lhs_span.to(rhs_span), r, ThinVec::new()); break } @@ -3353,9 +3353,7 @@ impl<'a> Parser<'a> { RangeLimits::Closed }; - let r = try!(self.mk_range(None, - opt_end, - limits)); + let r = self.mk_range(None, opt_end, limits)?; Ok(self.mk_expr(lo.to(hi), r, attrs)) } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ce7708cc42e56..828e5d5988707 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1525,7 +1525,7 @@ impl<'a> State<'a> { pub fn print_defaultness(&mut self, defaultness: ast::Defaultness) -> io::Result<()> { if let ast::Defaultness::Default = defaultness { - try!(self.word_nbsp("default")); + self.word_nbsp("default")?; } Ok(()) } diff --git a/src/libsyntax_ext/format_foreign.rs b/src/libsyntax_ext/format_foreign.rs index 6eba3c4f2bbc9..9c854019de6f8 100644 --- a/src/libsyntax_ext/format_foreign.rs +++ b/src/libsyntax_ext/format_foreign.rs @@ -264,7 +264,7 @@ pub mod printf { match *self { Num::Num(n) => write!(s, "{}", n), Num::Arg(n) => { - let n = try!(n.checked_sub(1).ok_or(::std::fmt::Error)); + let n = n.checked_sub(1).ok_or(::std::fmt::Error)?; write!(s, "{}$", n) }, Num::Next => write!(s, "*"), From 1e18cc916f653d5bea212bddded8960f548a975d Mon Sep 17 00:00:00 2001 From: Hidehito Yabuuchi Date: Sun, 2 Dec 2018 16:07:57 +0900 Subject: [PATCH 13/18] Update issue number of `shrink_to` methods to point the tracking issue --- src/liballoc/collections/binary_heap.rs | 2 +- src/liballoc/collections/vec_deque.rs | 2 +- src/liballoc/string.rs | 2 +- src/liballoc/vec.rs | 2 +- src/libstd/collections/hash/map.rs | 2 +- src/libstd/collections/hash/set.rs | 2 +- src/libstd/ffi/os_str.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index fcadcb544c431..8c36962a299c2 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -529,7 +529,7 @@ impl BinaryHeap { /// assert!(heap.capacity() >= 10); /// ``` #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + #[unstable(feature = "shrink_to", reason = "new API", issue="56431")] pub fn shrink_to(&mut self, min_capacity: usize) { self.data.shrink_to(min_capacity) } diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index cbf104a8fcde9..baa26ffd9376f 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -701,7 +701,7 @@ impl VecDeque { /// buf.shrink_to(0); /// assert!(buf.capacity() >= 4); /// ``` - #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + #[unstable(feature = "shrink_to", reason = "new API", issue="56431")] pub fn shrink_to(&mut self, min_capacity: usize) { assert!(self.capacity() >= min_capacity, "Tried to shrink to a larger capacity"); diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 0b25d911a299c..662f8ae614fcb 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1050,7 +1050,7 @@ impl String { /// assert!(s.capacity() >= 3); /// ``` #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + #[unstable(feature = "shrink_to", reason = "new API", issue="56431")] pub fn shrink_to(&mut self, min_capacity: usize) { self.vec.shrink_to(min_capacity) } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index f7a0bbdceafc9..ca7c766e41330 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -613,7 +613,7 @@ impl Vec { /// vec.shrink_to(0); /// assert!(vec.capacity() >= 3); /// ``` - #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + #[unstable(feature = "shrink_to", reason = "new API", issue="56431")] pub fn shrink_to(&mut self, min_capacity: usize) { self.buf.shrink_to_fit(cmp::max(self.len, min_capacity)); } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 349aa029ba8cb..536ce2e16a09b 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1018,7 +1018,7 @@ impl HashMap /// map.shrink_to(0); /// assert!(map.capacity() >= 2); /// ``` - #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + #[unstable(feature = "shrink_to", reason = "new API", issue="56431")] pub fn shrink_to(&mut self, min_capacity: usize) { assert!(self.capacity() >= min_capacity, "Tried to shrink to a larger capacity"); diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 5ac3e8f9cf7d3..4bb3ce0cf4489 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -315,7 +315,7 @@ impl HashSet /// assert!(set.capacity() >= 2); /// ``` #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + #[unstable(feature = "shrink_to", reason = "new API", issue="56431")] pub fn shrink_to(&mut self, min_capacity: usize) { self.map.shrink_to(min_capacity) } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index e9390630445a1..edca8c9e5b591 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -324,7 +324,7 @@ impl OsString { /// assert!(s.capacity() >= 3); /// ``` #[inline] - #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + #[unstable(feature = "shrink_to", reason = "new API", issue="56431")] pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity) } From 70371fde17ea4b1e3aa4d443103a15157eafdcdc Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 2 Dec 2018 17:01:44 +0900 Subject: [PATCH 14/18] Add description about `crate` for parse_visibility's comment This rule was introduced by https://github.com/rust-lang/rust/pull/45401. --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f13bb7df0b444..6c119dd3e76a5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6282,7 +6282,7 @@ impl<'a> Parser<'a> { self.parse_single_struct_field(lo, vis, attrs) } - /// Parse `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `pub(self)` for `pub(in self)` + /// Parse `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`, `pub(self)` for `pub(in self)` /// and `pub(super)` for `pub(in super)`. If the following element can't be a tuple (i.e. it's /// a function definition, it's not a tuple struct field) and the contents within the parens /// isn't valid, emit a proper diagnostic. From 172ec724af5013e9e9b2cf8f3bc12eda2db52876 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 2 Dec 2018 18:33:12 +0900 Subject: [PATCH 15/18] Fix "line longer than 100 chars" --- src/libsyntax/parse/parser.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6c119dd3e76a5..4884e5e28c0ae 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6282,9 +6282,10 @@ impl<'a> Parser<'a> { self.parse_single_struct_field(lo, vis, attrs) } - /// Parse `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`, `pub(self)` for `pub(in self)` - /// and `pub(super)` for `pub(in super)`. If the following element can't be a tuple (i.e. it's - /// a function definition, it's not a tuple struct field) and the contents within the parens + /// Parse `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`, + /// `pub(self)` for `pub(in self)` and `pub(super)` for `pub(in super)`. + /// If the following element can't be a tuple (i.e. it's a function definition, + /// it's not a tuple struct field) and the contents within the parens /// isn't valid, emit a proper diagnostic. pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> { maybe_whole!(self, NtVis, |x| x); From d605e1d055dfd31b03e6e0da634928d4d5418866 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 2 Dec 2018 13:27:12 +0100 Subject: [PATCH 16/18] explicitly control compiler_builts/c feature from libstd --- src/libstd/Cargo.toml | 2 +- src/rustc/compiler_builtins_shim/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index c1446218367e4..9c2c1cab01584 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -18,7 +18,7 @@ panic_unwind = { path = "../libpanic_unwind", optional = true } panic_abort = { path = "../libpanic_abort" } core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } +compiler_builtins = { path = "../rustc/compiler_builtins_shim", features = ["c"] } profiler_builtins = { path = "../libprofiler_builtins", optional = true } unwind = { path = "../libunwind" } diff --git a/src/rustc/compiler_builtins_shim/Cargo.toml b/src/rustc/compiler_builtins_shim/Cargo.toml index 7d8423ca84eb4..9804177280f66 100644 --- a/src/rustc/compiler_builtins_shim/Cargo.toml +++ b/src/rustc/compiler_builtins_shim/Cargo.toml @@ -34,7 +34,7 @@ cc = "1.0.1" [features] c = [] -default = ["c", "rustbuild", "compiler-builtins"] +default = ["rustbuild", "compiler-builtins"] mem = [] rustbuild = [] compiler-builtins = [] From bd20718c8f14cc7f486e1556f7d7897f8f32725b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 2 Dec 2018 13:33:00 +0100 Subject: [PATCH 17/18] make the C part of compiler-builtins opt-out --- src/libstd/Cargo.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 9c2c1cab01584..cae2f405318be 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -18,7 +18,7 @@ panic_unwind = { path = "../libpanic_unwind", optional = true } panic_abort = { path = "../libpanic_abort" } core = { path = "../libcore" } libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim", features = ["c"] } +compiler_builtins = { path = "../rustc/compiler_builtins_shim" } profiler_builtins = { path = "../libprofiler_builtins", optional = true } unwind = { path = "../libunwind" } @@ -43,9 +43,12 @@ cc = "1.0" build_helper = { path = "../build_helper" } [features] +default = ["compiler_builtins_c"] + backtrace = [] panic-unwind = ["panic_unwind"] profiler = ["profiler_builtins"] +compiler_builtins_c = ["compiler_builtins/c"] # Make panics and failed asserts immediately abort without formatting any message panic_immediate_abort = ["core/panic_immediate_abort"] From 96bf06baf308e5cd2ad43962895f626724395e7d Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 2 Dec 2018 22:15:50 +0900 Subject: [PATCH 18/18] Remove not used `DotEq` token Currently libproc_macro does not use `DotEq` token. https://github.com/rust-lang/rust/pull/49545 changed libproc_macro to not generate `DotEq` token. --- src/librustc/ich/impls_syntax.rs | 1 - src/librustdoc/html/highlight.rs | 2 +- src/libsyntax/ext/quote.rs | 1 - src/libsyntax/parse/token.rs | 5 +---- src/libsyntax/print/pprust.rs | 1 - src/libsyntax_ext/proc_macro_server.rs | 1 - 6 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 4be467c01aac1..b629fb820b34d 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -314,7 +314,6 @@ fn hash_token<'a, 'gcx, W: StableHasherResult>( token::Token::DotDot | token::Token::DotDotDot | token::Token::DotDotEq | - token::Token::DotEq | token::Token::Comma | token::Token::Semi | token::Token::Colon | diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 6522261fe1e7c..8fb91cc23f7ba 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -346,7 +346,7 @@ impl<'a> Classifier<'a> { token::Lifetime(..) => Class::Lifetime, token::Eof | token::Interpolated(..) | - token::Tilde | token::At | token::DotEq | token::SingleQuote => Class::None, + token::Tilde | token::At| token::SingleQuote => Class::None, }; // Anything that didn't return above is the simple case where we the diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index c6e0adbb5a43e..69ed318b0498f 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -703,7 +703,6 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { token::At => "At", token::Dot => "Dot", token::DotDot => "DotDot", - token::DotEq => "DotEq", token::DotDotDot => "DotDotDot", token::DotDotEq => "DotDotEq", token::Comma => "Comma", diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 46fc6454d1c3b..4a5f3e240daee 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -163,7 +163,6 @@ pub enum Token { DotDot, DotDotDot, DotDotEq, - DotEq, // HACK(durka42) never produced by the parser, only used for libproc_macro Comma, Semi, Colon, @@ -454,7 +453,6 @@ impl Token { Dot => match joint { Dot => DotDot, DotDot => DotDotDot, - DotEq => DotDotEq, _ => return None, }, DotDot => match joint { @@ -477,7 +475,7 @@ impl Token { _ => return None, }, - Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot | DotEq | + Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot | DotDotEq | Comma | Semi | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | OpenDelim(..) | CloseDelim(..) => return None, @@ -606,7 +604,6 @@ impl Token { (&DotDot, &DotDot) | (&DotDotDot, &DotDotDot) | (&DotDotEq, &DotDotEq) | - (&DotEq, &DotEq) | (&Comma, &Comma) | (&Semi, &Semi) | (&Colon, &Colon) | diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 14ad4b5c6f815..4fa1d0fac352a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -210,7 +210,6 @@ pub fn token_to_string(tok: &Token) -> String { token::DotDot => "..".to_string(), token::DotDotDot => "...".to_string(), token::DotDotEq => "..=".to_string(), - token::DotEq => ".=".to_string(), token::Comma => ",".to_string(), token::Semi => ";".to_string(), token::Colon => ":".to_string(), diff --git a/src/libsyntax_ext/proc_macro_server.rs b/src/libsyntax_ext/proc_macro_server.rs index 56bd58b28a66e..4babc2e612fd8 100644 --- a/src/libsyntax_ext/proc_macro_server.rs +++ b/src/libsyntax_ext/proc_macro_server.rs @@ -213,7 +213,6 @@ impl FromInternal<(TokenStream, &'_ ParseSess, &'_ mut Vec)> }) } - DotEq => op!('.', '='), OpenDelim(..) | CloseDelim(..) => unreachable!(), Whitespace | Comment | Shebang(..) | Eof => unreachable!(), }