From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/traits/default-method/auxiliary/xc.rs | 40 --------- .../ui/traits/default-method/auxiliary/xc_2.rs | 17 ---- src/test/ui/traits/default-method/bound-subst.rs | 18 ---- src/test/ui/traits/default-method/bound-subst2.rs | 16 ---- src/test/ui/traits/default-method/bound-subst3.rs | 17 ---- src/test/ui/traits/default-method/bound-subst4.rs | 19 ---- src/test/ui/traits/default-method/bound.rs | 16 ---- src/test/ui/traits/default-method/macro.rs | 20 ----- src/test/ui/traits/default-method/mut.rs | 11 --- .../default-method/rustc_must_implement_one_of.rs | 44 --------- .../rustc_must_implement_one_of.stderr | 15 ---- .../rustc_must_implement_one_of_duplicates.rs | 19 ---- .../rustc_must_implement_one_of_duplicates.stderr | 34 ------- .../rustc_must_implement_one_of_gated.rs | 13 --- .../rustc_must_implement_one_of_gated.stderr | 11 --- .../rustc_must_implement_one_of_misuse.rs | 46 ---------- .../rustc_must_implement_one_of_misuse.stderr | 100 --------------------- src/test/ui/traits/default-method/self.rs | 18 ---- src/test/ui/traits/default-method/supervtable.rs | 28 ------ src/test/ui/traits/default-method/trivial.rs | 21 ----- src/test/ui/traits/default-method/xc-2.rs | 26 ------ src/test/ui/traits/default-method/xc.rs | 81 ----------------- 22 files changed, 630 deletions(-) delete mode 100644 src/test/ui/traits/default-method/auxiliary/xc.rs delete mode 100644 src/test/ui/traits/default-method/auxiliary/xc_2.rs delete mode 100644 src/test/ui/traits/default-method/bound-subst.rs delete mode 100644 src/test/ui/traits/default-method/bound-subst2.rs delete mode 100644 src/test/ui/traits/default-method/bound-subst3.rs delete mode 100644 src/test/ui/traits/default-method/bound-subst4.rs delete mode 100644 src/test/ui/traits/default-method/bound.rs delete mode 100644 src/test/ui/traits/default-method/macro.rs delete mode 100644 src/test/ui/traits/default-method/mut.rs delete mode 100644 src/test/ui/traits/default-method/rustc_must_implement_one_of.rs delete mode 100644 src/test/ui/traits/default-method/rustc_must_implement_one_of.stderr delete mode 100644 src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.rs delete mode 100644 src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.stderr delete mode 100644 src/test/ui/traits/default-method/rustc_must_implement_one_of_gated.rs delete mode 100644 src/test/ui/traits/default-method/rustc_must_implement_one_of_gated.stderr delete mode 100644 src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs delete mode 100644 src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr delete mode 100644 src/test/ui/traits/default-method/self.rs delete mode 100644 src/test/ui/traits/default-method/supervtable.rs delete mode 100644 src/test/ui/traits/default-method/trivial.rs delete mode 100644 src/test/ui/traits/default-method/xc-2.rs delete mode 100644 src/test/ui/traits/default-method/xc.rs (limited to 'src/test/ui/traits/default-method') diff --git a/src/test/ui/traits/default-method/auxiliary/xc.rs b/src/test/ui/traits/default-method/auxiliary/xc.rs deleted file mode 100644 index 0fb26af80..000000000 --- a/src/test/ui/traits/default-method/auxiliary/xc.rs +++ /dev/null @@ -1,40 +0,0 @@ -pub struct Something { pub x: isize } - -pub trait A { - fn f(&self) -> isize; - fn g(&self) -> isize { 10 } - fn h(&self) -> isize { 11 } - fn lurr(x: &Self, y: &Self) -> isize { x.g() + y.h() } -} - - -impl A for isize { - fn f(&self) -> isize { 10 } -} - -impl A for Something { - fn f(&self) -> isize { 10 } -} - -pub trait B { - fn thing(&self, x: T, y: U) -> (T, U) { (x, y) } - fn staticthing(_z: &Self, x: T, y: U) -> (T, U) { (x, y) } -} - -impl B for isize { } -impl B for bool { } - - - -pub trait TestEquality { - fn test_eq(&self, rhs: &Self) -> bool; - fn test_neq(&self, rhs: &Self) -> bool { - !self.test_eq(rhs) - } -} - -impl TestEquality for isize { - fn test_eq(&self, rhs: &isize) -> bool { - *self == *rhs - } -} diff --git a/src/test/ui/traits/default-method/auxiliary/xc_2.rs b/src/test/ui/traits/default-method/auxiliary/xc_2.rs deleted file mode 100644 index 979233820..000000000 --- a/src/test/ui/traits/default-method/auxiliary/xc_2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// aux-build:xc.rs - -extern crate xc as aux; -use aux::A; - -pub struct a_struct { pub x: isize } - -impl A for a_struct { - fn f(&self) -> isize { 10 } -} - -// This function will need to get inlined, and badness may result. -pub fn welp(x: A) -> A { - let a = a_struct { x: 0 }; - a.g(); - x -} diff --git a/src/test/ui/traits/default-method/bound-subst.rs b/src/test/ui/traits/default-method/bound-subst.rs deleted file mode 100644 index 6a5d5c8ba..000000000 --- a/src/test/ui/traits/default-method/bound-subst.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass - - -trait A { - fn g(&self, x: T, y: U) -> (T, U) { (x, y) } -} - -impl A for i32 { } -impl A for u32 { } - -fn f>(i: V, j: T, k: U) -> (T, U) { - i.g(j, k) -} - -pub fn main () { - assert_eq!(f(0, 1, 2), (1, 2)); - assert_eq!(f(0, 1, 2), (1, 2)); -} diff --git a/src/test/ui/traits/default-method/bound-subst2.rs b/src/test/ui/traits/default-method/bound-subst2.rs deleted file mode 100644 index 78eabba2d..000000000 --- a/src/test/ui/traits/default-method/bound-subst2.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-pass - - -trait A { - fn g(&self, x: T) -> T { x } -} - -impl A for isize { } - -fn f>(i: V, j: T) -> T { - i.g(j) -} - -pub fn main () { - assert_eq!(f(0, 2), 2); -} diff --git a/src/test/ui/traits/default-method/bound-subst3.rs b/src/test/ui/traits/default-method/bound-subst3.rs deleted file mode 100644 index dd39dec4b..000000000 --- a/src/test/ui/traits/default-method/bound-subst3.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass - - -trait A { - fn g(&self, x: T, y: T) -> (T, T) { (x, y) } -} - -impl A for isize { } - -fn f(i: V, j: T, k: T) -> (T, T) { - i.g(j, k) -} - -pub fn main () { - assert_eq!(f(0, 1, 2), (1, 2)); - assert_eq!(f(0, 1u8, 2u8), (1u8, 2u8)); -} diff --git a/src/test/ui/traits/default-method/bound-subst4.rs b/src/test/ui/traits/default-method/bound-subst4.rs deleted file mode 100644 index ef1330645..000000000 --- a/src/test/ui/traits/default-method/bound-subst4.rs +++ /dev/null @@ -1,19 +0,0 @@ -// run-pass -#![allow(unused_variables)] - - -trait A { - fn g(&self, x: usize) -> usize { x } - fn h(&self, x: T) { } -} - -impl A for isize { } - -fn f>(i: V, j: usize) -> usize { - i.g(j) -} - -pub fn main () { - assert_eq!(f::(0, 2), 2); - assert_eq!(f::(0, 2), 2); -} diff --git a/src/test/ui/traits/default-method/bound.rs b/src/test/ui/traits/default-method/bound.rs deleted file mode 100644 index 0855a9db8..000000000 --- a/src/test/ui/traits/default-method/bound.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-pass - - -trait A { - fn g(&self) -> isize { 10 } -} - -impl A for isize { } - -fn f(i: T) { - assert_eq!(i.g(), 10); -} - -pub fn main () { - f(0); -} diff --git a/src/test/ui/traits/default-method/macro.rs b/src/test/ui/traits/default-method/macro.rs deleted file mode 100644 index 2b50ee9b4..000000000 --- a/src/test/ui/traits/default-method/macro.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-pass - - -trait Foo { - fn bar(&self) -> String { - format!("test") - } -} - -enum Baz { - Quux -} - -impl Foo for Baz { -} - -pub fn main() { - let q = Baz::Quux; - assert_eq!(q.bar(), "test".to_string()); -} diff --git a/src/test/ui/traits/default-method/mut.rs b/src/test/ui/traits/default-method/mut.rs deleted file mode 100644 index 5f8e983b0..000000000 --- a/src/test/ui/traits/default-method/mut.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-pass -#![allow(unused_assignments)] -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] - -trait Foo { - fn foo(&self, mut v: isize) { v = 1; } -} - -pub fn main() {} diff --git a/src/test/ui/traits/default-method/rustc_must_implement_one_of.rs b/src/test/ui/traits/default-method/rustc_must_implement_one_of.rs deleted file mode 100644 index 5ba2f5ce3..000000000 --- a/src/test/ui/traits/default-method/rustc_must_implement_one_of.rs +++ /dev/null @@ -1,44 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_must_implement_one_of(eq, neq)] -trait Equal { - fn eq(&self, other: &Self) -> bool { - !self.neq(other) - } - - fn neq(&self, other: &Self) -> bool { - !self.eq(other) - } -} - -struct T0; -struct T1; -struct T2; -struct T3; - -impl Equal for T0 { - fn eq(&self, _other: &Self) -> bool { - true - } -} - -impl Equal for T1 { - fn neq(&self, _other: &Self) -> bool { - false - } -} - -impl Equal for T2 { - fn eq(&self, _other: &Self) -> bool { - true - } - - fn neq(&self, _other: &Self) -> bool { - false - } -} - -impl Equal for T3 {} -//~^ not all trait items implemented, missing one of: `eq`, `neq` - -fn main() {} diff --git a/src/test/ui/traits/default-method/rustc_must_implement_one_of.stderr b/src/test/ui/traits/default-method/rustc_must_implement_one_of.stderr deleted file mode 100644 index 5a4dd1388..000000000 --- a/src/test/ui/traits/default-method/rustc_must_implement_one_of.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0046]: not all trait items implemented, missing one of: `eq`, `neq` - --> $DIR/rustc_must_implement_one_of.rs:41:1 - | -LL | impl Equal for T3 {} - | ^^^^^^^^^^^^^^^^^ missing one of `eq`, `neq` in implementation - | -note: required because of this annotation - --> $DIR/rustc_must_implement_one_of.rs:3:1 - | -LL | #[rustc_must_implement_one_of(eq, neq)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0046`. diff --git a/src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.rs b/src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.rs deleted file mode 100644 index 56e8fcff0..000000000 --- a/src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_must_implement_one_of(a, a)] -//~^ Functions names are duplicated -trait Trait { - fn a() {} -} - -#[rustc_must_implement_one_of(b, a, a, c, b, c)] -//~^ Functions names are duplicated -//~| Functions names are duplicated -//~| Functions names are duplicated -trait Trait1 { - fn a() {} - fn b() {} - fn c() {} -} - -fn main() {} diff --git a/src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.stderr b/src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.stderr deleted file mode 100644 index 777beba61..000000000 --- a/src/test/ui/traits/default-method/rustc_must_implement_one_of_duplicates.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error: Functions names are duplicated - --> $DIR/rustc_must_implement_one_of_duplicates.rs:3:31 - | -LL | #[rustc_must_implement_one_of(a, a)] - | ^ ^ - | - = note: All `#[rustc_must_implement_one_of]` arguments must be unique - -error: Functions names are duplicated - --> $DIR/rustc_must_implement_one_of_duplicates.rs:9:34 - | -LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)] - | ^ ^ - | - = note: All `#[rustc_must_implement_one_of]` arguments must be unique - -error: Functions names are duplicated - --> $DIR/rustc_must_implement_one_of_duplicates.rs:9:31 - | -LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)] - | ^ ^ - | - = note: All `#[rustc_must_implement_one_of]` arguments must be unique - -error: Functions names are duplicated - --> $DIR/rustc_must_implement_one_of_duplicates.rs:9:40 - | -LL | #[rustc_must_implement_one_of(b, a, a, c, b, c)] - | ^ ^ - | - = note: All `#[rustc_must_implement_one_of]` arguments must be unique - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/traits/default-method/rustc_must_implement_one_of_gated.rs b/src/test/ui/traits/default-method/rustc_must_implement_one_of_gated.rs deleted file mode 100644 index ec2995872..000000000 --- a/src/test/ui/traits/default-method/rustc_must_implement_one_of_gated.rs +++ /dev/null @@ -1,13 +0,0 @@ -#[rustc_must_implement_one_of(eq, neq)] -//~^ the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete definition of a trait, it's currently in experimental form and should be changed before being exposed outside of the std -trait Equal { - fn eq(&self, other: &Self) -> bool { - !self.neq(other) - } - - fn neq(&self, other: &Self) -> bool { - !self.eq(other) - } -} - -fn main() {} diff --git a/src/test/ui/traits/default-method/rustc_must_implement_one_of_gated.stderr b/src/test/ui/traits/default-method/rustc_must_implement_one_of_gated.stderr deleted file mode 100644 index 228bc3e35..000000000 --- a/src/test/ui/traits/default-method/rustc_must_implement_one_of_gated.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: the `#[rustc_must_implement_one_of]` attribute is used to change minimal complete definition of a trait, it's currently in experimental form and should be changed before being exposed outside of the std - --> $DIR/rustc_must_implement_one_of_gated.rs:1:1 - | -LL | #[rustc_must_implement_one_of(eq, neq)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs b/src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs deleted file mode 100644 index 1f896da94..000000000 --- a/src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_must_implement_one_of(a, b)] -//~^ Function not found in this trait -//~| Function not found in this trait -trait Tr0 {} - -#[rustc_must_implement_one_of(a, b)] -//~^ Function not found in this trait -trait Tr1 { - fn a() {} -} - -#[rustc_must_implement_one_of(a)] -//~^ the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args -trait Tr2 { - fn a() {} -} - -#[rustc_must_implement_one_of] -//~^ malformed `rustc_must_implement_one_of` attribute input -trait Tr3 {} - -#[rustc_must_implement_one_of(A, B)] -trait Tr4 { - const A: u8 = 1; //~ Not a function - - type B; //~ Not a function -} - -#[rustc_must_implement_one_of(a, b)] -trait Tr5 { - fn a(); //~ This function doesn't have a default implementation - - fn b(); //~ This function doesn't have a default implementation -} - -#[rustc_must_implement_one_of(abc, xyz)] -//~^ attribute should be applied to a trait -fn function() {} - -#[rustc_must_implement_one_of(abc, xyz)] -//~^ attribute should be applied to a trait -struct Struct {} - -fn main() {} diff --git a/src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr b/src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr deleted file mode 100644 index 869184f0d..000000000 --- a/src/test/ui/traits/default-method/rustc_must_implement_one_of_misuse.stderr +++ /dev/null @@ -1,100 +0,0 @@ -error: malformed `rustc_must_implement_one_of` attribute input - --> $DIR/rustc_must_implement_one_of_misuse.rs:20:1 - | -LL | #[rustc_must_implement_one_of] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_must_implement_one_of(function1, function2, ...)]` - -error: attribute should be applied to a trait - --> $DIR/rustc_must_implement_one_of_misuse.rs:38:1 - | -LL | #[rustc_must_implement_one_of(abc, xyz)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | fn function() {} - | ---------------- not a trait - -error: attribute should be applied to a trait - --> $DIR/rustc_must_implement_one_of_misuse.rs:42:1 - | -LL | #[rustc_must_implement_one_of(abc, xyz)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | -LL | struct Struct {} - | ---------------- not a trait - -error: Function not found in this trait - --> $DIR/rustc_must_implement_one_of_misuse.rs:3:31 - | -LL | #[rustc_must_implement_one_of(a, b)] - | ^ - -error: Function not found in this trait - --> $DIR/rustc_must_implement_one_of_misuse.rs:3:34 - | -LL | #[rustc_must_implement_one_of(a, b)] - | ^ - -error: Function not found in this trait - --> $DIR/rustc_must_implement_one_of_misuse.rs:8:34 - | -LL | #[rustc_must_implement_one_of(a, b)] - | ^ - -error: the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args - --> $DIR/rustc_must_implement_one_of_misuse.rs:14:1 - | -LL | #[rustc_must_implement_one_of(a)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: Not a function - --> $DIR/rustc_must_implement_one_of_misuse.rs:26:5 - | -LL | const A: u8 = 1; - | ^^^^^^^^^^^^^^^^ - | -note: required by this annotation - --> $DIR/rustc_must_implement_one_of_misuse.rs:24:1 - | -LL | #[rustc_must_implement_one_of(A, B)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: All `#[rustc_must_implement_one_of]` arguments must be associated function names - -error: Not a function - --> $DIR/rustc_must_implement_one_of_misuse.rs:28:5 - | -LL | type B; - | ^^^^^^^ - | -note: required by this annotation - --> $DIR/rustc_must_implement_one_of_misuse.rs:24:1 - | -LL | #[rustc_must_implement_one_of(A, B)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: All `#[rustc_must_implement_one_of]` arguments must be associated function names - -error: This function doesn't have a default implementation - --> $DIR/rustc_must_implement_one_of_misuse.rs:33:5 - | -LL | fn a(); - | ^^^^^^^ - | -note: required by this annotation - --> $DIR/rustc_must_implement_one_of_misuse.rs:31:1 - | -LL | #[rustc_must_implement_one_of(a, b)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: This function doesn't have a default implementation - --> $DIR/rustc_must_implement_one_of_misuse.rs:35:5 - | -LL | fn b(); - | ^^^^^^^ - | -note: required by this annotation - --> $DIR/rustc_must_implement_one_of_misuse.rs:31:1 - | -LL | #[rustc_must_implement_one_of(a, b)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 11 previous errors - diff --git a/src/test/ui/traits/default-method/self.rs b/src/test/ui/traits/default-method/self.rs deleted file mode 100644 index cdf4d1e14..000000000 --- a/src/test/ui/traits/default-method/self.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass - - -trait Cat { - fn meow(&self) -> bool; - fn scratch(&self) -> bool { self.purr() } - fn purr(&self) -> bool { true } -} - -impl Cat for isize { - fn meow(&self) -> bool { - self.scratch() - } -} - -pub fn main() { - assert!(5.meow()); -} diff --git a/src/test/ui/traits/default-method/supervtable.rs b/src/test/ui/traits/default-method/supervtable.rs deleted file mode 100644 index 939ad5135..000000000 --- a/src/test/ui/traits/default-method/supervtable.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass - - -// Tests that we can call a function bounded over a supertrait from -// a default method - -fn require_y(x: T) -> isize { x.y() } - -trait Y { - fn y(self) -> isize; -} - - -trait Z: Y + Sized { - fn x(self) -> isize { - require_y(self) - } -} - -impl Y for isize { - fn y(self) -> isize { self } -} - -impl Z for isize {} - -pub fn main() { - assert_eq!(12.x(), 12); -} diff --git a/src/test/ui/traits/default-method/trivial.rs b/src/test/ui/traits/default-method/trivial.rs deleted file mode 100644 index dc41938ec..000000000 --- a/src/test/ui/traits/default-method/trivial.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass - - -trait Cat { - fn meow(&self) -> bool; - fn scratch(&self) -> bool; - fn purr(&self) -> bool { true } -} - -impl Cat for isize { - fn meow(&self) -> bool { - self.scratch() - } - fn scratch(&self) -> bool { - self.purr() - } -} - -pub fn main() { - assert!(5.meow()); -} diff --git a/src/test/ui/traits/default-method/xc-2.rs b/src/test/ui/traits/default-method/xc-2.rs deleted file mode 100644 index 1de61dcf8..000000000 --- a/src/test/ui/traits/default-method/xc-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// run-pass -// aux-build:xc.rs -// aux-build:xc_2.rs - - - -extern crate xc as aux; -extern crate xc_2 as aux2; -use aux::A; -use aux2::{a_struct, welp}; - - -pub fn main () { - - let a = a_struct { x: 0 }; - let b = a_struct { x: 1 }; - - assert_eq!(0.g(), 10); - assert_eq!(a.g(), 10); - assert_eq!(a.h(), 11); - assert_eq!(b.g(), 10); - assert_eq!(b.h(), 11); - assert_eq!(A::lurr(&a, &b), 21); - - welp(&0); -} diff --git a/src/test/ui/traits/default-method/xc.rs b/src/test/ui/traits/default-method/xc.rs deleted file mode 100644 index 76a1573d6..000000000 --- a/src/test/ui/traits/default-method/xc.rs +++ /dev/null @@ -1,81 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] - -// aux-build:xc.rs - - -extern crate xc as aux; -use aux::{A, TestEquality, Something}; -use aux::B; - -fn f(i: T) { - assert_eq!(i.g(), 10); -} - -fn welp(i: isize, _x: &T) -> isize { - i.g() -} - -mod stuff { - pub struct thing { pub x: isize } -} - -impl A for stuff::thing { - fn f(&self) -> isize { 10 } -} - -fn g>(i: V, j: T, k: U) -> (T, U) { - i.thing(j, k) -} - -fn eq(lhs: &T, rhs: &T) -> bool { - lhs.test_eq(rhs) -} -fn neq(lhs: &T, rhs: &T) -> bool { - lhs.test_neq(rhs) -} - - -impl TestEquality for stuff::thing { - fn test_eq(&self, rhs: &stuff::thing) -> bool { - //self.x.test_eq(&rhs.x) - eq(&self.x, &rhs.x) - } -} - - -pub fn main() { - // Some tests of random things - f(0); - - assert_eq!(A::lurr(&0, &1), 21); - - let a = stuff::thing { x: 0 }; - let b = stuff::thing { x: 1 }; - let c = Something { x: 1 }; - - assert_eq!(0.g(), 10); - assert_eq!(a.g(), 10); - assert_eq!(a.h(), 11); - assert_eq!(c.h(), 11); - - assert_eq!(0.thing(3.14f64, 1), (3.14f64, 1)); - assert_eq!(B::staticthing(&0, 3.14f64, 1), (3.14f64, 1)); - assert_eq!(B::::staticthing::(&0, 3.14, 1), (3.14, 1)); - - assert_eq!(g(0, 3.14f64, 1), (3.14f64, 1)); - assert_eq!(g(false, 3.14f64, 1), (3.14, 1)); - - - // Trying out a real one - assert!(12.test_neq(&10)); - assert!(!10.test_neq(&10)); - assert!(a.test_neq(&b)); - assert!(!a.test_neq(&a)); - - assert!(neq(&12, &10)); - assert!(!neq(&10, &10)); - assert!(neq(&a, &b)); - assert!(!neq(&a, &a)); -} -- cgit v1.2.3