From 9b5accade787beb0c82fe1f6937c43bfb6abd054 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 31 Mar 2015 19:58:01 -0400 Subject: [PATCH] Fallout in tests --- src/test/auxiliary/coherence_orphan_lib.rs | 2 +- src/test/auxiliary/lang-item-public.rs | 8 +-- ...ed-types-ICE-when-projecting-out-of-err.rs | 6 +-- src/test/compile-fail/issue-13853-2.rs | 4 +- src/test/compile-fail/issue-19660.rs | 6 +-- .../compile-fail/kindck-impl-type-params.rs | 2 +- src/test/compile-fail/lint-unsafe-code.rs | 7 +-- .../compile-fail/object-safety-phantom-fn.rs | 6 +-- .../compile-fail/on-unimplemented-bad-anno.rs | 6 --- src/test/compile-fail/on-unimplemented.rs | 3 -- src/test/compile-fail/privacy1.rs | 8 +-- src/test/compile-fail/privacy4.rs | 8 +-- ...c-type-in-supertrait-outlives-container.rs | 4 +- ...ions-assoc-type-outlives-container-hrtb.rs | 4 +- ...egions-assoc-type-outlives-container-wc.rs | 4 +- .../regions-assoc-type-outlives-container.rs | 4 +- .../regions-close-object-into-object-1.rs | 6 +-- .../regions-close-object-into-object-2.rs | 6 +-- .../regions-close-object-into-object-3.rs | 8 ++- .../regions-close-object-into-object-4.rs | 6 +-- src/test/compile-fail/required-lang-item.rs | 6 +-- .../trait-bounds-impl-comparison-1.rs | 3 +- .../trait-bounds-impl-comparison-2.rs | 1 - .../unboxed-closure-sugar-equiv.rs | 4 +- .../unboxed-closure-sugar-lifetime-elision.rs | 2 +- .../variance-contravariant-arg-object.rs | 6 ++- .../variance-contravariant-arg-trait-match.rs | 4 +- ...variance-contravariant-self-trait-match.rs | 5 +- .../variance-covariant-arg-object.rs | 3 +- .../variance-covariant-arg-trait-match.rs | 3 +- .../variance-covariant-self-trait-match.rs | 3 +- .../compile-fail/variance-region-bounds.rs | 4 +- .../variance-regions-unused-direct.rs | 2 +- .../compile-fail/variance-trait-bounds.rs | 10 ++-- .../compile-fail/variance-trait-matching.rs | 45 ++++++++++++----- .../compile-fail/variance-types-bounds.rs | 10 ++-- .../variance-unused-region-param.rs | 2 +- .../variance-unused-type-param.rs | 4 -- src/test/run-make/simd-ffi/simd.rs | 8 +-- src/test/run-make/target-specs/foo.rs | 8 +-- .../coherence-subtyping.rs | 4 +- src/test/run-pass/cycle-generic-bound.rs | 4 +- src/test/run-pass/issue-22356.rs | 4 +- ...egions-early-bound-lifetime-in-assoc-fn.rs | 4 +- src/test/run-pass/unsized.rs | 20 ++++---- src/test/run-pass/variance-trait-matching.rs | 49 ------------------- src/test/run-pass/where-for-self.rs | 7 +-- 47 files changed, 117 insertions(+), 216 deletions(-) rename src/test/{compile-fail => run-pass}/coherence-subtyping.rs (94%) delete mode 100644 src/test/run-pass/variance-trait-matching.rs diff --git a/src/test/auxiliary/coherence_orphan_lib.rs b/src/test/auxiliary/coherence_orphan_lib.rs index 93d8fd3da88..b22d12300c7 100644 --- a/src/test/auxiliary/coherence_orphan_lib.rs +++ b/src/test/auxiliary/coherence_orphan_lib.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait TheTrait : ::std::marker::PhantomFn { +pub trait TheTrait { fn the_fn(&self); } diff --git a/src/test/auxiliary/lang-item-public.rs b/src/test/auxiliary/lang-item-public.rs index 72dfc75f41b..d195bd7e77b 100644 --- a/src/test/auxiliary/lang-item-public.rs +++ b/src/test/auxiliary/lang-item-public.rs @@ -12,12 +12,8 @@ #![no_std] #![feature(lang_items)] -#[lang="phantom_fn"] -pub trait PhantomFn { } -impl PhantomFn for U { } - #[lang="sized"] -pub trait Sized : PhantomFn {} +pub trait Sized { } #[lang="panic"] fn panic(_: &(&'static str, &'static str, usize)) -> ! { loop {} } @@ -29,7 +25,7 @@ extern fn stack_exhausted() {} extern fn eh_personality() {} #[lang="copy"] -pub trait Copy : PhantomFn { +pub trait Copy { // Empty. } diff --git a/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs b/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs index 04170779ed2..0e083e47236 100644 --- a/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs +++ b/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs @@ -16,12 +16,8 @@ #![feature(no_std)] #![no_std] -#[lang="phantom_fn"] -pub trait PhantomFn { } -impl PhantomFn for U { } - #[lang="sized"] -pub trait Sized : PhantomFn { +pub trait Sized { // Empty. } diff --git a/src/test/compile-fail/issue-13853-2.rs b/src/test/compile-fail/issue-13853-2.rs index dc697e4784f..ea0d880f4a1 100644 --- a/src/test/compile-fail/issue-13853-2.rs +++ b/src/test/compile-fail/issue-13853-2.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::marker::PhantomFn; - -trait FromStructReader<'a> : PhantomFn<(Self,&'a ())> { } +trait FromStructReader<'a> { } trait ResponseHook { fn get<'a, T: FromStructReader<'a>>(&'a self); } diff --git a/src/test/compile-fail/issue-19660.rs b/src/test/compile-fail/issue-19660.rs index 4435ee0cb22..a4a8eac682d 100644 --- a/src/test/compile-fail/issue-19660.rs +++ b/src/test/compile-fail/issue-19660.rs @@ -13,12 +13,8 @@ #![feature(lang_items, start, no_std)] #![no_std] -#[lang="phantom_fn"] -trait PhantomFn { } -impl PhantomFn for U { } - #[lang = "sized"] -trait Sized : PhantomFn {} +trait Sized { } #[start] fn main(_: isize, _: *const *const u8) -> isize { diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs index 71494fd5f38..d4ee93e9ca5 100644 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ b/src/test/compile-fail/kindck-impl-type-params.rs @@ -41,7 +41,7 @@ fn g(val: T) { fn foo<'a>() { let t: S<&'a isize> = S(marker::PhantomData); let a = &t as &Gettable<&'a isize>; - //~^ ERROR cannot infer + //~^ ERROR does not fulfill } fn foo2<'a>() { diff --git a/src/test/compile-fail/lint-unsafe-code.rs b/src/test/compile-fail/lint-unsafe-code.rs index 8440cf3a88e..10f245aaaf9 100644 --- a/src/test/compile-fail/lint-unsafe-code.rs +++ b/src/test/compile-fail/lint-unsafe-code.rs @@ -12,18 +12,15 @@ #![allow(dead_code)] #![deny(unsafe_code)] -use std::marker::PhantomFn; - struct Bar; struct Bar2; struct Bar3; #[allow(unsafe_code)] mod allowed_unsafe { - use std::marker::PhantomFn; fn allowed() { unsafe {} } unsafe fn also_allowed() {} - unsafe trait AllowedUnsafe : PhantomFn {} + unsafe trait AllowedUnsafe { } unsafe impl AllowedUnsafe for super::Bar {} } @@ -34,7 +31,7 @@ macro_rules! unsafe_in_macro { } unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function -unsafe trait Foo : PhantomFn {} //~ ERROR: declaration of an `unsafe` trait +unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait trait Baz { diff --git a/src/test/compile-fail/object-safety-phantom-fn.rs b/src/test/compile-fail/object-safety-phantom-fn.rs index 1c95ee43d27..518c45ac9df 100644 --- a/src/test/compile-fail/object-safety-phantom-fn.rs +++ b/src/test/compile-fail/object-safety-phantom-fn.rs @@ -13,12 +13,10 @@ #![feature(rustc_attrs)] #![allow(dead_code)] -use std::marker::PhantomFn; - -trait Baz : PhantomFn { +trait Baz { } -trait Bar : PhantomFn<(Self, T)> { +trait Bar { } fn make_bar>(t: &T) -> &Bar { diff --git a/src/test/compile-fail/on-unimplemented-bad-anno.rs b/src/test/compile-fail/on-unimplemented-bad-anno.rs index 7538b1c85e5..8580749084d 100644 --- a/src/test/compile-fail/on-unimplemented-bad-anno.rs +++ b/src/test/compile-fail/on-unimplemented-bad-anno.rs @@ -13,11 +13,8 @@ #![allow(unused)] -use std::marker; - #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"] trait Foo - : marker::PhantomFn<(Self,Bar,Baz,Quux)> {} #[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"] @@ -28,19 +25,16 @@ trait MyFromIterator { #[rustc_on_unimplemented] //~ ERROR this attribute must have a value trait BadAnnotation1 - : marker::MarkerTrait {} #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"] //~^ ERROR there is no type parameter C on trait BadAnnotation2 trait BadAnnotation2 - : marker::PhantomFn<(Self,A,B)> {} #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"] //~^ only named substitution parameters are allowed trait BadAnnotation3 - : marker::PhantomFn<(Self,A,B)> {} pub fn main() { diff --git a/src/test/compile-fail/on-unimplemented.rs b/src/test/compile-fail/on-unimplemented.rs index 2447d086422..c4eb467c4f9 100644 --- a/src/test/compile-fail/on-unimplemented.rs +++ b/src/test/compile-fail/on-unimplemented.rs @@ -11,11 +11,8 @@ #![feature(on_unimplemented)] -use std::marker; - #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"] trait Foo - : marker::PhantomFn<(Self,Bar,Baz,Quux)> {} fn foobar>() -> T { diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs index 67dccb4c93e..f728fdfaf9a 100644 --- a/src/test/compile-fail/privacy1.rs +++ b/src/test/compile-fail/privacy1.rs @@ -11,15 +11,11 @@ #![feature(lang_items, start, no_std)] #![no_std] // makes debugging this test *a lot* easier (during resolve) -#[lang="phantom_fn"] -pub trait PhantomFn { } -impl PhantomFn for U { } - #[lang="sized"] -pub trait Sized : PhantomFn {} +pub trait Sized {} #[lang="copy"] -pub trait Copy : PhantomFn {} +pub trait Copy {} mod bar { // shouldn't bring in too much diff --git a/src/test/compile-fail/privacy4.rs b/src/test/compile-fail/privacy4.rs index adce93af079..bcb46663aa8 100644 --- a/src/test/compile-fail/privacy4.rs +++ b/src/test/compile-fail/privacy4.rs @@ -11,12 +11,8 @@ #![feature(lang_items, start, no_std)] #![no_std] // makes debugging this test *a lot* easier (during resolve) -#[lang="phantom_fn"] -pub trait PhantomFn { } -impl PhantomFn for U { } - -#[lang = "sized"] pub trait Sized : PhantomFn {} -#[lang="copy"] pub trait Copy : PhantomFn {} +#[lang = "sized"] pub trait Sized {} +#[lang="copy"] pub trait Copy {} // Test to make sure that private items imported through globs remain private // when they're used. diff --git a/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs b/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs index 6aa0cc003ce..9a13541bd0b 100644 --- a/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs +++ b/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs @@ -15,11 +15,9 @@ #![allow(dead_code)] -use std::marker::PhantomFn; - /////////////////////////////////////////////////////////////////////////// -pub trait TheTrait: PhantomFn { +pub trait TheTrait { type TheAssocType; } diff --git a/src/test/compile-fail/regions-assoc-type-outlives-container-hrtb.rs b/src/test/compile-fail/regions-assoc-type-outlives-container-hrtb.rs index 9736910d7b5..0d3d2e296be 100644 --- a/src/test/compile-fail/regions-assoc-type-outlives-container-hrtb.rs +++ b/src/test/compile-fail/regions-assoc-type-outlives-container-hrtb.rs @@ -14,11 +14,9 @@ #![allow(dead_code)] #![feature(rustc_attrs)] -use std::marker::PhantomFn; - /////////////////////////////////////////////////////////////////////////// -pub trait TheTrait<'b> : PhantomFn<&'b Self,Self> { +pub trait TheTrait<'b> { type TheAssocType; } diff --git a/src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs b/src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs index da7546ce21c..2ceaea98d27 100644 --- a/src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs +++ b/src/test/compile-fail/regions-assoc-type-outlives-container-wc.rs @@ -15,11 +15,9 @@ #![allow(dead_code)] -use std::marker::PhantomFn; - /////////////////////////////////////////////////////////////////////////// -pub trait TheTrait: PhantomFn { +pub trait TheTrait { type TheAssocType; } diff --git a/src/test/compile-fail/regions-assoc-type-outlives-container.rs b/src/test/compile-fail/regions-assoc-type-outlives-container.rs index e1e72e6f56e..e3e57ff1711 100644 --- a/src/test/compile-fail/regions-assoc-type-outlives-container.rs +++ b/src/test/compile-fail/regions-assoc-type-outlives-container.rs @@ -15,11 +15,9 @@ #![allow(dead_code)] #![feature(rustc_attrs)] -use std::marker::PhantomFn; - /////////////////////////////////////////////////////////////////////////// -pub trait TheTrait: PhantomFn { +pub trait TheTrait { type TheAssocType; } diff --git a/src/test/compile-fail/regions-close-object-into-object-1.rs b/src/test/compile-fail/regions-close-object-into-object-1.rs index 4c831a2b659..5472e09ba4b 100644 --- a/src/test/compile-fail/regions-close-object-into-object-1.rs +++ b/src/test/compile-fail/regions-close-object-into-object-1.rs @@ -11,12 +11,10 @@ #![feature(box_syntax)] #![allow(warnings)] -use std::marker::PhantomFn; - -trait A : PhantomFn<(Self,T)> { } +trait A { } struct B<'a, T>(&'a (A+'a)); -trait X : ::std::marker::MarkerTrait {} +trait X { } impl<'a, T> X for B<'a, T> {} diff --git a/src/test/compile-fail/regions-close-object-into-object-2.rs b/src/test/compile-fail/regions-close-object-into-object-2.rs index 6de49020a6f..1ef000852d5 100644 --- a/src/test/compile-fail/regions-close-object-into-object-2.rs +++ b/src/test/compile-fail/regions-close-object-into-object-2.rs @@ -10,12 +10,10 @@ #![feature(box_syntax)] -use std::marker::PhantomFn; - -trait A : PhantomFn<(Self,T)> { } +trait A { } struct B<'a, T>(&'a (A+'a)); -trait X : PhantomFn {} +trait X { } impl<'a, T> X for B<'a, T> {} fn g<'a, T: 'static>(v: Box+'a>) -> Box { diff --git a/src/test/compile-fail/regions-close-object-into-object-3.rs b/src/test/compile-fail/regions-close-object-into-object-3.rs index b723efff3c9..b7dc759b271 100644 --- a/src/test/compile-fail/regions-close-object-into-object-3.rs +++ b/src/test/compile-fail/regions-close-object-into-object-3.rs @@ -11,15 +11,13 @@ #![feature(box_syntax)] #![allow(warnings)] -use std::marker::PhantomFn; - -trait A : PhantomFn<(Self,T)> {} +trait A { } struct B<'a, T>(&'a (A+'a)); -trait X : PhantomFn {} +trait X { } impl<'a, T> X for B<'a, T> {} -fn h<'a, T, U>(v: Box+'static>) -> Box { +fn h<'a, T, U:'static>(v: Box+'static>) -> Box { box B(&*v) as Box //~ ERROR `*v` does not live long enough } diff --git a/src/test/compile-fail/regions-close-object-into-object-4.rs b/src/test/compile-fail/regions-close-object-into-object-4.rs index 9b311588bb1..247578d253e 100644 --- a/src/test/compile-fail/regions-close-object-into-object-4.rs +++ b/src/test/compile-fail/regions-close-object-into-object-4.rs @@ -10,12 +10,10 @@ #![feature(box_syntax)] -use std::marker::PhantomFn; - -trait A : PhantomFn<(Self,T)> {} +trait A { } struct B<'a, T>(&'a (A+'a)); -trait X : PhantomFn {} +trait X { } impl<'a, T> X for B<'a, T> {} fn i<'a, T, U>(v: Box+'a>) -> Box { diff --git a/src/test/compile-fail/required-lang-item.rs b/src/test/compile-fail/required-lang-item.rs index 1b749faf1b8..bb80c763a8b 100644 --- a/src/test/compile-fail/required-lang-item.rs +++ b/src/test/compile-fail/required-lang-item.rs @@ -11,11 +11,7 @@ #![feature(lang_items, no_std)] #![no_std] -#[lang="phantom_fn"] -pub trait PhantomFn { } -impl PhantomFn for U { } - -#[lang="sized"] pub trait Sized : PhantomFn {} +#[lang="sized"] pub trait Sized { } // error-pattern:requires `start` lang_item diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs index 34e06cc9365..a2369f8ffb4 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs @@ -13,8 +13,7 @@ use std::marker; -trait A : marker::PhantomFn { -} +trait A { } trait B: A {} diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs index 217540415a7..beabdcea2bb 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs @@ -15,7 +15,6 @@ trait Iterator { } trait IteratorUtil - : ::std::marker::PhantomFn<(),A> { fn zip>(self, other: U) -> ZipIterator; } diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs index 6d315c1b7a9..dc5576aee65 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs @@ -16,14 +16,12 @@ #![feature(unboxed_closures)] #![allow(dead_code)] -use std::marker::PhantomFn; - trait Foo { type Output; fn dummy(&self, t: T, u: Self::Output); } -trait Eq : PhantomFn<(Self,X)> { } +trait Eq { } impl Eq for X { } fn eq>() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs index bd3530e6e30..a6f59b78823 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs @@ -23,7 +23,7 @@ trait Foo { fn dummy(&self, t: T); } -trait Eq : marker::PhantomFn<(Self, X)> { } +trait Eq { } impl Eq for X { } fn eq>() { } diff --git a/src/test/compile-fail/variance-contravariant-arg-object.rs b/src/test/compile-fail/variance-contravariant-arg-object.rs index 3330e1d0d51..e47d0c33d8f 100644 --- a/src/test/compile-fail/variance-contravariant-arg-object.rs +++ b/src/test/compile-fail/variance-contravariant-arg-object.rs @@ -10,6 +10,9 @@ #![allow(dead_code)] +// This test was previously testing variance on traits. +// But now that it is removed, both cases error. + trait Get : 'static { fn get(&self, t: T); } @@ -25,7 +28,8 @@ fn get_max_from_min<'min, 'max, G>(v: Box>) -> Box> where 'max : 'min { - v + // Previously OK: + v //~ ERROR mismatched types } fn main() { } diff --git a/src/test/compile-fail/variance-contravariant-arg-trait-match.rs b/src/test/compile-fail/variance-contravariant-arg-trait-match.rs index caaad4014ad..b96e19220d0 100644 --- a/src/test/compile-fail/variance-contravariant-arg-trait-match.rs +++ b/src/test/compile-fail/variance-contravariant-arg-trait-match.rs @@ -23,7 +23,9 @@ fn get_min_from_max<'min, 'max, G>() fn get_max_from_min<'min, 'max, G>() where 'max : 'min, G : Get<&'min i32> { - impls_get::() + // Previously OK, but now an error because traits are invariant: + + impls_get::() //~ ERROR mismatched types } fn impls_get() where G : Get { } diff --git a/src/test/compile-fail/variance-contravariant-self-trait-match.rs b/src/test/compile-fail/variance-contravariant-self-trait-match.rs index 013511ed517..9d2766d878b 100644 --- a/src/test/compile-fail/variance-contravariant-self-trait-match.rs +++ b/src/test/compile-fail/variance-contravariant-self-trait-match.rs @@ -23,7 +23,10 @@ fn get_min_from_max<'min, 'max, G>() fn get_max_from_min<'min, 'max, G>() where 'max : 'min, G : 'max, &'min G : Get { - impls_get::<&'max G>(); + // Previously OK, but now error because traits are invariant with + // respect to all inputs. + + impls_get::<&'max G>(); //~ ERROR mismatched types } fn impls_get() where G : Get { } diff --git a/src/test/compile-fail/variance-covariant-arg-object.rs b/src/test/compile-fail/variance-covariant-arg-object.rs index 828c987c082..757c1c9a8a2 100644 --- a/src/test/compile-fail/variance-covariant-arg-object.rs +++ b/src/test/compile-fail/variance-covariant-arg-object.rs @@ -18,7 +18,8 @@ fn get_min_from_max<'min, 'max>(v: Box>) -> Box> where 'max : 'min { - v + // Previously OK, now an error as traits are invariant. + v //~ ERROR mismatched types } fn get_max_from_min<'min, 'max, G>(v: Box>) diff --git a/src/test/compile-fail/variance-covariant-arg-trait-match.rs b/src/test/compile-fail/variance-covariant-arg-trait-match.rs index 17761b9c0b1..097f8eb9864 100644 --- a/src/test/compile-fail/variance-covariant-arg-trait-match.rs +++ b/src/test/compile-fail/variance-covariant-arg-trait-match.rs @@ -17,7 +17,8 @@ trait Get { fn get_min_from_max<'min, 'max, G>() where 'max : 'min, G : Get<&'max i32> { - impls_get::() + // Previously OK, now an error as traits are invariant. + impls_get::() //~ ERROR mismatched types } fn get_max_from_min<'min, 'max, G>() diff --git a/src/test/compile-fail/variance-covariant-self-trait-match.rs b/src/test/compile-fail/variance-covariant-self-trait-match.rs index 4e94a3eeb46..57ea367b49c 100644 --- a/src/test/compile-fail/variance-covariant-self-trait-match.rs +++ b/src/test/compile-fail/variance-covariant-self-trait-match.rs @@ -17,7 +17,8 @@ trait Get { fn get_min_from_max<'min, 'max, G>() where 'max : 'min, G : 'max, &'max G : Get { - impls_get::<&'min G>(); + // Previously OK, now an error as traits are invariant. + impls_get::<&'min G>(); //~ ERROR mismatched types } fn get_max_from_min<'min, 'max, G>() diff --git a/src/test/compile-fail/variance-region-bounds.rs b/src/test/compile-fail/variance-region-bounds.rs index 96ae201f6ae..dfa5dc14441 100644 --- a/src/test/compile-fail/variance-region-bounds.rs +++ b/src/test/compile-fail/variance-region-bounds.rs @@ -13,11 +13,11 @@ #![feature(rustc_attrs)] #[rustc_variance] -trait Foo: 'static { //~ ERROR types=[[];[-];[]] +trait Foo: 'static { //~ ERROR types=[[];[o];[]] } #[rustc_variance] -trait Bar { //~ ERROR types=[[+];[-];[]] +trait Bar { //~ ERROR types=[[o];[o];[]] fn do_it(&self) where T: 'static; } diff --git a/src/test/compile-fail/variance-regions-unused-direct.rs b/src/test/compile-fail/variance-regions-unused-direct.rs index 396e7765206..037fff72c80 100644 --- a/src/test/compile-fail/variance-regions-unused-direct.rs +++ b/src/test/compile-fail/variance-regions-unused-direct.rs @@ -18,7 +18,7 @@ struct Struct<'a, 'd> { //~ ERROR parameter `'d` is never used field: &'a [i32] } -trait Trait<'a, 'd> { //~ ERROR parameter `'d` is never used +trait Trait<'a, 'd> { // OK on traits fn method(&'a self); } diff --git a/src/test/compile-fail/variance-trait-bounds.rs b/src/test/compile-fail/variance-trait-bounds.rs index 88b50058b65..222d8338aa2 100644 --- a/src/test/compile-fail/variance-trait-bounds.rs +++ b/src/test/compile-fail/variance-trait-bounds.rs @@ -16,12 +16,12 @@ // influence variance. #[rustc_variance] -trait Getter { //~ ERROR types=[[+];[-];[]] +trait Getter { //~ ERROR types=[[o];[o];[]] fn get(&self) -> T; } #[rustc_variance] -trait Setter { //~ ERROR types=[[-];[-];[]] +trait Setter { //~ ERROR types=[[o];[o];[]] fn get(&self, T); } @@ -37,16 +37,16 @@ enum TestEnum> {//~ ERROR types=[[*, +];[];[]] } #[rustc_variance] -trait TestTrait> { //~ ERROR types=[[-, +];[-];[]] +trait TestTrait> { //~ ERROR types=[[o, o];[o];[]] fn getter(&self, u: U) -> T; } #[rustc_variance] -trait TestTrait2 : Getter { //~ ERROR types=[[+];[-];[]] +trait TestTrait2 : Getter { //~ ERROR types=[[o];[o];[]] } #[rustc_variance] -trait TestTrait3 { //~ ERROR types=[[-];[-];[]] +trait TestTrait3 { //~ ERROR types=[[o];[o];[]] fn getter>(&self); } diff --git a/src/test/compile-fail/variance-trait-matching.rs b/src/test/compile-fail/variance-trait-matching.rs index ec020f18818..49dc1e68c22 100644 --- a/src/test/compile-fail/variance-trait-matching.rs +++ b/src/test/compile-fail/variance-trait-matching.rs @@ -1,4 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,22 +8,43 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Issue #5781. Tests that subtyping is handled properly in trait matching. +// pretty-expanded FIXME #23616 -trait Make<'a> { - fn make(x: &'a mut isize) -> Self; +#![allow(dead_code)] + +// Get is covariant in T +trait Get { + fn get(&self) -> T; } -impl<'a> Make<'a> for &'a mut isize { - fn make(x: &'a mut isize) -> &'a mut isize { - x +struct Cloner { + t: T +} + +impl Get for Cloner { + fn get(&self) -> T { + self.t.clone() } } -fn f() -> &'static mut isize { - let mut x = 1; - let y: &'static mut isize = Make::make(&mut x); //~ ERROR `x` does not live long enough - y +fn get<'a, G>(get: &G) -> i32 + where G : Get<&'a i32> +{ + // This fails to type-check because, without variance, we can't + // use `G : Get<&'a i32>` as evidence that `G : Get<&'b i32>`, + // even if `'a : 'b`. + pick(get, &22) //~ ERROR cannot infer } -fn main() {} +fn pick<'b, G>(get: &'b G, if_odd: &'b i32) -> i32 + where G : Get<&'b i32> +{ + let v = *get.get(); + if v % 2 != 0 { v } else { *if_odd } +} + +fn main() { + let x = Cloner { t: &23 }; + let y = get(&x); + assert_eq!(y, 23); +} diff --git a/src/test/compile-fail/variance-types-bounds.rs b/src/test/compile-fail/variance-types-bounds.rs index d53e4cd7610..a02f20656e7 100644 --- a/src/test/compile-fail/variance-types-bounds.rs +++ b/src/test/compile-fail/variance-types-bounds.rs @@ -37,12 +37,12 @@ struct TestIndirect2 { //~ ERROR types=[[o, o];[];[]] } #[rustc_variance] -trait Getter { //~ ERROR types=[[+];[-];[]] +trait Getter { //~ ERROR types=[[o];[o];[]] fn get(&self) -> A; } #[rustc_variance] -trait Setter { //~ ERROR types=[[-];[o];[]] +trait Setter { //~ ERROR types=[[o];[o];[]] fn set(&mut self, a: A); } @@ -53,7 +53,7 @@ trait GetterSetter { //~ ERROR types=[[o];[o];[]] } #[rustc_variance] -trait GetterInTypeBound { //~ ERROR types=[[-];[-];[]] +trait GetterInTypeBound { //~ ERROR types=[[o];[o];[]] // Here, the use of `A` in the method bound *does* affect // variance. Think of it as if the method requested a dictionary // for `T:Getter`. Since this dictionary is an input, it is @@ -63,12 +63,12 @@ trait GetterInTypeBound { //~ ERROR types=[[-];[-];[]] } #[rustc_variance] -trait SetterInTypeBound { //~ ERROR types=[[+];[-];[]] +trait SetterInTypeBound { //~ ERROR types=[[o];[o];[]] fn do_it>(&self); } #[rustc_variance] -struct TestObject { //~ ERROR types=[[-, +];[];[]] +struct TestObject { //~ ERROR types=[[o, o];[];[]] n: Box+Send>, m: Box+Send>, } diff --git a/src/test/compile-fail/variance-unused-region-param.rs b/src/test/compile-fail/variance-unused-region-param.rs index 5f504226370..407282e5ce0 100644 --- a/src/test/compile-fail/variance-unused-region-param.rs +++ b/src/test/compile-fail/variance-unused-region-param.rs @@ -12,6 +12,6 @@ struct SomeStruct<'a> { x: u32 } //~ ERROR parameter `'a` is never used enum SomeEnum<'a> { Nothing } //~ ERROR parameter `'a` is never used -trait SomeTrait<'a> { fn foo(&self); } //~ ERROR parameter `'a` is never used +trait SomeTrait<'a> { fn foo(&self); } // OK on traits. fn main() {} diff --git a/src/test/compile-fail/variance-unused-type-param.rs b/src/test/compile-fail/variance-unused-type-param.rs index 2e867ec3c93..862d842d62c 100644 --- a/src/test/compile-fail/variance-unused-type-param.rs +++ b/src/test/compile-fail/variance-unused-type-param.rs @@ -21,10 +21,6 @@ enum SomeEnum { Nothing } //~^ ERROR parameter `A` is never used //~| HELP PhantomData -trait SomeTrait { fn foo(&self); } -//~^ ERROR parameter `A` is never used -//~| HELP PhantomFn - // Here T might *appear* used, but in fact it isn't. enum ListCell { //~^ ERROR parameter `T` is never used diff --git a/src/test/run-make/simd-ffi/simd.rs b/src/test/run-make/simd-ffi/simd.rs index f418d5d1fb7..563fe79e537 100644 --- a/src/test/run-make/simd-ffi/simd.rs +++ b/src/test/run-make/simd-ffi/simd.rs @@ -70,14 +70,10 @@ pub fn bar(a: i32x4, b: i32x4) -> i32x4 { } #[lang = "sized"] -pub trait Sized : PhantomFn {} +pub trait Sized { } #[lang = "copy"] -pub trait Copy : PhantomFn {} - -#[lang="phantom_fn"] -pub trait PhantomFn { } -impl PhantomFn for U { } +pub trait Copy { } mod core { pub mod marker { diff --git a/src/test/run-make/target-specs/foo.rs b/src/test/run-make/target-specs/foo.rs index b13c41be559..9dbae193388 100644 --- a/src/test/run-make/target-specs/foo.rs +++ b/src/test/run-make/target-specs/foo.rs @@ -11,15 +11,11 @@ #![feature(lang_items, no_std)] #![no_std] -#[lang="phantom_fn"] -trait PhantomFn { } -impl PhantomFn for U { } - #[lang="copy"] -trait Copy : PhantomFn { } +trait Copy { } #[lang="sized"] -trait Sized : PhantomFn { } +trait Sized { } #[lang="start"] fn start(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize { 0 } diff --git a/src/test/compile-fail/coherence-subtyping.rs b/src/test/run-pass/coherence-subtyping.rs similarity index 94% rename from src/test/compile-fail/coherence-subtyping.rs rename to src/test/run-pass/coherence-subtyping.rs index 897cb083f84..082a39f5631 100644 --- a/src/test/compile-fail/coherence-subtyping.rs +++ b/src/test/run-pass/coherence-subtyping.rs @@ -16,7 +16,6 @@ trait Contravariant { } impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) { - //~^ ERROR E0119 } impl Contravariant for for<'a> fn(&'a u8, &'a u8) { @@ -29,7 +28,6 @@ trait Covariant { } impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) { - //~^ ERROR E0119 } impl Covariant for for<'a> fn(&'a u8, &'a u8) { @@ -38,7 +36,7 @@ impl Covariant for for<'a> fn(&'a u8, &'a u8) { /////////////////////////////////////////////////////////////////////////// trait Invariant { - fn foo(&self) -> Self { } + fn foo(&self) { } } impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) { diff --git a/src/test/run-pass/cycle-generic-bound.rs b/src/test/run-pass/cycle-generic-bound.rs index 94e4665bb86..86b41284cdf 100644 --- a/src/test/run-pass/cycle-generic-bound.rs +++ b/src/test/run-pass/cycle-generic-bound.rs @@ -12,9 +12,7 @@ // pretty-expanded FIXME #23616 -use std::marker::PhantomFn; - -trait Chromosome> : PhantomFn<(Self,X)> { +trait Chromosome> { } fn main() { } diff --git a/src/test/run-pass/issue-22356.rs b/src/test/run-pass/issue-22356.rs index a54490386d0..51a871d59b3 100644 --- a/src/test/run-pass/issue-22356.rs +++ b/src/test/run-pass/issue-22356.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -use std::marker::{PhantomData, PhantomFn}; +use std::marker::PhantomData; pub struct Handle(T, I); @@ -34,7 +34,7 @@ impl BufferHandle { pub type RawBufferHandle = Handle<::Buffer, String>; -pub trait Device: PhantomFn { +pub trait Device { type Buffer; } diff --git a/src/test/run-pass/regions-early-bound-lifetime-in-assoc-fn.rs b/src/test/run-pass/regions-early-bound-lifetime-in-assoc-fn.rs index 9aed9155124..0ffbc432aae 100644 --- a/src/test/run-pass/regions-early-bound-lifetime-in-assoc-fn.rs +++ b/src/test/run-pass/regions-early-bound-lifetime-in-assoc-fn.rs @@ -27,9 +27,7 @@ pub trait Decoder<'v> { fn read(&mut self) -> Value<'v>; } -pub trait Decodable<'v, D: Decoder<'v>> - : marker::PhantomFn<(), &'v isize> -{ +pub trait Decodable<'v, D: Decoder<'v>> { fn decode(d: &mut D) -> Self; } diff --git a/src/test/run-pass/unsized.rs b/src/test/run-pass/unsized.rs index 8ff8169ef49..449d6b37e9f 100644 --- a/src/test/run-pass/unsized.rs +++ b/src/test/run-pass/unsized.rs @@ -12,17 +12,17 @@ // pretty-expanded FIXME #23616 -use std::marker::{PhantomData, PhantomFn}; +use std::marker::PhantomData; -trait T1 : PhantomFn { } -pub trait T2 : PhantomFn { } -trait T3 : T2 + PhantomFn { } -trait T4 : PhantomFn<(Self,X)> {} -trait T5 : PhantomFn<(Self,X,Y)> {} -trait T6 : PhantomFn<(Self,X,Y)> {} -trait T7 : PhantomFn<(Self,X,Y)> {} -trait T8 : PhantomFn<(Self,X)> {} -trait T9 : PhantomFn<(Self,X)> {} +trait T1 { } +pub trait T2 { } +trait T3 : T2 { } +trait T4 { } +trait T5 { } +trait T6 { } +trait T7 { } +trait T8 { } +trait T9 { } struct S1(PhantomData); enum E { E1(PhantomData) } impl T1 for S1 {} diff --git a/src/test/run-pass/variance-trait-matching.rs b/src/test/run-pass/variance-trait-matching.rs deleted file mode 100644 index 5a179bfc7d4..00000000000 --- a/src/test/run-pass/variance-trait-matching.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -// Get is covariant in T -trait Get { - fn get(&self) -> T; -} - -struct Cloner { - t: T -} - -impl Get for Cloner { - fn get(&self) -> T { - self.t.clone() - } -} - -fn get<'a, G>(get: &G) -> i32 - where G : Get<&'a i32> -{ - // This call only type checks if we can use `G : Get<&'a i32>` as - // evidence that `G : Get<&'b i32>` where `'a : 'b`. - pick(get, &22) -} - -fn pick<'b, G>(get: &'b G, if_odd: &'b i32) -> i32 - where G : Get<&'b i32> -{ - let v = *get.get(); - if v % 2 != 0 { v } else { *if_odd } -} - -fn main() { - let x = Cloner { t: &23 }; - let y = get(&x); - assert_eq!(y, 23); -} diff --git a/src/test/run-pass/where-for-self.rs b/src/test/run-pass/where-for-self.rs index 8535d76d471..eb95b13d3fa 100644 --- a/src/test/run-pass/where-for-self.rs +++ b/src/test/run-pass/where-for-self.rs @@ -13,18 +13,13 @@ // pretty-expanded FIXME #23616 -use std::marker::PhantomFn; - static mut COUNT: u32 = 1; -trait Bar<'a> - : PhantomFn<&'a ()> -{ +trait Bar<'a> { fn bar(&self); } trait Baz<'a> - : PhantomFn<&'a ()> { fn baz(&self); }