From ff5e31ffb5224f458711a35392e0acddb1d4080a Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:02:56 +0000 Subject: [PATCH 01/48] Fix a broken link to the rustc-guide --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e785f03d7de2b..1fc942c7cd98a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,6 +28,7 @@ can give you a good example of how a typical contribution would go. [pound-rust-internals]: https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals [internals]: https://internals.rust-lang.org [coc]: https://www.rust-lang.org/conduct.html +[rustc-guide]: https://rust-lang.github.io/rustc-guide/ [walkthrough]: https://rust-lang.github.io/rustc-guide/walkthrough.html ## Feature Requests From 6e449daceacd5959b830d24a8c9fc9971a2fc8ea Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:03:11 +0000 Subject: [PATCH 02/48] Remove trailing newlines --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1fc942c7cd98a..02777621d6571 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ can give you a good example of how a typical contribution would go. [feature-requests]: #feature-requests 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 +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. @@ -191,7 +191,7 @@ before the PR is merged. [breaking-tools-built-with-the-compiler]: #breaking-tools-built-with-the-compiler Rust's build system builds a number of tools that make use of the -internals of the compiler. This includes +internals of the compiler. This includes [Clippy](https://github.com/rust-lang/rust-clippy), [RLS](https://github.com/rust-lang/rls) and [rustfmt](https://github.com/rust-lang/rustfmt). If these tools From 205ab0c260e983615de3a2ed71c8e82e5c48dd8d Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:04:19 +0000 Subject: [PATCH 03/48] Add a link to the Discord and Zulip servers --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 02777621d6571..35a741babd23f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ links to the major sections: * [Helpful Links and Information](#helpful-links-and-information) If you have questions, please make a post on [internals.rust-lang.org][internals] or -hop on [#rust-internals][pound-rust-internals]. +hop on the [Rust Discord server][rust-discord], [Rust Zulip server][rust-zulip] or [#rust-internals][pound-rust-internals]. As a reminder, all contributors are expected to follow our [Code of Conduct][coc]. @@ -27,6 +27,8 @@ can give you a good example of how a typical contribution would go. [pound-rust-internals]: https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals [internals]: https://internals.rust-lang.org +[rust-discord]: http://discord.gg/rust-lang +[rust-zulip]: https://rust-lang.zulipchat.com [coc]: https://www.rust-lang.org/conduct.html [rustc-guide]: https://rust-lang.github.io/rustc-guide/ [walkthrough]: https://rust-lang.github.io/rustc-guide/walkthrough.html From 6f3fda9d1d603084c8e6a323bdbea7b780ba87ca Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:07:00 +0000 Subject: [PATCH 04/48] Add links to @rust-highfive and @bors --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35a741babd23f..dde4ac3bbeb77 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,7 +132,7 @@ request); you can add [git hooks](https://git-scm.com/book/en/v2/Customizing-Git before every push to make sure you never forget to make this check. All pull requests are reviewed by another person. We have a bot, -@rust-highfive, that will automatically assign a random person to review your +[@rust-highfive][rust-highfive], that will automatically assign a random person to review your request. If you want to request that a specific person reviews your pull request, @@ -149,11 +149,13 @@ on the pull request with an `r+`. It will look something like this: @bors: r+ 38fe8d2 -This tells @bors, our lovable integration bot, that your pull request has +This tells [@bors][bors], our lovable integration bot, that your pull request has been approved. The PR then enters the [merge queue][merge-queue], where @bors will run all the tests on every platform we support. If it all works out, @bors will merge your code into `master` and close the pull request. +[rust-highfive]: https://github.com/rust-highfive +[bors]: https://github.com/bors [merge-queue]: https://buildbot2.rust-lang.org/homu/queue/rust Speaking of tests, Rust has a comprehensive test suite. More information about From eadb8443f3ea4269b7010afa3bd5de21515c23b1 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:09:32 +0000 Subject: [PATCH 05/48] Update r+ syntax --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dde4ac3bbeb77..5276171728f0e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -147,7 +147,7 @@ of a random person. This is entirely optional. After someone has reviewed your pull request, they will leave an annotation on the pull request with an `r+`. It will look something like this: - @bors: r+ 38fe8d2 + @bors r+ This tells [@bors][bors], our lovable integration bot, that your pull request has been approved. The PR then enters the [merge queue][merge-queue], where @bors @@ -302,7 +302,7 @@ from the source code itself. Documentation pull requests function in the same way as other pull requests, though you may see a slightly different form of `r+`: - @bors: r+ 38fe8d2 rollup + @bors r+ rollup That additional `rollup` tells @bors that this change is eligible for a 'rollup'. To save @bors some work, and to get small changes through more quickly, when From 308a002eb16425b5164c1d2931d26d802ae89f6f Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:13:26 +0000 Subject: [PATCH 06/48] Make all references to @bors or users links --- CONTRIBUTING.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5276171728f0e..d6253dcb2338a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -136,12 +136,12 @@ All pull requests are reviewed by another person. We have a bot, request. If you want to request that a specific person reviews your pull request, -you can add an `r?` to the message. For example, Steve usually reviews +you can add an `r?` to the message. For example, [Steve][steveklabnik] usually reviews documentation changes. So if you were to make a documentation change, add r? @steveklabnik -to the end of the message, and @rust-highfive will assign @steveklabnik instead +to the end of the message, and @rust-highfive will assign [@steveklabnik][steveklabnik] instead of a random person. This is entirely optional. After someone has reviewed your pull request, they will leave an annotation @@ -150,11 +150,12 @@ on the pull request with an `r+`. It will look something like this: @bors r+ This tells [@bors][bors], our lovable integration bot, that your pull request has -been approved. The PR then enters the [merge queue][merge-queue], where @bors +been approved. The PR then enters the [merge queue][merge-queue], where [@bors][bors] will run all the tests on every platform we support. If it all works out, -@bors will merge your code into `master` and close the pull request. +[@bors][bors] will merge your code into `master` and close the pull request. [rust-highfive]: https://github.com/rust-highfive +[steveklabnik]: https://github.com/steveklabnik [bors]: https://github.com/bors [merge-queue]: https://buildbot2.rust-lang.org/homu/queue/rust @@ -304,9 +305,9 @@ though you may see a slightly different form of `r+`: @bors r+ rollup -That additional `rollup` tells @bors that this change is eligible for a 'rollup'. -To save @bors some work, and to get small changes through more quickly, when -@bors attempts to merge a commit that's rollup-eligible, it will also merge +That additional `rollup` tells [@bors][bors] that this change is eligible for a 'rollup'. +To save [@bors][bors] some work, and to get small changes through more quickly, when +[@bors][bors] attempts to merge a commit that's rollup-eligible, it will also merge the other rollup-eligible patches too, and they'll get tested and merged at the same time. @@ -433,7 +434,7 @@ are: * Although out of date, [Tom Lee's great blog article][tlgba] is very helpful * [rustaceans.org][ro] is helpful, but mostly dedicated to IRC * The [Rust Compiler Testing Docs][rctd] -* For @bors, [this cheat sheet][cheatsheet] is helpful (Remember to replace `@homu` with `@bors` in the commands that you use.) +* For [@bors][bors], [this cheat sheet][cheatsheet] is helpful (Remember to replace `@homu` with `@bors` in the commands that you use.) * **Google!** ([search only in Rust Documentation][gsearchdocs] to find types, traits, etc. quickly) * Don't be afraid to ask! The Rust community is friendly and helpful. From 3a00649256c64cacfdbf5f0e7b370d660291d06e Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:17:49 +0000 Subject: [PATCH 07/48] Move rollup description earlier --- CONTRIBUTING.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6253dcb2338a..ee56f5bf9954e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -154,6 +154,15 @@ been approved. The PR then enters the [merge queue][merge-queue], where [@bors][ will run all the tests on every platform we support. If it all works out, [@bors][bors] will merge your code into `master` and close the pull request. +Depending on the scale of the change, you may see a slightly different form of `r+`: + + @bors r+ rollup + +The additional `rollup` tells [@bors][bors] that this change is eligible for to be +"rolled up". Changes that are rolled up are tested and merged at the same time, to +speed the process up. Typically only small changes that are expected not to conflict +with one another are rolled up. + [rust-highfive]: https://github.com/rust-highfive [steveklabnik]: https://github.com/steveklabnik [bors]: https://github.com/bors @@ -298,18 +307,8 @@ the submodule to. Running `./x.py build` should work now. Documentation improvements are very welcome. The source of `doc.rust-lang.org` is located in `src/doc` in the tree, and standard API documentation is generated -from the source code itself. - -Documentation pull requests function in the same way as other pull requests, -though you may see a slightly different form of `r+`: - - @bors r+ rollup - -That additional `rollup` tells [@bors][bors] that this change is eligible for a 'rollup'. -To save [@bors][bors] some work, and to get small changes through more quickly, when -[@bors][bors] attempts to merge a commit that's rollup-eligible, it will also merge -the other rollup-eligible patches too, and they'll get tested and merged at -the same time. +from the source code itself. Documentation pull requests function in the same way +as other pull requests. To find documentation-related issues, sort by the [T-doc label][tdoc]. From 037596c4ce1548543479ace50500ee3dc2f6720e Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 01:20:41 +0000 Subject: [PATCH 08/48] Fix capitalisation problem --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee56f5bf9954e..fa408935cc8cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -433,7 +433,8 @@ are: * Although out of date, [Tom Lee's great blog article][tlgba] is very helpful * [rustaceans.org][ro] is helpful, but mostly dedicated to IRC * The [Rust Compiler Testing Docs][rctd] -* For [@bors][bors], [this cheat sheet][cheatsheet] is helpful (Remember to replace `@homu` with `@bors` in the commands that you use.) +* For [@bors][bors], [this cheat sheet][cheatsheet] is helpful +(though you'll need to replace `@homu` with `@bors` in any commands) * **Google!** ([search only in Rust Documentation][gsearchdocs] to find types, traits, etc. quickly) * Don't be afraid to ask! The Rust community is friendly and helpful. From fec0ff2ce83ca771eabb61fcf449a5380cf98de0 Mon Sep 17 00:00:00 2001 From: Grigorii Kargin Date: Fri, 15 Mar 2019 00:08:44 +0300 Subject: [PATCH 09/48] consistent naming for Rhs type parameter in libcore/ops --- src/libcore/ops/arith.rs | 54 ++++++++++++++++++++-------------------- src/libcore/ops/bit.rs | 46 +++++++++++++++++----------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 0252edee23125..38ec0d8e1431c 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -1,6 +1,6 @@ /// The addition operator `+`. /// -/// Note that `RHS` is `Self` by default, but this is not mandatory. For +/// Note that `Rhs` is `Self` by default, but this is not mandatory. For /// example, [`std::time::SystemTime`] implements `Add`, which permits /// operations of the form `SystemTime = SystemTime + Duration`. /// @@ -67,18 +67,18 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented( on( - all(_Self="{integer}", RHS="{float}"), + all(_Self="{integer}", Rhs="{float}"), message="cannot add a float to an integer", ), on( - all(_Self="{float}", RHS="{integer}"), + all(_Self="{float}", Rhs="{integer}"), message="cannot add an integer to a float", ), - message="cannot add `{RHS}` to `{Self}`", - label="no implementation for `{Self} + {RHS}`", + message="cannot add `{Rhs}` to `{Self}`", + label="no implementation for `{Self} + {Rhs}`", )] #[doc(alias = "+")] -pub trait Add { +pub trait Add { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -86,7 +86,7 @@ pub trait Add { /// Performs the `+` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn add(self, rhs: RHS) -> Self::Output; + fn add(self, rhs: Rhs) -> Self::Output; } macro_rules! add_impl { @@ -108,7 +108,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// The subtraction operator `-`. /// -/// Note that `RHS` is `Self` by default, but this is not mandatory. For +/// Note that `Rhs` is `Self` by default, but this is not mandatory. For /// example, [`std::time::SystemTime`] implements `Sub`, which permits /// operations of the form `SystemTime = SystemTime - Duration`. /// @@ -173,10 +173,10 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot subtract `{RHS}` from `{Self}`", - label="no implementation for `{Self} - {RHS}`")] +#[rustc_on_unimplemented(message="cannot subtract `{Rhs}` from `{Self}`", + label="no implementation for `{Self} - {Rhs}`")] #[doc(alias = "-")] -pub trait Sub { +pub trait Sub { /// The resulting type after applying the `-` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -184,7 +184,7 @@ pub trait Sub { /// Performs the `-` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn sub(self, rhs: RHS) -> Self::Output; + fn sub(self, rhs: Rhs) -> Self::Output; } macro_rules! sub_impl { @@ -206,7 +206,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// The multiplication operator `*`. /// -/// Note that `RHS` is `Self` by default, but this is not mandatory. +/// Note that `Rhs` is `Self` by default, but this is not mandatory. /// /// # Examples /// @@ -293,10 +293,10 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot multiply `{RHS}` to `{Self}`", - label="no implementation for `{Self} * {RHS}`")] +#[rustc_on_unimplemented(message="cannot multiply `{Rhs}` to `{Self}`", + label="no implementation for `{Self} * {Rhs}`")] #[doc(alias = "*")] -pub trait Mul { +pub trait Mul { /// The resulting type after applying the `*` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -304,7 +304,7 @@ pub trait Mul { /// Performs the `*` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn mul(self, rhs: RHS) -> Self::Output; + fn mul(self, rhs: Rhs) -> Self::Output; } macro_rules! mul_impl { @@ -326,7 +326,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// The division operator `/`. /// -/// Note that `RHS` is `Self` by default, but this is not mandatory. +/// Note that `Rhs` is `Self` by default, but this is not mandatory. /// /// # Examples /// @@ -417,10 +417,10 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot divide `{Self}` by `{RHS}`", - label="no implementation for `{Self} / {RHS}`")] +#[rustc_on_unimplemented(message="cannot divide `{Self}` by `{Rhs}`", + label="no implementation for `{Self} / {Rhs}`")] #[doc(alias = "/")] -pub trait Div { +pub trait Div { /// The resulting type after applying the `/` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -428,7 +428,7 @@ pub trait Div { /// Performs the `/` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn div(self, rhs: RHS) -> Self::Output; + fn div(self, rhs: Rhs) -> Self::Output; } macro_rules! div_impl_integer { @@ -467,7 +467,7 @@ div_impl_float! { f32 f64 } /// The remainder operator `%`. /// -/// Note that `RHS` is `Self` by default, but this is not mandatory. +/// Note that `Rhs` is `Self` by default, but this is not mandatory. /// /// # Examples /// @@ -502,10 +502,10 @@ div_impl_float! { f32 f64 } /// ``` #[lang = "rem"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot mod `{Self}` by `{RHS}`", - label="no implementation for `{Self} % {RHS}`")] +#[rustc_on_unimplemented(message="cannot mod `{Self}` by `{Rhs}`", + label="no implementation for `{Self} % {Rhs}`")] #[doc(alias = "%")] -pub trait Rem { +pub trait Rem { /// The resulting type after applying the `%` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output = Self; @@ -513,7 +513,7 @@ pub trait Rem { /// Performs the `%` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn rem(self, rhs: RHS) -> Self::Output; + fn rem(self, rhs: Rhs) -> Self::Output; } macro_rules! rem_impl_integer { diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs index 2c9bf248633c4..1b9c5e6bae3fd 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs @@ -59,7 +59,7 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// The bitwise AND operator `&`. /// -/// Note that `RHS` is `Self` by default, but this is not mandatory. +/// Note that `Rhs` is `Self` by default, but this is not mandatory. /// /// # Examples /// @@ -112,9 +112,9 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[lang = "bitand"] #[doc(alias = "&")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} & {RHS}`", - label="no implementation for `{Self} & {RHS}`")] -pub trait BitAnd { +#[rustc_on_unimplemented(message="no implementation for `{Self} & {Rhs}`", + label="no implementation for `{Self} & {Rhs}`")] +pub trait BitAnd { /// The resulting type after applying the `&` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -122,7 +122,7 @@ pub trait BitAnd { /// Performs the `&` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn bitand(self, rhs: RHS) -> Self::Output; + fn bitand(self, rhs: Rhs) -> Self::Output; } macro_rules! bitand_impl { @@ -143,7 +143,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// The bitwise OR operator `|`. /// -/// Note that `RHS` is `Self` by default, but this is not mandatory. +/// Note that `Rhs` is `Self` by default, but this is not mandatory. /// /// # Examples /// @@ -196,9 +196,9 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[lang = "bitor"] #[doc(alias = "|")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} | {RHS}`", - label="no implementation for `{Self} | {RHS}`")] -pub trait BitOr { +#[rustc_on_unimplemented(message="no implementation for `{Self} | {Rhs}`", + label="no implementation for `{Self} | {Rhs}`")] +pub trait BitOr { /// The resulting type after applying the `|` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -206,7 +206,7 @@ pub trait BitOr { /// Performs the `|` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn bitor(self, rhs: RHS) -> Self::Output; + fn bitor(self, rhs: Rhs) -> Self::Output; } macro_rules! bitor_impl { @@ -227,7 +227,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// The bitwise XOR operator `^`. /// -/// Note that `RHS` is `Self` by default, but this is not mandatory. +/// Note that `Rhs` is `Self` by default, but this is not mandatory. /// /// # Examples /// @@ -283,9 +283,9 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[lang = "bitxor"] #[doc(alias = "^")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} ^ {RHS}`", - label="no implementation for `{Self} ^ {RHS}`")] -pub trait BitXor { +#[rustc_on_unimplemented(message="no implementation for `{Self} ^ {Rhs}`", + label="no implementation for `{Self} ^ {Rhs}`")] +pub trait BitXor { /// The resulting type after applying the `^` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -293,7 +293,7 @@ pub trait BitXor { /// Performs the `^` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn bitxor(self, rhs: RHS) -> Self::Output; + fn bitxor(self, rhs: Rhs) -> Self::Output; } macro_rules! bitxor_impl { @@ -371,9 +371,9 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } #[lang = "shl"] #[doc(alias = "<<")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} << {RHS}`", - label="no implementation for `{Self} << {RHS}`")] -pub trait Shl { +#[rustc_on_unimplemented(message="no implementation for `{Self} << {Rhs}`", + label="no implementation for `{Self} << {Rhs}`")] +pub trait Shl { /// The resulting type after applying the `<<` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -381,7 +381,7 @@ pub trait Shl { /// Performs the `<<` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn shl(self, rhs: RHS) -> Self::Output; + fn shl(self, rhs: Rhs) -> Self::Output; } macro_rules! shl_impl { @@ -480,9 +480,9 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } #[lang = "shr"] #[doc(alias = ">>")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} >> {RHS}`", - label="no implementation for `{Self} >> {RHS}`")] -pub trait Shr { +#[rustc_on_unimplemented(message="no implementation for `{Self} >> {Rhs}`", + label="no implementation for `{Self} >> {Rhs}`")] +pub trait Shr { /// The resulting type after applying the `>>` operator. #[stable(feature = "rust1", since = "1.0.0")] type Output; @@ -490,7 +490,7 @@ pub trait Shr { /// Performs the `>>` operation. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] - fn shr(self, rhs: RHS) -> Self::Output; + fn shr(self, rhs: Rhs) -> Self::Output; } macro_rules! shr_impl { From 7f395d2b3a5829f0557bfdca137e7838aa30d85a Mon Sep 17 00:00:00 2001 From: Grigorii Kargin Date: Sat, 16 Mar 2019 02:56:26 +0300 Subject: [PATCH 10/48] fix tests --- src/test/ui/issues/issue-21950.stderr | 4 ++-- src/test/ui/issues/issue-22560.stderr | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/ui/issues/issue-21950.stderr b/src/test/ui/issues/issue-21950.stderr index 5f401d13feb55..bda2e3c457499 100644 --- a/src/test/ui/issues/issue-21950.stderr +++ b/src/test/ui/issues/issue-21950.stderr @@ -1,8 +1,8 @@ -error[E0393]: the type parameter `RHS` must be explicitly specified +error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-21950.rs:7:14 | LL | &Add; - | ^^^ missing reference to `RHS` + | ^^^ missing reference to `Rhs` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr index be4f3dda0cbc7..694a4af51bc9d 100644 --- a/src/test/ui/issues/issue-22560.stderr +++ b/src/test/ui/issues/issue-22560.stderr @@ -1,16 +1,16 @@ -error[E0393]: the type parameter `RHS` must be explicitly specified +error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-22560.rs:5:13 | LL | type Test = Add + - | ^^^ missing reference to `RHS` + | ^^^ missing reference to `Rhs` | = note: because of the default `Self` reference, type parameters must be specified on object types -error[E0393]: the type parameter `RHS` must be explicitly specified +error[E0393]: the type parameter `Rhs` must be explicitly specified --> $DIR/issue-22560.rs:8:13 | LL | Sub; - | ^^^ missing reference to `RHS` + | ^^^ missing reference to `Rhs` | = note: because of the default `Self` reference, type parameters must be specified on object types From a7bd36c9e8cdfac6a6edd4124e0d1d99a41b99a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Mon, 11 Mar 2019 16:07:31 +0000 Subject: [PATCH 11/48] Add peer_addr function to UdpSocket --- src/libstd/net/udp.rs | 17 +++++++++++++++++ src/libstd/sys/cloudabi/shims/net.rs | 4 ++++ src/libstd/sys/redox/net/udp.rs | 5 +++++ src/libstd/sys/sgx/net.rs | 4 ++++ src/libstd/sys_common/net.rs | 6 ++++++ 5 files changed, 36 insertions(+) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index edc9d665444a0..c7ccf45b953e7 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -180,6 +180,23 @@ impl UdpSocket { } } + /// Returns the socket address of the remote peer this socket was connected to. + /// + /// # Examples + /// + /// ```no_run + /// use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, UdpSocket}; + /// + /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); + /// socket.connect("192.168.0.1:41203").expect("couldn't connect to address"); + /// assert_eq!(socket.peer_addr().unwrap(), + /// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 41203))); + /// ``` + #[stable(feature = "rust1", since = "1.0.0")] + pub fn peer_addr(&self) -> io::Result { + self.0.peer_addr() + } + /// Returns the socket address that this socket was created from. /// /// # Examples diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 6d2a4962ab444..4364a1365443a 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -159,6 +159,10 @@ impl UdpSocket { unsupported() } + pub fn peer_addr(&self) -> io::Result { + match self.0 {} + } + pub fn socket_addr(&self) -> io::Result { match self.0 {} } diff --git a/src/libstd/sys/redox/net/udp.rs b/src/libstd/sys/redox/net/udp.rs index b1a60b1457083..274123dce4b58 100644 --- a/src/libstd/sys/redox/net/udp.rs +++ b/src/libstd/sys/redox/net/udp.rs @@ -72,6 +72,11 @@ impl UdpSocket { Ok(None) } + pub fn peer_addr(&self) -> Result { + let path = self.0.path()?; + Ok(path_to_peer_addr(path.to_str().unwrap_or(""))) + } + pub fn socket_addr(&self) -> Result { let path = self.0.path()?; Ok(path_to_local_addr(path.to_str().unwrap_or(""))) diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index e5e42e3d0b048..e851bdfe6a831 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -257,6 +257,10 @@ impl UdpSocket { unsupported() } + pub fn peer_addr(&self) -> io::Result { + match self.0 {} + } + pub fn socket_addr(&self) -> io::Result { match self.0 {} } diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index b9505aaa69ba5..b77bcee4b9d04 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -472,6 +472,12 @@ impl UdpSocket { pub fn into_socket(self) -> Socket { self.inner } + pub fn peer_addr(&self) -> io::Result { + sockname(|buf, len| unsafe { + c::getpeername(*self.inner.as_inner(), buf, len) + }) + } + pub fn socket_addr(&self) -> io::Result { sockname(|buf, len| unsafe { c::getsockname(*self.inner.as_inner(), buf, len) From bf473e3c153dfa84056249864a9f696d72f4e9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 12 Mar 2019 10:32:23 +0000 Subject: [PATCH 12/48] Mark UdpSocket peer_addr unstable w/ tracking issue --- src/libstd/net/udp.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index c7ccf45b953e7..164039b303230 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -185,6 +185,7 @@ impl UdpSocket { /// # Examples /// /// ```no_run + /// #![feature(udp_peer_addr)] /// use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, UdpSocket}; /// /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); @@ -192,7 +193,7 @@ impl UdpSocket { /// assert_eq!(socket.peer_addr().unwrap(), /// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 41203))); /// ``` - #[stable(feature = "rust1", since = "1.0.0")] + #[unstable(feature = "udp_peer_addr", issue = "59127")] pub fn peer_addr(&self) -> io::Result { self.0.peer_addr() } From 24e3fa079c150675e1911f1a9f958b690ecaa1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 12 Mar 2019 11:19:33 +0000 Subject: [PATCH 13/48] Document UdpSocket peer_addr NotConnected error --- src/libstd/net/udp.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 164039b303230..79e5ae79e4c01 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -193,6 +193,19 @@ impl UdpSocket { /// assert_eq!(socket.peer_addr().unwrap(), /// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 41203))); /// ``` + /// + /// If the socket isn't connected, it will return a [`NotConnected`] error. + /// + /// [`NotConnected`]: ../../std/io/enum.ErrorKind.html#variant.NotConnected + /// + /// ```no_run + /// #![feature(udp_peer_addr)] + /// use std::net::UdpSocket; + /// + /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); + /// assert_eq!(socket.peer_addr().unwrap_err().kind(), + /// ::std::io::ErrorKind::NotConnected); + /// ``` #[unstable(feature = "udp_peer_addr", issue = "59127")] pub fn peer_addr(&self) -> io::Result { self.0.peer_addr() From 7f7cfaee6aafbaa2477cb00b273299ec4e7d18d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 12 Mar 2019 16:50:00 +0000 Subject: [PATCH 14/48] Add test for UdpSocket peer_addr --- src/libstd/net/udp.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 79e5ae79e4c01..f3f65034f4256 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -903,6 +903,16 @@ mod tests { }) } + #[test] + fn socket_peer_ip4() { + each_ip(&mut |addr1, addr2| { + let server = t!(UdpSocket::bind(&addr1)); + assert_eq!(server.peer_addr().unwrap_err().kind(), ErrorKind::NotConnected); + t!(server.connect(&addr2)); + assert_eq!(addr2, t!(server.peer_addr())); + }) + } + #[test] fn udp_clone_smoke() { each_ip(&mut |addr1, addr2| { From 7e73cd48c4d531d8c3048941b4436833ec8651e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 12 Mar 2019 17:18:07 +0000 Subject: [PATCH 15/48] Fix test names regarding ip version --- src/libstd/net/udp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index f3f65034f4256..b42a812304269 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -896,7 +896,7 @@ mod tests { } #[test] - fn socket_name_ip4() { + fn socket_name() { each_ip(&mut |addr, _| { let server = t!(UdpSocket::bind(&addr)); assert_eq!(addr, t!(server.local_addr())); @@ -904,7 +904,7 @@ mod tests { } #[test] - fn socket_peer_ip4() { + fn socket_peer() { each_ip(&mut |addr1, addr2| { let server = t!(UdpSocket::bind(&addr1)); assert_eq!(server.peer_addr().unwrap_err().kind(), ErrorKind::NotConnected); From 214110bb4c7902e4787612efc265e4b2bdf0c1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Sat, 16 Mar 2019 11:19:01 +0000 Subject: [PATCH 16/48] Add UdpSocket peer_addr implementation for L4Re --- src/libstd/sys/unix/l4re.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/l4re.rs b/src/libstd/sys/unix/l4re.rs index b9e725371a36e..b3dd1cf6aaac7 100644 --- a/src/libstd/sys/unix/l4re.rs +++ b/src/libstd/sys/unix/l4re.rs @@ -292,6 +292,10 @@ pub mod net { pub fn into_socket(self) -> Socket { self.inner } + pub fn peer_addr(&self) -> io::Result { + unimpl!(); + } + pub fn socket_addr(&self) -> io::Result { unimpl!(); } @@ -463,4 +467,3 @@ pub mod net { } } } - From 81d5fb5c6fc65e947ff97c02997bfff9a1f6ce16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Sat, 16 Mar 2019 11:20:02 +0000 Subject: [PATCH 17/48] Add UdpSocket peer_addr implementation for Wasm --- src/libstd/sys/wasm/net.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs index a2ea2dfbbc032..c85dd000afe6f 100644 --- a/src/libstd/sys/wasm/net.rs +++ b/src/libstd/sys/wasm/net.rs @@ -156,6 +156,10 @@ impl UdpSocket { unsupported() } + pub fn peer_addr(&self) -> io::Result { + match self.0 {} + } + pub fn socket_addr(&self) -> io::Result { match self.0 {} } From 6007e6f649feac9a0cb39270444033f8dbfa9259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 17 Mar 2019 20:09:53 -0700 Subject: [PATCH 18/48] Do not complain about non-existing fields after parse recovery When failing to parse struct-like enum variants, the ADT gets recorded as having no fields. Record that we have actually recovered during parsing of this variant to avoid complaing about non-existing fields when actually using it. --- src/librustc/hir/lowering.rs | 3 +- src/librustc/hir/mod.rs | 4 +-- src/librustc/ty/mod.rs | 28 +++++++++++-------- src/librustc_metadata/decoder.rs | 3 +- src/librustc_save_analysis/dump_visitor.rs | 6 ++-- src/librustc_save_analysis/sig.rs | 18 +++++++----- src/librustc_typeck/check/_match.rs | 20 +++++++------ src/librustc_typeck/check/mod.rs | 17 +++++++---- src/librustc_typeck/collect.rs | 7 ++++- src/libsyntax/ast.rs | 6 ++-- src/libsyntax/config.rs | 2 +- src/libsyntax/mut_visit.rs | 2 +- src/libsyntax/parse/parser.rs | 28 ++++++++++++------- .../ui/parser/recovered-struct-variant.rs | 13 +++++++++ .../ui/parser/recovered-struct-variant.stderr | 8 ++++++ 15 files changed, 108 insertions(+), 57 deletions(-) create mode 100644 src/test/ui/parser/recovered-struct-variant.rs create mode 100644 src/test/ui/parser/recovered-struct-variant.stderr diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 949fdd2682b96..73c3b3026d98b 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2672,7 +2672,7 @@ impl<'a> LoweringContext<'a> { fn lower_variant_data(&mut self, vdata: &VariantData) -> hir::VariantData { match *vdata { - VariantData::Struct(ref fields, id) => { + VariantData::Struct(ref fields, id, recovered) => { let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(id); hir::VariantData::Struct( @@ -2682,6 +2682,7 @@ impl<'a> LoweringContext<'a> { .map(|f| self.lower_struct_field(f)) .collect(), hir_id, + recovered, ) }, VariantData::Tuple(ref fields, id) => { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 88ab58d10fc34..785d7745b297b 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2173,7 +2173,7 @@ impl StructField { /// Id of the whole struct lives in `Item`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum VariantData { - Struct(HirVec, HirId), + Struct(HirVec, HirId, bool), Tuple(HirVec, HirId), Unit(HirId), } @@ -2187,7 +2187,7 @@ impl VariantData { } pub fn hir_id(&self) -> HirId { match *self { - VariantData::Struct(_, hir_id) + VariantData::Struct(_, hir_id, _) | VariantData::Tuple(_, hir_id) | VariantData::Unit(hir_id) => hir_id, } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 882e2dc62b1c3..47dbed914ddc3 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1811,6 +1811,7 @@ pub struct VariantDef { pub fields: Vec, pub ctor_kind: CtorKind, flags: VariantFlags, + pub recovered: bool, } impl<'a, 'gcx, 'tcx> VariantDef { @@ -1829,16 +1830,17 @@ impl<'a, 'gcx, 'tcx> VariantDef { /// /// If someone speeds up attribute loading to not be a performance concern, they can /// remove this hack and use the constructor `DefId` everywhere. - pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>, - did: DefId, - ident: Ident, - discr: VariantDiscr, - fields: Vec, - adt_kind: AdtKind, - ctor_kind: CtorKind, - attribute_def_id: DefId) - -> Self - { + pub fn new( + tcx: TyCtxt<'a, 'gcx, 'tcx>, + did: DefId, + ident: Ident, + discr: VariantDiscr, + fields: Vec, + adt_kind: AdtKind, + ctor_kind: CtorKind, + attribute_def_id: DefId, + recovered: bool, + ) -> Self { debug!("VariantDef::new({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?})", did, ident, discr, fields, adt_kind, ctor_kind, attribute_def_id); let mut flags = VariantFlags::NO_VARIANT_FLAGS; @@ -1852,7 +1854,8 @@ impl<'a, 'gcx, 'tcx> VariantDef { discr, fields, ctor_kind, - flags + flags, + recovered, } } @@ -1868,7 +1871,8 @@ impl_stable_hash_for!(struct VariantDef { discr, fields, ctor_kind, - flags + flags, + recovered }); #[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)] diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 6fe00a4ad2ff2..c608c03095aa3 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -576,7 +576,8 @@ impl<'a, 'tcx> CrateMetadata { }).collect(), adt_kind, data.ctor_kind, - attribute_def_id + attribute_def_id, + false, ) } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 3fea515ae401e..01bb643c1d587 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -481,8 +481,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { }; let (value, fields) = match item.node { - ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, _), _) | - ast::ItemKind::Union(ast::VariantData::Struct(ref fields, _), _) => { + ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, ..), _) | + ast::ItemKind::Union(ast::VariantData::Struct(ref fields, ..), _) => { let include_priv_fields = !self.save_ctxt.config.pub_only; let fields_str = fields .iter() @@ -560,7 +560,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { let name_span = variant.node.ident.span; match variant.node.data { - ast::VariantData::Struct(ref fields, _) => { + ast::VariantData::Struct(ref fields, ..) => { let fields_str = fields .iter() .enumerate() diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 64a2c92d04dbd..6e47ae6b15984 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -703,7 +703,7 @@ impl Sig for ast::Variant_ { fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let mut text = self.ident.to_string(); match self.data { - ast::VariantData::Struct(ref fields, id) => { + ast::VariantData::Struct(ref fields, id, r) => { let name_def = SigElement { id: id_from_node_id(id, scx), start: offset, @@ -712,12 +712,16 @@ impl Sig for ast::Variant_ { text.push_str(" { "); let mut defs = vec![name_def]; let mut refs = vec![]; - for f in fields { - let field_sig = f.make(offset + text.len(), Some(id), scx)?; - text.push_str(&field_sig.text); - text.push_str(", "); - defs.extend(field_sig.defs.into_iter()); - refs.extend(field_sig.refs.into_iter()); + if r { + text.push_str("/* parse error */ "); + } else { + for f in fields { + let field_sig = f.make(offset + text.len(), Some(id), scx)?; + text.push_str(&field_sig.text); + text.push_str(", "); + defs.extend(field_sig.defs.into_iter()); + refs.extend(field_sig.refs.into_iter()); + } } text.push('}'); Ok(Signature { text, defs, refs }) diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index c6b66393dd2f1..c30b9d65fec83 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -918,14 +918,16 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); pat_ty } - fn check_struct_pat_fields(&self, - adt_ty: Ty<'tcx>, - pat_id: hir::HirId, - span: Span, - variant: &'tcx ty::VariantDef, - fields: &'gcx [Spanned], - etc: bool, - def_bm: ty::BindingMode) -> bool { + fn check_struct_pat_fields( + &self, + adt_ty: Ty<'tcx>, + pat_id: hir::HirId, + span: Span, + variant: &'tcx ty::VariantDef, + fields: &'gcx [Spanned], + etc: bool, + def_bm: ty::BindingMode, + ) -> bool { let tcx = self.tcx; let (substs, adt) = match adt_ty.sty { @@ -985,7 +987,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); .map(|field| field.ident.modern()) .filter(|ident| !used_fields.contains_key(&ident)) .collect::>(); - if inexistent_fields.len() > 0 { + if inexistent_fields.len() > 0 && !variant.recovered { let (field_names, t, plural) = if inexistent_fields.len() == 1 { (format!("a field named `{}`", inexistent_fields[0].1), "this", "") } else { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index fa4bb02189f20..e38a575c560e3 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3689,12 +3689,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { field, expr_t) } - fn report_unknown_field(&self, - ty: Ty<'tcx>, - variant: &'tcx ty::VariantDef, - field: &hir::Field, - skip_fields: &[hir::Field], - kind_name: &str) { + fn report_unknown_field( + &self, + ty: Ty<'tcx>, + variant: &'tcx ty::VariantDef, + field: &hir::Field, + skip_fields: &[hir::Field], + kind_name: &str, + ) { + if variant.recovered { + return; + } let mut err = self.type_error_struct_with_diag( field.ident.span, |actual| match ty.sty { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 10e9613bf21a2..c0739db3df6a2 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -598,6 +598,10 @@ fn convert_variant<'a, 'tcx>( } }) .collect(); + let recovered = match def { + hir::VariantData::Struct(_, _, r) => *r, + _ => false, + }; ty::VariantDef::new(tcx, did, ident, @@ -605,7 +609,8 @@ fn convert_variant<'a, 'tcx>( fields, adt_kind, CtorKind::from_hir(def), - attribute_def_id + attribute_def_id, + recovered, ) } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1a0da73880cfc..5da00ef8ebee2 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2133,7 +2133,7 @@ pub enum VariantData { /// Struct variant. /// /// E.g., `Bar { .. }` as in `enum Foo { Bar { .. } }`. - Struct(Vec, NodeId), + Struct(Vec, NodeId, bool), /// Tuple variant. /// /// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`. @@ -2147,13 +2147,13 @@ pub enum VariantData { impl VariantData { pub fn fields(&self) -> &[StructField] { match *self { - VariantData::Struct(ref fields, _) | VariantData::Tuple(ref fields, _) => fields, + VariantData::Struct(ref fields, ..) | VariantData::Tuple(ref fields, _) => fields, _ => &[], } } pub fn id(&self) -> NodeId { match *self { - VariantData::Struct(_, id) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id, + VariantData::Struct(_, id, _) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id, } } pub fn is_struct(&self) -> bool { diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index c300ffc2d61b9..7159c949513ac 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -225,7 +225,7 @@ impl<'a> StripUnconfigured<'a> { fn configure_variant_data(&mut self, vdata: &mut ast::VariantData) { match vdata { - ast::VariantData::Struct(fields, _id) | + ast::VariantData::Struct(fields, _id, _) | ast::VariantData::Tuple(fields, _id) => fields.flat_map_in_place(|field| self.configure(field)), ast::VariantData::Unit(_id) => {} diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 462346df7d76d..5bb1d8a4b9476 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -765,7 +765,7 @@ pub fn noop_visit_where_predicate(pred: &mut WherePredicate, vis: pub fn noop_visit_variant_data(vdata: &mut VariantData, vis: &mut T) { match vdata { - VariantData::Struct(fields, id) | + VariantData::Struct(fields, id, _) | VariantData::Tuple(fields, id) => { visit_vec(fields, |field| vis.visit_struct_field(field)); vis.visit_id(id); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aa70c54a1ef8a..360a101a64faf 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6829,14 +6829,16 @@ impl<'a> Parser<'a> { VariantData::Unit(ast::DUMMY_NODE_ID) } else { // If we see: `struct Foo where T: Copy { ... }` - VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) + let (fields, recovered) = self.parse_record_struct_body()?; + VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered) } // No `where` so: `struct Foo;` } else if self.eat(&token::Semi) { VariantData::Unit(ast::DUMMY_NODE_ID) // Record-style struct definition } else if self.token == token::OpenDelim(token::Brace) { - VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) + let (fields, recovered) = self.parse_record_struct_body()?; + VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered) // Tuple-style struct definition with optional where-clause. } else if self.token == token::OpenDelim(token::Paren) { let body = VariantData::Tuple(self.parse_tuple_struct_body()?, ast::DUMMY_NODE_ID); @@ -6864,9 +6866,11 @@ impl<'a> Parser<'a> { let vdata = if self.token.is_keyword(keywords::Where) { generics.where_clause = self.parse_where_clause()?; - VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) + let (fields, recovered) = self.parse_record_struct_body()?; + VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered) } else if self.token == token::OpenDelim(token::Brace) { - VariantData::Struct(self.parse_record_struct_body()?, ast::DUMMY_NODE_ID) + let (fields, recovered) = self.parse_record_struct_body()?; + VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered) } else { let token_str = self.this_token_descr(); let mut err = self.fatal(&format!( @@ -6898,12 +6902,14 @@ impl<'a> Parser<'a> { } } - fn parse_record_struct_body(&mut self) -> PResult<'a, Vec> { + fn parse_record_struct_body(&mut self) -> PResult<'a, (Vec, bool)> { let mut fields = Vec::new(); + let mut recovered = false; if self.eat(&token::OpenDelim(token::Brace)) { while self.token != token::CloseDelim(token::Brace) { let field = self.parse_struct_decl_field().map_err(|e| { self.recover_stmt(); + recovered = true; e }); match field { @@ -6922,7 +6928,7 @@ impl<'a> Parser<'a> { return Err(err); } - Ok(fields) + Ok((fields, recovered)) } fn parse_tuple_struct_body(&mut self) -> PResult<'a, Vec> { @@ -7684,12 +7690,14 @@ impl<'a> Parser<'a> { if self.check(&token::OpenDelim(token::Brace)) { // Parse a struct variant. all_nullary = false; - struct_def = VariantData::Struct(self.parse_record_struct_body()?, - ast::DUMMY_NODE_ID); + let (fields, recovered) = self.parse_record_struct_body()?; + struct_def = VariantData::Struct(fields, ast::DUMMY_NODE_ID, recovered); } else if self.check(&token::OpenDelim(token::Paren)) { all_nullary = false; - struct_def = VariantData::Tuple(self.parse_tuple_struct_body()?, - ast::DUMMY_NODE_ID); + struct_def = VariantData::Tuple( + self.parse_tuple_struct_body()?, + ast::DUMMY_NODE_ID, + ); } else if self.eat(&token::Eq) { disr_expr = Some(AnonConst { id: ast::DUMMY_NODE_ID, diff --git a/src/test/ui/parser/recovered-struct-variant.rs b/src/test/ui/parser/recovered-struct-variant.rs new file mode 100644 index 0000000000000..5b195dcc37878 --- /dev/null +++ b/src/test/ui/parser/recovered-struct-variant.rs @@ -0,0 +1,13 @@ +enum Foo { + A { a, b: usize } + //~^ ERROR expected `:`, found `,` +} + +fn main() { + // no complaints about non-existing fields + let f = Foo::A { a:3, b: 4}; + match f { + // no complaints about non-existing fields + Foo::A {a, b} => {} + } +} diff --git a/src/test/ui/parser/recovered-struct-variant.stderr b/src/test/ui/parser/recovered-struct-variant.stderr new file mode 100644 index 0000000000000..51aaf8bb3cfbe --- /dev/null +++ b/src/test/ui/parser/recovered-struct-variant.stderr @@ -0,0 +1,8 @@ +error: expected `:`, found `,` + --> $DIR/recovered-struct-variant.rs:2:10 + | +LL | A { a, b: usize } + | ^ expected `:` + +error: aborting due to previous error + From bb832c2560c8d2c6d1a47d9a9bb0eed518f0b3ad Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Mon, 18 Mar 2019 09:02:57 +0100 Subject: [PATCH 19/48] some small HIR doc improvements --- src/librustc/hir/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 88ab58d10fc34..8941158e561d1 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -816,6 +816,9 @@ pub struct MacroDef { pub legacy: bool, } +/// A block of statements `{ .. }`, which may have a label (in this case the +/// `targeted_by_break` field will be `true`) and may be `unsafe` by means of +/// the `rules` being anything but `DefaultBlock`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Block { /// Statements in a block. @@ -1178,6 +1181,7 @@ impl fmt::Debug for Stmt { } } +/// The contents of a statement. #[derive(Clone, RustcEncodable, RustcDecodable, HashStable)] pub enum StmtKind { /// A local (`let`) binding. @@ -1208,21 +1212,28 @@ impl StmtKind { #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Local { pub pat: P, + /// Type annotation, if any (otherwise the type will be inferred). pub ty: Option>, /// Initializer expression to set the value, if any. pub init: Option>, pub hir_id: HirId, pub span: Span, pub attrs: ThinVec, + /// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop + /// desugaring. Otherwise will be `Normal`. pub source: LocalSource, } -/// Represents a single arm of a `match` expression. +/// Represents a single arm of a `match` expression, e.g. +/// ` (if ) => `. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct Arm { pub attrs: HirVec, + /// Multiple patterns can be combined with `|` pub pats: HirVec>, + /// Optional guard clause. pub guard: Option, + /// The action to take if this arm matches. pub body: P, } From ec6f983e243ed7988be4eebd356181be7b1f5525 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:37:02 +0000 Subject: [PATCH 20/48] Rename typarams to param_names Co-Authored-By: Gabriel Smith --- src/librustc/hir/print.rs | 4 ++-- src/librustdoc/clean/auto_trait.rs | 8 ++++---- src/librustdoc/clean/mod.rs | 32 +++++++++++++++--------------- src/librustdoc/html/format.rs | 20 +++++++++---------- src/librustdoc/html/render.rs | 6 +++--- src/libsyntax/print/pprust.rs | 4 ++-- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 54a21f2ed5c2a..bff4190ae7925 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -591,12 +591,12 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - hir::ItemKind::Fn(ref decl, header, ref typarams, body) => { + hir::ItemKind::Fn(ref decl, header, ref param_names, body) => { self.head("")?; self.print_fn(decl, header, Some(item.ident.name), - typarams, + param_names, &item.vis, &[], Some(body))?; diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 20fa6009b310b..23b5794fb1eef 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -435,7 +435,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { let new_ty = match &poly_trait.trait_ { &Type::ResolvedPath { ref path, - ref typarams, + ref param_names, ref did, ref is_generic, } => { @@ -469,7 +469,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { Type::ResolvedPath { path: new_path, - typarams: typarams.clone(), + param_names: param_names.clone(), did: did.clone(), is_generic: *is_generic, } @@ -669,7 +669,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { match **trait_ { Type::ResolvedPath { path: ref trait_path, - ref typarams, + ref param_names, ref did, ref is_generic, } => { @@ -724,7 +724,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { PolyTrait { trait_: Type::ResolvedPath { path: new_trait_path, - typarams: typarams.clone(), + param_names: param_names.clone(), did: did.clone(), is_generic: *is_generic, }, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c51c8027de64e..6739873c6044f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1176,7 +1176,7 @@ impl<'a, 'tcx> Clean for (&'a ty::TraitRef<'tcx>, Vec PolyTrait { trait_: ResolvedPath { path, - typarams: None, + param_names: None, did: trait_ref.def_id, is_generic: false, }, @@ -2244,7 +2244,7 @@ pub enum Type { /// Structs/enums/traits (most that'd be an `hir::TyKind::Path`). ResolvedPath { path: Path, - typarams: Option>, + param_names: Option>, did: DefId, /// `true` if is a `T::Name` path for associated types. is_generic: bool, @@ -2706,7 +2706,7 @@ impl Clean for hir::Ty { } TyKind::TraitObject(ref bounds, ref lifetime) => { match bounds[0].clean(cx).trait_ { - ResolvedPath { path, typarams: None, did, is_generic } => { + ResolvedPath { path, param_names: None, did, is_generic } => { let mut bounds: Vec = bounds[1..].iter().map(|bound| { self::GenericBound::TraitBound(bound.clean(cx), hir::TraitBoundModifier::None) @@ -2714,7 +2714,7 @@ impl Clean for hir::Ty { if !lifetime.is_elided() { bounds.push(self::GenericBound::Outlives(lifetime.clean(cx))); } - ResolvedPath { path, typarams: Some(bounds), did, is_generic, } + ResolvedPath { path, param_names: Some(bounds), did, is_generic, } } _ => Infer // shouldn't happen } @@ -2781,7 +2781,7 @@ impl<'tcx> Clean for Ty<'tcx> { None, false, vec![], substs); ResolvedPath { path, - typarams: None, + param_names: None, did, is_generic: false, } @@ -2792,7 +2792,7 @@ impl<'tcx> Clean for Ty<'tcx> { None, false, vec![], InternalSubsts::empty()); ResolvedPath { path: path, - typarams: None, + param_names: None, did: did, is_generic: false, } @@ -2813,8 +2813,8 @@ impl<'tcx> Clean for Ty<'tcx> { inline::record_extern_fqn(cx, did, TypeKind::Trait); - let mut typarams = vec![]; - reg.clean(cx).map(|b| typarams.push(GenericBound::Outlives(b))); + let mut param_names = vec![]; + reg.clean(cx).map(|b| param_names.push(GenericBound::Outlives(b))); for did in dids { let empty = cx.tcx.intern_substs(&[]); let path = external_path(cx, &cx.tcx.item_name(did).as_str(), @@ -2823,13 +2823,13 @@ impl<'tcx> Clean for Ty<'tcx> { let bound = GenericBound::TraitBound(PolyTrait { trait_: ResolvedPath { path, - typarams: None, + param_names: None, did, is_generic: false, }, generic_params: Vec::new(), }, hir::TraitBoundModifier::None); - typarams.push(bound); + param_names.push(bound); } let mut bindings = vec![]; @@ -2844,7 +2844,7 @@ impl<'tcx> Clean for Ty<'tcx> { false, bindings, substs); ResolvedPath { path, - typarams: Some(typarams), + param_names: Some(param_names), did, is_generic: false, } @@ -3294,8 +3294,8 @@ impl Clean for hir::PathSegment { fn strip_type(ty: Type) -> Type { match ty { - Type::ResolvedPath { path, typarams, did, is_generic } => { - Type::ResolvedPath { path: strip_path(&path), typarams, did, is_generic } + Type::ResolvedPath { path, param_names, did, is_generic } => { + Type::ResolvedPath { path: strip_path(&path), param_names, did, is_generic } } Type::Tuple(inner_tys) => { Type::Tuple(inner_tys.iter().map(|t| strip_type(t.clone())).collect()) @@ -3955,7 +3955,7 @@ fn resolve_type(cx: &DocContext<'_>, _ => false, }; let did = register_def(&*cx, path.def); - ResolvedPath { path: path, typarams: None, did: did, is_generic: is_generic } + ResolvedPath { path: path, param_names: None, did: did, is_generic: is_generic } } pub fn register_def(cx: &DocContext<'_>, def: Def) -> DefId { @@ -4381,9 +4381,9 @@ impl From for SimpleBound { match bound.clone() { GenericBound::Outlives(l) => SimpleBound::Outlives(l), GenericBound::TraitBound(t, mod_) => match t.trait_ { - Type::ResolvedPath { path, typarams, .. } => { + Type::ResolvedPath { path, param_names, .. } => { SimpleBound::TraitBound(path.segments, - typarams + param_names .map_or_else(|| Vec::new(), |v| v.iter() .map(|p| SimpleBound::from(p.clone())) .collect()), diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index d204a179ca62c..36257914d192f 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -521,8 +521,8 @@ fn primitive_link(f: &mut fmt::Formatter<'_>, /// Helper to render type parameters fn tybounds(w: &mut fmt::Formatter<'_>, - typarams: &Option>) -> fmt::Result { - match *typarams { + param_names: &Option>) -> fmt::Result { + match *param_names { Some(ref params) => { for param in params { write!(w, " + ")?; @@ -559,13 +559,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> clean::Generic(ref name) => { f.write_str(name) } - clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => { - if typarams.is_some() { + clean::ResolvedPath{ did, ref param_names, ref path, is_generic } => { + if param_names.is_some() { f.write_str("dyn ")?; } // Paths like T::Output and Self::Output should be rendered with all segments resolved_path(f, did, path, is_generic, use_absolute)?; - tybounds(f, typarams) + tybounds(f, param_names) } clean::Infer => write!(f, "_"), clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()), @@ -663,7 +663,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> } } } - clean::ResolvedPath { typarams: Some(ref v), .. } if !v.is_empty() => { + clean::ResolvedPath { param_names: Some(ref v), .. } if !v.is_empty() => { write!(f, "{}{}{}(", amp, lt, m)?; fmt_type(&ty, f, use_absolute)?; write!(f, ")") @@ -717,7 +717,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> // the ugliness comes from inlining across crates where // everything comes in as a fully resolved QPath (hard to // look at). - box clean::ResolvedPath { did, ref typarams, .. } => { + box clean::ResolvedPath { did, ref param_names, .. } => { match href(did) { Some((ref url, _, ref path)) if !f.alternate() => { write!(f, @@ -731,8 +731,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> _ => write!(f, "{}", name)?, } - // FIXME: `typarams` are not rendered, and this seems bad? - drop(typarams); + // FIXME: `param_names` are not rendered, and this seems bad? + drop(param_names); Ok(()) } _ => { @@ -771,7 +771,7 @@ fn fmt_impl(i: &clean::Impl, fmt::Display::fmt(ty, f)?; } else { match *ty { - clean::ResolvedPath { typarams: None, ref path, is_generic: false, .. } => { + clean::ResolvedPath { param_names: None, ref path, is_generic: false, .. } => { let last = path.segments.last().unwrap(); fmt::Display::fmt(&last.name, f)?; fmt::Display::fmt(&last.args, f)?; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index b3a816d17f56c..b1c4a8fc1afbe 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -271,7 +271,7 @@ pub struct Cache { /// Mapping of typaram ids to the name of the type parameter. This is used /// when pretty-printing a type (so pretty-printing doesn't have to /// painfully maintain a context like this) - pub typarams: FxHashMap, + pub param_names: FxHashMap, /// Maps a type ID to all known implementations for that type. This is only /// recognized for intra-crate `ResolvedPath` types, and is used to print @@ -635,7 +635,7 @@ pub fn run(mut krate: clean::Crate, deref_mut_trait_did, owned_box_did, masked_crates: mem::replace(&mut krate.masked_crates, Default::default()), - typarams: external_typarams, + param_names: external_param_names, aliases: Default::default(), }; @@ -1751,7 +1751,7 @@ impl<'a> Cache { clean::GenericParamDefKind::Lifetime => {} clean::GenericParamDefKind::Type { did, .. } | clean::GenericParamDefKind::Const { did, .. } => { - self.typarams.insert(did, param.name.clone()); + self.param_names.insert(did, param.name.clone()); } } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e04e127ccf15a..07df14ddc722c 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1263,13 +1263,13 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - ast::ItemKind::Fn(ref decl, header, ref typarams, ref body) => { + ast::ItemKind::Fn(ref decl, header, ref param_names, ref body) => { self.head("")?; self.print_fn( decl, header, Some(item.ident), - typarams, + param_names, &item.vis )?; self.s.word(" ")?; From c915fe0245c7506e3f15660dee2d597fb48e9230 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:37:43 +0000 Subject: [PATCH 21/48] Rename external_typarams to external_param_names Co-Authored-By: Gabriel Smith --- src/librustdoc/clean/mod.rs | 4 ++-- src/librustdoc/html/render.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 6739873c6044f..5a22614fc71c6 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1045,7 +1045,7 @@ impl GenericBound { GenericBound::TraitBound(PolyTrait { trait_: ResolvedPath { path, - typarams: None, + param_names: None, did, is_generic: false, }, @@ -1469,7 +1469,7 @@ impl<'tcx> Clean for ty::GenericParamDef { (self.name.to_string(), GenericParamDefKind::Lifetime) } ty::GenericParamDefKind::Type { has_default, .. } => { - cx.renderinfo.borrow_mut().external_typarams + cx.renderinfo.borrow_mut().external_param_names .insert(self.def_id, self.name.clean(cx)); let default = if has_default { Some(cx.tcx.type_of(self.def_id).clean(cx)) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index b1c4a8fc1afbe..ed46ac0b62d30 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -368,7 +368,7 @@ pub struct Cache { pub struct RenderInfo { pub inlined: FxHashSet, pub external_paths: crate::core::ExternalPaths, - pub external_typarams: FxHashMap, + pub external_param_names: FxHashMap, pub exact_paths: FxHashMap>, pub access_levels: AccessLevels, pub deref_trait_did: Option, @@ -601,7 +601,7 @@ pub fn run(mut krate: clean::Crate, let RenderInfo { inlined: _, external_paths, - external_typarams, + external_param_names, exact_paths, access_levels, deref_trait_did, From 14913159e0509a2b7d1c86984a044b76dd4e4902 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:38:33 +0000 Subject: [PATCH 22/48] Implement `Clean` for const generics Co-Authored-By: Gabriel Smith --- src/librustdoc/clean/mod.rs | 19 +++++++++++++++++++ src/librustdoc/html/format.rs | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5a22614fc71c6..0f976c11938c0 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2921,6 +2921,25 @@ impl<'tcx> Clean for Ty<'tcx> { } } +impl<'tcx> Clean for ty::LazyConst<'tcx> { + fn clean(&self, cx: &DocContext<'_>) -> Constant { + if let ty::LazyConst::Evaluated(ct) = self { + ct.clean(cx) + } else { + unimplemented!() // FIXME(const_generics) + } + } +} + +impl<'tcx> Clean for ty::Const<'tcx> { + fn clean(&self, cx: &DocContext<'_>) -> Constant { + Constant { + type_: self.ty.clean(cx), + expr: format!("{:?}", self.val), // FIXME(const_generics) + } + } +} + impl Clean for hir::StructField { fn clean(&self, cx: &DocContext<'_>) -> Item { let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id); diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 36257914d192f..2cba3c58889ab 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -259,6 +259,12 @@ impl fmt::Display for clean::Lifetime { } } +impl fmt::Display for clean::Constant { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}: {}", self.expr, self.type_) + } +} + impl fmt::Display for clean::PolyTrait { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if !self.generic_params.is_empty() { From 29ed491743df4dbab25fec6f725e6f3b3ace860b Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:39:03 +0000 Subject: [PATCH 23/48] Add `GenericArg` Co-Authored-By: Gabriel Smith --- src/librustdoc/clean/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 0f976c11938c0..8581c40c843e8 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3247,6 +3247,23 @@ impl Clean for hir::Path { } } +#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] +pub enum GenericArg { + Lifetime(Lifetime), + Type(Type), + Const(Constant), +} + +impl fmt::Display for GenericArg { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + GenericArg::Lifetime(lt) => lt.fmt(f), + GenericArg::Type(ty) => ty.fmt(f), + GenericArg::Const(ct) => ct.fmt(f), + } + } +} + #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] pub enum GenericArgs { AngleBracketed { From cd9a2c0b54ee50135fbeb4d83c00f713114f7f67 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:39:56 +0000 Subject: [PATCH 24/48] Refactor `GenericArgs` to include const generics Co-Authored-By: Gabriel Smith --- src/librustdoc/clean/auto_trait.rs | 8 +- src/librustdoc/clean/mod.rs | 116 ++++++++++++++--------------- src/librustdoc/html/format.rs | 19 ++--- 3 files changed, 70 insertions(+), 73 deletions(-) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 23b5794fb1eef..adbe73b165ef4 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -444,7 +444,13 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { .expect("segments were empty"); let (old_input, old_output) = match last_segment.args { - GenericArgs::AngleBracketed { types, .. } => (types, None), + GenericArgs::AngleBracketed { args, .. } => { + let types = args.iter().filter_map(|arg| match arg { + GenericArg::Type(ty) => Some(ty.clone()), + _ => None, + }).collect(); + (types, None) + } GenericArgs::Parenthesized { inputs, output, .. } => { (inputs, output) } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 8581c40c843e8..50210bcb85d56 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -21,7 +21,7 @@ use rustc::hir::{self, GenericArg, HirVec}; use rustc::hir::def::{self, Def, CtorKind}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::hir::map::DisambiguatedDefPathData; -use rustc::ty::subst::{Kind, InternalSubsts, SubstsRef}; +use rustc::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind}; use rustc::ty::{self, DefIdTree, TyCtxt, Region, RegionVid, Ty, AdtKind}; use rustc::ty::fold::TypeFolder; use rustc::ty::layout::VariantIdx; @@ -1089,24 +1089,37 @@ impl Clean for hir::GenericBound { } } -fn external_generic_args(cx: &DocContext<'_>, trait_did: Option, has_self: bool, - bindings: Vec, substs: SubstsRef<'_>) -> GenericArgs { - let lifetimes = substs.regions().filter_map(|v| v.clean(cx)).collect(); - let types = substs.types().skip(has_self as usize).collect::>(); +fn external_generic_args( + cx: &DocContext<'_>, + trait_did: Option, + has_self: bool, + bindings: Vec, + substs: SubstsRef<'_>, +) -> GenericArgs { + let mut skip_self = has_self; + let mut first_ty_sty = None; + let args: Vec<_> = substs.iter().filter_map(|kind| match kind.unpack() { + UnpackedKind::Lifetime(lt) => { + lt.clean(cx).and_then(|lt| Some(GenericArg::Lifetime(lt))) + } + UnpackedKind::Type(_) if skip_self => { + skip_self = false; + None + } + UnpackedKind::Type(ty) => { + first_ty_sty = Some(&ty.sty); + Some(GenericArg::Type(ty.clean(cx))) + } + UnpackedKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), + }).collect(); match trait_did { // Attempt to sugar an external path like Fn<(A, B,), C> to Fn(A, B) -> C Some(did) if cx.tcx.lang_items().fn_trait_kind(did).is_some() => { - assert_eq!(types.len(), 1); - let inputs = match types[0].sty { - ty::Tuple(ref tys) => tys.iter().map(|t| t.clean(cx)).collect(), - _ => { - return GenericArgs::AngleBracketed { - lifetimes, - types: types.clean(cx), - bindings, - } - } + assert!(first_ty_sty.is_some()); + let inputs = match first_ty_sty { + Some(ty::Tuple(ref tys)) => tys.iter().map(|t| t.clean(cx)).collect(), + _ => return GenericArgs::AngleBracketed { args, bindings }, }; let output = None; // FIXME(#20299) return type comes from a projection now @@ -1114,17 +1127,10 @@ fn external_generic_args(cx: &DocContext<'_>, trait_did: Option, has_self // ty::Tuple(ref v) if v.is_empty() => None, // -> () // _ => Some(types[1].clean(cx)) // }; - GenericArgs::Parenthesized { - inputs, - output, - } + GenericArgs::Parenthesized { inputs, output } }, _ => { - GenericArgs::AngleBracketed { - lifetimes, - types: types.clean(cx), - bindings, - } + GenericArgs::AngleBracketed { args, bindings } } } } @@ -1462,7 +1468,7 @@ impl GenericParamDef { } } -impl<'tcx> Clean for ty::GenericParamDef { +impl Clean for ty::GenericParamDef { fn clean(&self, cx: &DocContext<'_>) -> GenericParamDef { let (name, kind) = match self.kind { ty::GenericParamDefKind::Lifetime => { @@ -1484,7 +1490,10 @@ impl<'tcx> Clean for ty::GenericParamDef { }) } ty::GenericParamDefKind::Const { .. } => { - unimplemented!() // FIXME(const_generics) + (self.name.clean(cx), GenericParamDefKind::Const { + did: self.def_id, + ty: cx.tcx.type_of(self.def_id).clean(cx), + }) } }; @@ -1685,9 +1694,7 @@ impl<'a, 'tcx> Clean for (&'a ty::Generics, .flat_map(|param| match param.kind { ty::GenericParamDefKind::Lifetime => Some(param.clean(cx)), ty::GenericParamDefKind::Type { .. } => None, - ty::GenericParamDefKind::Const { .. } => { - unimplemented!() // FIXME(const_generics) - } + ty::GenericParamDefKind::Const { .. } => Some(param.clean(cx)), }).chain(simplify::ty_params(stripped_typarams).into_iter()) .collect(), where_predicates: simplify::where_clauses(cx, where_predicates), @@ -2365,12 +2372,15 @@ impl Type { } } - pub fn generics(&self) -> Option<&[Type]> { + pub fn generics(&self) -> Option> { match *self { ResolvedPath { ref path, .. } => { path.segments.last().and_then(|seg| { - if let GenericArgs::AngleBracketed { ref types, .. } = seg.args { - Some(&**types) + if let GenericArgs::AngleBracketed { ref args, .. } = seg.args { + Some(args.iter().filter_map(|arg| match arg { + GenericArg::Type(ty) => Some(ty.clone()), + _ => None, + }).collect()) } else { None } @@ -3267,8 +3277,7 @@ impl fmt::Display for GenericArg { #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Hash)] pub enum GenericArgs { AngleBracketed { - lifetimes: Vec, - types: Vec, + args: Vec, bindings: Vec, }, Parenthesized { @@ -3286,27 +3295,19 @@ impl Clean for hir::GenericArgs { output: if output != Type::Tuple(Vec::new()) { Some(output) } else { None } } } else { - let (mut lifetimes, mut types) = (vec![], vec![]); - let mut elided_lifetimes = true; - for arg in &self.args { - match arg { - GenericArg::Lifetime(lt) => { - if !lt.is_elided() { - elided_lifetimes = false; - } - lifetimes.push(lt.clean(cx)); - } - GenericArg::Type(ty) => { - types.push(ty.clean(cx)); - } - GenericArg::Const(..) => { - unimplemented!() // FIXME(const_generics) - } - } - } + let elide_lifetimes = self.args.iter().all(|arg| match arg { + hir::GenericArg::Lifetime(lt) => lt.is_elided(), + _ => true, + }); GenericArgs::AngleBracketed { - lifetimes: if elided_lifetimes { vec![] } else { lifetimes }, - types, + args: self.args.iter().filter_map(|arg| match arg { + hir::GenericArg::Lifetime(lt) if !elide_lifetimes => { + Some(GenericArg::Lifetime(lt.clean(cx))) + } + hir::GenericArg::Lifetime(_) => None, + hir::GenericArg::Type(ty) => Some(GenericArg::Type(ty.clean(cx))), + hir::GenericArg::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), + }).collect(), bindings: self.bindings.clean(cx), } } @@ -3358,9 +3359,8 @@ fn strip_path(path: &Path) -> Path { PathSegment { name: s.name.clone(), args: GenericArgs::AngleBracketed { - lifetimes: Vec::new(), - types: Vec::new(), - bindings: Vec::new(), + args: vec![], + bindings: vec![], } } }).collect(); @@ -3511,7 +3511,7 @@ impl Clean for doctree::Static { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)] pub struct Constant { pub type_: Type, pub expr: String, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 2cba3c58889ab..116839edc2f80 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -306,32 +306,23 @@ impl fmt::Display for clean::GenericBound { impl fmt::Display for clean::GenericArgs { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - clean::GenericArgs::AngleBracketed { - ref lifetimes, ref types, ref bindings - } => { - if !lifetimes.is_empty() || !types.is_empty() || !bindings.is_empty() { + clean::GenericArgs::AngleBracketed { ref args, ref bindings } => { + if !args.is_empty() || !bindings.is_empty() { if f.alternate() { f.write_str("<")?; } else { f.write_str("<")?; } let mut comma = false; - for lifetime in lifetimes { - if comma { - f.write_str(", ")?; - } - comma = true; - write!(f, "{}", *lifetime)?; - } - for ty in types { + for arg in args { if comma { f.write_str(", ")?; } comma = true; if f.alternate() { - write!(f, "{:#}", *ty)?; + write!(f, "{:#}", *arg)?; } else { - write!(f, "{}", *ty)?; + write!(f, "{}", *arg)?; } } for binding in bindings { From 38d98a1b2242b6b8fac041ccb249eb492a09d260 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:40:10 +0000 Subject: [PATCH 25/48] Implement const generics in `generics_to_path_params` Co-Authored-By: Gabriel Smith --- src/librustdoc/core.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index dca6458c701c5..1982a16f3b81d 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -236,8 +236,16 @@ impl<'tcx> DocContext<'tcx> { ty::GenericParamDefKind::Type { .. } => { args.push(hir::GenericArg::Type(self.ty_param_to_ty(param.clone()))); } - ty::GenericParamDefKind::Const { .. } => { - unimplemented!() // FIXME(const_generics) + ty::GenericParamDefKind::Const => { + args.push(hir::GenericArg::Const(hir::ConstArg { + value: hir::AnonConst { + hir_id: hir::DUMMY_HIR_ID, + body: hir::BodyId { + hir_id: hir::DUMMY_HIR_ID, + } + }, + span: DUMMY_SP, + })) } } } From 9925d9b3b6dd0abe34e48f7d4b6730bb97c7ebd4 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 14 Mar 2019 09:54:37 +0000 Subject: [PATCH 26/48] Fix indentation issue --- src/librustdoc/html/format.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 116839edc2f80..f56322d9f0631 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -307,7 +307,7 @@ impl fmt::Display for clean::GenericArgs { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { clean::GenericArgs::AngleBracketed { ref args, ref bindings } => { - if !args.is_empty() || !bindings.is_empty() { + if !args.is_empty() || !bindings.is_empty() { if f.alternate() { f.write_str("<")?; } else { From b39e664ee8add0f6a36462c18927648aa3dc207e Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 18 Mar 2019 19:29:25 +0000 Subject: [PATCH 27/48] Make clean::Constant display respect f.alternate() --- src/librustdoc/html/format.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index f56322d9f0631..3a0a19d58008b 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -261,7 +261,9 @@ impl fmt::Display for clean::Lifetime { impl fmt::Display for clean::Constant { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}: {}", self.expr, self.type_) + fmt::Display::fmt(&self.expr, f)?; + f.write_str(": ")?; + fmt::Display::fmt(&self.type_, f) } } From f93ad414ab1b78bb219df84b6a0a5e367dc81a66 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 18 Mar 2019 19:37:42 +0000 Subject: [PATCH 28/48] Rename first_ty_sty to ty_sty --- src/librustdoc/clean/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 50210bcb85d56..51f1ad1a3765b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1097,7 +1097,7 @@ fn external_generic_args( substs: SubstsRef<'_>, ) -> GenericArgs { let mut skip_self = has_self; - let mut first_ty_sty = None; + let mut ty_sty = None; let args: Vec<_> = substs.iter().filter_map(|kind| match kind.unpack() { UnpackedKind::Lifetime(lt) => { lt.clean(cx).and_then(|lt| Some(GenericArg::Lifetime(lt))) @@ -1107,7 +1107,7 @@ fn external_generic_args( None } UnpackedKind::Type(ty) => { - first_ty_sty = Some(&ty.sty); + ty_sty = Some(&ty.sty); Some(GenericArg::Type(ty.clean(cx))) } UnpackedKind::Const(ct) => Some(GenericArg::Const(ct.clean(cx))), @@ -1116,8 +1116,8 @@ fn external_generic_args( match trait_did { // Attempt to sugar an external path like Fn<(A, B,), C> to Fn(A, B) -> C Some(did) if cx.tcx.lang_items().fn_trait_kind(did).is_some() => { - assert!(first_ty_sty.is_some()); - let inputs = match first_ty_sty { + assert!(ty_sty.is_some()); + let inputs = match ty_sty { Some(ty::Tuple(ref tys)) => tys.iter().map(|t| t.clean(cx)).collect(), _ => return GenericArgs::AngleBracketed { args, bindings }, }; From 9bc58118fc80e01eab53c72cfd8658b58d21c593 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 18 Mar 2019 19:46:59 +0000 Subject: [PATCH 29/48] Rebase over LazyConst changes --- src/librustdoc/clean/mod.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 51f1ad1a3765b..5adce4a41709e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -17,7 +17,7 @@ use rustc::middle::resolve_lifetime as rl; use rustc::middle::lang_items; use rustc::middle::stability; use rustc::mir::interpret::{GlobalId, ConstValue}; -use rustc::hir::{self, GenericArg, HirVec}; +use rustc::hir::{self, HirVec}; use rustc::hir::def::{self, Def, CtorKind}; use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc::hir::map::DisambiguatedDefPathData; @@ -2931,16 +2931,6 @@ impl<'tcx> Clean for Ty<'tcx> { } } -impl<'tcx> Clean for ty::LazyConst<'tcx> { - fn clean(&self, cx: &DocContext<'_>) -> Constant { - if let ty::LazyConst::Evaluated(ct) = self { - ct.clean(cx) - } else { - unimplemented!() // FIXME(const_generics) - } - } -} - impl<'tcx> Clean for ty::Const<'tcx> { fn clean(&self, cx: &DocContext<'_>) -> Constant { Constant { From 37789c4a1d6e46af2ef619f5640c05764b875dbb Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 19 Mar 2019 06:10:59 +0100 Subject: [PATCH 30/48] Update src/librustc/hir/mod.rs Co-Authored-By: llogiq --- src/librustc/hir/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 8941158e561d1..24c145b3811e3 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1233,7 +1233,7 @@ pub struct Arm { pub pats: HirVec>, /// Optional guard clause. pub guard: Option, - /// The action to take if this arm matches. + /// The expression the arm evaluates to if this arm matches. pub body: P, } From 8cf720bd19a00f52e3db630947f6424946ee0f6c Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 19 Mar 2019 13:59:38 +0100 Subject: [PATCH 31/48] Make Option no larger than ThreadId, with NonZeroU64 --- src/libstd/thread/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 08f0aa2f0d206..40682da8f8b0f 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -163,6 +163,7 @@ use crate::ffi::{CStr, CString}; use crate::fmt; use crate::io; use crate::mem; +use crate::num::NonZeroU64; use crate::panic; use crate::panicking; use crate::str; @@ -1036,7 +1037,7 @@ pub fn park_timeout(dur: Duration) { /// [`Thread`]: ../../std/thread/struct.Thread.html #[stable(feature = "thread_id", since = "1.19.0")] #[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)] -pub struct ThreadId(u64); +pub struct ThreadId(NonZeroU64); impl ThreadId { // Generate a new unique thread ID. @@ -1044,7 +1045,7 @@ impl ThreadId { // We never call `GUARD.init()`, so it is UB to attempt to // acquire this mutex reentrantly! static GUARD: mutex::Mutex = mutex::Mutex::new(); - static mut COUNTER: u64 = 0; + static mut COUNTER: u64 = 1; unsafe { let _guard = GUARD.lock(); @@ -1058,7 +1059,7 @@ impl ThreadId { let id = COUNTER; COUNTER += 1; - ThreadId(id) + ThreadId(NonZeroU64::new(id).unwrap()) } } } From a291d4e94cbcd9082f942147cde92b8ae5a39cdc Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Tue, 19 Mar 2019 15:54:21 -0400 Subject: [PATCH 32/48] convert field/method confusion help to suggestions --- src/librustc_typeck/check/method/suggest.rs | 83 +++++++++++-------- .../issue-18343.stderr | 4 +- .../issue-2392.stderr | 48 +++++++---- .../issue-32128.stderr | 4 +- .../issue-33784.stderr | 12 ++- 5 files changed, 98 insertions(+), 53 deletions(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 4bf6471a6293c..83a98c38c90ce 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -332,44 +332,61 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If the method name is the name of a field with a function or closure type, // give a helping note that it has to be called as `(x.f)(...)`. if let SelfSource::MethodCall(expr) = source { - for (ty, _) in self.autoderef(span, rcvr_ty) { - if let ty::Adt(def, substs) = ty.sty { - if !def.is_enum() { + let field_receiver = self + .autoderef(span, rcvr_ty) + .find_map(|(ty, _)| match ty.sty { + ty::Adt(def, substs) if !def.is_enum() => { let variant = &def.non_enum_variant(); - if let Some(index) = self.tcx.find_field_index(item_name, variant) { + self.tcx.find_field_index(item_name, variant).map(|index| { let field = &variant.fields[index]; - let snippet = tcx.sess.source_map().span_to_snippet(expr.span); - let expr_string = match snippet { - Ok(expr_string) => expr_string, - _ => "s".into(), // Default to a generic placeholder for the - // expression when we can't generate a - // string snippet. - }; - let field_ty = field.ty(tcx, substs); - let scope = self.tcx.hir().get_module_parent_by_hir_id( - self.body_id); - if field.vis.is_accessible_from(scope, self.tcx) { - if self.is_fn_ty(&field_ty, span) { - err.help(&format!("use `({0}.{1})(...)` if you \ - meant to call the function \ - stored in the `{1}` field", - expr_string, - item_name)); - } else { - err.help(&format!("did you mean to write `{0}.{1}` \ - instead of `{0}.{1}(...)`?", - expr_string, - item_name)); - } - err.span_label(span, "field, not a method"); - } else { - err.span_label(span, "private field, not a method"); - } - break; - } + (field, field_ty) + }) + } + _ => None, + }); + + if let Some((field, field_ty)) = field_receiver { + let scope = self.tcx.hir().get_module_parent_by_hir_id(self.body_id); + let is_accessible = field.vis.is_accessible_from(scope, self.tcx); + + if is_accessible { + if self.is_fn_ty(&field_ty, span) { + let expr_span = expr.span.to(item_name.span); + err.multipart_suggestion( + &format!( + "to call the function stored in `{}`, \ + surround the field access with parentheses", + item_name, + ), + vec![ + (expr_span.shrink_to_lo(), '('.to_string()), + (expr_span.shrink_to_hi(), ')'.to_string()), + ], + Applicability::MachineApplicable, + ); + } else { + let call_expr = self.tcx.hir().expect_expr_by_hir_id( + self.tcx.hir().get_parent_node_by_hir_id(expr.hir_id), + ); + + let span = call_expr.span.trim_start(item_name.span).unwrap(); + + err.span_suggestion( + span, + "remove the arguments", + String::new(), + Applicability::MaybeIncorrect, + ); } } + + let field_kind = if is_accessible { + "field" + } else { + "private field" + }; + err.span_label(item_name.span, format!("{}, not a method", field_kind)); } } else { err.span_label(span, format!("{} not found in `{}`", item_kind, ty_str)); diff --git a/src/test/ui/confuse-field-and-method/issue-18343.stderr b/src/test/ui/confuse-field-and-method/issue-18343.stderr index 36112cd0e10c9..03f9d990dbb23 100644 --- a/src/test/ui/confuse-field-and-method/issue-18343.stderr +++ b/src/test/ui/confuse-field-and-method/issue-18343.stderr @@ -6,8 +6,10 @@ LL | struct Obj where F: FnMut() -> u32 { ... LL | o.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(o.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (o.closure)(); + | ^ ^ error: aborting due to previous error diff --git a/src/test/ui/confuse-field-and-method/issue-2392.stderr b/src/test/ui/confuse-field-and-method/issue-2392.stderr index 7cd1941d80e83..a3ad54da025a4 100644 --- a/src/test/ui/confuse-field-and-method/issue-2392.stderr +++ b/src/test/ui/confuse-field-and-method/issue-2392.stderr @@ -6,8 +6,10 @@ LL | struct Obj where F: FnOnce() -> u32 { ... LL | o_closure.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(o_closure.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (o_closure.closure)(); + | ^ ^ error[E0599]: no method named `not_closure` found for type `Obj<[closure@$DIR/issue-2392.rs:39:36: 39:41]>` in the current scope --> $DIR/issue-2392.rs:42:15 @@ -16,9 +18,9 @@ LL | struct Obj where F: FnOnce() -> u32 { | -------------------------------------- method `not_closure` not found for this ... LL | o_closure.not_closure(); - | ^^^^^^^^^^^ field, not a method - | - = help: did you mean to write `o_closure.not_closure` instead of `o_closure.not_closure(...)`? + | ^^^^^^^^^^^-- help: remove the arguments + | | + | field, not a method error[E0599]: no method named `closure` found for type `Obj u32 {func}>` in the current scope --> $DIR/issue-2392.rs:46:12 @@ -28,8 +30,10 @@ LL | struct Obj where F: FnOnce() -> u32 { ... LL | o_func.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(o_func.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (o_func.closure)(); + | ^ ^ error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope --> $DIR/issue-2392.rs:49:14 @@ -39,8 +43,10 @@ LL | struct BoxedObj { ... LL | boxed_fn.boxed_closure(); | ^^^^^^^^^^^^^ field, not a method +help: to call the function stored in `boxed_closure`, surround the field access with parentheses | - = help: use `(boxed_fn.boxed_closure)(...)` if you meant to call the function stored in the `boxed_closure` field +LL | (boxed_fn.boxed_closure)(); + | ^ ^ error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope --> $DIR/issue-2392.rs:52:19 @@ -50,8 +56,10 @@ LL | struct BoxedObj { ... LL | boxed_closure.boxed_closure(); | ^^^^^^^^^^^^^ field, not a method +help: to call the function stored in `boxed_closure`, surround the field access with parentheses | - = help: use `(boxed_closure.boxed_closure)(...)` if you meant to call the function stored in the `boxed_closure` field +LL | (boxed_closure.boxed_closure)(); + | ^ ^ error[E0599]: no method named `closure` found for type `Obj u32 {func}>` in the current scope --> $DIR/issue-2392.rs:57:12 @@ -61,8 +69,10 @@ LL | struct Obj where F: FnOnce() -> u32 { ... LL | w.wrap.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(w.wrap.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (w.wrap.closure)(); + | ^ ^ error[E0599]: no method named `not_closure` found for type `Obj u32 {func}>` in the current scope --> $DIR/issue-2392.rs:59:12 @@ -71,9 +81,9 @@ LL | struct Obj where F: FnOnce() -> u32 { | -------------------------------------- method `not_closure` not found for this ... LL | w.wrap.not_closure(); - | ^^^^^^^^^^^ field, not a method - | - = help: did you mean to write `w.wrap.not_closure` instead of `w.wrap.not_closure(...)`? + | ^^^^^^^^^^^-- help: remove the arguments + | | + | field, not a method error[E0599]: no method named `closure` found for type `Obj + 'static)>>` in the current scope --> $DIR/issue-2392.rs:62:24 @@ -83,8 +93,10 @@ LL | struct Obj where F: FnOnce() -> u32 { ... LL | check_expression().closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(check_expression().closure)(...)` if you meant to call the function stored in the `closure` field +LL | (check_expression().closure)(); + | ^ ^ error[E0599]: no method named `f1` found for type `FuncContainer` in the current scope --> $DIR/issue-2392.rs:68:31 @@ -94,8 +106,10 @@ LL | struct FuncContainer { ... LL | (*self.container).f1(1); | ^^ field, not a method +help: to call the function stored in `f1`, surround the field access with parentheses | - = help: use `((*self.container).f1)(...)` if you meant to call the function stored in the `f1` field +LL | ((*self.container).f1)(1); + | ^ ^ error[E0599]: no method named `f2` found for type `FuncContainer` in the current scope --> $DIR/issue-2392.rs:69:31 @@ -105,8 +119,10 @@ LL | struct FuncContainer { ... LL | (*self.container).f2(1); | ^^ field, not a method +help: to call the function stored in `f2`, surround the field access with parentheses | - = help: use `((*self.container).f2)(...)` if you meant to call the function stored in the `f2` field +LL | ((*self.container).f2)(1); + | ^ ^ error[E0599]: no method named `f3` found for type `FuncContainer` in the current scope --> $DIR/issue-2392.rs:70:31 @@ -116,8 +132,10 @@ LL | struct FuncContainer { ... LL | (*self.container).f3(1); | ^^ field, not a method +help: to call the function stored in `f3`, surround the field access with parentheses | - = help: use `((*self.container).f3)(...)` if you meant to call the function stored in the `f3` field +LL | ((*self.container).f3)(1); + | ^ ^ error: aborting due to 11 previous errors diff --git a/src/test/ui/confuse-field-and-method/issue-32128.stderr b/src/test/ui/confuse-field-and-method/issue-32128.stderr index 902f60668f2ed..fbabb3a88cc6c 100644 --- a/src/test/ui/confuse-field-and-method/issue-32128.stderr +++ b/src/test/ui/confuse-field-and-method/issue-32128.stderr @@ -6,8 +6,10 @@ LL | struct Example { ... LL | demo.example(1); | ^^^^^^^ field, not a method +help: to call the function stored in `example`, surround the field access with parentheses | - = help: use `(demo.example)(...)` if you meant to call the function stored in the `example` field +LL | (demo.example)(1); + | ^ ^ error: aborting due to previous error diff --git a/src/test/ui/confuse-field-and-method/issue-33784.stderr b/src/test/ui/confuse-field-and-method/issue-33784.stderr index cce961f1e4edc..60f1a932f4442 100644 --- a/src/test/ui/confuse-field-and-method/issue-33784.stderr +++ b/src/test/ui/confuse-field-and-method/issue-33784.stderr @@ -3,24 +3,30 @@ error[E0599]: no method named `closure` found for type `&Obj<[closure@$DIR/issue | LL | p.closure(); | ^^^^^^^ field, not a method +help: to call the function stored in `closure`, surround the field access with parentheses | - = help: use `(p.closure)(...)` if you meant to call the function stored in the `closure` field +LL | (p.closure)(); + | ^ ^ error[E0599]: no method named `fn_ptr` found for type `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope --> $DIR/issue-33784.rs:29:7 | LL | q.fn_ptr(); | ^^^^^^ field, not a method +help: to call the function stored in `fn_ptr`, surround the field access with parentheses | - = help: use `(q.fn_ptr)(...)` if you meant to call the function stored in the `fn_ptr` field +LL | (q.fn_ptr)(); + | ^ ^ error[E0599]: no method named `c_fn_ptr` found for type `&D` in the current scope --> $DIR/issue-33784.rs:32:7 | LL | s.c_fn_ptr(); | ^^^^^^^^ field, not a method +help: to call the function stored in `c_fn_ptr`, surround the field access with parentheses | - = help: use `(s.c_fn_ptr)(...)` if you meant to call the function stored in the `c_fn_ptr` field +LL | (s.c_fn_ptr)(); + | ^ ^ error: aborting due to 3 previous errors From 757eb679927e2c85457f567487e887eb080eb7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 19 Mar 2019 13:17:25 -0700 Subject: [PATCH 33/48] review comments --- src/librustc/hir/mod.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/parse/parser.rs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 785d7745b297b..51d91cc562f68 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2173,7 +2173,7 @@ impl StructField { /// Id of the whole struct lives in `Item`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum VariantData { - Struct(HirVec, HirId, bool), + Struct(HirVec, HirId, /* recovered */ bool), Tuple(HirVec, HirId), Unit(HirId), } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5da00ef8ebee2..2cbd2dfeb25d6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -620,7 +620,7 @@ pub enum PatKind { /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`). /// The `bool` is `true` in the presence of a `..`. - Struct(Path, Vec>, bool), + Struct(Path, Vec>, /* recovered */ bool), /// A tuple struct/variant pattern (`Variant(x, y, .., z)`). /// If the `..` pattern fragment is present, then `Option` denotes its position. diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 360a101a64faf..361ecce5bc438 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6902,7 +6902,9 @@ impl<'a> Parser<'a> { } } - fn parse_record_struct_body(&mut self) -> PResult<'a, (Vec, bool)> { + fn parse_record_struct_body( + &mut self, + ) -> PResult<'a, (Vec, /* recovered */ bool)> { let mut fields = Vec::new(); let mut recovered = false; if self.eat(&token::OpenDelim(token::Brace)) { From 46a8beb4b2536740b632d01abff8d341bbf20b6d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 20 Mar 2019 01:22:19 +0100 Subject: [PATCH 34/48] Move some bench tests back from libtest --- src/libtest/lib.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 3fcba0f579145..cb0ce480e4273 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -44,3 +44,28 @@ pub fn black_box(dummy: T) -> T { pub fn black_box(dummy: T) -> T { dummy } + +#[cfg(test)] +mod tests { + use crate::Bencher; + use libtest::stats::Stats; + + #[bench] + pub fn sum_three_items(b: &mut Bencher) { + b.iter(|| { + [1e20f64, 1.5f64, -1e20f64].sum(); + }) + } + + #[bench] + pub fn sum_many_f64(b: &mut Bencher) { + let nums = [-1e30f64, 1e60, 1e30, 1.0, -1e60]; + let v = (0..500).map(|i| nums[i % 5]).collect::>(); + b.iter(|| { + v.sum(); + }) + } + + #[bench] + pub fn no_iter(_: &mut Bencher) {} +} From b6e5d7348a6205bdfec582baf150f2471b865e54 Mon Sep 17 00:00:00 2001 From: O01eg Date: Wed, 20 Mar 2019 12:50:18 +0300 Subject: [PATCH 35/48] Add messages for different verbosity levels. Output copy actions --- src/bootstrap/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 976b30a55c94b..0c3daea7a3cd6 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -726,6 +726,17 @@ impl Build { } } + pub fn is_verbose_than(&self, level: usize) -> bool { + self.verbosity > level + } + + /// Prints a message if this build is configured in more verbose mode than `level`. + fn verbose_than(&self, level: usize, msg: &str) { + if self.is_verbose_than(level) { + println!("{}", msg); + } + } + fn info(&self, msg: &str) { if self.config.dry_run { return; } println!("{}", msg); @@ -1158,6 +1169,7 @@ impl Build { /// Copies a file from `src` to `dst` pub fn copy(&self, src: &Path, dst: &Path) { if self.config.dry_run { return; } + self.verbose_than(1, &format!("Copy {:?} to {:?}", src, dst)); let _ = fs::remove_file(&dst); let metadata = t!(src.symlink_metadata()); if metadata.file_type().is_symlink() { From c1d9191fa576c600775b4fbb90a3d09ca5e0fa0b Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 20 Mar 2019 19:04:38 +0100 Subject: [PATCH 36/48] Add a test for size_of Option --- src/libstd/thread/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 40682da8f8b0f..d856f9b465e04 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1485,9 +1485,10 @@ fn _assert_sync_and_send() { mod tests { use super::Builder; use crate::any::Any; + use crate::mem; use crate::sync::mpsc::{channel, Sender}; use crate::result; - use crate::thread; + use crate::thread::{self, ThreadId}; use crate::time::Duration; use crate::u32; @@ -1717,6 +1718,11 @@ mod tests { thread::sleep(Duration::from_millis(2)); } + #[test] + fn test_size_of_option_thread_id() { + assert_eq!(mem::size_of::>(), mem::size_of::()); + } + #[test] fn test_thread_id_equal() { assert!(thread::current().id() == thread::current().id()); From c745708aa31e9a54d5a6b10f810a296fe3a56376 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 20 Mar 2019 18:32:13 +0000 Subject: [PATCH 37/48] Unify E0109, E0110 and E0111 diagnostic messages --- src/librustc_typeck/diagnostics.rs | 39 +++++++++++------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 399cd6f890c25..cde37fb23c320 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1290,45 +1290,34 @@ fn main() { "##, E0109: r##" -You tried to give a type parameter to a type which doesn't need it. Erroneous -code example: +You tried to provide a generic argument to a type which doesn't need it. +Erroneous code example: ```compile_fail,E0109 -type X = u32; // error: type arguments are not allowed on this entity +type X = u32; // error: type arguments are not allowed for this type +type Y = bool<'static>; // error: lifetime parameters are not allowed on + // this type ``` -Please check that you used the correct type and recheck its definition. Perhaps -it doesn't need the type parameter. +Check that you used the correct argument and that the definition is correct. Example: ``` -type X = u32; // this compiles +type X = u32; // ok! +type Y = bool; // ok! ``` -Note that type parameters for enum-variant constructors go after the variant, -not after the enum (`Option::None::`, not `Option::::None`). +Note that generic arguments for enum variant constructors go after the variant, +not after the enum. For example, you would write `Option::None::`, +rather than `Option::::None`. "##, E0110: r##" -You tried to give a lifetime parameter to a type which doesn't need it. -Erroneous code example: - -```compile_fail,E0110 -type X = u32<'static>; // error: lifetime parameters are not allowed on - // this type -``` - -Please check that the correct type was used and recheck its definition; perhaps -it doesn't need the lifetime parameter. Example: - -``` -type X = u32; // ok! -``` -"##, +#### Note: this error code is no longer emitted by the compiler. -E0111: r##" -You tried to give a const parameter to a type which doesn't need it. +You tried to provide a lifetime to a type which doesn't need it. +See `E0109` for more details. "##, E0116: r##" From 4900585a4f15f93bb466f8c194445a0e9e628d49 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 20 Mar 2019 18:32:30 +0000 Subject: [PATCH 38/48] Unify E0109, E0110 and E0111 errors --- src/librustc_typeck/astconv.rs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index df8b1bcfe706e..c65f3443fbb54 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1486,37 +1486,34 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { segment.with_generic_args(|generic_args| { let (mut err_for_lt, mut err_for_ty, mut err_for_ct) = (false, false, false); for arg in &generic_args.args { - let (mut span_err, span, kind) = match arg { - // FIXME(varkor): unify E0109, E0110 and E0111. + let (span, kind) = match arg { hir::GenericArg::Lifetime(lt) => { if err_for_lt { continue } err_for_lt = true; has_err = true; - (struct_span_err!(self.tcx().sess, lt.span, E0110, - "lifetime arguments are not allowed on this entity"), - lt.span, - "lifetime") + (lt.span, "lifetime") } hir::GenericArg::Type(ty) => { if err_for_ty { continue } err_for_ty = true; has_err = true; - (struct_span_err!(self.tcx().sess, ty.span, E0109, - "type arguments are not allowed on this entity"), - ty.span, - "type") + (ty.span, "type") } hir::GenericArg::Const(ct) => { if err_for_ct { continue } err_for_ct = true; - (struct_span_err!(self.tcx().sess, ct.span, E0111, - "const parameters are not allowed on this type"), - ct.span, - "const") + (ct.span, "const") } }; - span_err.span_label(span, format!("{} argument not allowed", kind)) - .emit(); + let mut err = struct_span_err!( + self.tcx().sess, + span, + E0109, + "{} arguments are not allowed for this type", + kind, + ); + err.span_label(span, format!("{} argument not allowed", kind)); + err.emit(); if err_for_lt && err_for_ty && err_for_ct { break; } From aff175b328d8d35969e5a76aa0fff4d6c4a5d262 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 20 Mar 2019 18:32:52 +0000 Subject: [PATCH 39/48] Update tests --- src/test/ui/enum-variant-generic-args.rs | 36 +++++++------- src/test/ui/enum-variant-generic-args.stderr | 36 +++++++------- src/test/ui/error-codes/E0109.stderr | 2 +- src/test/ui/error-codes/E0110.rs | 2 +- src/test/ui/error-codes/E0110.stderr | 4 +- src/test/ui/issues/issue-22706.rs | 2 +- src/test/ui/issues/issue-22706.stderr | 2 +- src/test/ui/mod-subitem-as-enum-variant.rs | 2 +- .../ui/mod-subitem-as-enum-variant.stderr | 2 +- src/test/ui/prim-with-args.rs | 44 ++++++++--------- src/test/ui/prim-with-args.stderr | 47 +++++++++---------- .../ui/qualified/qualified-path-params-2.rs | 2 +- .../qualified/qualified-path-params-2.stderr | 2 +- .../collections.rs | 12 ++--- .../collections.stderr | 13 +++-- .../construct_with_other_type.rs | 8 ++-- .../construct_with_other_type.stderr | 8 ++-- ...ic_associated_type_undeclared_lifetimes.rs | 8 ++-- ...ssociated_type_undeclared_lifetimes.stderr | 10 ++-- .../iterable.rs | 14 +++--- .../iterable.stderr | 14 +++--- .../parameter_number_and_kind.rs | 12 ++--- .../parameter_number_and_kind.stderr | 13 +++-- .../pointer_family.rs | 8 ++-- .../pointer_family.stderr | 8 ++-- .../streaming_iterator.rs | 10 ++-- .../streaming_iterator.stderr | 12 ++--- .../ui/structs/struct-path-associated-type.rs | 6 +-- .../struct-path-associated-type.stderr | 6 +-- src/test/ui/structs/struct-path-self.rs | 6 +-- src/test/ui/structs/struct-path-self.stderr | 6 +-- src/test/ui/type-alias-enum-variants.rs | 2 +- src/test/ui/type-alias-enum-variants.stderr | 2 +- 33 files changed, 179 insertions(+), 182 deletions(-) diff --git a/src/test/ui/enum-variant-generic-args.rs b/src/test/ui/enum-variant-generic-args.rs index 6eddd70964546..dd1f5f334df1d 100644 --- a/src/test/ui/enum-variant-generic-args.rs +++ b/src/test/ui/enum-variant-generic-args.rs @@ -9,27 +9,27 @@ impl Enum { Self::TSVariant(()); //~^ ERROR mismatched types [E0308] Self::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] Self::<()>::TSVariant(()); - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] //~^^ ERROR mismatched types [E0308] Self::<()>::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed on this entity [E0109] - //~^^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] + //~^^ ERROR type arguments are not allowed for this type [E0109] } fn s_variant() { Self::SVariant { v: () }; //~^ ERROR mismatched types [E0308] Self::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] //~^^ ERROR mismatched types [E0308] Self::<()>::SVariant { v: () }; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] //~^^ ERROR mismatched types [E0308] Self::<()>::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed on this entity [E0109] - //~^^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] + //~^^ ERROR type arguments are not allowed for this type [E0109] //~^^^ ERROR mismatched types [E0308] } } @@ -38,36 +38,36 @@ fn main() { // Tuple struct variant Enum::<()>::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] Alias::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] Alias::<()>::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] AliasFixed::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] AliasFixed::<()>::TSVariant(()); //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] AliasFixed::<()>::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] // Struct variant Enum::<()>::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] Alias::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] Alias::<()>::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] AliasFixed::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] AliasFixed::<()>::SVariant { v: () }; //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] AliasFixed::<()>::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] //~^^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] } diff --git a/src/test/ui/enum-variant-generic-args.stderr b/src/test/ui/enum-variant-generic-args.stderr index 4d3b576734643..09b9a4eed6be8 100644 --- a/src/test/ui/enum-variant-generic-args.stderr +++ b/src/test/ui/enum-variant-generic-args.stderr @@ -7,13 +7,13 @@ LL | Self::TSVariant(()); = note: expected type `T` found type `()` -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:11:27 | LL | Self::TSVariant::<()>(()); | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:13:16 | LL | Self::<()>::TSVariant(()); @@ -28,13 +28,13 @@ LL | Self::<()>::TSVariant(()); = note: expected type `T` found type `()` -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:16:16 | LL | Self::<()>::TSVariant::<()>(()); | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:16:33 | LL | Self::<()>::TSVariant::<()>(()); @@ -49,7 +49,7 @@ LL | Self::SVariant { v: () }; = note: expected type `T` found type `()` -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:24:26 | LL | Self::SVariant::<()> { v: () }; @@ -64,7 +64,7 @@ LL | Self::SVariant::<()> { v: () }; = note: expected type `T` found type `()` -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:27:16 | LL | Self::<()>::SVariant { v: () }; @@ -79,13 +79,13 @@ LL | Self::<()>::SVariant { v: () }; = note: expected type `T` found type `()` -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:30:16 | LL | Self::<()>::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:30:32 | LL | Self::<()>::SVariant::<()> { v: () }; @@ -100,25 +100,25 @@ LL | Self::<()>::SVariant::<()> { v: () }; = note: expected type `T` found type `()` -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:40:29 | LL | Enum::<()>::TSVariant::<()>(()); | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:43:24 | LL | Alias::TSVariant::<()>(()); | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:45:30 | LL | Alias::<()>::TSVariant::<()>(()); | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:48:29 | LL | AliasFixed::TSVariant::<()>(()); @@ -136,31 +136,31 @@ error[E0107]: wrong number of type arguments: expected 0, found 1 LL | AliasFixed::<()>::TSVariant::<()>(()); | ^^ unexpected type argument -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:52:35 | LL | AliasFixed::<()>::TSVariant::<()>(()); | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:58:28 | LL | Enum::<()>::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:61:23 | LL | Alias::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:63:29 | LL | Alias::<()>::SVariant::<()> { v: () }; | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:66:28 | LL | AliasFixed::SVariant::<()> { v: () }; @@ -178,7 +178,7 @@ error[E0107]: wrong number of type arguments: expected 0, found 1 LL | AliasFixed::<()>::SVariant::<()> { v: () }; | ^^ unexpected type argument -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/enum-variant-generic-args.rs:70:34 | LL | AliasFixed::<()>::SVariant::<()> { v: () }; diff --git a/src/test/ui/error-codes/E0109.stderr b/src/test/ui/error-codes/E0109.stderr index a807f2d44a6fe..577e286fcc6ce 100644 --- a/src/test/ui/error-codes/E0109.stderr +++ b/src/test/ui/error-codes/E0109.stderr @@ -1,4 +1,4 @@ -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/E0109.rs:1:14 | LL | type X = u32; diff --git a/src/test/ui/error-codes/E0110.rs b/src/test/ui/error-codes/E0110.rs index 764b62b8dfecf..314c7f5af6036 100644 --- a/src/test/ui/error-codes/E0110.rs +++ b/src/test/ui/error-codes/E0110.rs @@ -1,3 +1,3 @@ -type X = u32<'static>; //~ ERROR E0110 +type X = u32<'static>; //~ ERROR E0109 fn main() {} diff --git a/src/test/ui/error-codes/E0110.stderr b/src/test/ui/error-codes/E0110.stderr index 3bc4775bdc12f..b022131808738 100644 --- a/src/test/ui/error-codes/E0110.stderr +++ b/src/test/ui/error-codes/E0110.stderr @@ -1,4 +1,4 @@ -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/E0110.rs:1:14 | LL | type X = u32<'static>; @@ -6,4 +6,4 @@ LL | type X = u32<'static>; error: aborting due to previous error -For more information about this error, try `rustc --explain E0110`. +For more information about this error, try `rustc --explain E0109`. diff --git a/src/test/ui/issues/issue-22706.rs b/src/test/ui/issues/issue-22706.rs index 413a0d9a4943a..28e8a72280481 100644 --- a/src/test/ui/issues/issue-22706.rs +++ b/src/test/ui/issues/issue-22706.rs @@ -1,3 +1,3 @@ fn is_copy::Copy>() {} -//~^ ERROR type arguments are not allowed on this entity [E0109] +//~^ ERROR type arguments are not allowed for this type [E0109] fn main() {} diff --git a/src/test/ui/issues/issue-22706.stderr b/src/test/ui/issues/issue-22706.stderr index a3cf716903d20..c5929397f6501 100644 --- a/src/test/ui/issues/issue-22706.stderr +++ b/src/test/ui/issues/issue-22706.stderr @@ -1,4 +1,4 @@ -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/issue-22706.rs:1:29 | LL | fn is_copy::Copy>() {} diff --git a/src/test/ui/mod-subitem-as-enum-variant.rs b/src/test/ui/mod-subitem-as-enum-variant.rs index ec809d44e942a..cd4459ae0ff42 100644 --- a/src/test/ui/mod-subitem-as-enum-variant.rs +++ b/src/test/ui/mod-subitem-as-enum-variant.rs @@ -6,5 +6,5 @@ mod Mod { fn main() { Mod::FakeVariant::(0); Mod::::FakeVariant(0); - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] } diff --git a/src/test/ui/mod-subitem-as-enum-variant.stderr b/src/test/ui/mod-subitem-as-enum-variant.stderr index d62bad81c3d8d..72eca588208bb 100644 --- a/src/test/ui/mod-subitem-as-enum-variant.stderr +++ b/src/test/ui/mod-subitem-as-enum-variant.stderr @@ -1,4 +1,4 @@ -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/mod-subitem-as-enum-variant.rs:8:11 | LL | Mod::::FakeVariant(0); diff --git a/src/test/ui/prim-with-args.rs b/src/test/ui/prim-with-args.rs index b5df0fb76ca6a..e5beaca6abb8c 100644 --- a/src/test/ui/prim-with-args.rs +++ b/src/test/ui/prim-with-args.rs @@ -1,27 +1,27 @@ fn main() { -let x: isize; //~ ERROR type arguments are not allowed on this entity -let x: i8; //~ ERROR type arguments are not allowed on this entity -let x: i16; //~ ERROR type arguments are not allowed on this entity -let x: i32; //~ ERROR type arguments are not allowed on this entity -let x: i64; //~ ERROR type arguments are not allowed on this entity -let x: usize; //~ ERROR type arguments are not allowed on this entity -let x: u8; //~ ERROR type arguments are not allowed on this entity -let x: u16; //~ ERROR type arguments are not allowed on this entity -let x: u32; //~ ERROR type arguments are not allowed on this entity -let x: u64; //~ ERROR type arguments are not allowed on this entity -let x: char; //~ ERROR type arguments are not allowed on this entity +let x: isize; //~ ERROR type arguments are not allowed for this type +let x: i8; //~ ERROR type arguments are not allowed for this type +let x: i16; //~ ERROR type arguments are not allowed for this type +let x: i32; //~ ERROR type arguments are not allowed for this type +let x: i64; //~ ERROR type arguments are not allowed for this type +let x: usize; //~ ERROR type arguments are not allowed for this type +let x: u8; //~ ERROR type arguments are not allowed for this type +let x: u16; //~ ERROR type arguments are not allowed for this type +let x: u32; //~ ERROR type arguments are not allowed for this type +let x: u64; //~ ERROR type arguments are not allowed for this type +let x: char; //~ ERROR type arguments are not allowed for this type -let x: isize<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: i8<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: i16<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: i32<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: i64<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: usize<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: u8<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: u16<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: u32<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: u64<'static>; //~ ERROR lifetime arguments are not allowed on this entity -let x: char<'static>; //~ ERROR lifetime arguments are not allowed on this entity +let x: isize<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: i8<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: i16<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: i32<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: i64<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: usize<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: u8<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: u16<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: u32<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: u64<'static>; //~ ERROR lifetime arguments are not allowed for this type +let x: char<'static>; //~ ERROR lifetime arguments are not allowed for this type } diff --git a/src/test/ui/prim-with-args.stderr b/src/test/ui/prim-with-args.stderr index 4535633bc6f31..4bde981e7f2d4 100644 --- a/src/test/ui/prim-with-args.stderr +++ b/src/test/ui/prim-with-args.stderr @@ -1,130 +1,130 @@ -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:3:14 | LL | let x: isize; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:4:11 | LL | let x: i8; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:5:12 | LL | let x: i16; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:6:12 | LL | let x: i32; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:7:12 | LL | let x: i64; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:8:14 | LL | let x: usize; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:9:11 | LL | let x: u8; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:10:12 | LL | let x: u16; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:11:12 | LL | let x: u32; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:12:12 | LL | let x: u64; | ^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/prim-with-args.rs:13:13 | LL | let x: char; | ^^^^^ type argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:15:14 | LL | let x: isize<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:16:11 | LL | let x: i8<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:17:12 | LL | let x: i16<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:18:12 | LL | let x: i32<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:19:12 | LL | let x: i64<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:20:14 | LL | let x: usize<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:21:11 | LL | let x: u8<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:22:12 | LL | let x: u16<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:23:12 | LL | let x: u32<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:24:12 | LL | let x: u64<'static>; | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/prim-with-args.rs:25:13 | LL | let x: char<'static>; @@ -132,5 +132,4 @@ LL | let x: char<'static>; error: aborting due to 22 previous errors -Some errors occurred: E0109, E0110. -For more information about an error, try `rustc --explain E0109`. +For more information about this error, try `rustc --explain E0109`. diff --git a/src/test/ui/qualified/qualified-path-params-2.rs b/src/test/ui/qualified/qualified-path-params-2.rs index 8412983fda549..ebdd749046239 100644 --- a/src/test/ui/qualified/qualified-path-params-2.rs +++ b/src/test/ui/qualified/qualified-path-params-2.rs @@ -16,7 +16,7 @@ impl S { } type A = ::A::f; -//~^ ERROR type arguments are not allowed on this entity +//~^ ERROR type arguments are not allowed for this type //~| ERROR ambiguous associated type fn main() {} diff --git a/src/test/ui/qualified/qualified-path-params-2.stderr b/src/test/ui/qualified/qualified-path-params-2.stderr index 4e073841b9740..2d14d6c5aa898 100644 --- a/src/test/ui/qualified/qualified-path-params-2.stderr +++ b/src/test/ui/qualified/qualified-path-params-2.stderr @@ -1,4 +1,4 @@ -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/qualified-path-params-2.rs:18:26 | LL | type A = ::A::f; diff --git a/src/test/ui/rfc1598-generic-associated-types/collections.rs b/src/test/ui/rfc1598-generic-associated-types/collections.rs index 5414bb4a6d20e..ede6a3b2b3938 100644 --- a/src/test/ui/rfc1598-generic-associated-types/collections.rs +++ b/src/test/ui/rfc1598-generic-associated-types/collections.rs @@ -2,7 +2,7 @@ //~^ WARNING the feature `generic_associated_types` is incomplete #![feature(associated_type_defaults)] -// FIXME(#44265): "lifetime arguments are not allowed on this entity" errors will be addressed in a +// FIXME(#44265): "lifetime arguments are not allowed for this type" errors will be addressed in a // follow-up PR. // A Collection trait and collection families. Based on @@ -15,14 +15,14 @@ trait Collection { // Test associated type defaults with parameters type Sibling: Collection = <>::Family as CollectionFamily>::Member; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] fn empty() -> Self; fn add(&mut self, value: T); fn iterate<'iter>(&'iter self) -> Self::Iter<'iter>; - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] } trait CollectionFamily { @@ -48,13 +48,13 @@ impl Collection for Vec { } fn iterate<'iter>(&'iter self) -> Self::Iter<'iter> { - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] self.iter() } } fn floatify(ints: &C) -> <>::Family as CollectionFamily>::Member -//~^ ERROR type arguments are not allowed on this entity [E0109] +//~^ ERROR type arguments are not allowed for this type [E0109] where C: Collection, { @@ -66,7 +66,7 @@ where } fn floatify_sibling(ints: &C) -> >::Sibling -//~^ ERROR type arguments are not allowed on this entity [E0109] +//~^ ERROR type arguments are not allowed for this type [E0109] where C: Collection, { diff --git a/src/test/ui/rfc1598-generic-associated-types/collections.stderr b/src/test/ui/rfc1598-generic-associated-types/collections.stderr index eeed04bd89213..d0fe5035bca46 100644 --- a/src/test/ui/rfc1598-generic-associated-types/collections.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/collections.stderr @@ -4,31 +4,31 @@ warning: the feature `generic_associated_types` is incomplete and may cause the LL | #![feature(generic_associated_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/collections.rs:56:90 | LL | fn floatify(ints: &C) -> <>::Family as CollectionFamily>::Member | ^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/collections.rs:68:69 | LL | fn floatify_sibling(ints: &C) -> >::Sibling | ^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/collections.rs:17:71 | LL | <>::Family as CollectionFamily>::Member; | ^ type argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/collections.rs:24:50 | LL | fn iterate<'iter>(&'iter self) -> Self::Iter<'iter>; | ^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/collections.rs:50:50 | LL | fn iterate<'iter>(&'iter self) -> Self::Iter<'iter> { @@ -36,5 +36,4 @@ LL | fn iterate<'iter>(&'iter self) -> Self::Iter<'iter> { error: aborting due to 5 previous errors -Some errors occurred: E0109, E0110. -For more information about an error, try `rustc --explain E0109`. +For more information about this error, try `rustc --explain E0109`. diff --git a/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.rs b/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.rs index d9c482e23e47c..3a459a4551c8d 100644 --- a/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.rs +++ b/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.rs @@ -3,7 +3,7 @@ use std::ops::Deref; -// FIXME(#44265): "lifetime arguments are not allowed on this entity" errors will be addressed in a +// FIXME(#44265): "lifetime arguments are not allowed for this type" errors will be addressed in a // follow-up PR. trait Foo { @@ -15,15 +15,15 @@ trait Baz { // This weird type tests that we can use universal function call syntax to access the Item on type Baa<'a>: Deref as Foo>::Bar<'a, 'static>>; - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] - //~| ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] + //~| ERROR lifetime arguments are not allowed for this type [E0109] } impl Baz for T where T: Foo { type Quux<'a> = T; type Baa<'a> = &'a ::Bar<'a, 'static>; - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] } fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.stderr b/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.stderr index fd6116d2da23a..b2dd523c8f597 100644 --- a/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.stderr @@ -4,19 +4,19 @@ warning: the feature `generic_associated_types` is incomplete and may cause the LL | #![feature(generic_associated_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/construct_with_other_type.rs:17:46 | LL | type Baa<'a>: Deref as Foo>::Bar<'a, 'static>>; | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/construct_with_other_type.rs:17:63 | LL | type Baa<'a>: Deref as Foo>::Bar<'a, 'static>>; | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/construct_with_other_type.rs:25:40 | LL | type Baa<'a> = &'a ::Bar<'a, 'static>; @@ -24,4 +24,4 @@ LL | type Baa<'a> = &'a ::Bar<'a, 'static>; error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0110`. +For more information about this error, try `rustc --explain E0109`. diff --git a/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs index 2e6d7470b49a2..150899a034b86 100644 --- a/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs +++ b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs @@ -3,20 +3,20 @@ use std::ops::Deref; -// FIXME(#44265): "lifetime arguments are not allowed on this entity" errors will be addressed in a +// FIXME(#44265): "lifetime arguments are not allowed for this type" errors will be addressed in a // follow-up PR. trait Iterable { type Item<'a>; type Iter<'a>: Iterator> - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] + Deref>; //~^ ERROR undeclared lifetime - //~| ERROR lifetime arguments are not allowed on this entity [E0110] + //~| ERROR lifetime arguments are not allowed for this type [E0109] fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; //~^ ERROR undeclared lifetime - //~| ERROR lifetime arguments are not allowed on this entity [E0110] + //~| ERROR lifetime arguments are not allowed for this type [E0109] } fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr index 3cebab6389557..d65edc6f7e247 100644 --- a/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr @@ -16,19 +16,19 @@ error[E0261]: use of undeclared lifetime name `'undeclared` LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; | ^^^^^^^^^^^ undeclared lifetime -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/generic_associated_type_undeclared_lifetimes.rs:11:47 | LL | type Iter<'a>: Iterator> | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/generic_associated_type_undeclared_lifetimes.rs:13:37 | LL | + Deref>; | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/generic_associated_type_undeclared_lifetimes.rs:17:41 | LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; @@ -36,5 +36,5 @@ LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; error: aborting due to 5 previous errors -Some errors occurred: E0110, E0261. -For more information about an error, try `rustc --explain E0110`. +Some errors occurred: E0109, E0261. +For more information about an error, try `rustc --explain E0109`. diff --git a/src/test/ui/rfc1598-generic-associated-types/iterable.rs b/src/test/ui/rfc1598-generic-associated-types/iterable.rs index 69258506651c4..29953b9db1a31 100644 --- a/src/test/ui/rfc1598-generic-associated-types/iterable.rs +++ b/src/test/ui/rfc1598-generic-associated-types/iterable.rs @@ -3,16 +3,16 @@ use std::ops::Deref; -// FIXME(#44265): "lifetime arguments are not allowed on this entity" errors will be addressed in a +// FIXME(#44265): "lifetime arguments are not allowed for this type" errors will be addressed in a // follow-up PR. trait Iterable { type Item<'a>; type Iter<'a>: Iterator>; - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] fn iter<'a>(&'a self) -> Self::Iter<'a>; - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] } // Impl for struct type @@ -21,7 +21,7 @@ impl Iterable for Vec { type Iter<'a> = std::slice::Iter<'a, T>; fn iter<'a>(&'a self) -> Self::Iter<'a> { - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] self.iter() } } @@ -32,18 +32,18 @@ impl Iterable for [T] { type Iter<'a> = std::slice::Iter<'a, T>; fn iter<'a>(&'a self) -> Self::Iter<'a> { - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] self.iter() } } fn make_iter<'a, I: Iterable>(it: &'a I) -> I::Iter<'a> { - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] it.iter() } fn get_first<'a, I: Iterable>(it: &'a I) -> Option> { - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] it.iter().next() } diff --git a/src/test/ui/rfc1598-generic-associated-types/iterable.stderr b/src/test/ui/rfc1598-generic-associated-types/iterable.stderr index cc3ade6f39d90..6d5d0cc382840 100644 --- a/src/test/ui/rfc1598-generic-associated-types/iterable.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/iterable.stderr @@ -4,37 +4,37 @@ warning: the feature `generic_associated_types` is incomplete and may cause the LL | #![feature(generic_associated_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/iterable.rs:11:47 | LL | type Iter<'a>: Iterator>; | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/iterable.rs:40:53 | LL | fn make_iter<'a, I: Iterable>(it: &'a I) -> I::Iter<'a> { | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/iterable.rs:45:60 | LL | fn get_first<'a, I: Iterable>(it: &'a I) -> Option> { | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/iterable.rs:14:41 | LL | fn iter<'a>(&'a self) -> Self::Iter<'a>; | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/iterable.rs:23:41 | LL | fn iter<'a>(&'a self) -> Self::Iter<'a> { | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/iterable.rs:34:41 | LL | fn iter<'a>(&'a self) -> Self::Iter<'a> { @@ -42,4 +42,4 @@ LL | fn iter<'a>(&'a self) -> Self::Iter<'a> { error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0110`. +For more information about this error, try `rustc --explain E0109`. diff --git a/src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.rs b/src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.rs index 851e331a0e965..aa3f4b186da83 100644 --- a/src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.rs +++ b/src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.rs @@ -2,7 +2,7 @@ //~^ WARNING the feature `generic_associated_types` is incomplete #![feature(associated_type_defaults)] -// FIXME(#44265): "lifetime arguments are not allowed on this entity" errors will be addressed in a +// FIXME(#44265): "lifetime arguments are not allowed for this type" errors will be addressed in a // follow-up PR. // FIXME(#44265): Update expected errors once E110 is resolved, now does not get past `trait Foo`. @@ -15,13 +15,13 @@ trait Foo { type E<'a, T>; // Test parameters in default values type FOk = Self::E<'static, T>; - //~^ ERROR type arguments are not allowed on this entity [E0109] - //~| ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR type arguments are not allowed for this type [E0109] + //~| ERROR lifetime arguments are not allowed for this type [E0109] type FErr1 = Self::E<'static, 'static>; // Error - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] type FErr2 = Self::E<'static, T, u32>; // Error - //~^ ERROR type arguments are not allowed on this entity [E0109] - //~| ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR type arguments are not allowed for this type [E0109] + //~| ERROR lifetime arguments are not allowed for this type [E0109] } struct Fooy; diff --git a/src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.stderr b/src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.stderr index 265b0fab77061..817d911184d0a 100644 --- a/src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/parameter_number_and_kind.stderr @@ -4,31 +4,31 @@ warning: the feature `generic_associated_types` is incomplete and may cause the LL | #![feature(generic_associated_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/parameter_number_and_kind.rs:17:27 | LL | type FOk = Self::E<'static, T>; | ^^^^^^^ lifetime argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/parameter_number_and_kind.rs:17:36 | LL | type FOk = Self::E<'static, T>; | ^ type argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/parameter_number_and_kind.rs:20:26 | LL | type FErr1 = Self::E<'static, 'static>; // Error | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/parameter_number_and_kind.rs:22:29 | LL | type FErr2 = Self::E<'static, T, u32>; // Error | ^^^^^^^ lifetime argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/parameter_number_and_kind.rs:22:38 | LL | type FErr2 = Self::E<'static, T, u32>; // Error @@ -36,5 +36,4 @@ LL | type FErr2 = Self::E<'static, T, u32>; // Error error: aborting due to 5 previous errors -Some errors occurred: E0109, E0110. -For more information about an error, try `rustc --explain E0109`. +For more information about this error, try `rustc --explain E0109`. diff --git a/src/test/ui/rfc1598-generic-associated-types/pointer_family.rs b/src/test/ui/rfc1598-generic-associated-types/pointer_family.rs index 2d188aed42778..edeeaba756549 100644 --- a/src/test/ui/rfc1598-generic-associated-types/pointer_family.rs +++ b/src/test/ui/rfc1598-generic-associated-types/pointer_family.rs @@ -10,7 +10,7 @@ use std::ops::Deref; trait PointerFamily { type Pointer: Deref; fn new(value: T) -> Self::Pointer; - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] } struct ArcFamily; @@ -18,7 +18,7 @@ struct ArcFamily; impl PointerFamily for ArcFamily { type Pointer = Arc; fn new(value: T) -> Self::Pointer { - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] Arc::new(value) } } @@ -28,14 +28,14 @@ struct RcFamily; impl PointerFamily for RcFamily { type Pointer = Rc; fn new(value: T) -> Self::Pointer { - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] Rc::new(value) } } struct Foo { bar: P::Pointer, - //~^ ERROR type arguments are not allowed on this entity [E0109] + //~^ ERROR type arguments are not allowed for this type [E0109] } fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/pointer_family.stderr b/src/test/ui/rfc1598-generic-associated-types/pointer_family.stderr index 2b9eed2a688a2..0966f8f9422aa 100644 --- a/src/test/ui/rfc1598-generic-associated-types/pointer_family.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/pointer_family.stderr @@ -4,25 +4,25 @@ warning: the feature `generic_associated_types` is incomplete and may cause the LL | #![feature(generic_associated_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/pointer_family.rs:37:21 | LL | bar: P::Pointer, | ^^^^^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/pointer_family.rs:12:42 | LL | fn new(value: T) -> Self::Pointer; | ^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/pointer_family.rs:20:42 | LL | fn new(value: T) -> Self::Pointer { | ^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/pointer_family.rs:30:42 | LL | fn new(value: T) -> Self::Pointer { diff --git a/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs index e0184164b3ac2..4e177fb41d732 100644 --- a/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs +++ b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs @@ -10,13 +10,13 @@ trait StreamingIterator { type Item<'a>; // Applying the lifetime parameter `'a` to `Self::Item` inside the trait. fn next<'a>(&'a self) -> Option>; - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] } struct Foo { // Applying a concrete lifetime to the constructor outside the trait. bar: ::Item<'static>, - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] } // Users can bound parameters by the type constructed by that trait's associated type constructor @@ -24,7 +24,7 @@ struct Foo { //FIXME(sunjay): This next line should parse and be valid //fn foo StreamingIterator=&'a [i32]>>(iter: T) { /* ... */ } fn foo(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ } -//~^ ERROR lifetime arguments are not allowed on this entity [E0110] +//~^ ERROR lifetime arguments are not allowed for this type [E0109] // Full example of enumerate iterator @@ -36,9 +36,9 @@ struct StreamEnumerate { impl StreamingIterator for StreamEnumerate { type Item<'a> = (usize, I::Item<'a>); - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] fn next<'a>(&'a self) -> Option> { - //~^ ERROR lifetime arguments are not allowed on this entity [E0110] + //~^ ERROR lifetime arguments are not allowed for this type [E0109] match self.iter.next() { None => None, Some(val) => { diff --git a/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.stderr b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.stderr index 5afbba5d2d744..5fc1e3dddbe74 100644 --- a/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.stderr @@ -4,31 +4,31 @@ warning: the feature `generic_associated_types` is incomplete and may cause the LL | #![feature(generic_associated_types)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/streaming_iterator.rs:18:41 | LL | bar: ::Item<'static>, | ^^^^^^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/streaming_iterator.rs:26:64 | LL | fn foo(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ } | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/streaming_iterator.rs:12:48 | LL | fn next<'a>(&'a self) -> Option>; | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/streaming_iterator.rs:38:37 | LL | type Item<'a> = (usize, I::Item<'a>); | ^^ lifetime argument not allowed -error[E0110]: lifetime arguments are not allowed on this entity +error[E0109]: lifetime arguments are not allowed for this type --> $DIR/streaming_iterator.rs:40:48 | LL | fn next<'a>(&'a self) -> Option> { @@ -36,4 +36,4 @@ LL | fn next<'a>(&'a self) -> Option> { error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0110`. +For more information about this error, try `rustc --explain E0109`. diff --git a/src/test/ui/structs/struct-path-associated-type.rs b/src/test/ui/structs/struct-path-associated-type.rs index 7c770852d22d2..15b37facc502d 100644 --- a/src/test/ui/structs/struct-path-associated-type.rs +++ b/src/test/ui/structs/struct-path-associated-type.rs @@ -13,7 +13,7 @@ fn f() { //~^ ERROR expected struct, variant or union type, found associated type let z = T::A:: {}; //~^ ERROR expected struct, variant or union type, found associated type - //~| ERROR type arguments are not allowed on this entity + //~| ERROR type arguments are not allowed for this type match S { T::A {} => {} //~^ ERROR expected struct, variant or union type, found associated type @@ -22,7 +22,7 @@ fn f() { fn g>() { let s = T::A {}; // OK - let z = T::A:: {}; //~ ERROR type arguments are not allowed on this entity + let z = T::A:: {}; //~ ERROR type arguments are not allowed for this type match S { T::A {} => {} // OK } @@ -31,7 +31,7 @@ fn g>() { fn main() { let s = S::A {}; //~ ERROR ambiguous associated type let z = S::A:: {}; //~ ERROR ambiguous associated type - //~^ ERROR type arguments are not allowed on this entity + //~^ ERROR type arguments are not allowed for this type match S { S::A {} => {} //~ ERROR ambiguous associated type } diff --git a/src/test/ui/structs/struct-path-associated-type.stderr b/src/test/ui/structs/struct-path-associated-type.stderr index 0ca64ed40a50b..f054bd3d29776 100644 --- a/src/test/ui/structs/struct-path-associated-type.stderr +++ b/src/test/ui/structs/struct-path-associated-type.stderr @@ -4,7 +4,7 @@ error[E0071]: expected struct, variant or union type, found associated type LL | let s = T::A {}; | ^^^^ not a struct -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/struct-path-associated-type.rs:14:20 | LL | let z = T::A:: {}; @@ -22,7 +22,7 @@ error[E0071]: expected struct, variant or union type, found associated type LL | T::A {} => {} | ^^^^ not a struct -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/struct-path-associated-type.rs:25:20 | LL | let z = T::A:: {}; @@ -34,7 +34,7 @@ error[E0223]: ambiguous associated type LL | let s = S::A {}; | ^^^^ help: use fully-qualified syntax: `::A` -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/struct-path-associated-type.rs:33:20 | LL | let z = S::A:: {}; diff --git a/src/test/ui/structs/struct-path-self.rs b/src/test/ui/structs/struct-path-self.rs index 51ed9e5457eb7..77880bfca4074 100644 --- a/src/test/ui/structs/struct-path-self.rs +++ b/src/test/ui/structs/struct-path-self.rs @@ -6,7 +6,7 @@ trait Tr { //~^ ERROR expected struct, variant or union type, found Self let z = Self:: {}; //~^ ERROR expected struct, variant or union type, found Self - //~| ERROR type arguments are not allowed on this entity + //~| ERROR type arguments are not allowed for this type match s { Self { .. } => {} //~^ ERROR expected struct, variant or union type, found Self @@ -17,7 +17,7 @@ trait Tr { impl Tr for S { fn f() { let s = Self {}; // OK - let z = Self:: {}; //~ ERROR type arguments are not allowed on this entity + let z = Self:: {}; //~ ERROR type arguments are not allowed for this type match s { Self { .. } => {} // OK } @@ -27,7 +27,7 @@ impl Tr for S { impl S { fn g() { let s = Self {}; // OK - let z = Self:: {}; //~ ERROR type arguments are not allowed on this entity + let z = Self:: {}; //~ ERROR type arguments are not allowed for this type match s { Self { .. } => {} // OK } diff --git a/src/test/ui/structs/struct-path-self.stderr b/src/test/ui/structs/struct-path-self.stderr index 0fb02b9c44b51..d9e84acdb3cda 100644 --- a/src/test/ui/structs/struct-path-self.stderr +++ b/src/test/ui/structs/struct-path-self.stderr @@ -4,7 +4,7 @@ error[E0071]: expected struct, variant or union type, found Self LL | let s = Self {}; | ^^^^ not a struct -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/struct-path-self.rs:7:24 | LL | let z = Self:: {}; @@ -22,13 +22,13 @@ error[E0071]: expected struct, variant or union type, found Self LL | Self { .. } => {} | ^^^^ not a struct -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/struct-path-self.rs:20:24 | LL | let z = Self:: {}; | ^^ type argument not allowed -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/struct-path-self.rs:30:24 | LL | let z = Self:: {}; diff --git a/src/test/ui/type-alias-enum-variants.rs b/src/test/ui/type-alias-enum-variants.rs index 3ec200d57c55d..c5974e5569223 100644 --- a/src/test/ui/type-alias-enum-variants.rs +++ b/src/test/ui/type-alias-enum-variants.rs @@ -7,5 +7,5 @@ fn main() { let _ = Option::None::; // OK (Lint in future!) let _ = Alias::::None; // OK let _ = Alias::None::; // Error - //~^ type arguments are not allowed on this entity + //~^ type arguments are not allowed for this type } diff --git a/src/test/ui/type-alias-enum-variants.stderr b/src/test/ui/type-alias-enum-variants.stderr index cf81f5b27ac6b..55f250fa7ee52 100644 --- a/src/test/ui/type-alias-enum-variants.stderr +++ b/src/test/ui/type-alias-enum-variants.stderr @@ -1,4 +1,4 @@ -error[E0109]: type arguments are not allowed on this entity +error[E0109]: type arguments are not allowed for this type --> $DIR/type-alias-enum-variants.rs:9:27 | LL | let _ = Alias::None::; // Error From a8120d660a47559b7ae8eb798bb8f6e62d575000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 20 Mar 2019 11:45:25 -0700 Subject: [PATCH 40/48] Tweak incorrect escaped char diagnostic --- src/libsyntax/parse/lexer/mod.rs | 38 +++++++++---------- src/libsyntax/parse/parser.rs | 13 +++++-- src/test/ui/parser/byte-literals.stderr | 4 +- .../ui/parser/byte-string-literals.stderr | 4 +- .../parser/issue-23620-invalid-escapes.stderr | 24 +++--------- .../ui/parser/lex-bad-char-literals-1.stderr | 4 +- ...-bare-cr-string-literal-doc-comment.stderr | 8 +--- src/test/ui/parser/pat-tuple-3.stderr | 4 +- .../trailing-carriage-return-in-string.stderr | 8 +--- .../wrong-escape-of-curly-braces.stderr | 16 ++------ 10 files changed, 51 insertions(+), 72 deletions(-) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index bcd53dbfeb2c5..cd4944deadb10 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -968,9 +968,10 @@ impl<'a> StringReader<'a> { } else { let span = self.mk_sp(start, self.pos); let mut suggestion = "\\u{".to_owned(); + let msg = "incorrect unicode escape sequence"; let mut err = self.sess.span_diagnostic.struct_span_err( span, - "incorrect unicode escape sequence", + msg, ); let mut i = 0; while let (Some(ch), true) = (self.ch, i < 6) { @@ -991,8 +992,8 @@ impl<'a> StringReader<'a> { Applicability::MaybeIncorrect, ); } else { - err.span_help( - span, + err.span_label(span, msg); + err.help( "format of unicode escape sequences is `\\u{...}`", ); } @@ -1018,25 +1019,24 @@ impl<'a> StringReader<'a> { } c => { let pos = self.pos; - let mut err = self.struct_err_span_char(escaped_pos, - pos, - if ascii_only { - "unknown byte escape" - } else { - "unknown character \ - escape" - }, - c); + let msg = if ascii_only { + "unknown byte escape" + } else { + "unknown character escape" + }; + let mut err = self.struct_err_span_char(escaped_pos, pos, msg, c); + err.span_label(self.mk_sp(escaped_pos, pos), msg); if e == '\r' { - err.span_help(self.mk_sp(escaped_pos, pos), - "this is an isolated carriage return; consider \ - checking your editor and version control \ - settings"); + err.help( + "this is an isolated carriage return; consider checking \ + your editor and version control settings", + ); } if (e == '{' || e == '}') && !ascii_only { - err.span_help(self.mk_sp(escaped_pos, pos), - "if used in a formatting string, curly braces \ - are escaped with `{{` and `}}`"); + err.help( + "if used in a formatting string, curly braces are escaped \ + with `{{` and `}}`", + ); } err.emit(); false diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aa70c54a1ef8a..48702cf3c4cba 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4229,19 +4229,24 @@ impl<'a> Parser<'a> { fn parse_pat_list(&mut self) -> PResult<'a, (Vec>, Option, bool)> { let mut fields = Vec::new(); let mut ddpos = None; + let mut prev_dd_sp = None; let mut trailing_comma = false; loop { if self.eat(&token::DotDot) { if ddpos.is_none() { ddpos = Some(fields.len()); + prev_dd_sp = Some(self.prev_span); } else { // Emit a friendly error, ignore `..` and continue parsing - self.struct_span_err( + let mut err = self.struct_span_err( self.prev_span, "`..` can only be used once per tuple or tuple struct pattern", - ) - .span_label(self.prev_span, "can only be used once per pattern") - .emit(); + ); + err.span_label(self.prev_span, "can only be used once per pattern"); + if let Some(sp) = prev_dd_sp { + err.span_label(sp, "previously present here"); + } + err.emit(); } } else if !self.check(&token::CloseDelim(token::Paren)) { fields.push(self.parse_pat(None)?); diff --git a/src/test/ui/parser/byte-literals.stderr b/src/test/ui/parser/byte-literals.stderr index 36cb0170a1404..4edeccfe47556 100644 --- a/src/test/ui/parser/byte-literals.stderr +++ b/src/test/ui/parser/byte-literals.stderr @@ -2,13 +2,13 @@ error: unknown byte escape: f --> $DIR/byte-literals.rs:6:21 | LL | static FOO: u8 = b'/f'; - | ^ + | ^ unknown byte escape error: unknown byte escape: f --> $DIR/byte-literals.rs:9:8 | LL | b'/f'; - | ^ + | ^ unknown byte escape error: invalid character in numeric character escape: Z --> $DIR/byte-literals.rs:10:10 diff --git a/src/test/ui/parser/byte-string-literals.stderr b/src/test/ui/parser/byte-string-literals.stderr index 2e9b13b933e2b..45c1a94b519a3 100644 --- a/src/test/ui/parser/byte-string-literals.stderr +++ b/src/test/ui/parser/byte-string-literals.stderr @@ -2,13 +2,13 @@ error: unknown byte escape: f --> $DIR/byte-string-literals.rs:6:32 | LL | static FOO: &'static [u8] = b"/f"; - | ^ + | ^ unknown byte escape error: unknown byte escape: f --> $DIR/byte-string-literals.rs:9:8 | LL | b"/f"; - | ^ + | ^ unknown byte escape error: invalid character in numeric character escape: Z --> $DIR/byte-string-literals.rs:10:10 diff --git a/src/test/ui/parser/issue-23620-invalid-escapes.stderr b/src/test/ui/parser/issue-23620-invalid-escapes.stderr index f6e476ab0cd1d..669a6d26905d1 100644 --- a/src/test/ui/parser/issue-23620-invalid-escapes.stderr +++ b/src/test/ui/parser/issue-23620-invalid-escapes.stderr @@ -14,13 +14,9 @@ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:10:15 | LL | let _ = b'/u'; - | ^^ - | -help: format of unicode escape sequences is `/u{...}` - --> $DIR/issue-23620-invalid-escapes.rs:10:15 + | ^^ incorrect unicode escape sequence | -LL | let _ = b'/u'; - | ^^ + = help: format of unicode escape sequences is `/u{...}` error: unicode escape sequences cannot be used as a byte or in a byte string --> $DIR/issue-23620-invalid-escapes.rs:10:15 @@ -80,13 +76,9 @@ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:28:28 | LL | let _ = b"/u{a4a4} /xf /u"; - | ^^ + | ^^ incorrect unicode escape sequence | -help: format of unicode escape sequences is `/u{...}` - --> $DIR/issue-23620-invalid-escapes.rs:28:28 - | -LL | let _ = b"/u{a4a4} /xf /u"; - | ^^ + = help: format of unicode escape sequences is `/u{...}` error: unicode escape sequences cannot be used as a byte or in a byte string --> $DIR/issue-23620-invalid-escapes.rs:28:28 @@ -110,13 +102,9 @@ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:34:18 | LL | let _ = "/xf /u"; - | ^^ + | ^^ incorrect unicode escape sequence | -help: format of unicode escape sequences is `/u{...}` - --> $DIR/issue-23620-invalid-escapes.rs:34:18 - | -LL | let _ = "/xf /u"; - | ^^ + = help: format of unicode escape sequences is `/u{...}` error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:39:14 diff --git a/src/test/ui/parser/lex-bad-char-literals-1.stderr b/src/test/ui/parser/lex-bad-char-literals-1.stderr index 3c8550e3dbe64..e6b71108086df 100644 --- a/src/test/ui/parser/lex-bad-char-literals-1.stderr +++ b/src/test/ui/parser/lex-bad-char-literals-1.stderr @@ -14,13 +14,13 @@ error: unknown character escape: /u{25cf} --> $DIR/lex-bad-char-literals-1.rs:11:7 | LL | '/●' - | ^ + | ^ unknown character escape error: unknown character escape: /u{25cf} --> $DIR/lex-bad-char-literals-1.rs:15:7 | LL | "/●" - | ^ + | ^ unknown character escape error: aborting due to 4 previous errors diff --git a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr index 19117bfa9c972..b4d538bf61312 100644 --- a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr +++ b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr @@ -38,13 +38,9 @@ error: unknown character escape: /r --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:27:19 | LL | let _s = "foo/ bar"; - | ^ + | ^ unknown character escape | -help: this is an isolated carriage return; consider checking your editor and version control settings - --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:27:19 - | -LL | let _s = "foo/ bar"; - | ^ + = help: this is an isolated carriage return; consider checking your editor and version control settings error: aborting due to 7 previous errors diff --git a/src/test/ui/parser/pat-tuple-3.stderr b/src/test/ui/parser/pat-tuple-3.stderr index 0ad7d27b94e54..c9f14bb90429b 100644 --- a/src/test/ui/parser/pat-tuple-3.stderr +++ b/src/test/ui/parser/pat-tuple-3.stderr @@ -2,7 +2,9 @@ error: `..` can only be used once per tuple or tuple struct pattern --> $DIR/pat-tuple-3.rs:3:19 | LL | (.., pat, ..) => {} - | ^^ can only be used once per pattern + | -- ^^ can only be used once per pattern + | | + | previously present here error: aborting due to previous error diff --git a/src/test/ui/parser/trailing-carriage-return-in-string.stderr b/src/test/ui/parser/trailing-carriage-return-in-string.stderr index 972e4296da358..f70f8ac8d7751 100644 --- a/src/test/ui/parser/trailing-carriage-return-in-string.stderr +++ b/src/test/ui/parser/trailing-carriage-return-in-string.stderr @@ -2,13 +2,9 @@ error: unknown character escape: /r --> $DIR/trailing-carriage-return-in-string.rs:10:25 | LL | let bad = "This is / a test"; - | ^ + | ^ unknown character escape | -help: this is an isolated carriage return; consider checking your editor and version control settings - --> $DIR/trailing-carriage-return-in-string.rs:10:25 - | -LL | let bad = "This is / a test"; - | ^ + = help: this is an isolated carriage return; consider checking your editor and version control settings error: aborting due to previous error diff --git a/src/test/ui/parser/wrong-escape-of-curly-braces.stderr b/src/test/ui/parser/wrong-escape-of-curly-braces.stderr index 90debfc337d83..346eba04c6500 100644 --- a/src/test/ui/parser/wrong-escape-of-curly-braces.stderr +++ b/src/test/ui/parser/wrong-escape-of-curly-braces.stderr @@ -2,25 +2,17 @@ error: unknown character escape: { --> $DIR/wrong-escape-of-curly-braces.rs:3:17 | LL | let bad = "/{it is wrong/}"; - | ^ + | ^ unknown character escape | -help: if used in a formatting string, curly braces are escaped with `{{` and `}}` - --> $DIR/wrong-escape-of-curly-braces.rs:3:17 - | -LL | let bad = "/{it is wrong/}"; - | ^ + = help: if used in a formatting string, curly braces are escaped with `{{` and `}}` error: unknown character escape: } --> $DIR/wrong-escape-of-curly-braces.rs:3:30 | LL | let bad = "/{it is wrong/}"; - | ^ + | ^ unknown character escape | -help: if used in a formatting string, curly braces are escaped with `{{` and `}}` - --> $DIR/wrong-escape-of-curly-braces.rs:3:30 - | -LL | let bad = "/{it is wrong/}"; - | ^ + = help: if used in a formatting string, curly braces are escaped with `{{` and `}}` error: aborting due to 2 previous errors From 2f8d9a23eea261152bb90fa620e96cfc2715de4a Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Wed, 20 Mar 2019 15:07:16 -0600 Subject: [PATCH 41/48] Add NAN test to docs --- src/libstd/f32.rs | 1 + src/libstd/f64.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 2fabe30fa9366..a5e28722054a5 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -970,6 +970,7 @@ impl f32 { /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32); /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32); /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32); + /// assert!((std::f32::NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index a471117f6d6fd..f69c0b8aae356 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -892,6 +892,7 @@ impl f64 { /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); + /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] From e2b5a0334de402b85af6b9aa681fe11c9a3bb6f0 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Wed, 20 Mar 2019 15:16:50 -0600 Subject: [PATCH 42/48] Fix formatting and add unit tests for panic cases --- src/libstd/f32.rs | 20 +++++++++++++++++++- src/libstd/f64.rs | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index a5e28722054a5..688d9c1aabbee 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -970,7 +970,7 @@ impl f32 { /// assert!((-3.0f32).clamp(-2.0f32, 1.0f32) == -2.0f32); /// assert!((0.0f32).clamp(-2.0f32, 1.0f32) == 0.0f32); /// assert!((2.0f32).clamp(-2.0f32, 1.0f32) == 1.0f32); - /// assert!((std::f32::NAN).clamp(-2.0f32, 1.0f32).is_nan()); + /// assert!((std::f32::NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] @@ -1582,4 +1582,22 @@ mod tests { assert_eq!(f32::from_bits(masked_nan1).to_bits(), masked_nan1); assert_eq!(f32::from_bits(masked_nan2).to_bits(), masked_nan2); } + + #[test] + #[should_panic] + fn test_clamp_min_greater_than_max() { + 1.0f32.clamp(3.0, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_min_is_nan() { + 1.0f32.clamp(NAN, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_max_is_nan() { + 1.0f32.clamp(3.0, NAN); + } } diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index f69c0b8aae356..5c3bc05c15f15 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -892,7 +892,7 @@ impl f64 { /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); - /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan()); + /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] @@ -1523,4 +1523,22 @@ mod tests { assert_eq!(f64::from_bits(masked_nan1).to_bits(), masked_nan1); assert_eq!(f64::from_bits(masked_nan2).to_bits(), masked_nan2); } + + #[test] + #[should_panic] + fn test_clamp_min_greater_than_max() { + 1.0f64.clamp(3.0, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_min_is_nan() { + 1.0f64.clamp(NAN, 1.0); + } + + #[test] + #[should_panic] + fn test_clamp_max_is_nan() { + 1.0f64.clamp(3.0, NAN); + } } From 295cc77e9472c0f61fd39e9f93d7853473f1f183 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 21 Mar 2019 01:17:45 +0300 Subject: [PATCH 43/48] cleanup: Remove compile-fail-fulldeps directory again --- .../auxiliary/lint_group_plugin_test.rs | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs deleted file mode 100644 index 16630e2b31285..0000000000000 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs +++ /dev/null @@ -1,45 +0,0 @@ -// force-host - -#![feature(plugin_registrar)] -#![feature(box_syntax, rustc_private)] - -// Load rustc as a plugin to get macros. -#[macro_use] -extern crate rustc; -extern crate rustc_plugin; - -use rustc::hir; -use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray}; -use rustc_plugin::Registry; - -declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); - -declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'"); - -struct Pass; - -impl LintPass for Pass { - fn name(&self) -> &'static str { - "Pass" - } - - fn get_lints(&self) -> LintArray { - lint_array!(TEST_LINT, PLEASE_LINT) - } -} - -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { - fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { - match &*it.ident.as_str() { - "lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"), - "pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"), - _ => {} - } - } -} - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_late_lint_pass(box Pass); - reg.register_lint_group("lint_me", None, vec![TEST_LINT, PLEASE_LINT]); -} From 72f5d9137e33fe4aa251dab44c0fc4de71a1a366 Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Wed, 20 Mar 2019 16:59:46 -0600 Subject: [PATCH 44/48] Fix f64 test --- src/libstd/f64.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 5c3bc05c15f15..b171e1c7ac93f 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -892,7 +892,7 @@ impl f64 { /// assert!((-3.0f64).clamp(-2.0f64, 1.0f64) == -2.0f64); /// assert!((0.0f64).clamp(-2.0f64, 1.0f64) == 0.0f64); /// assert!((2.0f64).clamp(-2.0f64, 1.0f64) == 1.0f64); - /// assert!((std::f64::NAN).clamp(-2.0f32, 1.0f32).is_nan()); + /// assert!((std::f64::NAN).clamp(-2.0f64, 1.0f64).is_nan()); /// ``` #[unstable(feature = "clamp", issue = "44095")] #[inline] From 16a8abe1bb159c4f1255533a4969590e3b7e0e61 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Wed, 20 Mar 2019 14:54:43 -0400 Subject: [PATCH 45/48] use suggestions for "enum instead of variant" error --- src/librustc_resolve/error_reporting.rs | 21 ++++-- .../issue-43871-enum-instead-of-variant.rs | 19 ++++++ ...issue-43871-enum-instead-of-variant.stderr | 55 ++++++++++++---- src/test/ui/glob-resolve1.stderr | 5 +- src/test/ui/resolve/privacy-enum-ctor.stderr | 65 ++++++++++++------- 5 files changed, 118 insertions(+), 47 deletions(-) diff --git a/src/librustc_resolve/error_reporting.rs b/src/librustc_resolve/error_reporting.rs index cd771d93e00f6..828ffc6d320e7 100644 --- a/src/librustc_resolve/error_reporting.rs +++ b/src/librustc_resolve/error_reporting.rs @@ -293,13 +293,20 @@ impl<'a> Resolver<'a> { (Def::Enum(..), PathSource::TupleStruct) | (Def::Enum(..), PathSource::Expr(..)) => { if let Some(variants) = self.collect_enum_variants(def) { - err.note(&format!("did you mean to use one \ - of the following variants?\n{}", - variants.iter() - .map(|suggestion| path_names_to_string(suggestion)) - .map(|suggestion| format!("- `{}`", suggestion)) - .collect::>() - .join("\n"))); + if !variants.is_empty() { + let msg = if variants.len() == 1 { + "try using the enum's variant" + } else { + "try using one of the enum's variants" + }; + + err.span_suggestions( + span, + msg, + variants.iter().map(path_names_to_string), + Applicability::MaybeIncorrect, + ); + } } else { err.note("did you mean to use one of the enum's variants?"); } diff --git a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs index f5dbab1ef3586..7d3aba364897f 100644 --- a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs +++ b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs @@ -1,5 +1,20 @@ enum Example { Ex(String), NotEx } +enum Void {} + +enum ManyVariants { + One, + Two, + Three, + Four, + Five, + Six, + Seven, + Eight, + Nine, + Ten, +} + fn result_test() { let x = Option(1); //~ ERROR expected function, found enum @@ -12,6 +27,10 @@ fn result_test() { if let Example(_) = y { //~ ERROR expected tuple struct/variant, found enum println!("It is OK."); } + + let y = Void(); //~ ERROR expected function, found enum + + let z = ManyVariants(); //~ ERROR expected function, found enum } fn main() {} diff --git a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr index 8a0d0096acbbd..4210b4e057ac1 100644 --- a/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr +++ b/src/test/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr @@ -1,34 +1,63 @@ error[E0423]: expected function, found enum `Option` - --> $DIR/issue-43871-enum-instead-of-variant.rs:4:13 + --> $DIR/issue-43871-enum-instead-of-variant.rs:19:13 | LL | let x = Option(1); | ^^^^^^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `std::prelude::v1::Option::None` - - `std::prelude::v1::Option::Some` +LL | let x = std::prelude::v1::Option::None(1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let x = std::prelude::v1::Option::Some(1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0532]: expected tuple struct/variant, found enum `Option` - --> $DIR/issue-43871-enum-instead-of-variant.rs:6:12 + --> $DIR/issue-43871-enum-instead-of-variant.rs:21:12 | LL | if let Option(_) = x { | ^^^^^^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `std::prelude::v1::Option::None` - - `std::prelude::v1::Option::Some` +LL | if let std::prelude::v1::Option::None(_) = x { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | if let std::prelude::v1::Option::Some(_) = x { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0532]: expected tuple struct/variant, found enum `Example` - --> $DIR/issue-43871-enum-instead-of-variant.rs:12:12 + --> $DIR/issue-43871-enum-instead-of-variant.rs:27:12 | LL | if let Example(_) = y { | ^^^^^^^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `Example::Ex` - - `Example::NotEx` +LL | if let Example::Ex(_) = y { + | ^^^^^^^^^^^ +LL | if let Example::NotEx(_) = y { + | ^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error[E0423]: expected function, found enum `Void` + --> $DIR/issue-43871-enum-instead-of-variant.rs:31:13 + | +LL | let y = Void(); + | ^^^^ + +error[E0423]: expected function, found enum `ManyVariants` + --> $DIR/issue-43871-enum-instead-of-variant.rs:33:13 + | +LL | let z = ManyVariants(); + | ^^^^^^^^^^^^ +help: try using one of the enum's variants + | +LL | let z = ManyVariants::Eight(); + | ^^^^^^^^^^^^^^^^^^^ +LL | let z = ManyVariants::Five(); + | ^^^^^^^^^^^^^^^^^^ +LL | let z = ManyVariants::Four(); + | ^^^^^^^^^^^^^^^^^^ +LL | let z = ManyVariants::Nine(); + | ^^^^^^^^^^^^^^^^^^ +and 6 other candidates + +error: aborting due to 5 previous errors Some errors occurred: E0423, E0532. For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/glob-resolve1.stderr b/src/test/ui/glob-resolve1.stderr index 01730c4d69566..c252a6e220c64 100644 --- a/src/test/ui/glob-resolve1.stderr +++ b/src/test/ui/glob-resolve1.stderr @@ -22,10 +22,7 @@ error[E0423]: expected value, found enum `B` --> $DIR/glob-resolve1.rs:24:5 | LL | B; - | ^ - | - = note: did you mean to use one of the following variants? - - `B::B1` + | ^ help: try using the enum's variant: `B::B1` error[E0425]: cannot find value `C` in this scope --> $DIR/glob-resolve1.rs:25:5 diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index 01f0941282e35..75d9c97513d31 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -3,22 +3,32 @@ error[E0423]: expected value, found enum `n::Z` | LL | n::Z; | ^^^^ - | - = note: did you mean to use one of the following variants? - - `m::Z::Fn` - - `m::Z::Struct` - - `m::Z::Unit` +help: try using one of the enum's variants + | +LL | m::Z::Fn; + | ^^^^^^^^ +LL | m::Z::Struct; + | ^^^^^^^^^^^^ +LL | m::Z::Unit; + | ^^^^^^^^^^ error[E0423]: expected value, found enum `Z` --> $DIR/privacy-enum-ctor.rs:25:9 | LL | Z; - | ^ help: a function with a similar name exists: `f` + | ^ +help: a function with a similar name exists | - = note: did you mean to use one of the following variants? - - `m::Z::Fn` - - `m::Z::Struct` - - `m::Z::Unit` +LL | f; + | ^ +help: try using one of the enum's variants + | +LL | m::Z::Fn; + | ^^^^^^^^ +LL | m::Z::Struct; + | ^^^^^^^^^^^^ +LL | m::Z::Unit; + | ^^^^^^^^^^ error[E0423]: expected value, found struct variant `Z::Struct` --> $DIR/privacy-enum-ctor.rs:29:20 @@ -31,15 +41,18 @@ error[E0423]: expected value, found enum `m::E` | LL | let _: E = m::E; | ^^^^ - | - = note: did you mean to use one of the following variants? - - `E::Fn` - - `E::Struct` - - `E::Unit` help: a function with a similar name exists | LL | let _: E = m::f; | ^ +help: try using one of the enum's variants + | +LL | let _: E = E::Fn; + | ^^^^^ +LL | let _: E = E::Struct; + | ^^^^^^^^^ +LL | let _: E = E::Unit; + | ^^^^^^^ help: possible better candidates are found in other modules, you can import them into scope | LL | use std::f32::consts::E; @@ -58,11 +71,14 @@ error[E0423]: expected value, found enum `E` | LL | let _: E = E; | ^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `E::Fn` - - `E::Struct` - - `E::Unit` +LL | let _: E = E::Fn; + | ^^^^^ +LL | let _: E = E::Struct; + | ^^^^^^^^^ +LL | let _: E = E::Unit; + | ^^^^^^^ help: possible better candidates are found in other modules, you can import them into scope | LL | use std::f32::consts::E; @@ -95,11 +111,14 @@ error[E0423]: expected value, found enum `m::n::Z` | LL | let _: Z = m::n::Z; | ^^^^^^^ +help: try using one of the enum's variants | - = note: did you mean to use one of the following variants? - - `m::Z::Fn` - - `m::Z::Struct` - - `m::Z::Unit` +LL | let _: Z = m::Z::Fn; + | ^^^^^^^^ +LL | let _: Z = m::Z::Struct; + | ^^^^^^^^^^^^ +LL | let _: Z = m::Z::Unit; + | ^^^^^^^^^^ error[E0412]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:61:12 From 6389478d7030f1d807a46599dfb7a0a2ba97a240 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 21 Mar 2019 23:36:50 +0300 Subject: [PATCH 46/48] Move one test from run-make-fulldeps to ui --- .../run-make-fulldeps/extern-prelude/Makefile | 11 ------- .../run-make-fulldeps/extern-prelude/basic.rs | 6 ---- .../extern-prelude/relative-only.rs | 9 ------ .../extern-prelude/shadow-mod.rs | 14 --------- .../extern-prelude/shadow-prelude.rs | 7 ----- .../auxiliary/extern-prelude-vec.rs} | 2 +- .../auxiliary/extern-prelude.rs} | 2 -- src/test/ui/extern-prelude-fail.rs | 9 ++++++ src/test/ui/extern-prelude-fail.stderr | 16 ++++++++++ src/test/ui/extern-prelude.rs | 31 +++++++++++++++++++ 10 files changed, 57 insertions(+), 50 deletions(-) delete mode 100644 src/test/run-make-fulldeps/extern-prelude/Makefile delete mode 100644 src/test/run-make-fulldeps/extern-prelude/basic.rs delete mode 100644 src/test/run-make-fulldeps/extern-prelude/relative-only.rs delete mode 100644 src/test/run-make-fulldeps/extern-prelude/shadow-mod.rs delete mode 100644 src/test/run-make-fulldeps/extern-prelude/shadow-prelude.rs rename src/test/{run-make-fulldeps/extern-prelude/ep-vec.rs => ui/auxiliary/extern-prelude-vec.rs} (60%) rename src/test/{run-make-fulldeps/extern-prelude/ep-lib.rs => ui/auxiliary/extern-prelude.rs} (69%) create mode 100644 src/test/ui/extern-prelude-fail.rs create mode 100644 src/test/ui/extern-prelude-fail.stderr create mode 100644 src/test/ui/extern-prelude.rs diff --git a/src/test/run-make-fulldeps/extern-prelude/Makefile b/src/test/run-make-fulldeps/extern-prelude/Makefile deleted file mode 100644 index 69af01ccf0369..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) ep-lib.rs - $(RUSTC) ep-vec.rs - - $(RUSTC) basic.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib - $(RUSTC) shadow-mod.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib - $(RUSTC) shadow-prelude.rs --extern Vec=$(TMPDIR)/libep_vec.rlib - $(RUSTC) relative-only.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib 2>&1 | $(CGREP) "unresolved import" - $(RUSTC) relative-only.rs --extern ep_lib=$(TMPDIR)/libep_lib.rlib 2>&1 | $(CGREP) "failed to resolve" diff --git a/src/test/run-make-fulldeps/extern-prelude/basic.rs b/src/test/run-make-fulldeps/extern-prelude/basic.rs deleted file mode 100644 index dc7cc1f27b6f6..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/basic.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(extern_prelude)] - -fn main() { - let s = ep_lib::S; // It works - s.external(); -} diff --git a/src/test/run-make-fulldeps/extern-prelude/relative-only.rs b/src/test/run-make-fulldeps/extern-prelude/relative-only.rs deleted file mode 100644 index 0fdf3b49d96b4..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/relative-only.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Extern prelude names are not available by absolute paths - -#![feature(extern_prelude)] - -use ep_lib::S; - -fn main() { - let s = ::ep_lib::S; -} diff --git a/src/test/run-make-fulldeps/extern-prelude/shadow-mod.rs b/src/test/run-make-fulldeps/extern-prelude/shadow-mod.rs deleted file mode 100644 index 69411aaf57c71..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/shadow-mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Local module shadows `ep_lib` from extern prelude - -mod ep_lib { - pub struct S; - - impl S { - pub fn internal(&self) {} - } -} - -fn main() { - let s = ep_lib::S; - s.internal(); // OK -} diff --git a/src/test/run-make-fulldeps/extern-prelude/shadow-prelude.rs b/src/test/run-make-fulldeps/extern-prelude/shadow-prelude.rs deleted file mode 100644 index 6c6ce12708d79..0000000000000 --- a/src/test/run-make-fulldeps/extern-prelude/shadow-prelude.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Extern prelude shadows standard library prelude - -#![feature(extern_prelude)] - -fn main() { - let x = Vec::new(0f32, ()); // OK -} diff --git a/src/test/run-make-fulldeps/extern-prelude/ep-vec.rs b/src/test/ui/auxiliary/extern-prelude-vec.rs similarity index 60% rename from src/test/run-make-fulldeps/extern-prelude/ep-vec.rs rename to src/test/ui/auxiliary/extern-prelude-vec.rs index 148a4a987266f..a643c8889109a 100644 --- a/src/test/run-make-fulldeps/extern-prelude/ep-vec.rs +++ b/src/test/ui/auxiliary/extern-prelude-vec.rs @@ -1,3 +1,3 @@ -#![crate_type = "rlib"] +#![crate_name = "Vec"] pub fn new(arg1: f32, arg2: ()) {} diff --git a/src/test/run-make-fulldeps/extern-prelude/ep-lib.rs b/src/test/ui/auxiliary/extern-prelude.rs similarity index 69% rename from src/test/run-make-fulldeps/extern-prelude/ep-lib.rs rename to src/test/ui/auxiliary/extern-prelude.rs index f5e129eca6631..2fdfd85a1da30 100644 --- a/src/test/run-make-fulldeps/extern-prelude/ep-lib.rs +++ b/src/test/ui/auxiliary/extern-prelude.rs @@ -1,5 +1,3 @@ -#![crate_type = "rlib"] - pub struct S; impl S { diff --git a/src/test/ui/extern-prelude-fail.rs b/src/test/ui/extern-prelude-fail.rs new file mode 100644 index 0000000000000..7d387025ad44d --- /dev/null +++ b/src/test/ui/extern-prelude-fail.rs @@ -0,0 +1,9 @@ +// compile-flags:--extern extern_prelude +// aux-build:extern-prelude.rs + +// Extern prelude names are not available by absolute paths + +fn main() { + use extern_prelude::S; //~ ERROR unresolved import `extern_prelude` + let s = ::extern_prelude::S; //~ ERROR failed to resolve +} diff --git a/src/test/ui/extern-prelude-fail.stderr b/src/test/ui/extern-prelude-fail.stderr new file mode 100644 index 0000000000000..ad148c04d08af --- /dev/null +++ b/src/test/ui/extern-prelude-fail.stderr @@ -0,0 +1,16 @@ +error[E0432]: unresolved import `extern_prelude` + --> $DIR/extern-prelude-fail.rs:7:9 + | +LL | use extern_prelude::S; + | ^^^^^^^^^^^^^^ maybe a missing `extern crate extern_prelude;`? + +error[E0433]: failed to resolve: maybe a missing `extern crate extern_prelude;`? + --> $DIR/extern-prelude-fail.rs:8:15 + | +LL | let s = ::extern_prelude::S; + | ^^^^^^^^^^^^^^ maybe a missing `extern crate extern_prelude;`? + +error: aborting due to 2 previous errors + +Some errors occurred: E0432, E0433. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/extern-prelude.rs b/src/test/ui/extern-prelude.rs new file mode 100644 index 0000000000000..0e52f2c5158d4 --- /dev/null +++ b/src/test/ui/extern-prelude.rs @@ -0,0 +1,31 @@ +// compile-pass +// compile-flags:--extern extern_prelude --extern Vec +// aux-build:extern-prelude.rs +// aux-build:extern-prelude-vec.rs + +fn basic() { + // It works + let s = extern_prelude::S; + s.external(); +} + +fn shadow_mod() { + // Local module shadows `extern_prelude` from extern prelude + mod extern_prelude { + pub struct S; + + impl S { + pub fn internal(&self) {} + } + } + + let s = extern_prelude::S; + s.internal(); // OK +} + +fn shadow_prelude() { + // Extern prelude shadows standard library prelude + let x = Vec::new(0f32, ()); // OK +} + +fn main() {} From c97d3d4dd174e8a80e9d0e55ea6f9a73aca60bf2 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Fri, 22 Mar 2019 11:25:44 +0100 Subject: [PATCH 47/48] Add tracking issue number for `seek_convenience` --- src/libstd/io/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 4c88fc889f31f..7147b641e4743 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1381,7 +1381,7 @@ pub trait Seek { /// Ok(()) /// } /// ``` - #[unstable(feature = "seek_convenience", issue = "0")] + #[unstable(feature = "seek_convenience", issue = "59359")] fn stream_len(&mut self) -> Result { let old_pos = self.stream_position()?; let len = self.seek(SeekFrom::End(0))?; @@ -1420,7 +1420,7 @@ pub trait Seek { /// Ok(()) /// } /// ``` - #[unstable(feature = "seek_convenience", issue = "0")] + #[unstable(feature = "seek_convenience", issue = "59359")] fn stream_position(&mut self) -> Result { self.seek(SeekFrom::Current(0)) } From 9ee3a4041eca0cfca015b82143b44b2f0d3b4a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 22 Mar 2019 12:39:59 +0100 Subject: [PATCH 48/48] Rename miri component to miri-preview It should fix installation via rustup and indicates it's not stable yet --- src/tools/build-manifest/src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 706fce262f0e4..3c360a81ba5be 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -390,7 +390,7 @@ impl Builder { package("rust-src", &["*"]); package("rls-preview", HOSTS); package("clippy-preview", HOSTS); - package("miri", HOSTS); + package("miri-preview", HOSTS); package("rustfmt-preview", HOSTS); package("rust-analysis", TARGETS); package("llvm-tools-preview", TARGETS); @@ -408,7 +408,7 @@ impl Builder { "rustc", "cargo", "rust-std", "rust-mingw", "rust-docs", "rustfmt-preview", "clippy-preview", "rls-preview", "rust-src", "llvm-tools-preview", - "lldb-preview", "rust-analysis", "miri" + "lldb-preview", "rust-analysis", "miri-preview" ]); } @@ -420,6 +420,7 @@ impl Builder { rename("rls", "rls-preview"); rename("rustfmt", "rustfmt-preview"); rename("clippy", "clippy-preview"); + rename("miri", "miri-preview"); } fn rust_package(&mut self, manifest: &Manifest) -> Package { @@ -468,7 +469,7 @@ impl Builder { // but might be marked as unavailable if they weren't built. extensions.extend(vec![ host_component("clippy-preview"), - host_component("miri"), + host_component("miri-preview"), host_component("rls-preview"), host_component("rustfmt-preview"), host_component("llvm-tools-preview"),