From 08fbe3dafa24429d17009bd5ee475e10a53be9b6 Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Mon, 14 Mar 2022 22:01:06 -0400 Subject: [PATCH 1/8] Include tracking issue in diagnostic --- compiler/rustc_attr/src/builtin.rs | 3 +-- .../ui/deprecation/feature-gate-deprecated_suggestion.stderr | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 613320087d2dd..ffad7dcf55774 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -750,8 +750,7 @@ where if sess.is_nightly_build() { diag.help("add `#![feature(deprecated_suggestion)]` to the crate root"); } - // FIXME(jhpratt) change this to an actual tracking issue - diag.note("see #XXX for more details").emit(); + diag.note("see #94785 for more details").emit(); } if !get(mi, &mut suggestion) { diff --git a/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr index 3b995fed75c8c..438ce3349d252 100644 --- a/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr +++ b/src/test/ui/deprecation/feature-gate-deprecated_suggestion.stderr @@ -5,7 +5,7 @@ LL | #[deprecated(suggestion = "foo")] | ^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(deprecated_suggestion)]` to the crate root - = note: see #XXX for more details + = note: see #94785 for more details error: aborting due to previous error From 06a1fc98eb93ca7062b11ec45053db990a4c127f Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Mon, 14 Mar 2022 22:05:30 -0400 Subject: [PATCH 2/8] Correct meta item diagnostic --- compiler/rustc_attr/src/builtin.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index ffad7dcf55774..e1eb014738fa6 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -763,10 +763,10 @@ where meta.span(), AttrError::UnknownMetaItem( pprust::path_to_string(&mi.path), - if attr.has_name(sym::deprecated) { - &["since", "note"] - } else { + if sess.features_untracked().deprecated_suggestion { &["since", "note", "suggestion"] + } else { + &["since", "note"] }, ), ); From 8a75d5551432512688bdb6865b3858f5d317d9b0 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 15 Mar 2022 20:59:13 -0700 Subject: [PATCH 3/8] Add Stream alias for AsyncIterator --- library/core/src/async_iter/async_iter.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/async_iter/async_iter.rs b/library/core/src/async_iter/async_iter.rs index f29de31171a67..016a3685e850c 100644 --- a/library/core/src/async_iter/async_iter.rs +++ b/library/core/src/async_iter/async_iter.rs @@ -12,6 +12,7 @@ use crate::task::{Context, Poll}; /// [impl]: index.html#implementing-async-iterator #[unstable(feature = "async_iterator", issue = "79024")] #[must_use = "async iterators do nothing unless polled"] +#[doc(alias = "Stream")] pub trait AsyncIterator { /// The type of items yielded by the async iterator. type Item; From 789eb08147d0f89b8cf6fbe04dbea1a4c81d7c42 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 17 Mar 2022 20:19:10 -0600 Subject: [PATCH 4/8] Fix debuginfo tests with GDB 11.2 GDB 11.2 added support for DW_ATE_UTF, which caused some test failures. This fixes these tests by changing the format that is used, and adds a new test to verify that characters are emitted as something that GDB can print in a char-like way. Fixes #94458 --- src/test/debuginfo/borrowed-basic.rs | 5 +---- src/test/debuginfo/borrowed-unique-basic.rs | 5 +---- src/test/debuginfo/gdb-char.rs | 23 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 src/test/debuginfo/gdb-char.rs diff --git a/src/test/debuginfo/borrowed-basic.rs b/src/test/debuginfo/borrowed-basic.rs index b4bb7c146d9df..45f5df228e3f4 100644 --- a/src/test/debuginfo/borrowed-basic.rs +++ b/src/test/debuginfo/borrowed-basic.rs @@ -1,6 +1,3 @@ -// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only -// its numerical value. - // compile-flags:-g // min-lldb-version: 310 @@ -13,7 +10,7 @@ // gdb-command:print *int_ref // gdb-check:$2 = -1 -// gdb-command:print *char_ref +// gdb-command:print/d *char_ref // gdb-check:$3 = 97 // gdb-command:print *i8_ref diff --git a/src/test/debuginfo/borrowed-unique-basic.rs b/src/test/debuginfo/borrowed-unique-basic.rs index f38cbc10dd3ac..94229bf27f3c9 100644 --- a/src/test/debuginfo/borrowed-unique-basic.rs +++ b/src/test/debuginfo/borrowed-unique-basic.rs @@ -1,8 +1,5 @@ // min-lldb-version: 310 -// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only -// its numerical value. - // compile-flags:-g // === GDB TESTS =================================================================================== @@ -15,7 +12,7 @@ // gdb-command:print *int_ref // gdb-check:$2 = -1 -// gdb-command:print *char_ref +// gdb-command:print/d *char_ref // gdb-check:$3 = 97 // gdb-command:print/d *i8_ref diff --git a/src/test/debuginfo/gdb-char.rs b/src/test/debuginfo/gdb-char.rs new file mode 100644 index 0000000000000..1863405bf1e92 --- /dev/null +++ b/src/test/debuginfo/gdb-char.rs @@ -0,0 +1,23 @@ +// GDB got support for DW_ATE_UTF in 11.2, see +// https://sourceware.org/bugzilla/show_bug.cgi?id=28637. + +// min-gdb-version: 11.2 +// compile-flags: -g + +// === GDB TESTS =================================================================================== + +// gdb-command:run +// gdb-command:print ch +// gdb-check:$1 = 97 'a' + +#![allow(unused_variables)] +#![feature(omit_gdb_pretty_printer_section)] +#![omit_gdb_pretty_printer_section] + +fn main() { + let ch: char = 'a'; + + zzz(); // #break +} + +fn zzz() {()} From edee46e257ec4aa6d6a78ac4f061cd525ef231f9 Mon Sep 17 00:00:00 2001 From: Waleed Dahshan <58462210+wmstack@users.noreply.github.com> Date: Sat, 19 Mar 2022 18:52:30 +1100 Subject: [PATCH 5/8] Provide more useful documentation of conversion methods I thought that the documentation for these methods needed to be a bit more explanatory for new users. For advanced users, the comments are relatively unnecessary. I think it would be useful to explain precisely what the method does. As a new user, when you see the `into` method, where the type is inferred, if you are new you don't even know what you convert to, because it is implicit. I believe this can help new users understand. --- library/core/src/convert/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index f5ea5f5ba50c0..e2ffc8c9121f3 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -154,7 +154,7 @@ pub const fn identity(x: T) -> T { #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "AsRef")] pub trait AsRef { - /// Performs the conversion. + /// Converts this type into a shared reference of the (usually inferred) input type. #[stable(feature = "rust1", since = "1.0.0")] fn as_ref(&self) -> &T; } @@ -196,7 +196,7 @@ pub trait AsRef { #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "AsMut")] pub trait AsMut { - /// Performs the conversion. + /// Converts this type into a mutable reference of the (usually inferred) input type. #[stable(feature = "rust1", since = "1.0.0")] fn as_mut(&mut self) -> &mut T; } @@ -272,7 +272,7 @@ pub trait AsMut { #[rustc_diagnostic_item = "Into"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Into: Sized { - /// Performs the conversion. + /// Converts this type into the (usually inferred) input type. #[must_use] #[stable(feature = "rust1", since = "1.0.0")] fn into(self) -> T; @@ -367,7 +367,7 @@ pub trait Into: Sized { note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix", ))] pub trait From: Sized { - /// Performs the conversion. + /// Converts to this type from the input type. #[lang = "from"] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] From 1338a45d9814b031466753a99a58ca688014f9cf Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sat, 19 Mar 2022 02:03:37 -0700 Subject: [PATCH 6/8] Give more details in `Display` for `hir::Target` Made because I was making a code change and got a very confusing "should be applied to a method, not a method" error. ``` error[E0718]: `into_try_type` language item must be applied to a method --> library\core\src\ops\try_trait.rs:352:32 | 352 | #[cfg_attr(not(bootstrap), lang = "into_try_type")] | ^^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a method, not a method ``` --- compiler/rustc_hir/src/target.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir/src/target.rs b/compiler/rustc_hir/src/target.rs index 29c948fe31845..70d9db4a84ba1 100644 --- a/compiler/rustc_hir/src/target.rs +++ b/compiler/rustc_hir/src/target.rs @@ -86,7 +86,11 @@ impl Display for Target { Target::Statement => "statement", Target::Arm => "match arm", Target::AssocConst => "associated const", - Target::Method(_) => "method", + Target::Method(kind) => match kind { + MethodKind::Inherent => "inherent method", + MethodKind::Trait { body: false } => "required trait method", + MethodKind::Trait { body: true } => "provided trait method", + }, Target::AssocTy => "associated type", Target::ForeignFn => "foreign function", Target::ForeignStatic => "foreign static item", From 0467300eecd0d816c43f1788d03bdde8dbc5ef4a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 18 Mar 2022 20:34:27 +0100 Subject: [PATCH 7/8] Don't declare test_variadic_fnptr with two conflicting signatures It is UB for LLVM and results in a compile error for Cranelift --- ...-sysroot-Disable-not-compiling-tests.patch | 20 ------------------- library/core/tests/lib.rs | 1 + library/core/tests/ptr.rs | 14 +++++++------ 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/patches/0022-sysroot-Disable-not-compiling-tests.patch b/compiler/rustc_codegen_cranelift/patches/0022-sysroot-Disable-not-compiling-tests.patch index 1c45c7573c813..301b3f9bde4dd 100644 --- a/compiler/rustc_codegen_cranelift/patches/0022-sysroot-Disable-not-compiling-tests.patch +++ b/compiler/rustc_codegen_cranelift/patches/0022-sysroot-Disable-not-compiling-tests.patch @@ -39,26 +39,6 @@ index a35897e..f0bf645 100644 pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { -diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs -index 1a6be3a..42dbd59 100644 ---- a/library/core/tests/ptr.rs -+++ b/library/core/tests/ptr.rs -@@ -250,6 +250,7 @@ fn test_unsized_nonnull() { - }; - } - -+/* - #[test] - #[allow(warnings)] - // Have a symbol for the test below. It doesn’t need to be an actual variadic function, match the -@@ -277,6 +277,7 @@ pub fn test_variadic_fnptr() { - let mut s = SipHasher::new(); - assert_eq!(p.hash(&mut s), q.hash(&mut s)); - } -+*/ - - #[test] - fn write_unaligned_drop() { diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 6609bc3..241b497 100644 --- a/library/core/tests/slice.rs diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index dc3740228274b..5c861236e86f1 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -23,6 +23,7 @@ #![feature(const_ptr_offset)] #![feature(const_trait_impl)] #![feature(const_likely)] +#![feature(core_ffi_c)] #![feature(core_intrinsics)] #![feature(core_private_bignum)] #![feature(core_private_diy_float)] diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs index af8e78f1f4e16..84d3ae03ef4a1 100644 --- a/library/core/tests/ptr.rs +++ b/library/core/tests/ptr.rs @@ -289,16 +289,18 @@ fn test_const_nonnull_new() { } #[test] -#[allow(warnings)] -// Have a symbol for the test below. It doesn’t need to be an actual variadic function, match the -// ABI, or even point to an actual executable code, because the function itself is never invoked. -#[no_mangle] +#[cfg(any(unix, windows))] // printf may not be available on other platforms +#[allow(deprecated)] // For SipHasher pub fn test_variadic_fnptr() { + use core::ffi; use core::hash::{Hash, SipHasher}; extern "C" { - fn test_variadic_fnptr(_: u64, ...) -> f64; + // This needs to use the correct function signature even though it isn't called as some + // codegen backends make it UB to declare a function with multiple conflicting signatures + // (like LLVM) while others straight up return an error (like Cranelift). + fn printf(_: *const ffi::c_char, ...) -> ffi::c_int; } - let p: unsafe extern "C" fn(u64, ...) -> f64 = test_variadic_fnptr; + let p: unsafe extern "C" fn(*const ffi::c_char, ...) -> ffi::c_int = printf; let q = p.clone(); assert_eq!(p, q); assert!(!(p < q)); From e69e652b65bd6019487eafd6d1ed1cdcc1727ef4 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Mon, 14 Mar 2022 15:31:48 +0000 Subject: [PATCH 8/8] Update libc to 0.2.121 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dce5357b12d33..02e7a92769095 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1965,9 +1965,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.116" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74" +checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" dependencies = [ "rustc-std-workspace-core", ]