From 4c1daba940837de49c1a45ce93356c87de27d433 Mon Sep 17 00:00:00 2001 From: SylvainDe Date: Thu, 19 May 2022 21:58:39 +0200 Subject: [PATCH 01/11] Add implicit call to from_str via parse in documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation mentions "FromStr’s from_str method is often used implicitly, through str’s parse method. See parse’s documentation for examples.". It may be nicer to show that in the code example as well. --- library/core/src/str/traits.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/core/src/str/traits.rs b/library/core/src/str/traits.rs index 8b6b4fa02f833..32c31803a5115 100644 --- a/library/core/src/str/traits.rs +++ b/library/core/src/str/traits.rs @@ -530,8 +530,12 @@ unsafe impl const SliceIndex for ops::RangeToInclusive { /// } /// } /// -/// let p = Point::from_str("(1,2)"); -/// assert_eq!(p.unwrap(), Point{ x: 1, y: 2} ) +/// let expected = Ok(Point { x: 1, y: 2 }); +/// // Explicit call +/// assert_eq!(Point::from_str("(1,2)"), expected); +/// // Implicit calls, through parse +/// assert_eq!("(1,2)".parse(), expected); +/// assert_eq!("(1,2)".parse::(), expected); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub trait FromStr: Sized { From 31c3c0449807d22a0f10e7a290a8e4ed114b98d4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 20 May 2022 17:16:41 +0200 Subject: [PATCH 02/11] make ptr::invalid not the same as a regular int2ptr cast --- library/core/src/ptr/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index ba8b0670147ae..dc229c9ff9b44 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -555,7 +555,11 @@ pub const fn null_mut() -> *mut T { #[unstable(feature = "strict_provenance", issue = "95228")] pub const fn invalid(addr: usize) -> *const T { // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. - addr as *const T + // We use transmute rather than a cast so tools like Miri can tell that this + // is *not* the same as from_exposed_addr. + // SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that + // pointer). + unsafe { mem::transmute(addr) } } /// Creates an invalid mutable pointer with the given address. @@ -582,7 +586,11 @@ pub const fn invalid(addr: usize) -> *const T { #[unstable(feature = "strict_provenance", issue = "95228")] pub const fn invalid_mut(addr: usize) -> *mut T { // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. - addr as *mut T + // We use transmute rather than a cast so tools like Miri can tell that this + // is *not* the same as from_exposed_addr. + // SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that + // pointer). + unsafe { mem::transmute(addr) } } /// Convert an address back to a pointer, picking up a previously 'exposed' provenance. From cd90406090c5439d4d403981d9503b66bd7bea0d Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 20 May 2022 19:34:31 +0200 Subject: [PATCH 03/11] Remove quadratic behaviour from -Zunpretty=hir-tree. --- compiler/rustc_hir/src/hir.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 57655365cca95..29b757b193514 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -796,7 +796,6 @@ impl<'tcx> AttributeMap<'tcx> { /// Map of all HIR nodes inside the current owner. /// These nodes are mapped by `ItemLocalId` alongside the index of their parent node. /// The HIR tree, including bodies, is pre-hashed. -#[derive(Debug)] pub struct OwnerNodes<'tcx> { /// Pre-computed hash of the full HIR. pub hash_including_bodies: Fingerprint, @@ -822,6 +821,18 @@ impl<'tcx> OwnerNodes<'tcx> { } } +impl fmt::Debug for OwnerNodes<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("OwnerNodes") + .field("node", &self.nodes[ItemLocalId::from_u32(0)]) + .field("bodies", &self.bodies) + .field("local_id_to_def_id", &self.local_id_to_def_id) + .field("hash_without_bodies", &self.hash_without_bodies) + .field("hash_including_bodies", &self.hash_including_bodies) + .finish() + } +} + /// Full information resulting from lowering an AST node. #[derive(Debug, HashStable_Generic)] pub struct OwnerInfo<'hir> { From b036fd378b55dcf42c72b9db6e2bcbaeeb4dfdf0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 20 May 2022 17:04:21 +0200 Subject: [PATCH 04/11] Add eslint arrow-spacing check --- src/librustdoc/html/static/.eslintrc.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 9d4c45b8a6251..6b63e3b714a3b 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -38,5 +38,9 @@ module.exports = { "error", { "before": true, "after": true } ], + "arrow-spacing": [ + "error", + { "before": true, "after": true } + ], } }; From 116c5a25e7966c8ca8438c525c30ca835e142467 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 20 May 2022 17:05:20 +0200 Subject: [PATCH 05/11] Add eslint key-spacing check --- src/librustdoc/html/static/.eslintrc.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 6b63e3b714a3b..cb163d540e0a8 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -42,5 +42,9 @@ module.exports = { "error", { "before": true, "after": true } ], + "key-spacing": [ + "error", + { "beforeColon": false, "afterColon": true, "mode": "strict" } + ], } }; From bb8a1205c642cd3241b9a5fd09feeb4820b6ca43 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Fri, 20 May 2022 22:02:20 +0200 Subject: [PATCH 06/11] typo --- compiler/rustc_ast/src/ptr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_ast/src/ptr.rs b/compiler/rustc_ast/src/ptr.rs index 89a0857992e49..bab85a3019d61 100644 --- a/compiler/rustc_ast/src/ptr.rs +++ b/compiler/rustc_ast/src/ptr.rs @@ -10,7 +10,7 @@ //! //! * **Immutability**: `P` disallows mutating its inner `T`, unlike `Box` //! (unless it contains an `Unsafe` interior, but that may be denied later). -//! This mainly prevents mistakes, but can also enforces a kind of "purity". +//! This mainly prevents mistakes, but also enforces a kind of "purity". //! //! * **Efficiency**: folding can reuse allocation space for `P` and `Vec`, //! the latter even when the input and output types differ (as it would be the From 51730fb171c7d92216451ca777a3981105bad374 Mon Sep 17 00:00:00 2001 From: Jaro Fietz Date: Tue, 29 Jun 2021 15:13:43 +0200 Subject: [PATCH 07/11] Make the most special expression even more special Add or-pattern syntax in argument position --- src/test/ui/weird-exprs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/weird-exprs.rs b/src/test/ui/weird-exprs.rs index 42acd30a0ff6a..d7420a00af42c 100644 --- a/src/test/ui/weird-exprs.rs +++ b/src/test/ui/weird-exprs.rs @@ -115,7 +115,7 @@ fn union() { } fn special_characters() { - let val = !((|(..):(_,_),__@_|__)((&*"\\",'πŸ€”')/**/,{})=={&[..=..][..];})// + let val = !((|(..):(_,_),(|__@_|__)|__)((&*"\\",'#')/**/,{})=={&[..=..][..];})// ; assert!(!val); } From df0b0d4ae381a863d84c1f1debc83c6adab65763 Mon Sep 17 00:00:00 2001 From: Jaro Fietz Date: Tue, 29 Jun 2021 20:22:44 +0200 Subject: [PATCH 08/11] Add unicode identifier to weird-exprs Use unicode identifiers and a unicode emoji in weird-exprs.rs --- src/test/ui/weird-exprs.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/ui/weird-exprs.rs b/src/test/ui/weird-exprs.rs index d7420a00af42c..fb8b32e280309 100644 --- a/src/test/ui/weird-exprs.rs +++ b/src/test/ui/weird-exprs.rs @@ -6,6 +6,7 @@ #![allow(dead_code)] #![allow(unreachable_code)] #![allow(unused_braces, unused_must_use, unused_parens)] +#![allow(uncommon_codepoints, confusable_idents)] #![recursion_limit = "256"] @@ -164,6 +165,13 @@ fn monkey_barrel() { assert_eq!(val, ()); } +fn unicode() { + fn πš‹πš›πšŽπšŠπš”() -> char { 'πŸ€”' } + assert_eq!(loop { + break πš‹πš›πšŽπšŠπš” (); + }, 'πŸ€”'); +} + fn bathroom_stall() { let mut i = 1; matches!(2, _|_|_|_|_|_ if (i+=1) != (i+=1)); @@ -189,5 +197,6 @@ pub fn main() { i_yield(); match_nested_if(); monkey_barrel(); + unicode(); bathroom_stall(); } From d85ba01ecb41873f47c2e6acb8cc397a6ae5f1bd Mon Sep 17 00:00:00 2001 From: Jaro Fietz Date: Tue, 29 Jun 2021 20:28:44 +0200 Subject: [PATCH 09/11] Add a function returning itself to weird-exprs --- src/test/ui/weird-exprs.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/ui/weird-exprs.rs b/src/test/ui/weird-exprs.rs index fb8b32e280309..c7ee9c7334a9e 100644 --- a/src/test/ui/weird-exprs.rs +++ b/src/test/ui/weird-exprs.rs @@ -1,6 +1,8 @@ // run-pass #![feature(generators)] +#![feature(destructuring_assignment)] +#![feature(unboxed_closures, fn_traits)] #![allow(non_camel_case_types)] #![allow(dead_code)] @@ -172,6 +174,17 @@ fn unicode() { }, 'πŸ€”'); } +fn function() { + struct foo; + impl FnOnce<()> for foo { + type Output = foo; + extern "rust-call" fn call_once(self, _args: ()) -> Self::Output { + foo + } + } + let foo = foo () ()() ()()() ()()()() ()()()()(); +} + fn bathroom_stall() { let mut i = 1; matches!(2, _|_|_|_|_|_ if (i+=1) != (i+=1)); @@ -198,5 +211,6 @@ pub fn main() { match_nested_if(); monkey_barrel(); unicode(); + function(); bathroom_stall(); } From 6491eb1e6c9fac20faad11e5da16db3185b2410d Mon Sep 17 00:00:00 2001 From: oberien Date: Sat, 21 May 2022 00:17:33 +0200 Subject: [PATCH 10/11] Add back thinking emoji --- src/test/ui/weird-exprs.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/test/ui/weird-exprs.rs b/src/test/ui/weird-exprs.rs index c7ee9c7334a9e..4066bcf3badd7 100644 --- a/src/test/ui/weird-exprs.rs +++ b/src/test/ui/weird-exprs.rs @@ -1,7 +1,6 @@ // run-pass #![feature(generators)] -#![feature(destructuring_assignment)] #![feature(unboxed_closures, fn_traits)] #![allow(non_camel_case_types)] @@ -118,7 +117,7 @@ fn union() { } fn special_characters() { - let val = !((|(..):(_,_),(|__@_|__)|__)((&*"\\",'#')/**/,{})=={&[..=..][..];})// + let val = !((|(..):(_,_),(|__@_|__)|__)((&*"\\",'πŸ€”')/**/,{})=={&[..=..][..];})// ; assert!(!val); } @@ -167,11 +166,15 @@ fn monkey_barrel() { assert_eq!(val, ()); } -fn unicode() { - fn πš‹πš›πšŽπšŠπš”() -> char { 'πŸ€”' } +fn πšŒπš˜πš—πšπš’πš—πšžπšŽ() { + type πš•πš˜πš˜πš™ = i32; + fn πš‹πš›πšŽπšŠπš”() -> πš•πš˜πš˜πš™ { + let πš›πšŽπšπšžπš›πš— = 42; + return πš›πšŽπšπšžπš›πš—; + } assert_eq!(loop { break πš‹πš›πšŽπšŠπš” (); - }, 'πŸ€”'); + }, 42); } fn function() { @@ -210,7 +213,7 @@ pub fn main() { i_yield(); match_nested_if(); monkey_barrel(); - unicode(); + πšŒπš˜πš—πšπš’πš—πšžπšŽ(); function(); bathroom_stall(); } From 7501995977d49238091b4ddee95c9595c4866ffe Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 20 May 2022 18:56:21 -0400 Subject: [PATCH 11/11] Bump LLVM fetched from CI to fix run-make --- src/bootstrap/dist.rs | 3 +++ src/bootstrap/download-ci-llvm-stamp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 16727f4398dff..a6fb72c03f3dd 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -2038,6 +2038,9 @@ impl Step for RustDev { tarball.set_overlay(OverlayKind::LLVM); let src_bindir = builder.llvm_out(target).join("bin"); + // If updating this list, you likely want to change + // src/bootstrap/download-ci-llvm-stamp as well, otherwise local users + // will not pick up the extra file until LLVM gets bumped. for bin in &[ "llvm-config", "llvm-ar", diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp index 20a98111bebaa..19504a51a584b 100644 --- a/src/bootstrap/download-ci-llvm-stamp +++ b/src/bootstrap/download-ci-llvm-stamp @@ -1,4 +1,4 @@ Change this file to make users of the `download-ci-llvm` configuration download a new version of LLVM from CI, even if the LLVM submodule hasn’t changed. -Last change is for: https://github.com/rust-lang/rust/pull/94023 +Last change is for: https://github.com/rust-lang/rust/pull/96867