From a5cbb5200d4ec3eb2dd2669f669a3a811a1ceb94 Mon Sep 17 00:00:00 2001 From: glowcoil Date: Fri, 6 Sep 2024 19:30:47 -0500 Subject: [PATCH 1/4] fix doc comments for Peekable::next_if(_eq) Fix references to a nonexistent `consume` function in the doc comments for `Peekable::next_if` and `Peekable::next_if_eq`. --- library/core/src/iter/adapters/peekable.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/iter/adapters/peekable.rs b/library/core/src/iter/adapters/peekable.rs index a11b73cbe8e..cc12cd9c356 100644 --- a/library/core/src/iter/adapters/peekable.rs +++ b/library/core/src/iter/adapters/peekable.rs @@ -269,7 +269,7 @@ pub fn peek_mut(&mut self) -> Option<&mut I::Item> { /// let mut iter = (0..5).peekable(); /// // The first item of the iterator is 0; consume it. /// assert_eq!(iter.next_if(|&x| x == 0), Some(0)); - /// // The next item returned is now 1, so `consume` will return `false`. + /// // The next item returned is now 1, so `next_if` will return `None`. /// assert_eq!(iter.next_if(|&x| x == 0), None); /// // `next_if` saves the value of the next item if it was not equal to `expected`. /// assert_eq!(iter.next(), Some(1)); @@ -304,7 +304,7 @@ pub fn next_if(&mut self, func: impl FnOnce(&I::Item) -> bool) -> Option Date: Thu, 12 Sep 2024 09:53:59 +0200 Subject: [PATCH 2/4] small_data_threshold.rs: Adapt to LLVM head changes --- tests/assembly/small_data_threshold.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/assembly/small_data_threshold.rs b/tests/assembly/small_data_threshold.rs index b0c0a63ca49..d3ba144600e 100644 --- a/tests/assembly/small_data_threshold.rs +++ b/tests/assembly/small_data_threshold.rs @@ -58,7 +58,7 @@ fn drop_in_place(_: *mut T) {} // Currently, only MIPS and RISCV successfully put any objects in the small data // sections so the U/V/W/X tests are skipped on Hexagon and M68K -//@ RISCV: .section .sdata, +//@ RISCV: .section .sdata //@ RISCV-NOT: .section //@ RISCV: U: //@ RISCV: .section .sbss @@ -71,7 +71,7 @@ fn drop_in_place(_: *mut T) {} //@ RISCV-NOT: .section //@ RISCV: X: -//@ MIPS: .section .sdata, +//@ MIPS: .section .sdata //@ MIPS-NOT: .section //@ MIPS: U: //@ MIPS: .section .sbss From b0db3a7bedc03d054834b675c417b988d7dc676f Mon Sep 17 00:00:00 2001 From: Giang Dao Date: Fri, 13 Sep 2024 23:07:08 +0800 Subject: [PATCH 3/4] (fix) conflicting negative impl marker and add tests --- .../src/error_reporting/traits/mod.rs | 3 ++- compiler/rustc_type_ir/src/predicate.rs | 11 +++++++++++ ...onflicting-repeated-negative-trait-impl-70849.rs | 10 ++++++++++ ...icting-repeated-negative-trait-impl-70849.stderr | 13 +++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/ui/coherence/coherence-conflicting-repeated-negative-trait-impl-70849.rs create mode 100644 tests/ui/coherence/coherence-conflicting-repeated-negative-trait-impl-70849.stderr diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index 9aa6d1f3d46..752ef729113 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -344,7 +344,8 @@ pub(crate) fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Opti write!( w, - " {} for {}", + " {}{} for {}", + tcx.impl_polarity(impl_def_id).as_str(), trait_ref.print_only_trait_path(), tcx.type_of(impl_def_id).instantiate_identity() ) diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index b30346ffc53..e4bf1e1379c 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -196,6 +196,17 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } +impl ImplPolarity { + /// The polarity marker in front of the impl trait ref if applicable. + pub fn as_str(self) -> &'static str { + match self { + Self::Positive => "", + Self::Negative => "!", + Self::Reservation => "", + } + } +} + /// Polarity for a trait predicate. May either be negative or positive. /// Distinguished from [`ImplPolarity`] since we never compute goals with /// "reservation" level. diff --git a/tests/ui/coherence/coherence-conflicting-repeated-negative-trait-impl-70849.rs b/tests/ui/coherence/coherence-conflicting-repeated-negative-trait-impl-70849.rs new file mode 100644 index 00000000000..88b9d9e62bf --- /dev/null +++ b/tests/ui/coherence/coherence-conflicting-repeated-negative-trait-impl-70849.rs @@ -0,0 +1,10 @@ +#![feature(negative_impls)] +//@ edition: 2021 +// Test to ensure we are printing the polarity of the impl trait ref +// when printing out conflicting trait impls + +struct MyType; + +impl !Clone for &mut MyType {} +//~^ ERROR conflicting implementations of trait `Clone` for type `&mut MyType` +fn main() {} diff --git a/tests/ui/coherence/coherence-conflicting-repeated-negative-trait-impl-70849.stderr b/tests/ui/coherence/coherence-conflicting-repeated-negative-trait-impl-70849.stderr new file mode 100644 index 00000000000..b317197eb40 --- /dev/null +++ b/tests/ui/coherence/coherence-conflicting-repeated-negative-trait-impl-70849.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Clone` for type `&mut MyType` + --> $DIR/coherence-conflicting-repeated-negative-trait-impl-70849.rs:8:1 + | +LL | impl !Clone for &mut MyType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl !Clone for &mut T + where T: ?Sized; + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0119`. From 56844c797ad65f25e1696bac966743fc47b9beb2 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sat, 14 Sep 2024 04:28:38 +0200 Subject: [PATCH 4/4] Fix SDKROOT ignore on macOS --- compiler/rustc_codegen_ssa/src/back/link.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 40eb35deea5..8b855bd0dd5 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -3044,7 +3044,7 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result { } - "macosx10.15" + "macosx" if sdkroot.contains("iPhoneOS.platform") || sdkroot.contains("iPhoneSimulator.platform") => {} "watchos"