| 1 |
// SPDX-License-Identifier: Apache-2.0 OR MIT |
| 2 |
|
| 3 |
#![feature(min_specialization)] |
| 4 |
|
| 5 |
// See also run-pass/specialization.rs. |
| 6 |
|
| 7 |
// https://github.com/rust-lang/rust/blob/1.84.0/tests/ui/specialization/min_specialization/implcit-well-formed-bounds.rs |
| 8 |
pub mod implicit_well_formed_bounds { |
| 9 |
use easy_ext::ext; |
| 10 |
|
| 11 |
struct OrdOnly<T: Ord>(T); |
| 12 |
|
| 13 |
#[ext(SpecTrait)] |
| 14 |
impl<T, U> T { |
| 15 |
default fn f() {} |
| 16 |
} |
| 17 |
|
| 18 |
impl<T: Ord> SpecTrait<()> for OrdOnly<T> { |
| 19 |
fn f() {} |
| 20 |
} |
| 21 |
|
| 22 |
impl<T: Ord> SpecTrait<OrdOnly<T>> for () { |
| 23 |
fn f() {} |
| 24 |
} |
| 25 |
|
| 26 |
impl<T: Ord, U: Ord, V: Ord> SpecTrait<(OrdOnly<T>, OrdOnly<U>)> for &[OrdOnly<V>] { |
| 27 |
fn f() {} |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
// https://github.com/rust-lang/rust/blob/1.84.0/tests/ui/specialization/min_specialization/spec-iter.rs |
| 32 |
pub mod spec_iter { |
| 33 |
use easy_ext::ext; |
| 34 |
|
| 35 |
#[ext(SpecFromIter)] |
| 36 |
impl<'a, T: 'a, I: Iterator<Item = &'a T>> I { |
| 37 |
default fn f(&self) {} |
| 38 |
} |
| 39 |
|
| 40 |
// See also spec_iter module in ui/min_specialization.rs. |
| 41 |
impl<'a, T> SpecFromIter<'a, T> for std::slice::Iter<'a, T> { |
| 42 |
fn f(&self) {} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
// https://github.com/rust-lang/rust/blob/1.84.0/tests/ui/specialization/min_specialization/spec-reference.rs |
| 47 |
pub mod spec_reference { |
| 48 |
use easy_ext::ext; |
| 49 |
|
| 50 |
#[ext(MySpecTrait)] |
| 51 |
impl<T> T { |
| 52 |
default fn f() {} |
| 53 |
} |
| 54 |
|
| 55 |
impl<'a, T: ?Sized> MySpecTrait for &'a T { |
| 56 |
fn f() {} |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
fn main() {} |