From 65f89990265211af0591c0b09e58ea833e4f7d0e Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 17 Sep 2024 15:14:27 -0300 Subject: [PATCH 1/2] Remove redundant test typeid equality by subtyping --- .../typeid-equality-by-subtyping.rs | 54 ------------------- .../typeid-equality-by-subtyping.stderr | 27 ---------- 2 files changed, 81 deletions(-) delete mode 100644 tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs delete mode 100644 tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs deleted file mode 100644 index 81be8d5c7d767..0000000000000 --- a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs +++ /dev/null @@ -1,54 +0,0 @@ -//@ known-bug: #110395 -//@ known-bug: #97156 - -#![feature(const_type_id, const_trait_impl, generic_const_exprs)] -#![allow(incomplete_features)] - -use std::any::TypeId; -// `One` and `Two` are currently considered equal types, as both -// `One <: Two` and `One :> Two` holds. -type One = for<'a> fn(&'a (), &'a ()); -type Two = for<'a, 'b> fn(&'a (), &'b ()); -trait AssocCt { - const ASSOC: usize; -} -const fn to_usize() -> usize { - const WHAT_A_TYPE: TypeId = TypeId::of::(); - match TypeId::of::() { - WHAT_A_TYPE => 0, - _ => 1000, - } -} -impl AssocCt for T { - const ASSOC: usize = to_usize::(); -} - -trait WithAssoc { - type Assoc; -} -impl WithAssoc<()> for T -where - [(); ::ASSOC]:, -{ - type Assoc = [u8; ::ASSOC]; -} - -fn generic(x: >::Assoc) -> >::Assoc -where - [(); ::ASSOC]:, - T: WithAssoc, -{ - x -} - -fn unsound(x: >::Assoc) -> >::Assoc -where - One: WithAssoc, -{ - let x: >::Assoc = generic::(x); - x -} - -fn main() { - println!("{:?}", unsound::<()>([])); -} diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr deleted file mode 100644 index 26e724c906137..0000000000000 --- a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: to use a constant of type `TypeId` in a pattern, `TypeId` must be annotated with `#[derive(PartialEq)]` - --> $DIR/typeid-equality-by-subtyping.rs:18:9 - | -LL | WHAT_A_TYPE => 0, - | ^^^^^^^^^^^ - | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details - -error[E0277]: the trait bound `for<'a, 'b> fn(&'a (), &'b ()): WithAssoc` is not satisfied - --> $DIR/typeid-equality-by-subtyping.rs:44:51 - | -LL | fn unsound(x: >::Assoc) -> >::Assoc - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WithAssoc` is not implemented for `for<'a, 'b> fn(&'a (), &'b ())` - -error[E0277]: the trait bound `for<'a, 'b> fn(&'a (), &'b ()): WithAssoc` is not satisfied - --> $DIR/typeid-equality-by-subtyping.rs:47:1 - | -LL | / { -LL | | let x: >::Assoc = generic::(x); -LL | | x -LL | | } - | |_^ the trait `WithAssoc` is not implemented for `for<'a, 'b> fn(&'a (), &'b ())` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. From 0c9a17689ad8d72610bedcb17dac42ac6822d171 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Tue, 17 Sep 2024 20:03:59 +0200 Subject: [PATCH 2/2] Remove uneeded PartialOrd bound in cmp::Ord::clamp There is a Self: PartialOrd bound in Ord::clamp, but it is already required by the trait itself. Likely a left-over from the const trait deletion in 76dbe2910465072f85e74d6f7115ec9e6803e8bf. Reported-by: @noeensarguet --- library/core/src/cmp.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index a1ed993b7d9bf..818a36002e759 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -901,7 +901,6 @@ pub trait Ord: Eq + PartialOrd { fn clamp(self, min: Self, max: Self) -> Self where Self: Sized, - Self: PartialOrd, { assert!(min <= max); if self < min {