Auto merge of #130492 - matthiaskrgr:rollup-9pxkd8i, r=matthiaskrgr
Rollup of 2 pull requests Successful merges: - #130481 (Remove uneeded PartialOrd bound in cmp::Ord::clamp) - #130482 (Remove redundant test typeid equality by subtyping) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
f7b4c72c8f
3 changed files with 0 additions and 82 deletions
|
@ -901,7 +901,6 @@ pub trait Ord: Eq + PartialOrd<Self> {
|
||||||
fn clamp(self, min: Self, max: Self) -> Self
|
fn clamp(self, min: Self, max: Self) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Self: PartialOrd,
|
|
||||||
{
|
{
|
||||||
assert!(min <= max);
|
assert!(min <= max);
|
||||||
if self < min {
|
if self < min {
|
||||||
|
|
|
@ -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<T: 'static>() -> usize {
|
|
||||||
const WHAT_A_TYPE: TypeId = TypeId::of::<One>();
|
|
||||||
match TypeId::of::<T>() {
|
|
||||||
WHAT_A_TYPE => 0,
|
|
||||||
_ => 1000,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T: 'static> AssocCt for T {
|
|
||||||
const ASSOC: usize = to_usize::<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
trait WithAssoc<U> {
|
|
||||||
type Assoc;
|
|
||||||
}
|
|
||||||
impl<T: 'static> WithAssoc<()> for T
|
|
||||||
where
|
|
||||||
[(); <T as AssocCt>::ASSOC]:,
|
|
||||||
{
|
|
||||||
type Assoc = [u8; <T as AssocCt>::ASSOC];
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generic<T: 'static, U>(x: <T as WithAssoc<U>>::Assoc) -> <T as WithAssoc<U>>::Assoc
|
|
||||||
where
|
|
||||||
[(); <T as AssocCt>::ASSOC]:,
|
|
||||||
T: WithAssoc<U>,
|
|
||||||
{
|
|
||||||
x
|
|
||||||
}
|
|
||||||
|
|
||||||
fn unsound<T>(x: <One as WithAssoc<T>>::Assoc) -> <Two as WithAssoc<T>>::Assoc
|
|
||||||
where
|
|
||||||
One: WithAssoc<T>,
|
|
||||||
{
|
|
||||||
let x: <Two as WithAssoc<T>>::Assoc = generic::<One, T>(x);
|
|
||||||
x
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
println!("{:?}", unsound::<()>([]));
|
|
||||||
}
|
|
|
@ -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<T>` is not satisfied
|
|
||||||
--> $DIR/typeid-equality-by-subtyping.rs:44:51
|
|
||||||
|
|
|
||||||
LL | fn unsound<T>(x: <One as WithAssoc<T>>::Assoc) -> <Two as WithAssoc<T>>::Assoc
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WithAssoc<T>` is not implemented for `for<'a, 'b> fn(&'a (), &'b ())`
|
|
||||||
|
|
||||||
error[E0277]: the trait bound `for<'a, 'b> fn(&'a (), &'b ()): WithAssoc<T>` is not satisfied
|
|
||||||
--> $DIR/typeid-equality-by-subtyping.rs:47:1
|
|
||||||
|
|
|
||||||
LL | / {
|
|
||||||
LL | | let x: <Two as WithAssoc<T>>::Assoc = generic::<One, T>(x);
|
|
||||||
LL | | x
|
|
||||||
LL | | }
|
|
||||||
| |_^ the trait `WithAssoc<T>` 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`.
|
|
Loading…
Add table
Add a link
Reference in a new issue