From e71d17b9b42b87a0e6ea754d499a553a4fc8e4b8 Mon Sep 17 00:00:00 2001 From: pierwill Date: Mon, 11 Oct 2021 12:56:55 -0500 Subject: Edit explanation of test for nested type ascriptions Closes #88233 --- .../bindings-after-at/nested-type-ascription-syntactically-invalid.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs b/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs index 5c7769ce604..a709e34b501 100644 --- a/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs +++ b/src/test/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs @@ -1,5 +1,5 @@ // Here we check that type ascription is syntactically invalid when -// not in the top position of a ascribing a let binding or function parameter. +// not in the top position of an ascribing `let` binding or function parameter. // This has no effect. -- cgit 1.4.1-3-g733a5 From e56d89ae6299f6820afc046c0d040594ce2ff8d6 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Mon, 11 Oct 2021 12:26:27 -0700 Subject: Add missing words in `Infallible` docs This sentence was previously incomplete. --- library/core/src/convert/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index abeeef1a17e..56d25c80d2e 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -662,7 +662,7 @@ impl AsMut for str { /// /// However there is one case where `!` syntax can be used /// before `!` is stabilized as a full-fledged type: in the position of a function’s return type. -/// Specifically, it is possible implementations for two different function pointer types: +/// Specifically, it is possible to have implementations for two different function pointer types: /// /// ``` /// trait MyTrait {} -- cgit 1.4.1-3-g733a5 From d2564ce5a9c0e92d02976ba8386cc91880691340 Mon Sep 17 00:00:00 2001 From: Shinwoo Park Date: Tue, 12 Oct 2021 04:47:34 +0900 Subject: rustdoc: update noto sans kr --- src/librustdoc/html/render/write_shared.rs | 5 +- src/librustdoc/html/static/css/rustdoc.css | 7 +- .../html/static/fonts/noto-sans-kr-LICENSE.txt | 93 +++++++++++++++++++++ .../html/static/fonts/noto-sans-kr-regular.woff | Bin 0 -> 279528 bytes .../html/static/fonts/noto-sans-kr-regular.woff2 | Bin 0 -> 245248 bytes .../noto-sans-kr-v13-korean-regular-LICENSE.txt | 93 --------------------- .../fonts/noto-sans-kr-v13-korean-regular.woff | Bin 287068 -> 0 bytes src/librustdoc/html/static_files.rs | 15 ++-- 8 files changed, 107 insertions(+), 106 deletions(-) create mode 100644 src/librustdoc/html/static/fonts/noto-sans-kr-LICENSE.txt create mode 100644 src/librustdoc/html/static/fonts/noto-sans-kr-regular.woff create mode 100644 src/librustdoc/html/static/fonts/noto-sans-kr-regular.woff2 delete mode 100644 src/librustdoc/html/static/fonts/noto-sans-kr-v13-korean-regular-LICENSE.txt delete mode 100644 src/librustdoc/html/static/fonts/noto-sans-kr-v13-korean-regular.woff diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index c1a83ad5820..e4c2556118a 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -39,8 +39,9 @@ static FILES_UNVERSIONED: Lazy> = Lazy::new(|| { "SourceCodePro-Semibold.ttf.woff" => static_files::source_code_pro::SEMIBOLD, "SourceCodePro-It.ttf.woff" => static_files::source_code_pro::ITALIC, "SourceCodePro-LICENSE.txt" => static_files::source_code_pro::LICENSE, - "noto-sans-kr-v13-korean-regular.woff" => static_files::noto_sans_kr::REGULAR, - "noto-sans-kr-v13-korean-regular-LICENSE.txt" => static_files::noto_sans_kr::LICENSE, + "noto-sans-kr-regular.woff2" => static_files::noto_sans_kr::REGULAR2, + "noto-sans-kr-regular.woff" => static_files::noto_sans_kr::REGULAR, + "noto-sans-kr-LICENSE.txt" => static_files::noto_sans_kr::LICENSE, "LICENSE-MIT.txt" => static_files::LICENSE_MIT, "LICENSE-APACHE.txt" => static_files::LICENSE_APACHE, "COPYRIGHT.txt" => static_files::COPYRIGHT, diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 962af66368d..11c54876dea 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -75,12 +75,13 @@ font-display: swap; } -/* Avoid using legacy CJK serif fonts in Windows like Batang */ +/* Avoid using legacy CJK serif fonts in Windows like Batang. */ @font-face { font-family: 'Noto Sans KR'; - src: url("noto-sans-kr-v13-korean-regular.woff") format("woff"); + src: url("noto-sans-kr-regular.woff2") format("woff2"), + url("noto-sans-kr-regular.woff") format("woff"); font-display: swap; - unicode-range: U+A960-A97F, U+AC00-D7AF, U+D7B0-D7FF; + unicode-range: U+AC00-D7AF, U+3130-318F, U+1100-11FF, U+A960-A97F, U+D7B0-D7FF; } * { diff --git a/src/librustdoc/html/static/fonts/noto-sans-kr-LICENSE.txt b/src/librustdoc/html/static/fonts/noto-sans-kr-LICENSE.txt new file mode 100644 index 00000000000..922d5fdc18d --- /dev/null +++ b/src/librustdoc/html/static/fonts/noto-sans-kr-LICENSE.txt @@ -0,0 +1,93 @@ +Copyright 2014, 2015 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/src/librustdoc/html/static/fonts/noto-sans-kr-regular.woff b/src/librustdoc/html/static/fonts/noto-sans-kr-regular.woff new file mode 100644 index 00000000000..65e939c6b9f Binary files /dev/null and b/src/librustdoc/html/static/fonts/noto-sans-kr-regular.woff differ diff --git a/src/librustdoc/html/static/fonts/noto-sans-kr-regular.woff2 b/src/librustdoc/html/static/fonts/noto-sans-kr-regular.woff2 new file mode 100644 index 00000000000..8126492e41d Binary files /dev/null and b/src/librustdoc/html/static/fonts/noto-sans-kr-regular.woff2 differ diff --git a/src/librustdoc/html/static/fonts/noto-sans-kr-v13-korean-regular-LICENSE.txt b/src/librustdoc/html/static/fonts/noto-sans-kr-v13-korean-regular-LICENSE.txt deleted file mode 100644 index 922d5fdc18d..00000000000 --- a/src/librustdoc/html/static/fonts/noto-sans-kr-v13-korean-regular-LICENSE.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright 2014, 2015 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. - -This Font Software is licensed under the SIL Open Font License, Version 1.1. - -This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/src/librustdoc/html/static/fonts/noto-sans-kr-v13-korean-regular.woff b/src/librustdoc/html/static/fonts/noto-sans-kr-v13-korean-regular.woff deleted file mode 100644 index 01d6b6b5466..00000000000 Binary files a/src/librustdoc/html/static/fonts/noto-sans-kr-v13-korean-regular.woff and /dev/null differ diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index ccc25e6cc49..924e3f1d29d 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -157,15 +157,14 @@ crate mod source_code_pro { } crate mod noto_sans_kr { - /// The file `noto-sans-kr-v13-korean-regular.woff`, the Regular variant of the Noto Sans KR - /// font. - crate static REGULAR: &[u8] = - include_bytes!("static/fonts/noto-sans-kr-v13-korean-regular.woff"); + /// The file `noto-sans-kr.woff`, the Regular variant of the Noto Sans KR font. + crate static REGULAR: &[u8] = include_bytes!("static/fonts/noto-sans-kr-regular.woff"); - /// The file `noto-sans-kr-v13-korean-regular-LICENSE.txt`, the license text of the Noto Sans KR - /// font. - crate static LICENSE: &[u8] = - include_bytes!("static/fonts/noto-sans-kr-v13-korean-regular-LICENSE.txt"); + /// The file `noto-sans-kr.woff2`, the Regular variant of the Noto Sans KR font. + crate static REGULAR2: &[u8] = include_bytes!("static/fonts/noto-sans-kr-regular.woff2"); + + /// The file `noto-sans-kr-LICENSE.txt`, the license text of the Noto Sans KR font. + crate static LICENSE: &[u8] = include_bytes!("static/fonts/noto-sans-kr-LICENSE.txt"); } /// Files related to the sidebar in rustdoc sources. -- cgit 1.4.1-3-g733a5 From 0cf84c8c19753d9614efcde455f5f987b2a43e90 Mon Sep 17 00:00:00 2001 From: John Kugelman Date: Mon, 11 Oct 2021 19:04:24 -0400 Subject: Add #[must_use] to to_value conversions --- library/core/src/char/methods.rs | 4 +++- library/core/src/ptr/non_null.rs | 4 ++++ library/std/src/ffi/c_str.rs | 6 ++++++ library/std/src/ffi/os_str.rs | 6 ++++++ library/std/src/net/ip.rs | 14 +++++++++++++- library/std/src/path.rs | 6 ++++++ 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 3e7c5b3189c..3c4972bd3c9 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -328,9 +328,11 @@ impl char { /// /// ```should_panic /// // this panics - /// '1'.to_digit(37); + /// let _ = '1'.to_digit(37); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn to_digit(self, radix: u32) -> Option { assert!(radix <= 36, "to_digit: radix is too high (maximum 36)"); diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 87c8674af0d..7695e3a4a8a 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -240,6 +240,8 @@ impl NonNull { /// The pointer can be later reconstructed with [`NonNull::from_raw_parts`]. #[unstable(feature = "ptr_metadata", issue = "81513")] #[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn to_raw_parts(self) -> (NonNull<()>, ::Metadata) { (self.cast(), super::metadata(self.as_ptr())) @@ -381,6 +383,8 @@ impl NonNull { /// ``` #[stable(feature = "nonnull_cast", since = "1.27.0")] #[rustc_const_stable(feature = "const_nonnull_cast", since = "1.36.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn cast(self) -> NonNull { // SAFETY: `self` is a `NonNull` pointer which is necessarily non-null diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index 8b51c4450c2..b6cc388a1dd 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -1337,6 +1337,8 @@ impl CStr { /// assert_eq!(cstr.to_bytes(), b"foo"); /// ``` #[inline] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] pub fn to_bytes(&self) -> &[u8] { let bytes = self.to_bytes_with_nul(); @@ -1362,6 +1364,8 @@ impl CStr { /// assert_eq!(cstr.to_bytes_with_nul(), b"foo\0"); /// ``` #[inline] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] pub fn to_bytes_with_nul(&self) -> &[u8] { unsafe { &*(&self.inner as *const [c_char] as *const [u8]) } @@ -1432,6 +1436,8 @@ impl CStr { /// Cow::Owned(String::from("Hello �World")) as Cow<'_, str> /// ); /// ``` + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[stable(feature = "cstr_to_str", since = "1.4.0")] pub fn to_string_lossy(&self) -> Cow<'_, str> { String::from_utf8_lossy(self.to_bytes()) diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index de745f21649..2828b2a8e45 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -575,6 +575,8 @@ impl OsStr { /// assert_eq!(os_str.to_str(), Some("foo")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn to_str(&self) -> Option<&str> { self.inner.to_str() @@ -626,6 +628,8 @@ impl OsStr { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() @@ -643,6 +647,8 @@ impl OsStr { /// assert_eq!(os_string, OsString::from("foo")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn to_os_string(&self) -> OsString { OsString { inner: self.inner.to_owned() } diff --git a/library/std/src/net/ip.rs b/library/std/src/net/ip.rs index 99922eef61f..2bd2ab31a3f 100644 --- a/library/std/src/net/ip.rs +++ b/library/std/src/net/ip.rs @@ -418,6 +418,8 @@ impl IpAddr { /// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).to_canonical().is_loopback(), true); /// ``` #[inline] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[rustc_const_unstable(feature = "const_ip", issue = "76205")] #[unstable(feature = "ip", issue = "27709")] pub const fn to_canonical(&self) -> IpAddr { @@ -882,6 +884,8 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn to_ipv6_compatible(&self) -> Ipv6Addr { let [a, b, c, d] = self.octets(); @@ -907,6 +911,8 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn to_ipv6_mapped(&self) -> Ipv6Addr { let [a, b, c, d] = self.octets(); @@ -1619,6 +1625,8 @@ impl Ipv6Addr { /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] #[unstable(feature = "ip", issue = "27709")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn to_ipv4_mapped(&self) -> Option { match self.octets() { @@ -1656,6 +1664,8 @@ impl Ipv6Addr { /// ``` #[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")] #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub const fn to_ipv4(&self) -> Option { if let [0, 0, 0, 0, 0, 0 | 0xffff, ab, cd] = self.segments() { @@ -1679,9 +1689,11 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).is_loopback(), false); /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).to_canonical().is_loopback(), true); /// ``` - #[inline] #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] #[unstable(feature = "ip", issue = "27709")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline] pub const fn to_canonical(&self) -> IpAddr { if let Some(mapped) = self.to_ipv4_mapped() { return IpAddr::V4(mapped); diff --git a/library/std/src/path.rs b/library/std/src/path.rs index a8a79fb9c8f..a5ebaa34d53 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1945,6 +1945,8 @@ impl Path { /// assert_eq!(path.to_str(), Some("foo.txt")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn to_str(&self) -> Option<&str> { self.inner.to_str() @@ -1971,6 +1973,8 @@ impl Path { /// Had `path` contained invalid unicode, the `to_string_lossy` call might /// have returned `"fo�.txt"`. #[stable(feature = "rust1", since = "1.0.0")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[inline] pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() @@ -1987,6 +1991,8 @@ impl Path { /// assert_eq!(path_buf, std::path::PathBuf::from("foo.txt")); /// ``` #[rustc_conversion_suggestion] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] pub fn to_path_buf(&self) -> PathBuf { PathBuf::from(self.inner.to_os_string()) -- cgit 1.4.1-3-g733a5 From 0767ed31f3860a7703a4a306f2f266279a55c3dc Mon Sep 17 00:00:00 2001 From: Marcel Hellwig Date: Mon, 11 Oct 2021 16:03:57 +0200 Subject: add some more testcases --- src/test/ui/consts/issue-88071.rs | 21 ++++++++ .../ui/generic-associated-types/issue-87750.rs | 22 +++++++++ .../ui/generic-associated-types/issue-87750.stderr | 9 ++++ src/test/ui/traits/issue-52893.rs | 57 ++++++++++++++++++++++ src/test/ui/traits/issue-52893.stderr | 15 ++++++ src/test/ui/traits/issue-68295.rs | 47 ++++++++++++++++++ src/test/ui/traits/issue-68295.stderr | 17 +++++++ 7 files changed, 188 insertions(+) create mode 100644 src/test/ui/consts/issue-88071.rs create mode 100644 src/test/ui/generic-associated-types/issue-87750.rs create mode 100644 src/test/ui/generic-associated-types/issue-87750.stderr create mode 100644 src/test/ui/traits/issue-52893.rs create mode 100644 src/test/ui/traits/issue-52893.stderr create mode 100644 src/test/ui/traits/issue-68295.rs create mode 100644 src/test/ui/traits/issue-68295.stderr diff --git a/src/test/ui/consts/issue-88071.rs b/src/test/ui/consts/issue-88071.rs new file mode 100644 index 00000000000..a2d4a642128 --- /dev/null +++ b/src/test/ui/consts/issue-88071.rs @@ -0,0 +1,21 @@ +// check-pass +// +// regression test for #88071 + +#![feature(const_btree_new)] +#![feature(const_fn_trait_bound)] + +use std::collections::BTreeMap; + +pub struct CustomMap(BTreeMap); + +impl CustomMap +where + K: Ord, +{ + pub const fn new() -> Self { + CustomMap(BTreeMap::new()) + } +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-87750.rs b/src/test/ui/generic-associated-types/issue-87750.rs new file mode 100644 index 00000000000..89bd79ac299 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87750.rs @@ -0,0 +1,22 @@ +#![feature(generic_associated_types)] + +trait PointerFamily { + type Pointer; +} + +struct Rc(Box); +struct RcFamily; + +impl PointerFamily for RcFamily { + type Pointer = Rc; +} + +#[allow(dead_code)] +enum Node where P::Pointer>: Sized { + Cons(P::Pointer>), +} + +fn main() { + let _list: ::Pointer>; + //~^ ERROR overflow evaluating the requirement `Node: Sized` +} diff --git a/src/test/ui/generic-associated-types/issue-87750.stderr b/src/test/ui/generic-associated-types/issue-87750.stderr new file mode 100644 index 00000000000..854541f3d8f --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87750.stderr @@ -0,0 +1,9 @@ +error[E0275]: overflow evaluating the requirement `Node: Sized` + --> $DIR/issue-87750.rs:20:16 + | +LL | let _list: ::Pointer>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/traits/issue-52893.rs b/src/test/ui/traits/issue-52893.rs new file mode 100644 index 00000000000..d72598d5d59 --- /dev/null +++ b/src/test/ui/traits/issue-52893.rs @@ -0,0 +1,57 @@ +// check-fail +// +// regression test for issue 52893 +trait At { + type AtRes; + fn at(self) -> Self::AtRes; +} + +trait Push { + type PushRes; + fn push(self, other: T) -> Self::PushRes; +} + +trait AddClass { + type AddRes; + fn init(self, func: F); +} + +trait ToRef { + type RefRes; + fn to_ref(&self) -> Self::RefRes; +} + +struct Class

(P); + +impl

Class

{ + fn with(self) -> >::AddRes + where + Self: AddClass, + { + todo!() + } + + fn from(self) -> >::AddRes + where + Self: AddClass, + { + todo!() + } +} + +impl AddClass for Class

+where + Self: At, + >::AtRes: Push, + <>::AtRes as Push>::PushRes: ToRef + Push, +{ + type AddRes = (); + + fn init(self, func: F) { + let builder = self.at().push(func); + let output = builder.to_ref(); + builder.push(output); //~ ERROR mismatched types [E0308] + } +} + +fn main() {} diff --git a/src/test/ui/traits/issue-52893.stderr b/src/test/ui/traits/issue-52893.stderr new file mode 100644 index 00000000000..bf732e24915 --- /dev/null +++ b/src/test/ui/traits/issue-52893.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/issue-52893.rs:53:22 + | +LL | impl AddClass for Class

+ | - this type parameter +... +LL | builder.push(output); + | ^^^^^^ expected type parameter `F`, found struct `Class` + | + = note: expected type parameter `F` + found struct `Class

` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/traits/issue-68295.rs b/src/test/ui/traits/issue-68295.rs new file mode 100644 index 00000000000..7ff54539adc --- /dev/null +++ b/src/test/ui/traits/issue-68295.rs @@ -0,0 +1,47 @@ +// check-fail +// +// regression test for #68295 + +struct Matrix(R, C, S); + +impl Matrix { + fn into_owned(self) -> Matrix> + where + (): Allocator, + { + unimplemented!() + } +} + +impl Matrix { + fn hermitian_part(&self) -> Matrix> + where + (): Allocator, + { + unimplemented!() + } +} + +trait Allocator { + type Buffer; +} + +trait Trait { + type Power; +} + +impl> Trait for () { + type Power = A::Buffer; +} + +type Owned = >::Power; + +fn crash(input: Matrix) -> Matrix +where + (): Allocator, +{ + input.into_owned() + //~^ ERROR mismatched types [E0308] +} + +fn main() {} diff --git a/src/test/ui/traits/issue-68295.stderr b/src/test/ui/traits/issue-68295.stderr new file mode 100644 index 00000000000..cb6e6e0769c --- /dev/null +++ b/src/test/ui/traits/issue-68295.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/issue-68295.rs:43:5 + | +LL | fn crash(input: Matrix) -> Matrix + | ----------------- expected `Matrix` because of return type +... +LL | input.into_owned() + | ^^^^^^^^^^^^^^^^^^ expected `u32`, found associated type + | + = note: expected struct `Matrix<_, _, u32>` + found struct `Matrix<_, _, <() as Allocator>::Buffer>` + = help: consider constraining the associated type `<() as Allocator>::Buffer` to `u32` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. -- cgit 1.4.1-3-g733a5 From 7943c9c44672e0d469e4fd8f83c238ca73becb71 Mon Sep 17 00:00:00 2001 From: LingMan Date: Tue, 12 Oct 2021 14:47:31 +0200 Subject: Use Option::map_or instead of open coding it --- compiler/rustc_index/src/bit_set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index 1995fd64e6f..573124c8ec9 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -841,7 +841,7 @@ impl GrowableBitSet { #[inline] pub fn contains(&self, elem: T) -> bool { let (word_index, mask) = word_index_and_mask(elem); - if let Some(word) = self.bit_set.words.get(word_index) { (word & mask) != 0 } else { false } + self.bit_set.words.get(word_index).map_or(false, |word| (word & mask) != 0) } } -- cgit 1.4.1-3-g733a5 From 81eeb3e775128ffb70609b463faa0b554f672d2c Mon Sep 17 00:00:00 2001 From: John Kugelman Date: Tue, 12 Oct 2021 08:53:54 -0400 Subject: Fix uppercase/lowercase error --- library/alloc/src/str.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs index ac7f2304456..e1d0ee42f4e 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs @@ -538,7 +538,7 @@ impl str { /// [`make_ascii_uppercase`]: str::make_ascii_uppercase /// [`to_uppercase`]: #method.to_uppercase #[cfg(not(no_global_oom_handling))] - #[must_use = "to uppercase the value in-place, use `make_ascii_lowercase()`"] + #[must_use = "to uppercase the value in-place, use `make_ascii_uppercase()`"] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[inline] pub fn to_ascii_uppercase(&self) -> String { -- cgit 1.4.1-3-g733a5 From e5cfe844c9d5c2e1e21cf97afd5f1ecbb99abc46 Mon Sep 17 00:00:00 2001 From: Canop Date: Tue, 12 Oct 2021 15:09:28 +0200 Subject: Fix invalid rules in .gitignore `**node_modules` in a .gitignore is the same than `*node_modules` or `*****node_modules`. It matches every file whose name ends with `node_modules`, including `not_node_modules`. The intent here was obviously to have `**/node_modules` which is the same than just `node_modules`. --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b7e8e8fa157..87437a16fb3 100644 --- a/.gitignore +++ b/.gitignore @@ -69,8 +69,8 @@ __pycache__/ *$py.class ## Node -**node_modules -**package-lock.json +node_modules +package-lock.json ## Rustdoc GUI tests src/test/rustdoc-gui/src/**.lock -- cgit 1.4.1-3-g733a5 From a6bb1fb6410ead3ce3fb828559cd1a8a389278d1 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 12 Oct 2021 15:21:14 +0200 Subject: Add #[inline] to int log10 functions. --- library/core/src/num/int_log10.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/core/src/num/int_log10.rs b/library/core/src/num/int_log10.rs index 398bb07a07e..a8455fb355b 100644 --- a/library/core/src/num/int_log10.rs +++ b/library/core/src/num/int_log10.rs @@ -1,5 +1,6 @@ mod unchecked { // 0 < val <= u8::MAX + #[inline] pub const fn u8(val: u8) -> u32 { let val = val as u32; @@ -20,6 +21,7 @@ mod unchecked { } // 0 < val < 100_000 + #[inline] const fn less_than_5(val: u32) -> u32 { // Similar to u8, when adding one of these constants to val, // we get two possible bit patterns above the low 17 bits, @@ -40,11 +42,13 @@ mod unchecked { } // 0 < val <= u16::MAX + #[inline] pub const fn u16(val: u16) -> u32 { less_than_5(val as u32) } // 0 < val <= u32::MAX + #[inline] pub const fn u32(mut val: u32) -> u32 { let mut log = 0; if val >= 100_000 { @@ -55,6 +59,7 @@ mod unchecked { } // 0 < val <= u64::MAX + #[inline] pub const fn u64(mut val: u64) -> u32 { let mut log = 0; if val >= 10_000_000_000 { @@ -69,6 +74,7 @@ mod unchecked { } // 0 < val <= u128::MAX + #[inline] pub const fn u128(mut val: u128) -> u32 { let mut log = 0; if val >= 100_000_000_000_000_000_000_000_000_000_000 { @@ -84,26 +90,31 @@ mod unchecked { } // 0 < val <= i8::MAX + #[inline] pub const fn i8(val: i8) -> u32 { u8(val as u8) } // 0 < val <= i16::MAX + #[inline] pub const fn i16(val: i16) -> u32 { u16(val as u16) } // 0 < val <= i32::MAX + #[inline] pub const fn i32(val: i32) -> u32 { u32(val as u32) } // 0 < val <= i64::MAX + #[inline] pub const fn i64(val: i64) -> u32 { u64(val as u64) } // 0 < val <= i128::MAX + #[inline] pub const fn i128(val: i128) -> u32 { u128(val as u128) } @@ -111,6 +122,7 @@ mod unchecked { macro_rules! impl_checked { ($T:ident) => { + #[inline] pub const fn $T(val: $T) -> Option { if val > 0 { Some(unchecked::$T(val)) } else { None } } -- cgit 1.4.1-3-g733a5 From 7a646df0985236ca8371865bcab978cc7d8ccda6 Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Mon, 11 Oct 2021 19:54:27 +0200 Subject: Add missing entries for overflow-checks to config.toml.example. --- config.toml.example | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config.toml.example b/config.toml.example index d811b914d20..b63ff14d7d3 100644 --- a/config.toml.example +++ b/config.toml.example @@ -423,6 +423,18 @@ changelog-seen = 2 # set this value to `true`. #debug-logging = rust.debug-assertions (boolean) +# Whether or not overflow checks are enabled for the compiler and standard +# library. +# +# Defaults to rust.debug value +#overflow-checks = rust.debug (boolean) + +# Whether or not overflow checks are enabled for the standard library. +# Overrides the `overflow-checks` option, if defined. +# +# Defaults to rust.overflow-checks value +#overflow-checks-std = rust.overflow-checks (boolean) + # Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`. # `0` - no debug info # `1` - line tables only - sufficient to generate backtraces that include line -- cgit 1.4.1-3-g733a5 From cfc7782a8457ff6e6856ef6741725c29b2e7c9c1 Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Mon, 11 Oct 2021 23:05:26 +0200 Subject: Add --enable-overflow-checks-std option to configure script. --- src/bootstrap/configure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index fd148d14478..ce029089c5a 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -76,6 +76,7 @@ o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface") o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") o("overflow-checks", "rust.overflow-checks", "build with overflow checks") +o("overflow-checks-std", "rust.overflow-checks-std", "build the standard library with overflow checks") o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata") v("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code") v("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler") -- cgit 1.4.1-3-g733a5 From bcf7cf6670adc17e84410e3d079002f5c338921a Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Tue, 12 Oct 2021 21:32:47 +0200 Subject: Add --enable-debug-assertions-std option to configure script. --- src/bootstrap/configure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index ce029089c5a..94424cb4548 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -75,6 +75,7 @@ o("optimize-llvm", "llvm.optimize", "build optimized LLVM") o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface") o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") +o("debug-assertions-std", "rust.debug-assertions-std", "build the standard library with debugging assertions") o("overflow-checks", "rust.overflow-checks", "build with overflow checks") o("overflow-checks-std", "rust.overflow-checks-std", "build the standard library with overflow checks") o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata") -- cgit 1.4.1-3-g733a5 From 905ed5fa89d613f7d77509f49f47ebbd85469063 Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Tue, 12 Oct 2021 21:28:49 +0200 Subject: Make `rust.overflow-checks-std`option default to `rust.overflow-checks`. --- src/bootstrap/config.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 062820040dc..7818b8b7d51 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -982,7 +982,8 @@ impl Config { config.rust_debug_assertions_std = debug_assertions_std.unwrap_or(config.rust_debug_assertions); config.rust_overflow_checks = overflow_checks.unwrap_or(default); - config.rust_overflow_checks_std = overflow_checks_std.unwrap_or(default); + config.rust_overflow_checks_std = + overflow_checks_std.unwrap_or(config.rust_overflow_checks); config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions); -- cgit 1.4.1-3-g733a5 From 4b4d3ee60b6602d2f32f02f170f531b5df15f127 Mon Sep 17 00:00:00 2001 From: Wang Qilin Date: Wed, 13 Oct 2021 15:47:15 +0800 Subject: fix the stage0 tools config file path in config.toml.example --- config.toml.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.toml.example b/config.toml.example index d811b914d20..2425adfd775 100644 --- a/config.toml.example +++ b/config.toml.example @@ -202,15 +202,15 @@ changelog-seen = 2 # You can use "$ROOT" to indicate the root of the git repository. #build-dir = "build" -# Instead of downloading the src/stage0.txt version of Cargo specified, use +# Instead of downloading the src/stage0.json version of Cargo specified, use # this Cargo binary instead to build all Rust code #cargo = "/path/to/cargo" -# Instead of downloading the src/stage0.txt version of the compiler +# Instead of downloading the src/stage0.json version of the compiler # specified, use this rustc binary instead as the stage0 snapshot compiler. #rustc = "/path/to/rustc" -# Instead of download the src/stage0.txt version of rustfmt specified, +# Instead of download the src/stage0.json version of rustfmt specified, # use this rustfmt binary instead as the stage0 snapshot rustfmt. #rustfmt = "/path/to/rustfmt" -- cgit 1.4.1-3-g733a5 From 646bc1d2391d655c09ae79d5604c9c0e048c0dac Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 13 Oct 2021 11:12:54 +0000 Subject: Add davidtwco to the `.mailmap` Signed-off-by: David Wood --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 2fbb480b85e..3b3e7334b75 100644 --- a/.mailmap +++ b/.mailmap @@ -72,6 +72,7 @@ Daniel Ramos David Klein David Manescu David Ross +David Wood Deadbeef Derek Chiang Derek Chiang (Enchi Jiang) Diggory Hardy Diggory Hardy -- cgit 1.4.1-3-g733a5