From 872ce479550a3d805babb0ca409dfc3cf6f52309 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 12 Feb 2015 10:29:52 -0500 Subject: [PATCH] Fallout: tests. As tests frequently elide things, lots of changes here. Some of this may have been poorly rebased, though I tried to be careful and preserve the spirit of the test. --- src/libcoretest/mem.rs | 2 +- src/test/auxiliary/coherence-orphan-lib.rs | 2 +- src/test/auxiliary/default_type_params_xc.rs | 3 +- src/test/auxiliary/inner_static.rs | 12 ++--- src/test/auxiliary/issue-14421.rs | 5 +- src/test/auxiliary/issue-16643.rs | 2 +- src/test/auxiliary/issue-17662.rs | 2 +- src/test/auxiliary/issue-2380.rs | 5 +- src/test/auxiliary/issue-2526.rs | 8 ++- src/test/auxiliary/issue_20389.rs | 1 + src/test/auxiliary/issue_3907.rs | 4 +- src/test/auxiliary/issue_8401.rs | 4 +- src/test/auxiliary/issue_9123.rs | 1 + src/test/auxiliary/lang-item-public.rs | 10 +++- src/test/auxiliary/lint_stability.rs | 2 +- src/test/auxiliary/nested_item.rs | 2 +- .../auxiliary/orphan_check_diagnostics.rs | 2 +- src/test/auxiliary/overloaded_autoderef_xc.rs | 5 +- src/test/auxiliary/private_trait_xc.rs | 2 +- src/test/auxiliary/svh-a-base.rs | 6 ++- src/test/auxiliary/svh-a-change-lit.rs | 6 ++- .../auxiliary/svh-a-change-significant-cfg.rs | 6 ++- .../auxiliary/svh-a-change-trait-bound.rs | 6 ++- src/test/auxiliary/svh-a-change-type-arg.rs | 6 ++- src/test/auxiliary/svh-a-change-type-ret.rs | 6 ++- .../auxiliary/svh-a-change-type-static.rs | 6 ++- src/test/auxiliary/svh-a-comment.rs | 6 ++- src/test/auxiliary/svh-a-doc.rs | 6 ++- src/test/auxiliary/svh-a-macro.rs | 6 ++- src/test/auxiliary/svh-a-no-change.rs | 6 ++- src/test/auxiliary/svh-a-redundant-cfg.rs | 6 ++- src/test/auxiliary/svh-a-whitespace.rs | 6 ++- .../trait_bounds_on_structs_and_enums_xc.rs | 4 +- src/test/auxiliary/trait_impl_conflict.rs | 2 +- src/test/auxiliary/use_from_trait_xc.rs | 2 +- ...ed-types-ICE-when-projecting-out-of-err.rs | 6 ++- .../associated-types-coherence-failure.rs | 3 +- .../associated-types-eq-expr-path.rs | 2 +- .../associated-types-issue-17359.rs | 2 +- ...sociated-types-multiple-types-one-trait.rs | 2 +- ...associated-types-no-suitable-supertrait.rs | 2 +- .../compile-fail/associated-types-path-2.rs | 2 + .../associated-types-unconstrained.rs | 2 +- .../compile-fail/bad-mid-path-type-params.rs | 7 --- src/test/compile-fail/bad-sized.rs | 2 +- ...nket-conflicts-with-blanket-implemented.rs | 5 +- ...et-conflicts-with-blanket-unimplemented.rs | 4 +- ...herence-conflicting-negative-trait-impl.rs | 8 +-- src/test/compile-fail/cross-borrow-trait.rs | 2 +- .../compile-fail/destructure-trait-ref.rs | 2 +- src/test/compile-fail/dst-bad-coerce1.rs | 2 +- src/test/compile-fail/dst-bad-coerce2.rs | 2 +- src/test/compile-fail/dst-bad-coerce3.rs | 2 +- src/test/compile-fail/dst-bad-coercions.rs | 4 +- .../dst-object-from-unsized-type.rs | 2 +- .../compile-fail/exclusive-drop-and-copy.rs | 2 +- .../generic-impl-less-params-with-defaults.rs | 7 ++- .../generic-impl-more-params-with-defaults.rs | 7 ++- .../generic-lifetime-trait-impl.rs | 5 +- .../generic-type-less-params-with-defaults.rs | 5 +- .../generic-type-more-params-with-defaults.rs | 5 +- .../generic-type-params-name-repr.rs | 8 +-- src/test/compile-fail/issue-11515.rs | 2 +- src/test/compile-fail/issue-13853-2.rs | 4 +- src/test/compile-fail/issue-13853-3.rs | 5 +- src/test/compile-fail/issue-13853.rs | 4 +- src/test/compile-fail/issue-14285.rs | 4 +- src/test/compile-fail/issue-14853.rs | 3 +- src/test/compile-fail/issue-16747.rs | 4 +- src/test/compile-fail/issue-17431-4.rs | 4 +- src/test/compile-fail/issue-17431-5.rs | 4 +- src/test/compile-fail/issue-17551.rs | 6 ++- src/test/compile-fail/issue-18107.rs | 4 +- src/test/compile-fail/issue-18611.rs | 4 +- src/test/compile-fail/issue-18783.rs | 1 + src/test/compile-fail/issue-18819.rs | 4 +- src/test/compile-fail/issue-19660.rs | 6 ++- src/test/compile-fail/issue-2063.rs | 3 +- src/test/compile-fail/issue-20831-debruijn.rs | 5 +- src/test/compile-fail/issue-2611-4.rs | 4 +- src/test/compile-fail/issue-3008-3.rs | 4 +- src/test/compile-fail/issue-4972.rs | 4 +- src/test/compile-fail/issue-5035-2.rs | 4 +- src/test/compile-fail/issue-5543.rs | 4 +- src/test/compile-fail/issue-5883.rs | 6 ++- src/test/compile-fail/issue-6458.rs | 6 ++- src/test/compile-fail/issue-7575.rs | 8 +-- src/test/compile-fail/issue-8727.rs | 10 ++-- src/test/compile-fail/kindck-copy.rs | 4 +- .../compile-fail/kindck-impl-type-params-2.rs | 4 +- .../compile-fail/kindck-impl-type-params.rs | 20 +++++--- src/test/compile-fail/kindck-send-object.rs | 4 +- src/test/compile-fail/kindck-send-object1.rs | 4 +- src/test/compile-fail/kindck-send-object2.rs | 4 +- ...me-inference-give-expl-lifetime-param-3.rs | 4 +- ...time-inference-give-expl-lifetime-param.rs | 4 +- src/test/compile-fail/lint-missing-doc.rs | 20 +++++--- .../compile-fail/lint-non-camel-case-types.rs | 1 + src/test/compile-fail/lint-stability.rs | 4 +- .../lint-visible-private-types.rs | 8 +-- .../compile-fail/liveness-use-after-send.rs | 4 +- src/test/compile-fail/map-types.rs | 5 +- .../method-ambig-one-trait-coerce.rs | 50 ------------------- .../object-does-not-impl-trait.rs | 3 +- .../object-lifetime-default-mybox.rs | 1 - .../compile-fail/object-safety-no-static.rs | 2 +- .../compile-fail/on-unimplemented-bad-anno.rs | 18 +++++-- src/test/compile-fail/on-unimplemented.rs | 6 ++- .../compile-fail/orphan-check-diagnostics.rs | 2 +- .../compile-fail/priv-in-bad-locations.rs | 4 +- src/test/compile-fail/privacy-ns2.rs | 8 +-- src/test/compile-fail/privacy1.rs | 8 ++- src/test/compile-fail/privacy4.rs | 8 ++- .../region-object-lifetime-in-coercion.rs | 2 +- ...ssoc-type-region-bound-in-trait-not-met.rs | 5 +- ...ssoc-type-static-bound-in-trait-not-met.rs | 5 +- .../regions-bound-missing-bound-in-impl.rs | 5 +- ...nded-method-type-parameters-trait-bound.rs | 6 --- ...gions-close-associated-type-into-object.rs | 4 +- .../regions-close-object-into-object-1.rs | 9 ++-- .../regions-close-object-into-object-2.rs | 6 ++- .../regions-close-object-into-object-3.rs | 6 ++- .../regions-close-object-into-object-4.rs | 6 ++- .../regions-close-over-borrowed-ref-in-obj.rs | 4 +- .../regions-close-param-into-object.rs | 2 +- ...egions-infer-contravariance-due-to-decl.rs | 2 +- .../regions-infer-covariance-due-to-decl.rs | 2 +- .../regions-infer-invariance-due-to-decl.rs | 2 +- src/test/compile-fail/required-lang-item.rs | 6 ++- .../compile-fail/shadowed-type-parameter.rs | 6 ++- .../slightly-nice-generic-literal-messages.rs | 6 ++- src/test/compile-fail/staticness-mismatch.rs | 2 +- .../trait-as-struct-constructor.rs | 2 +- .../compile-fail/trait-bounds-cant-coerce.rs | 1 + .../trait-bounds-impl-comparison-1.rs | 14 ++++-- .../trait-bounds-impl-comparison-2.rs | 4 +- .../trait-bounds-not-on-bare-trait.rs | 1 + ...rait-bounds-on-structs-and-enums-locals.rs | 4 +- ...rait-bounds-on-structs-and-enums-static.rs | 4 +- .../trait-bounds-on-structs-and-enums.rs | 10 ++-- src/test/compile-fail/trait-bounds-sugar.rs | 3 +- src/test/compile-fail/trait-impl-1.rs | 4 +- src/test/compile-fail/trait-object-safety.rs | 1 + .../trait-static-method-generic-inference.rs | 1 + .../typeck-negative-impls-builtin.rs | 4 +- .../typeck_type_placeholder_mismatch.rs | 10 ++-- .../unboxed-closure-feature-gate.rs | 4 ++ .../unboxed-closure-sugar-default.rs | 2 +- .../unboxed-closure-sugar-equiv.rs | 4 +- .../unboxed-closure-sugar-lifetime-elision.rs | 4 +- .../unboxed-closure-sugar-region.rs | 2 +- ...oxed-closures-recursive-fn-using-fn-mut.rs | 6 +-- src/test/compile-fail/unnecessary-private.rs | 4 +- .../unsized-inherent-impl-self-type.rs | 2 +- .../unsized-trait-impl-self-type.rs | 3 +- .../unsized-trait-impl-trait-arg.rs | 3 +- src/test/compile-fail/unsized3.rs | 5 +- src/test/compile-fail/unsized6.rs | 3 +- src/test/compile-fail/unsized7.rs | 8 ++- src/test/compile-fail/unused-attr.rs | 4 +- src/test/compile-fail/useless-priv.rs | 8 +-- src/test/compile-fail/useless-priv2.rs | 6 ++- .../compile-fail/variance-regions-direct.rs | 1 + .../compile-fail/variance-regions-indirect.rs | 4 ++ .../variance-trait-object-bound.rs | 2 +- .../visible-private-types-generics.rs | 4 +- .../visible-private-types-supertrait.rs | 4 +- .../where-clause-method-substituion.rs | 4 +- .../where-clauses-not-parameter.rs | 4 +- src/test/debuginfo/type-names.rs | 17 ++++--- src/test/pretty/empty-impl.rs | 4 +- src/test/pretty/path-type-bounds.rs | 4 +- src/test/run-fail/bug-811.rs | 4 ++ src/test/run-make/rustdoc-json/foo.rs | 2 +- .../run-make/rustdoc-negative-impl/foo.rs | 2 +- .../run-make/rustdoc-search-index/index.rs | 2 +- src/test/run-make/rustdoc-smoke/foo.rs | 2 +- .../run-make/rustdoc-viewpath-self/foo.rs | 2 +- src/test/run-make/rustdoc-where/foo.rs | 15 +++--- src/test/run-make/save-analysis/foo.rs | 1 + src/test/run-make/simd-ffi/simd.rs | 8 ++- .../run-make/symbols-are-reasonable/lib.rs | 2 +- src/test/run-make/target-specs/foo.rs | 8 ++- .../cleanup-auto-borrow-obj.rs | 2 +- src/test/run-pass-valgrind/dst-dtor-1.rs | 2 +- src/test/run-pass/associated-types-basic.rs | 4 +- .../associated-types-conditional-dispatch.rs | 7 ++- .../run-pass/associated-types-issue-20371.rs | 4 +- .../run-pass/associated-types-issue-21212.rs | 3 +- .../associated-types-nested-projections.rs | 5 +- ...iated-types-normalize-in-bounds-binding.rs | 6 ++- ...sociated-types-normalize-in-bounds-ufcs.rs | 10 ++-- .../associated-types-normalize-in-bounds.rs | 10 ++-- ...ociated-types-normalize-unifield-struct.rs | 5 +- ...ypes-projection-from-known-type-in-impl.rs | 2 + ...ociated-types-projection-in-object-type.rs | 2 + ...sociated-types-projection-in-supertrait.rs | 2 + ...ciated-types-projection-in-where-clause.rs | 2 + .../associated-types-ref-in-struct-literal.rs | 2 + .../associated-types-resolve-lifetime.rs | 2 + .../associated-types-struct-field-named.rs | 2 + .../associated-types-struct-field-numbered.rs | 2 + .../run-pass/associated-types-sugar-path.rs | 3 +- src/test/run-pass/borrowck-trait-lifetime.rs | 5 +- src/test/run-pass/bug-7295.rs | 6 +-- .../builtin-superkinds-in-metadata.rs | 1 + .../builtin-superkinds-phantom-typaram.rs | 6 ++- src/test/run-pass/class-typarams.rs | 7 ++- src/test/run-pass/dst-coercions.rs | 2 +- src/test/run-pass/enum-null-pointer-opt.rs | 2 +- src/test/run-pass/explicit-self-generic.rs | 8 ++- src/test/run-pass/export-non-interference.rs | 14 ------ ...generic-default-type-params-cross-crate.rs | 10 ++-- src/test/run-pass/hrtb-opt-in-copy.rs | 4 +- src/test/run-pass/inner-static.rs | 6 +-- src/test/run-pass/issue-10456.rs | 4 +- src/test/run-pass/issue-10802.rs | 2 +- src/test/run-pass/issue-10902.rs | 4 +- src/test/run-pass/issue-11205.rs | 2 +- src/test/run-pass/issue-11384.rs | 2 +- src/test/run-pass/issue-11612.rs | 2 +- src/test/run-pass/issue-11677.rs | 9 +++- src/test/run-pass/issue-13105.rs | 4 +- src/test/run-pass/issue-14399.rs | 2 +- src/test/run-pass/issue-14589.rs | 7 +-- src/test/run-pass/issue-14958.rs | 2 +- src/test/run-pass/issue-14959.rs | 8 +-- src/test/run-pass/issue-15858.rs | 12 ++--- src/test/run-pass/issue-16596.rs | 2 +- src/test/run-pass/issue-16643.rs | 2 +- src/test/run-pass/issue-17662.rs | 6 ++- src/test/run-pass/issue-17732.rs | 3 +- src/test/run-pass/issue-17771.rs | 2 +- src/test/run-pass/issue-17816.rs | 6 ++- src/test/run-pass/issue-17904.rs | 4 +- src/test/run-pass/issue-18232.rs | 4 +- src/test/run-pass/issue-18906.rs | 2 +- src/test/run-pass/issue-19121.rs | 2 + src/test/run-pass/issue-19129-2.rs | 2 +- src/test/run-pass/issue-19135.rs | 6 ++- src/test/run-pass/issue-19358.rs | 2 +- src/test/run-pass/issue-19398.rs | 4 +- src/test/run-pass/issue-19479.rs | 6 ++- src/test/run-pass/issue-19631.rs | 1 + src/test/run-pass/issue-19632.rs | 1 + src/test/run-pass/issue-20055-box-trait.rs | 4 +- src/test/run-pass/issue-20343.rs | 2 +- src/test/run-pass/issue-20763-1.rs | 5 +- src/test/run-pass/issue-20763-2.rs | 5 +- src/test/run-pass/issue-21363.rs | 1 + src/test/run-pass/issue-21909.rs | 6 ++- src/test/run-pass/issue-2311-2.rs | 5 +- src/test/run-pass/issue-2311.rs | 2 +- src/test/run-pass/issue-2312.rs | 2 +- src/test/run-pass/issue-2611-3.rs | 4 +- src/test/run-pass/issue-2734.rs | 4 +- src/test/run-pass/issue-2735.rs | 4 +- src/test/run-pass/issue-4107.rs | 12 ++--- src/test/run-pass/issue-5192.rs | 1 + src/test/run-pass/issue-5708.rs | 4 +- src/test/run-pass/issue-6128.rs | 4 ++ src/test/run-pass/issue-6318.rs | 4 +- src/test/run-pass/issue-7575.rs | 1 + ...7673-cast-generically-implemented-trait.rs | 5 +- src/test/run-pass/issue-7911.rs | 4 +- src/test/run-pass/issue-8248.rs | 4 +- src/test/run-pass/issue-8249.rs | 4 +- src/test/run-pass/issue-9719.rs | 8 ++- src/test/run-pass/lint-cstack.rs | 2 +- .../method-early-bound-lifetimes-on-self.rs | 8 ++- .../run-pass/method-recursive-blanket-impl.rs | 8 +-- ...nomorphized-callees-with-ty-params-3314.rs | 3 +- .../run-pass/overloaded-autoderef-vtable.rs | 6 ++- .../overloaded-calls-param-vtables.rs | 5 +- .../parameterized-trait-with-bounds.rs | 8 +-- src/test/run-pass/privacy-ns.rs | 3 ++ .../regions-assoc-type-static-bound.rs | 5 +- .../regions-bound-lists-feature-gate-2.rs | 4 +- .../regions-bound-lists-feature-gate.rs | 5 +- ...egions-early-bound-lifetime-in-assoc-fn.rs | 6 ++- .../regions-early-bound-trait-param.rs | 6 +-- src/test/run-pass/regions-infer-bivariance.rs | 28 ----------- .../regions-no-bound-in-argument-cleanup.rs | 4 +- .../regions-no-variance-from-fn-generics.rs | 10 +++- src/test/run-pass/self-impl.rs | 1 + src/test/run-pass/simple-match-generic-tag.rs | 9 ++-- src/test/run-pass/syntax-trait-polarity.rs | 6 +-- src/test/run-pass/trailing-comma.rs | 4 +- src/test/run-pass/trait-bounds-basic.rs | 2 +- .../trait-bounds-on-structs-and-enums.rs | 6 +-- src/test/run-pass/trait-bounds-recursion.rs | 8 +-- .../trait-default-method-bound-subst4.rs | 1 + src/test/run-pass/trait-impl.rs | 3 +- src/test/run-pass/trait-inheritance-num2.rs | 3 +- .../run-pass/trait-inheritance-static2.rs | 4 +- src/test/run-pass/trait-object-generics.rs | 11 ++-- .../trait-static-method-overwriting.rs | 10 ++-- .../unboxed-closures-infer-recursive-fn.rs | 6 +-- src/test/run-pass/unique-object-move.rs | 2 +- src/test/run-pass/unsized.rs | 24 +++++---- src/test/run-pass/unsized2.rs | 12 +++-- .../visible-private-types-feature-gate.rs | 2 +- .../where-clause-bounds-inconsistency.rs | 4 +- .../where-clause-early-bound-lifetimes.rs | 2 +- .../where-clause-method-substituion.rs | 4 +- src/test/run-pass/where-for-self.rs | 10 +++- 306 files changed, 915 insertions(+), 580 deletions(-) delete mode 100644 src/test/compile-fail/method-ambig-one-trait-coerce.rs delete mode 100644 src/test/run-pass/export-non-interference.rs delete mode 100644 src/test/run-pass/regions-infer-bivariance.rs diff --git a/src/libcoretest/mem.rs b/src/libcoretest/mem.rs index 421ce76caaf4..5aeb330b78b5 100644 --- a/src/libcoretest/mem.rs +++ b/src/libcoretest/mem.rs @@ -92,7 +92,7 @@ fn test_transmute_copy() { #[test] fn test_transmute() { - trait Foo {} + trait Foo { fn dummy(&self) { } } impl Foo for int {} let a = box 100 as Box; diff --git a/src/test/auxiliary/coherence-orphan-lib.rs b/src/test/auxiliary/coherence-orphan-lib.rs index 2e5d18b58f22..cc42b288e663 100644 --- a/src/test/auxiliary/coherence-orphan-lib.rs +++ b/src/test/auxiliary/coherence-orphan-lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait TheTrait { +pub trait TheTrait : ::std::marker::PhantomFn { fn the_fn(&self); } diff --git a/src/test/auxiliary/default_type_params_xc.rs b/src/test/auxiliary/default_type_params_xc.rs index d12f716decf9..0a65174911ec 100644 --- a/src/test/auxiliary/default_type_params_xc.rs +++ b/src/test/auxiliary/default_type_params_xc.rs @@ -12,4 +12,5 @@ pub struct Heap; pub struct FakeHeap; -pub struct FakeVec; +pub struct FakeVec { pub f: Option<(T,A)> } + diff --git a/src/test/auxiliary/inner_static.rs b/src/test/auxiliary/inner_static.rs index 94acea066183..ca5c6072cb37 100644 --- a/src/test/auxiliary/inner_static.rs +++ b/src/test/auxiliary/inner_static.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub struct A; -pub struct B; +pub struct A { pub v: T } +pub struct B { pub v: T } pub mod test { - pub struct A; + pub struct A { pub v: T } impl A { pub fn foo(&self) -> int { @@ -52,9 +52,9 @@ impl B { } pub fn foo() -> int { - let a = A::<()>; - let b = B::<()>; - let c = test::A::<()>; + let a = A { v: () }; + let b = B { v: () }; + let c = test::A { v: () }; return a.foo() + a.bar() + b.foo() + b.bar() + c.foo() + c.bar(); diff --git a/src/test/auxiliary/issue-14421.rs b/src/test/auxiliary/issue-14421.rs index 7c69cba179ca..a48088609f98 100644 --- a/src/test/auxiliary/issue-14421.rs +++ b/src/test/auxiliary/issue-14421.rs @@ -10,6 +10,7 @@ #![crate_type="lib"] #![deny(warnings)] +#![allow(dead_code)] pub use src::aliases::B; pub use src::hidden_core::make; @@ -23,9 +24,9 @@ mod src { pub mod hidden_core { use super::aliases::B; - pub struct A; + pub struct A { t: T } - pub fn make() -> B { A } + pub fn make() -> B { A { t: 1.0 } } impl A { pub fn foo(&mut self) { println!("called foo"); } diff --git a/src/test/auxiliary/issue-16643.rs b/src/test/auxiliary/issue-16643.rs index c5b3fceaf4a5..b590160a0c2a 100644 --- a/src/test/auxiliary/issue-16643.rs +++ b/src/test/auxiliary/issue-16643.rs @@ -10,7 +10,7 @@ #![crate_type = "lib"] -pub struct TreeBuilder; +pub struct TreeBuilder { pub h: H } impl TreeBuilder { pub fn process_token(&mut self) { diff --git a/src/test/auxiliary/issue-17662.rs b/src/test/auxiliary/issue-17662.rs index be10ca1dd8fd..fb55a077005e 100644 --- a/src/test/auxiliary/issue-17662.rs +++ b/src/test/auxiliary/issue-17662.rs @@ -11,7 +11,7 @@ #![crate_type = "lib"] pub trait Foo<'a, T> { - fn foo(&self) -> T; + fn foo(&'a self) -> T; } pub fn foo<'a, T>(x: &'a Foo<'a, T>) -> T { diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index 8eb6cd6e2631..96f33f97a696 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -14,7 +14,10 @@ #![allow(unknown_features)] #![feature(box_syntax)] -pub trait i { } +pub trait i +{ + fn dummy(&self, t: T) -> T { panic!() } +} pub fn f() -> Box+'static> { impl i for () { } diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index e3ce4e8f6565..89b3b56121a1 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -13,8 +13,11 @@ #![feature(unsafe_destructor)] +use std::marker; + struct arc_destruct { - _data: int, + _data: int, + _marker: marker::PhantomData } #[unsafe_destructor] @@ -24,7 +27,8 @@ impl Drop for arc_destruct { fn arc_destruct(data: int) -> arc_destruct { arc_destruct { - _data: data + _data: data, + _marker: marker::PhantomData } } diff --git a/src/test/auxiliary/issue_20389.rs b/src/test/auxiliary/issue_20389.rs index 7a378b06df9e..4ce7e3079e33 100644 --- a/src/test/auxiliary/issue_20389.rs +++ b/src/test/auxiliary/issue_20389.rs @@ -10,4 +10,5 @@ pub trait T { type C; + fn dummy(&self) { } } diff --git a/src/test/auxiliary/issue_3907.rs b/src/test/auxiliary/issue_3907.rs index 2e254e5431d5..545e15fe1664 100644 --- a/src/test/auxiliary/issue_3907.rs +++ b/src/test/auxiliary/issue_3907.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait Foo { +use std::marker::MarkerTrait; + +pub trait Foo : MarkerTrait { fn bar(); } diff --git a/src/test/auxiliary/issue_8401.rs b/src/test/auxiliary/issue_8401.rs index 0831993119ae..9006a5d1775f 100644 --- a/src/test/auxiliary/issue_8401.rs +++ b/src/test/auxiliary/issue_8401.rs @@ -12,7 +12,9 @@ use std::mem; -trait A {} +trait A { + fn dummy(&self) { } +} struct B; impl A for B {} diff --git a/src/test/auxiliary/issue_9123.rs b/src/test/auxiliary/issue_9123.rs index 000cc100a12f..4f2792aebcd2 100644 --- a/src/test/auxiliary/issue_9123.rs +++ b/src/test/auxiliary/issue_9123.rs @@ -15,5 +15,6 @@ pub trait X { fn f() { } f(); } + fn dummy(&self) { } } diff --git a/src/test/auxiliary/lang-item-public.rs b/src/test/auxiliary/lang-item-public.rs index 834667968c85..b9cc20b63cc5 100644 --- a/src/test/auxiliary/lang-item-public.rs +++ b/src/test/auxiliary/lang-item-public.rs @@ -12,8 +12,12 @@ #![no_std] #![feature(lang_items)] +#[lang="phantom_fn"] +pub trait PhantomFn { } +impl PhantomFn for U { } + #[lang="sized"] -pub trait Sized {} +pub trait Sized : PhantomFn {} #[lang="panic"] fn panic(_: &(&'static str, &'static str, uint)) -> ! { loop {} } @@ -25,6 +29,8 @@ extern fn stack_exhausted() {} extern fn eh_personality() {} #[lang="copy"] -pub trait Copy {} +pub trait Copy : PhantomFn { + // Empty. +} diff --git a/src/test/auxiliary/lint_stability.rs b/src/test/auxiliary/lint_stability.rs index 01b2b748ba9d..fb535eb8336f 100644 --- a/src/test/auxiliary/lint_stability.rs +++ b/src/test/auxiliary/lint_stability.rs @@ -96,7 +96,7 @@ pub trait Trait { impl Trait for MethodTester {} #[unstable(feature = "test_feature")] -pub trait UnstableTrait {} +pub trait UnstableTrait { fn dummy(&self) { } } #[stable(feature = "test_feature", since = "1.0.0")] #[deprecated(since = "1.0.0")] diff --git a/src/test/auxiliary/nested_item.rs b/src/test/auxiliary/nested_item.rs index 21784bda27a8..fc1bea5a9fd4 100644 --- a/src/test/auxiliary/nested_item.rs +++ b/src/test/auxiliary/nested_item.rs @@ -25,7 +25,7 @@ impl Foo { } // issue 8134 -pub struct Parser; +pub struct Parser(T); impl> Parser { fn in_doctype(&mut self) { static DOCTYPEPattern: [char; 6] = ['O', 'C', 'T', 'Y', 'P', 'E']; diff --git a/src/test/auxiliary/orphan_check_diagnostics.rs b/src/test/auxiliary/orphan_check_diagnostics.rs index 7647f159401a..cf3e9903b5ad 100644 --- a/src/test/auxiliary/orphan_check_diagnostics.rs +++ b/src/test/auxiliary/orphan_check_diagnostics.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait RemoteTrait {} +pub trait RemoteTrait { fn dummy(&self) { } } diff --git a/src/test/auxiliary/overloaded_autoderef_xc.rs b/src/test/auxiliary/overloaded_autoderef_xc.rs index caa9bbe5736e..3c8cba13ae73 100644 --- a/src/test/auxiliary/overloaded_autoderef_xc.rs +++ b/src/test/auxiliary/overloaded_autoderef_xc.rs @@ -11,7 +11,8 @@ use std::ops::Deref; struct DerefWithHelper { - pub helper: H + pub helper: H, + pub value: Option } trait Helper { @@ -34,6 +35,6 @@ impl> Deref for DerefWithHelper { // Test cross-crate autoderef + vtable. pub fn check(x: T, y: T) -> bool { - let d: DerefWithHelper, T> = DerefWithHelper { helper: Some(x) }; + let d: DerefWithHelper, T> = DerefWithHelper { helper: Some(x), value: None }; d.eq(&y) } diff --git a/src/test/auxiliary/private_trait_xc.rs b/src/test/auxiliary/private_trait_xc.rs index 37ee10c8d373..42691579491b 100644 --- a/src/test/auxiliary/private_trait_xc.rs +++ b/src/test/auxiliary/private_trait_xc.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo : ::std::marker::MarkerTrait {} diff --git a/src/test/auxiliary/svh-a-base.rs b/src/test/auxiliary/svh-a-base.rs index 12833daf6045..04f1062c16f0 100644 --- a/src/test/auxiliary/svh-a-base.rs +++ b/src/test/auxiliary/svh-a-base.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-change-lit.rs b/src/test/auxiliary/svh-a-change-lit.rs index 9e74bf281358..fabd2289e9a4 100644 --- a/src/test/auxiliary/svh-a-change-lit.rs +++ b/src/test/auxiliary/svh-a-change-lit.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-change-significant-cfg.rs b/src/test/auxiliary/svh-a-change-significant-cfg.rs index c900550041b5..3fdb861bd40c 100644 --- a/src/test/auxiliary/svh-a-change-significant-cfg.rs +++ b/src/test/auxiliary/svh-a-change-significant-cfg.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-change-trait-bound.rs b/src/test/auxiliary/svh-a-change-trait-bound.rs index 04f8eb3cf9bc..3116d24673d4 100644 --- a/src/test/auxiliary/svh-a-change-trait-bound.rs +++ b/src/test/auxiliary/svh-a-change-trait-bound.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-change-type-arg.rs b/src/test/auxiliary/svh-a-change-type-arg.rs index c7e0a18768a3..b49a1533628f 100644 --- a/src/test/auxiliary/svh-a-change-type-arg.rs +++ b/src/test/auxiliary/svh-a-change-type-arg.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-change-type-ret.rs b/src/test/auxiliary/svh-a-change-type-ret.rs index 5100af323183..6562a93135f3 100644 --- a/src/test/auxiliary/svh-a-change-type-ret.rs +++ b/src/test/auxiliary/svh-a-change-type-ret.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-change-type-static.rs b/src/test/auxiliary/svh-a-change-type-static.rs index 077c33cb90d7..c7b392c6ee82 100644 --- a/src/test/auxiliary/svh-a-change-type-static.rs +++ b/src/test/auxiliary/svh-a-change-type-static.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-comment.rs b/src/test/auxiliary/svh-a-comment.rs index d481fa5a1fa3..450f61020260 100644 --- a/src/test/auxiliary/svh-a-comment.rs +++ b/src/test/auxiliary/svh-a-comment.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-doc.rs b/src/test/auxiliary/svh-a-doc.rs index 9e99a355ac1e..c000737c854c 100644 --- a/src/test/auxiliary/svh-a-doc.rs +++ b/src/test/auxiliary/svh-a-doc.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-macro.rs b/src/test/auxiliary/svh-a-macro.rs index b8dd497ac99c..1e12659dc4b9 100644 --- a/src/test/auxiliary/svh-a-macro.rs +++ b/src/test/auxiliary/svh-a-macro.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-no-change.rs b/src/test/auxiliary/svh-a-no-change.rs index 12833daf6045..04f1062c16f0 100644 --- a/src/test/auxiliary/svh-a-no-change.rs +++ b/src/test/auxiliary/svh-a-no-change.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-redundant-cfg.rs b/src/test/auxiliary/svh-a-redundant-cfg.rs index 690ddc670f5f..1e82b74f1ef2 100644 --- a/src/test/auxiliary/svh-a-redundant-cfg.rs +++ b/src/test/auxiliary/svh-a-redundant-cfg.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/svh-a-whitespace.rs b/src/test/auxiliary/svh-a-whitespace.rs index 216e8e997f22..3c3dac9cdab9 100644 --- a/src/test/auxiliary/svh-a-whitespace.rs +++ b/src/test/auxiliary/svh-a-whitespace.rs @@ -15,12 +15,14 @@ #![crate_name = "a"] +use std::marker::MarkerTrait; + macro_rules! three { () => { 3 } } -pub trait U {} -pub trait V {} +pub trait U : MarkerTrait {} +pub trait V : MarkerTrait {} impl U for () {} impl V for () {} diff --git a/src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs b/src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs index 1695e474de99..a7c469fccaa5 100644 --- a/src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs +++ b/src/test/auxiliary/trait_bounds_on_structs_and_enums_xc.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait Trait {} +pub trait Trait { + fn dummy(&self) { } +} pub struct Foo { pub x: T, diff --git a/src/test/auxiliary/trait_impl_conflict.rs b/src/test/auxiliary/trait_impl_conflict.rs index 990bc2160495..0982efbdbf47 100644 --- a/src/test/auxiliary/trait_impl_conflict.rs +++ b/src/test/auxiliary/trait_impl_conflict.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait Foo { +pub trait Foo : ::std::marker::MarkerTrait { } impl Foo for int { diff --git a/src/test/auxiliary/use_from_trait_xc.rs b/src/test/auxiliary/use_from_trait_xc.rs index 22e0d3168cad..56fb40bc0a46 100644 --- a/src/test/auxiliary/use_from_trait_xc.rs +++ b/src/test/auxiliary/use_from_trait_xc.rs @@ -11,7 +11,7 @@ pub use self::sub::{Bar, Baz}; pub trait Trait { - fn foo(); + fn foo(&self); } struct Foo; 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 621f5ec9660f..edd1b8255ccd 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,8 +16,12 @@ #![feature(no_std)] #![no_std] +#[lang="phantom_fn"] +pub trait PhantomFn { } +impl PhantomFn for U { } + #[lang="sized"] -pub trait Sized { +pub trait Sized : PhantomFn { // Empty. } diff --git a/src/test/compile-fail/associated-types-coherence-failure.rs b/src/test/compile-fail/associated-types-coherence-failure.rs index 95a68dd66983..b7a16c68a34e 100644 --- a/src/test/compile-fail/associated-types-coherence-failure.rs +++ b/src/test/compile-fail/associated-types-coherence-failure.rs @@ -11,9 +11,10 @@ // Test that coherence detects overlap when some of the types in the // impls are projections of associated type. Issue #20624. +use std::marker::PhantomData; use std::ops::Deref; -pub struct Cow<'a, B: ?Sized>; +pub struct Cow<'a, B: ?Sized>(PhantomData<(&'a (),B)>); /// Trait for moving into a `Cow` pub trait IntoCow<'a, B: ?Sized> { diff --git a/src/test/compile-fail/associated-types-eq-expr-path.rs b/src/test/compile-fail/associated-types-eq-expr-path.rs index 9baa7f1ad5a6..c48f9972ebc1 100644 --- a/src/test/compile-fail/associated-types-eq-expr-path.rs +++ b/src/test/compile-fail/associated-types-eq-expr-path.rs @@ -10,7 +10,7 @@ // Check that an associated type cannot be bound in an expression path. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { type A; fn bar() -> isize; } diff --git a/src/test/compile-fail/associated-types-issue-17359.rs b/src/test/compile-fail/associated-types-issue-17359.rs index fa09ae793bf6..625f4cdb8ef3 100644 --- a/src/test/compile-fail/associated-types-issue-17359.rs +++ b/src/test/compile-fail/associated-types-issue-17359.rs @@ -11,7 +11,7 @@ // Test that we do not ICE when an impl is missing an associated type (and that we report // a useful error, of course). -trait Trait { +trait Trait : ::std::marker::MarkerTrait { type Type; } diff --git a/src/test/compile-fail/associated-types-multiple-types-one-trait.rs b/src/test/compile-fail/associated-types-multiple-types-one-trait.rs index 9436f825de89..5632f148da67 100644 --- a/src/test/compile-fail/associated-types-multiple-types-one-trait.rs +++ b/src/test/compile-fail/associated-types-multiple-types-one-trait.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { type X; type Y; } diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs index a3f2850b2946..2b84c38f80b5 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs @@ -11,7 +11,7 @@ // Check that we get an error when you use `::Value` in // the trait definition but `Self` does not, in fact, implement `Get`. -trait Get { +trait Get : ::std::marker::MarkerTrait { type Value; } diff --git a/src/test/compile-fail/associated-types-path-2.rs b/src/test/compile-fail/associated-types-path-2.rs index 51a37b517dde..b9a62ff4e417 100644 --- a/src/test/compile-fail/associated-types-path-2.rs +++ b/src/test/compile-fail/associated-types-path-2.rs @@ -12,6 +12,8 @@ pub trait Foo { type A; + + fn dummy(&self) { } } impl Foo for i32 { diff --git a/src/test/compile-fail/associated-types-unconstrained.rs b/src/test/compile-fail/associated-types-unconstrained.rs index aecbf217a5b2..8832028f9aba 100644 --- a/src/test/compile-fail/associated-types-unconstrained.rs +++ b/src/test/compile-fail/associated-types-unconstrained.rs @@ -10,7 +10,7 @@ // Check that an associated type cannot be bound in an expression path. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { type A; fn bar() -> isize; } diff --git a/src/test/compile-fail/bad-mid-path-type-params.rs b/src/test/compile-fail/bad-mid-path-type-params.rs index c91849ca53e1..3e02a11c378b 100644 --- a/src/test/compile-fail/bad-mid-path-type-params.rs +++ b/src/test/compile-fail/bad-mid-path-type-params.rs @@ -10,13 +10,6 @@ // ignore-tidy-linelength -#![feature(no_std)] -#![no_std] -#![feature(lang_items)] - -#[lang="sized"] -pub trait Sized {} - struct S { contents: T, } diff --git a/src/test/compile-fail/bad-sized.rs b/src/test/compile-fail/bad-sized.rs index 69be6414e4c9..1944acbe1f34 100644 --- a/src/test/compile-fail/bad-sized.rs +++ b/src/test/compile-fail/bad-sized.rs @@ -12,7 +12,7 @@ use std::cell::RefCell; -trait Trait {} +trait Trait : ::std::marker::MarkerTrait {} pub fn main() { let x: Vec = Vec::new(); diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs index 27d97d18c949..d4decb713498 100644 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs +++ b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs @@ -10,6 +10,7 @@ use std::fmt::Show; use std::default::Default; +use std::marker::MarkerTrait; // Test that two blanket impls conflict (at least without negative // bounds). After all, some other crate could implement Even or Odd @@ -19,9 +20,9 @@ trait MyTrait { fn get(&self) -> usize; } -trait Even { } +trait Even : MarkerTrait { } -trait Odd { } +trait Odd : MarkerTrait { } impl Even for isize { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs index 0f233b78c721..b1ee1762b6e7 100644 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs +++ b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs @@ -19,9 +19,9 @@ trait MyTrait { fn get(&self) -> usize; } -trait Even { } +trait Even : ::std::marker::MarkerTrait { } -trait Odd { } +trait Odd : ::std::marker::MarkerTrait { } impl MyTrait for T { //~ ERROR E0119 fn get(&self) -> usize { 0 } diff --git a/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs b/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs index c9dfb8201a98..a225f6cf4730 100644 --- a/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs +++ b/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs @@ -10,18 +10,18 @@ #![feature(optin_builtin_traits)] -trait MyTrait {} +trait MyTrait : ::std::marker::MarkerTrait {} -struct TestType; +struct TestType(::std::marker::PhantomData); -unsafe impl Send for TestType {} +unsafe impl Send for TestType {} //~^ ERROR conflicting implementations for trait `core::marker::Send` //~^^ ERROR conflicting implementations for trait `core::marker::Send` impl !Send for TestType {} //~^ ERROR conflicting implementations for trait `core::marker::Send` -unsafe impl Send for TestType {} +unsafe impl Send for TestType {} //~^ ERROR error: conflicting implementations for trait `core::marker::Send` impl !Send for TestType {} diff --git a/src/test/compile-fail/cross-borrow-trait.rs b/src/test/compile-fail/cross-borrow-trait.rs index 86b7a8c89184..c97a9950d78d 100644 --- a/src/test/compile-fail/cross-borrow-trait.rs +++ b/src/test/compile-fail/cross-borrow-trait.rs @@ -14,7 +14,7 @@ #![feature(box_syntax)] struct Foo; -trait Trait {} +trait Trait : ::std::marker::MarkerTrait {} impl Trait for Foo {} pub fn main() { diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs index f2e068cc4ff1..d8b3f297a112 100644 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ b/src/test/compile-fail/destructure-trait-ref.rs @@ -14,7 +14,7 @@ #![feature(box_patterns)] #![feature(box_syntax)] -trait T {} +trait T : ::std::marker::MarkerTrait {} impl T for isize {} fn main() { diff --git a/src/test/compile-fail/dst-bad-coerce1.rs b/src/test/compile-fail/dst-bad-coerce1.rs index 2b96c5ebe128..6d9ba8d44c08 100644 --- a/src/test/compile-fail/dst-bad-coerce1.rs +++ b/src/test/compile-fail/dst-bad-coerce1.rs @@ -15,7 +15,7 @@ struct Fat { } struct Foo; -trait Bar {} +trait Bar : ::std::marker::MarkerTrait {} pub fn main() { // With a vec of isize. diff --git a/src/test/compile-fail/dst-bad-coerce2.rs b/src/test/compile-fail/dst-bad-coerce2.rs index 160197368d6d..aa687266acb8 100644 --- a/src/test/compile-fail/dst-bad-coerce2.rs +++ b/src/test/compile-fail/dst-bad-coerce2.rs @@ -15,7 +15,7 @@ struct Fat { } struct Foo; -trait Bar {} +trait Bar : ::std::marker::MarkerTrait {} impl Bar for Foo {} pub fn main() { diff --git a/src/test/compile-fail/dst-bad-coerce3.rs b/src/test/compile-fail/dst-bad-coerce3.rs index 347a2d2ecbe6..46b89e1122a2 100644 --- a/src/test/compile-fail/dst-bad-coerce3.rs +++ b/src/test/compile-fail/dst-bad-coerce3.rs @@ -15,7 +15,7 @@ struct Fat { } struct Foo; -trait Bar {} +trait Bar : ::std::marker::MarkerTrait {} impl Bar for Foo {} fn baz<'a>() { diff --git a/src/test/compile-fail/dst-bad-coercions.rs b/src/test/compile-fail/dst-bad-coercions.rs index b30eada162b8..8ec1034bc4d2 100644 --- a/src/test/compile-fail/dst-bad-coercions.rs +++ b/src/test/compile-fail/dst-bad-coercions.rs @@ -10,8 +10,10 @@ // Test implicit coercions involving DSTs and raw pointers. +use std::marker::MarkerTrait; + struct S; -trait T {} +trait T : MarkerTrait {} impl T for S {} struct Foo { diff --git a/src/test/compile-fail/dst-object-from-unsized-type.rs b/src/test/compile-fail/dst-object-from-unsized-type.rs index 87ff4291f50e..a1f0dda671e7 100644 --- a/src/test/compile-fail/dst-object-from-unsized-type.rs +++ b/src/test/compile-fail/dst-object-from-unsized-type.rs @@ -10,7 +10,7 @@ // Test that we cannot create objects from unsized types. -trait Foo {} +trait Foo : ::std::marker::MarkerTrait {} impl Foo for str {} fn test1(t: &T) { diff --git a/src/test/compile-fail/exclusive-drop-and-copy.rs b/src/test/compile-fail/exclusive-drop-and-copy.rs index 17453bc677f2..f47f14d58799 100644 --- a/src/test/compile-fail/exclusive-drop-and-copy.rs +++ b/src/test/compile-fail/exclusive-drop-and-copy.rs @@ -20,7 +20,7 @@ impl Drop for Foo { } #[derive(Copy)] //~ ERROR the trait `Copy` may not be implemented -struct Bar; +struct Bar(::std::marker::PhantomData); #[unsafe_destructor] impl Drop for Bar { diff --git a/src/test/compile-fail/generic-impl-less-params-with-defaults.rs b/src/test/compile-fail/generic-impl-less-params-with-defaults.rs index 02f09749d614..9fea5e609d1f 100644 --- a/src/test/compile-fail/generic-impl-less-params-with-defaults.rs +++ b/src/test/compile-fail/generic-impl-less-params-with-defaults.rs @@ -8,10 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo; +use std::marker; + +struct Foo( + marker::PhantomData<(A,B,C)>); impl Foo { - fn new() -> Foo {Foo} + fn new() -> Foo {Foo(marker::PhantomData)} } fn main() { diff --git a/src/test/compile-fail/generic-impl-more-params-with-defaults.rs b/src/test/compile-fail/generic-impl-more-params-with-defaults.rs index d88da2625c18..73c19aa012dc 100644 --- a/src/test/compile-fail/generic-impl-more-params-with-defaults.rs +++ b/src/test/compile-fail/generic-impl-more-params-with-defaults.rs @@ -8,12 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct Heap; -struct Vec; +struct Vec( + marker::PhantomData<(T,A)>); impl Vec { - fn new() -> Vec {Vec} + fn new() -> Vec {Vec(marker::PhantomData)} } fn main() { diff --git a/src/test/compile-fail/generic-lifetime-trait-impl.rs b/src/test/compile-fail/generic-lifetime-trait-impl.rs index fc54002820e0..9b9f09f47775 100644 --- a/src/test/compile-fail/generic-lifetime-trait-impl.rs +++ b/src/test/compile-fail/generic-lifetime-trait-impl.rs @@ -16,9 +16,12 @@ // // Regression test for issue #16218. -trait Bar<'a> {} +trait Bar<'a> { + fn dummy(&'a self); +} trait Foo<'a> { + fn dummy(&'a self) { } fn bar<'b, T: Bar<'b>>(self) -> &'b str; } diff --git a/src/test/compile-fail/generic-type-less-params-with-defaults.rs b/src/test/compile-fail/generic-type-less-params-with-defaults.rs index f25d8f99b8d5..37737fda4749 100644 --- a/src/test/compile-fail/generic-type-less-params-with-defaults.rs +++ b/src/test/compile-fail/generic-type-less-params-with-defaults.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct Heap; -struct Vec; +struct Vec( + marker::PhantomData<(T,A)>); fn main() { let _: Vec; //~ ERROR wrong number of type arguments: expected at least 1, found 0 diff --git a/src/test/compile-fail/generic-type-more-params-with-defaults.rs b/src/test/compile-fail/generic-type-more-params-with-defaults.rs index 19d303488acb..ad7e4f190c5b 100644 --- a/src/test/compile-fail/generic-type-more-params-with-defaults.rs +++ b/src/test/compile-fail/generic-type-more-params-with-defaults.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct Heap; -struct Vec; +struct Vec( + marker::PhantomData<(T,A)>); fn main() { let _: Vec; diff --git a/src/test/compile-fail/generic-type-params-name-repr.rs b/src/test/compile-fail/generic-type-params-name-repr.rs index 3e34344d78b9..a452cd35f943 100644 --- a/src/test/compile-fail/generic-type-params-name-repr.rs +++ b/src/test/compile-fail/generic-type-params-name-repr.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct A; struct B; struct C; -struct Foo; +struct Foo(marker::PhantomData<(T,U,V)>); -struct Hash; -struct HashMap>; +struct Hash(marker::PhantomData); +struct HashMap>(marker::PhantomData<(K,V,H)>); fn main() { // Ensure that the printed type doesn't include the default type params... diff --git a/src/test/compile-fail/issue-11515.rs b/src/test/compile-fail/issue-11515.rs index f0089b0ae5b3..4ff574e939df 100644 --- a/src/test/compile-fail/issue-11515.rs +++ b/src/test/compile-fail/issue-11515.rs @@ -10,7 +10,7 @@ #![feature(box_syntax)] -struct Test<'s> { +struct Test { func: Box } diff --git a/src/test/compile-fail/issue-13853-2.rs b/src/test/compile-fail/issue-13853-2.rs index ea0d880f4a1c..dc697e4784f8 100644 --- a/src/test/compile-fail/issue-13853-2.rs +++ b/src/test/compile-fail/issue-13853-2.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait FromStructReader<'a> { } +use std::marker::PhantomFn; + +trait FromStructReader<'a> : PhantomFn<(Self,&'a ())> { } trait ResponseHook { fn get<'a, T: FromStructReader<'a>>(&'a self); } diff --git a/src/test/compile-fail/issue-13853-3.rs b/src/test/compile-fail/issue-13853-3.rs index f10c47b594ea..7ca158c3e320 100644 --- a/src/test/compile-fail/issue-13853-3.rs +++ b/src/test/compile-fail/issue-13853-3.rs @@ -10,6 +10,8 @@ #![crate_type = "lib"] +use std::marker::PhantomData; + enum NodeContents<'a> { Children(Vec>), } @@ -22,11 +24,12 @@ impl<'a> Drop for NodeContents<'a> { struct Node<'a> { contents: NodeContents<'a>, + marker: PhantomData<&'a ()>, } impl<'a> Node<'a> { fn noName(contents: NodeContents<'a>) -> Node<'a> { - Node{ contents: contents,} + Node { contents: contents, marker: PhantomData } } } diff --git a/src/test/compile-fail/issue-13853.rs b/src/test/compile-fail/issue-13853.rs index 251da2c6b3ee..cd3f337c4ab6 100644 --- a/src/test/compile-fail/issue-13853.rs +++ b/src/test/compile-fail/issue-13853.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Node { +use std::marker::MarkerTrait; + +trait Node : MarkerTrait { fn zomg(); } diff --git a/src/test/compile-fail/issue-14285.rs b/src/test/compile-fail/issue-14285.rs index cbf4412a81df..3a5df9e805bd 100644 --- a/src/test/compile-fail/issue-14285.rs +++ b/src/test/compile-fail/issue-14285.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo { + fn dummy(&self) { } +} struct A; diff --git a/src/test/compile-fail/issue-14853.rs b/src/test/compile-fail/issue-14853.rs index 51deb99a4f2c..0b846651acf4 100644 --- a/src/test/compile-fail/issue-14853.rs +++ b/src/test/compile-fail/issue-14853.rs @@ -9,8 +9,9 @@ // except according to those terms. use std::fmt::Debug; +use std::marker::MarkerTrait; -trait Str {} +trait Str : MarkerTrait {} trait Something { fn yay(_: Option, thing: &[T]); diff --git a/src/test/compile-fail/issue-16747.rs b/src/test/compile-fail/issue-16747.rs index 814b885e3aaf..a213234b89b0 100644 --- a/src/test/compile-fail/issue-16747.rs +++ b/src/test/compile-fail/issue-16747.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait ListItem<'a> { +use std::marker::MarkerTrait; + +trait ListItem<'a> : MarkerTrait { fn list_name() -> &'a str; } diff --git a/src/test/compile-fail/issue-17431-4.rs b/src/test/compile-fail/issue-17431-4.rs index 1e27f0255647..22aaa796ad0f 100644 --- a/src/test/compile-fail/issue-17431-4.rs +++ b/src/test/compile-fail/issue-17431-4.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo { foo: Option>> } +use std::marker; + +struct Foo { foo: Option>>, marker: marker::PhantomData } //~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable impl Foo { fn bar(&self) {} } diff --git a/src/test/compile-fail/issue-17431-5.rs b/src/test/compile-fail/issue-17431-5.rs index d22d79ecaa55..cc9cc2e3c035 100644 --- a/src/test/compile-fail/issue-17431-5.rs +++ b/src/test/compile-fail/issue-17431-5.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + struct Foo { foo: Bar } -struct Bar { x: Bar } +struct Bar { x: Bar , marker: marker::PhantomData } //~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable impl Foo { fn foo(&self) {} } diff --git a/src/test/compile-fail/issue-17551.rs b/src/test/compile-fail/issue-17551.rs index e037ba92b4a6..5781cb741174 100644 --- a/src/test/compile-fail/issue-17551.rs +++ b/src/test/compile-fail/issue-17551.rs @@ -10,9 +10,11 @@ #![feature(unboxed_closures)] -struct B; +use std::marker; + +struct B(marker::PhantomData); fn main() { - let foo = B; //~ ERROR: unable to infer enough type information + let foo = B(marker::PhantomData); //~ ERROR unable to infer enough type information let closure = || foo; } diff --git a/src/test/compile-fail/issue-18107.rs b/src/test/compile-fail/issue-18107.rs index 83427e8aa67f..bdb5af0b8248 100644 --- a/src/test/compile-fail/issue-18107.rs +++ b/src/test/compile-fail/issue-18107.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker::MarkerTrait; - -pub trait AbstractRenderer {} +pub trait AbstractRenderer : MarkerTrait {} fn _create_render(_: &()) -> AbstractRenderer diff --git a/src/test/compile-fail/issue-18611.rs b/src/test/compile-fail/issue-18611.rs index a662e9ca98ee..e81a576fa63d 100644 --- a/src/test/compile-fail/issue-18611.rs +++ b/src/test/compile-fail/issue-18611.rs @@ -8,11 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker::MarkerTrait; + fn add_state(op: ::State) { //~^ ERROR the trait `HasState` is not implemented for the type `isize` } -trait HasState { +trait HasState : MarkerTrait { type State; } diff --git a/src/test/compile-fail/issue-18783.rs b/src/test/compile-fail/issue-18783.rs index d26bf68cb5df..1bbbdf79d28b 100644 --- a/src/test/compile-fail/issue-18783.rs +++ b/src/test/compile-fail/issue-18783.rs @@ -26,6 +26,7 @@ fn ufcs() { Push::push(&c, box || y = 0); Push::push(&c, box || y = 0); +//~^ ERROR cannot borrow `y` as mutable more than once at a time } trait Push<'c> { diff --git a/src/test/compile-fail/issue-18819.rs b/src/test/compile-fail/issue-18819.rs index 3a9de7410436..951d78410b81 100644 --- a/src/test/compile-fail/issue-18819.rs +++ b/src/test/compile-fail/issue-18819.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait { type Item; } diff --git a/src/test/compile-fail/issue-19660.rs b/src/test/compile-fail/issue-19660.rs index 14601e67a77c..77aba7335bdf 100644 --- a/src/test/compile-fail/issue-19660.rs +++ b/src/test/compile-fail/issue-19660.rs @@ -13,8 +13,12 @@ #![feature(lang_items, start, no_std)] #![no_std] +#[lang="phantom_fn"] +trait PhantomFn { } +impl PhantomFn for U { } + #[lang = "sized"] -trait Sized {} +trait Sized : PhantomFn {} #[start] fn main(_: int, _: *const *const u8) -> int { diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs index 00607f850347..aed395d17ea9 100644 --- a/src/test/compile-fail/issue-2063.rs +++ b/src/test/compile-fail/issue-2063.rs @@ -12,10 +12,11 @@ // cause compiler to loop. Note that no instances // of such a type could ever be constructed. +use std::marker::MarkerTrait; struct t(Box); //~ ERROR this type cannot be instantiated -trait to_str_2 { +trait to_str_2 : MarkerTrait { fn my_to_string() -> String; } diff --git a/src/test/compile-fail/issue-20831-debruijn.rs b/src/test/compile-fail/issue-20831-debruijn.rs index aaf45f273989..5b623ac377b2 100644 --- a/src/test/compile-fail/issue-20831-debruijn.rs +++ b/src/test/compile-fail/issue-20831-debruijn.rs @@ -13,10 +13,11 @@ // below. Note that changing to a named lifetime made the problem go // away. -use std::ops::{Shl, Shr}; use std::cell::RefCell; +use std::marker::MarkerTrait; +use std::ops::{Shl, Shr}; -pub trait Subscriber { +pub trait Subscriber : MarkerTrait { type Input; } diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 31796e5e20c4..24cc0099b89a 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -12,7 +12,7 @@ // than the trait method it's implementing trait A { - fn b(x: C) -> C; + fn b(&self, x: C) -> C; } struct E { @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { panic!() } + fn b(&self, _x: F) -> F { panic!() } //~^ ERROR `F : core::marker::Sync` appears on the impl method } diff --git a/src/test/compile-fail/issue-3008-3.rs b/src/test/compile-fail/issue-3008-3.rs index a338a01690de..af6cee1f1074 100644 --- a/src/test/compile-fail/issue-3008-3.rs +++ b/src/test/compile-fail/issue-3008-3.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + enum E1 { V1(E2), } -enum E2 { V2(E2), } +enum E2 { V2(E2, marker::PhantomData), } //~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable impl E1 { fn foo(&self) {} } diff --git a/src/test/compile-fail/issue-4972.rs b/src/test/compile-fail/issue-4972.rs index 9a398796d2ab..f384dba7c9e3 100644 --- a/src/test/compile-fail/issue-4972.rs +++ b/src/test/compile-fail/issue-4972.rs @@ -11,7 +11,9 @@ #![feature(box_patterns)] #![feature(box_syntax)] -trait MyTrait { } +trait MyTrait { + fn dummy(&self) {} +} pub enum TraitWrapper { A(Box), diff --git a/src/test/compile-fail/issue-5035-2.rs b/src/test/compile-fail/issue-5035-2.rs index 9e324cdd61eb..d316b44794ad 100644 --- a/src/test/compile-fail/issue-5035-2.rs +++ b/src/test/compile-fail/issue-5035-2.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait I {} +use std::marker::MarkerTrait; + +trait I : MarkerTrait {} type K = I+'static; fn foo(_x: K) {} //~ ERROR: the trait `core::marker::Sized` is not implemented diff --git a/src/test/compile-fail/issue-5543.rs b/src/test/compile-fail/issue-5543.rs index cf98f1572e56..eccbc7896605 100644 --- a/src/test/compile-fail/issue-5543.rs +++ b/src/test/compile-fail/issue-5543.rs @@ -10,7 +10,9 @@ #![feature(box_syntax)] -trait Foo {} +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait {} impl Foo for u8 {} fn main() { diff --git a/src/test/compile-fail/issue-5883.rs b/src/test/compile-fail/issue-5883.rs index 9ff957b6e6de..b0db99061953 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait A {} +use std::marker::MarkerTrait; + +trait A : MarkerTrait {} struct Struct { r: A+'static @@ -20,6 +22,6 @@ fn new_struct(r: A+'static) Struct { r: r } } -trait Curve {} +trait Curve : MarkerTrait {} enum E {X(Curve+'static)} fn main() {} diff --git a/src/test/compile-fail/issue-6458.rs b/src/test/compile-fail/issue-6458.rs index efa3100360b5..0bf9a3c2d486 100644 --- a/src/test/compile-fail/issue-6458.rs +++ b/src/test/compile-fail/issue-6458.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub struct TypeWithState; +use std::marker; + +pub struct TypeWithState(marker::PhantomData); pub struct MyState; pub fn foo(_: TypeWithState) {} pub fn bar() { - foo(TypeWithState); //~ ERROR type annotations required + foo(TypeWithState(marker::PhantomData)); //~ ERROR type annotations required } fn main() { diff --git a/src/test/compile-fail/issue-7575.rs b/src/test/compile-fail/issue-7575.rs index 49e54f25bf64..7d65870e2dbc 100644 --- a/src/test/compile-fail/issue-7575.rs +++ b/src/test/compile-fail/issue-7575.rs @@ -10,12 +10,14 @@ // Test the mechanism for warning about possible missing `self` declarations. +use std::marker::MarkerTrait; + trait CtxtFn { fn f8(self, usize) -> usize; fn f9(usize) -> usize; //~ NOTE candidate } -trait OtherTrait { +trait OtherTrait : MarkerTrait { fn f9(usize) -> usize; //~ NOTE candidate } @@ -24,7 +26,7 @@ trait OtherTrait { // declaration to match against, so we wind up prisizeing it as a // candidate. This seems not unreasonable -- perhaps the user meant to // implement it, after all. -trait UnusedTrait { +trait UnusedTrait : MarkerTrait { fn f9(usize) -> usize; //~ NOTE candidate } @@ -52,7 +54,7 @@ impl Myisize { } } -trait ManyImplTrait { +trait ManyImplTrait : MarkerTrait { fn is_str() -> bool { //~ NOTE candidate false } diff --git a/src/test/compile-fail/issue-8727.rs b/src/test/compile-fail/issue-8727.rs index d1a86d334cb4..72da6dcaa6c4 100644 --- a/src/test/compile-fail/issue-8727.rs +++ b/src/test/compile-fail/issue-8727.rs @@ -13,16 +13,12 @@ // Verify the compiler fails with an error on infinite function // recursions. -struct Data(Box>); - -fn generic( _ : Vec<(Data,T)> ) { - let rec : Vec<(Data,(bool,T))> = Vec::new(); - generic( rec ); +fn generic() { + generic::>(); } fn main () { // Use generic at least once to trigger instantiation. - let input : Vec<(Data,())> = Vec::new(); - generic(input); + generic::(); } diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index 56f83d930086..74e372e41eb0 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -10,12 +10,12 @@ // Test which of the builtin types are considered POD. - +use std::marker::MarkerTrait; use std::rc::Rc; fn assert_copy() { } -trait Dummy { } +trait Dummy : MarkerTrait { } #[derive(Copy)] struct MyStruct { diff --git a/src/test/compile-fail/kindck-impl-type-params-2.rs b/src/test/compile-fail/kindck-impl-type-params-2.rs index 2731be7308a4..b575144f637f 100644 --- a/src/test/compile-fail/kindck-impl-type-params-2.rs +++ b/src/test/compile-fail/kindck-impl-type-params-2.rs @@ -10,7 +10,9 @@ #![feature(box_syntax)] -trait Foo { +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait { } impl Foo for T { diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs index d5276efa8be9..dffc8fa2abd7 100644 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ b/src/test/compile-fail/kindck-impl-type-params.rs @@ -13,40 +13,44 @@ #![feature(box_syntax)] -struct S; +use std::marker; -trait Gettable {} +struct S(marker::PhantomData); + +trait Gettable { + fn get(&self) -> T { panic!() } +} impl Gettable for S {} fn f(val: T) { - let t: S = S; + let t: S = S(marker::PhantomData); let a = &t as &Gettable; //~^ ERROR the trait `core::marker::Send` is not implemented //~^^ ERROR the trait `core::marker::Copy` is not implemented } fn g(val: T) { - let t: S = S; + let t: S = S(marker::PhantomData); let a: &Gettable = &t; //~^ ERROR the trait `core::marker::Send` is not implemented //~^^ ERROR the trait `core::marker::Copy` is not implemented } fn foo<'a>() { - let t: S<&'a isize> = S; + let t: S<&'a isize> = S(marker::PhantomData); let a = &t as &Gettable<&'a isize>; - //~^ ERROR the type `&'a isize` does not fulfill the required lifetime + //~^ ERROR cannot infer } fn foo2<'a>() { - let t: Box> = box S; + let t: Box> = box S(marker::PhantomData); let a = t as Box>; //~^ ERROR the trait `core::marker::Copy` is not implemented } fn foo3<'a>() { - let t: Box> = box S; + let t: Box> = box S(marker::PhantomData); let a: Box> = t; //~^ ERROR the trait `core::marker::Copy` is not implemented } diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs index 570f7ad7fe3b..0c68401bb2b9 100644 --- a/src/test/compile-fail/kindck-send-object.rs +++ b/src/test/compile-fail/kindck-send-object.rs @@ -12,8 +12,10 @@ // in this file all test the "kind" violates detected during kindck. // See all `regions-bounded-by-send.rs` +use std::marker::MarkerTrait; + fn assert_send() { } -trait Dummy { } +trait Dummy : MarkerTrait { } trait Message : Send { } // careful with object types, who knows what they close over... diff --git a/src/test/compile-fail/kindck-send-object1.rs b/src/test/compile-fail/kindck-send-object1.rs index 48d5215b7085..f86eac8b16bd 100644 --- a/src/test/compile-fail/kindck-send-object1.rs +++ b/src/test/compile-fail/kindck-send-object1.rs @@ -12,8 +12,10 @@ // is broken into two parts because some errors occur in distinct // phases in the compiler. See kindck-send-object2.rs as well! +use std::marker::MarkerTrait; + fn assert_send() { } -trait Dummy { } +trait Dummy : MarkerTrait { } // careful with object types, who knows what they close over... fn test51<'a>() { diff --git a/src/test/compile-fail/kindck-send-object2.rs b/src/test/compile-fail/kindck-send-object2.rs index d3d166e2a691..08516e67318c 100644 --- a/src/test/compile-fail/kindck-send-object2.rs +++ b/src/test/compile-fail/kindck-send-object2.rs @@ -10,8 +10,10 @@ // Continue kindck-send-object1.rs. +use std::marker::MarkerTrait; + fn assert_send() { } -trait Dummy { } +trait Dummy : MarkerTrait { } fn test50() { assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Sync` is not implemented diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs index 04c5b223cb87..66d8927ee51b 100644 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs @@ -10,7 +10,9 @@ // ignore-tidy-linelength -struct Bar<'x, 'y, 'z> { bar: &'y i32, baz: i32 } +use std::marker::PhantomData; + +struct Bar<'x, 'y, 'z> { bar: &'y i32, baz: i32, marker: PhantomData<(&'x(),&'y(),&'z())> } fn bar1<'a>(x: &Bar) -> (&'a i32, &'a i32, &'a i32) { //~^ HELP: consider using an explicit lifetime parameter as shown: fn bar1<'b, 'c, 'a>(x: &'a Bar<'b, 'a, 'c>) -> (&'a i32, &'a i32, &'a i32) (x.bar, &x.baz, &x.baz) diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs index c60e321219bd..a85776a938b4 100644 --- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs +++ b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs @@ -10,7 +10,9 @@ // ignore-tidy-linelength -struct Foo<'x> { bar: isize } +use std::marker::PhantomData; + +struct Foo<'x> { bar: isize, marker: PhantomData<&'x ()> } fn foo1<'a>(x: &Foo) -> &'a isize { //~^ HELP: consider using an explicit lifetime parameter as shown: fn foo1<'a>(x: &'a Foo) -> &'a isize &x.bar //~ ERROR: cannot infer diff --git a/src/test/compile-fail/lint-missing-doc.rs b/src/test/compile-fail/lint-missing-doc.rs index 3b96fd64fa20..73a58741bbbb 100644 --- a/src/test/compile-fail/lint-missing-doc.rs +++ b/src/test/compile-fail/lint-missing-doc.rs @@ -47,20 +47,26 @@ fn foo3() {} /// dox pub trait A { /// dox - fn foo(); + fn foo(&self); /// dox - fn foo_with_impl() {} + fn foo_with_impl(&self) {} } + #[allow(missing_docs)] trait B { - fn foo(); - fn foo_with_impl() {} + fn foo(&self); + fn foo_with_impl(&self) {} } + pub trait C { //~ ERROR: missing documentation - fn foo(); //~ ERROR: missing documentation - fn foo_with_impl() {} //~ ERROR: missing documentation + fn foo(&self); //~ ERROR: missing documentation + fn foo_with_impl(&self) {} //~ ERROR: missing documentation +} + +#[allow(missing_docs)] +pub trait D { + fn dummy(&self) { } } -#[allow(missing_docs)] pub trait D {} impl Foo { pub fn foo() {} diff --git a/src/test/compile-fail/lint-non-camel-case-types.rs b/src/test/compile-fail/lint-non-camel-case-types.rs index 70d6b240985b..9f58d5791cb0 100644 --- a/src/test/compile-fail/lint-non-camel-case-types.rs +++ b/src/test/compile-fail/lint-non-camel-case-types.rs @@ -30,6 +30,7 @@ enum Foo5 { } trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6` + fn dummy(&self) { } } fn f(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty` diff --git a/src/test/compile-fail/lint-stability.rs b/src/test/compile-fail/lint-stability.rs index f9cdfa4f7d68..88f2cbdea6d7 100644 --- a/src/test/compile-fail/lint-stability.rs +++ b/src/test/compile-fail/lint-stability.rs @@ -341,7 +341,9 @@ mod this_crate { #[unstable(feature = "test_feature")] #[deprecated(since = "1.0.0")] - pub trait DeprecatedTrait {} + pub trait DeprecatedTrait { + fn dummy(&self) { } + } struct S; diff --git a/src/test/compile-fail/lint-visible-private-types.rs b/src/test/compile-fail/lint-visible-private-types.rs index 8cf375f80fbb..918b4ee209ca 100644 --- a/src/test/compile-fail/lint-visible-private-types.rs +++ b/src/test/compile-fail/lint-visible-private-types.rs @@ -12,8 +12,10 @@ #![allow(dead_code)] #![crate_type="lib"] -struct Private; -pub struct Public; +use std::marker; + +struct Private(marker::PhantomData); +pub struct Public(marker::PhantomData); impl Private> { pub fn a(&self) -> Private { panic!() } @@ -103,7 +105,7 @@ impl PrivTrait for (Private,) { fn bar(&self) -> Private { panic!() } } -pub trait ParamTrait { +pub trait ParamTrait : marker::MarkerTrait { fn foo() -> T; } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index a49339ecd7f2..03d8d62e0b4d 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker; + fn send(ch: _chan, data: T) { println!("{:?}", ch); println!("{:?}", data); @@ -15,7 +17,7 @@ fn send(ch: _chan, data: T) { } #[derive(Debug)] -struct _chan(isize); +struct _chan(isize, marker::PhantomData); // Tests that "log(debug, message);" is flagged as using // message after the send deinitializes it diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index ba2205f5868d..6e8719eeaced 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -14,7 +14,10 @@ extern crate collections; use std::collections::HashMap; -trait Map {} +trait Map +{ + fn get(&self, k: K) -> V { panic!() } +} impl Map for HashMap {} diff --git a/src/test/compile-fail/method-ambig-one-trait-coerce.rs b/src/test/compile-fail/method-ambig-one-trait-coerce.rs deleted file mode 100644 index cb5da4bb5477..000000000000 --- a/src/test/compile-fail/method-ambig-one-trait-coerce.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 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. - -// Test that when we pick a trait based on coercion, versus subtyping, -// we consider all possible coercions equivalent and don't try to pick -// a best one. - -trait Object { } - -trait foo { - fn foo(self) -> isize; -} - -impl foo for Box { - fn foo(self) -> isize {1} -} - -impl foo for Box { - fn foo(self) -> isize {2} -} - -fn test1(x: Box) { - // FIXME(#18737) -- we ought to consider this to be ambiguous, - // since we could coerce to either impl. However, what actually - // happens is that we consider both impls applicable because of - // incorrect subtyping relation. We then decide to call this a - // call to the `foo` trait, leading to the following error - // message. - - x.foo(); //~ ERROR `foo` is not implemented -} - -fn test2(x: Box) { - // Not ambiguous because it is a precise match: - x.foo(); -} - -fn test3(x: Box) { - // Not ambiguous because it is a precise match: - x.foo(); -} - -fn main() { } diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs index cfaf149a49ca..607ab13d1220 100644 --- a/src/test/compile-fail/object-does-not-impl-trait.rs +++ b/src/test/compile-fail/object-does-not-impl-trait.rs @@ -11,8 +11,9 @@ // Test that an object type `Box` is not considered to implement the // trait `Foo`. Issue #5087. +use std::marker::MarkerTrait; -trait Foo {} +trait Foo : MarkerTrait {} fn take_foo(f: F) {} fn take_object(f: Box) { take_foo(f); } //~^ ERROR the trait `Foo` is not implemented diff --git a/src/test/compile-fail/object-lifetime-default-mybox.rs b/src/test/compile-fail/object-lifetime-default-mybox.rs index c107c8d131d3..23ddea4499a7 100644 --- a/src/test/compile-fail/object-lifetime-default-mybox.rs +++ b/src/test/compile-fail/object-lifetime-default-mybox.rs @@ -37,7 +37,6 @@ fn load1<'a,'b>(a: &'a MyBox, a //~^ ERROR cannot infer //~| ERROR mismatched types - //~| ERROR mismatched types } fn main() { diff --git a/src/test/compile-fail/object-safety-no-static.rs b/src/test/compile-fail/object-safety-no-static.rs index 6a010d49692d..aae829ec7b56 100644 --- a/src/test/compile-fail/object-safety-no-static.rs +++ b/src/test/compile-fail/object-safety-no-static.rs @@ -11,7 +11,7 @@ // Check that we correctly prevent users from making trait objects // from traits with static methods. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { fn foo(); } diff --git a/src/test/compile-fail/on-unimplemented-bad-anno.rs b/src/test/compile-fail/on-unimplemented-bad-anno.rs index dda534cc489b..7538b1c85e53 100644 --- a/src/test/compile-fail/on-unimplemented-bad-anno.rs +++ b/src/test/compile-fail/on-unimplemented-bad-anno.rs @@ -13,8 +13,12 @@ #![allow(unused)] +use std::marker; + #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"] -trait Foo{} +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}`"] trait MyFromIterator { @@ -23,15 +27,21 @@ trait MyFromIterator { } #[rustc_on_unimplemented] //~ ERROR this attribute must have a value -trait BadAnnotation1 {} +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 {} +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 {} +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 7b406afcf1f5..2447d0864226 100644 --- a/src/test/compile-fail/on-unimplemented.rs +++ b/src/test/compile-fail/on-unimplemented.rs @@ -11,8 +11,12 @@ #![feature(on_unimplemented)] +use std::marker; + #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"] -trait Foo{} +trait Foo + : marker::PhantomFn<(Self,Bar,Baz,Quux)> +{} fn foobar>() -> T { diff --git a/src/test/compile-fail/orphan-check-diagnostics.rs b/src/test/compile-fail/orphan-check-diagnostics.rs index ff5c101b9178..8201565c3318 100644 --- a/src/test/compile-fail/orphan-check-diagnostics.rs +++ b/src/test/compile-fail/orphan-check-diagnostics.rs @@ -15,7 +15,7 @@ extern crate orphan_check_diagnostics; use orphan_check_diagnostics::RemoteTrait; -trait LocalTrait {} +trait LocalTrait { fn dummy(&self) { } } impl RemoteTrait for T where T: LocalTrait {} //~^ ERROR type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/compile-fail/priv-in-bad-locations.rs b/src/test/compile-fail/priv-in-bad-locations.rs index db649ed0cc60..43d112b8aa00 100644 --- a/src/test/compile-fail/priv-in-bad-locations.rs +++ b/src/test/compile-fail/priv-in-bad-locations.rs @@ -14,7 +14,7 @@ pub extern { } trait A { - fn foo() {} + fn foo(&self) {} } struct B; @@ -22,7 +22,7 @@ struct B; pub impl B {} //~ ERROR: unnecessary visibility pub impl A for B { //~ ERROR: unnecessary visibility - pub fn foo() {} //~ ERROR: unnecessary visibility + pub fn foo(&self) {} //~ ERROR: unnecessary visibility } pub fn main() {} diff --git a/src/test/compile-fail/privacy-ns2.rs b/src/test/compile-fail/privacy-ns2.rs index 7fe0574ab7d9..67bb566ea682 100644 --- a/src/test/compile-fail/privacy-ns2.rs +++ b/src/test/compile-fail/privacy-ns2.rs @@ -17,7 +17,9 @@ // public type, private value pub mod foo1 { - pub trait Bar { + use std::marker::MarkerTrait; + + pub trait Bar : MarkerTrait { } pub struct Baz; @@ -39,7 +41,7 @@ fn test_list1() { // private type, public value pub mod foo2 { - trait Bar { + trait Bar : ::std::marker::MarkerTrait { } pub struct Baz; @@ -60,7 +62,7 @@ fn test_list2() { // neither public pub mod foo3 { - trait Bar { + trait Bar : ::std::marker::MarkerTrait { } pub struct Baz; diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs index 7ebbcc2809a5..1ae79adbad76 100644 --- a/src/test/compile-fail/privacy1.rs +++ b/src/test/compile-fail/privacy1.rs @@ -11,11 +11,15 @@ #![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 {} +pub trait Sized : PhantomFn {} #[lang="copy"] -pub trait Copy {} +pub trait Copy : PhantomFn {} 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 bcb46663aa84..adce93af0794 100644 --- a/src/test/compile-fail/privacy4.rs +++ b/src/test/compile-fail/privacy4.rs @@ -11,8 +11,12 @@ #![feature(lang_items, start, no_std)] #![no_std] // makes debugging this test *a lot* easier (during resolve) -#[lang = "sized"] pub trait Sized {} -#[lang="copy"] pub trait Copy {} +#[lang="phantom_fn"] +pub trait PhantomFn { } +impl PhantomFn for U { } + +#[lang = "sized"] pub trait Sized : PhantomFn {} +#[lang="copy"] pub trait Copy : PhantomFn {} // Test to make sure that private items imported through globs remain private // when they're used. diff --git a/src/test/compile-fail/region-object-lifetime-in-coercion.rs b/src/test/compile-fail/region-object-lifetime-in-coercion.rs index 20cc624ab190..2da414befd89 100644 --- a/src/test/compile-fail/region-object-lifetime-in-coercion.rs +++ b/src/test/compile-fail/region-object-lifetime-in-coercion.rs @@ -13,7 +13,7 @@ #![feature(box_syntax)] -trait Foo {} +trait Foo : ::std::marker::MarkerTrait {} impl<'a> Foo for &'a [u8] {} fn a(v: &[u8]) -> Box { diff --git a/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs b/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs index f833361e3b50..f921eccef1f8 100644 --- a/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs +++ b/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs @@ -11,7 +11,10 @@ // Test that the compiler checks that arbitrary region bounds declared // in the trait must be satisfied on the impl. Issue #20890. -trait Foo<'a> { type Value: 'a; } +trait Foo<'a> { + type Value: 'a; + fn dummy(&'a self) { } +} impl<'a> Foo<'a> for &'a i16 { // OK. diff --git a/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs b/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs index 0871d8b01f6e..1cf83b8ac585 100644 --- a/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs +++ b/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs @@ -11,7 +11,10 @@ // Test that the compiler checks that the 'static bound declared in // the trait must be satisfied on the impl. Issue #20890. -trait Foo { type Value: 'static; } +trait Foo { + type Value: 'static; + fn dummy(&self) { } +} impl<'a> Foo for &'a i32 { //~^ ERROR cannot infer diff --git a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs index a3c38dff6b0f..278ccd3c1193 100644 --- a/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs +++ b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs @@ -21,10 +21,9 @@ pub trait Foo<'a, 't> { fn has_bound<'b:'a>(self, b: Inv<'b>); fn wrong_bound1<'b,'c,'d:'a+'b>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); fn okay_bound<'b,'c,'d:'a+'b+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>); - fn another_bound<'x: 'a>(self, x: Inv<'x>); + fn another_bound<'x: 'a>(self, x: Inv<'x>, y: Inv<'t>); } - impl<'a, 't> Foo<'a, 't> for &'a isize { fn no_bound<'b:'a>(self, b: Inv<'b>) { //~^ ERROR lifetime parameters or bounds on method `no_bound` do not match @@ -51,7 +50,7 @@ impl<'a, 't> Foo<'a, 't> for &'a isize { fn okay_bound<'b,'c,'e:'b+'c>(self, b: Inv<'b>, c: Inv<'c>, e: Inv<'e>) { } - fn another_bound<'x: 't>(self, x: Inv<'x>) {} + fn another_bound<'x: 't>(self, x: Inv<'x>, y: Inv<'t>) {} } fn main() { } diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs b/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs index 74c2c6e584b4..f13d8a60894c 100644 --- a/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs +++ b/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs @@ -8,16 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(lang_items, no_std)] -#![no_std] - // Check that explicit region bounds are allowed on the various // nominal types (but not on other types) and that they are type // checked. -#[lang="sized"] -trait Sized { } - struct Inv<'a> { // invariant w/r/t 'a x: &'a mut &'a isize } diff --git a/src/test/compile-fail/regions-close-associated-type-into-object.rs b/src/test/compile-fail/regions-close-associated-type-into-object.rs index 8a03f36972dd..979c1e997d03 100644 --- a/src/test/compile-fail/regions-close-associated-type-into-object.rs +++ b/src/test/compile-fail/regions-close-associated-type-into-object.rs @@ -10,7 +10,9 @@ #![feature(box_syntax)] -trait X {} +use std::marker::MarkerTrait; + +trait X : MarkerTrait {} trait Iter { type Item: X; 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 7a0e3cf4611c..7bbce7dad530 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,13 +11,16 @@ #![feature(box_syntax)] #![allow(warnings)] -trait A {} +use std::marker::PhantomFn; + +trait A : PhantomFn<(Self,T)> { } struct B<'a, T>(&'a (A+'a)); -trait X {} +trait X : ::std::marker::MarkerTrait {} + impl<'a, T> X for B<'a, T> {} -fn f<'a, T, U>(v: Box+'static>) -> Box { +fn f<'a, T:'static, U>(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-2.rs b/src/test/compile-fail/regions-close-object-into-object-2.rs index 7861fb95fef6..6de49020a6fb 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,10 +10,12 @@ #![feature(box_syntax)] -trait A {} +use std::marker::PhantomFn; + +trait A : PhantomFn<(Self,T)> { } struct B<'a, T>(&'a (A+'a)); -trait X {} +trait X : PhantomFn {} 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 31354de2a27d..e22d0c7d0a4f 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,10 +11,12 @@ #![feature(box_syntax)] #![allow(warnings)] -trait A {} +use std::marker::PhantomFn; + +trait A : PhantomFn<(Self,T)> {} struct B<'a, T>(&'a (A+'a)); -trait X {} +trait X : PhantomFn {} impl<'a, T> X for B<'a, T> {} fn h<'a, T, U>(v: Box+'static>) -> Box { 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 c60975f97e13..147a575d38ca 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,10 +10,12 @@ #![feature(box_syntax)] -trait A {} +use std::marker::PhantomFn; + +trait A : PhantomFn<(Self,T)> {} struct B<'a, T>(&'a (A+'a)); -trait X {} +trait X : PhantomFn {} impl<'a, T> X for B<'a, T> {} fn i<'a, T, U>(v: Box+'a>) -> Box { diff --git a/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs b/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs index 25b8137d29ca..2341d2397c9b 100644 --- a/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs +++ b/src/test/compile-fail/regions-close-over-borrowed-ref-in-obj.rs @@ -10,7 +10,9 @@ #![feature(box_syntax)] -trait Foo { } +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait { } impl<'a> Foo for &'a isize { } diff --git a/src/test/compile-fail/regions-close-param-into-object.rs b/src/test/compile-fail/regions-close-param-into-object.rs index 74b36958c92f..9ad49a6703ee 100644 --- a/src/test/compile-fail/regions-close-param-into-object.rs +++ b/src/test/compile-fail/regions-close-param-into-object.rs @@ -10,7 +10,7 @@ #![feature(box_syntax)] -trait X {} +trait X : ::std::marker::MarkerTrait {} fn p1(v: T) -> Box where T : X diff --git a/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs index 6c5e90a54de2..b7ef19d1e3bf 100644 --- a/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs +++ b/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs @@ -20,7 +20,7 @@ use std::marker; // Contravariant<'foo> <: Contravariant<'static> because // 'foo <= 'static struct Contravariant<'a> { - marker: marker::ContravariantLifetime<'a> + marker: marker::PhantomData<&'a()> } fn use_<'short,'long>(c: Contravariant<'short>, diff --git a/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs index d8e31fa1374a..0d3d9dacbd6f 100644 --- a/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs +++ b/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs @@ -17,7 +17,7 @@ use std::marker; struct Covariant<'a> { - marker: marker::CovariantLifetime<'a> + marker: marker::PhantomData } fn use_<'short,'long>(c: Covariant<'long>, diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs index 5f4a1af6bf90..65decb4da1b9 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs @@ -11,7 +11,7 @@ use std::marker; struct invariant<'a> { - marker: marker::InvariantLifetime<'a> + marker: marker::PhantomData<*mut &'a()> } fn to_same_lifetime<'r>(bi: invariant<'r>) { diff --git a/src/test/compile-fail/required-lang-item.rs b/src/test/compile-fail/required-lang-item.rs index 7d252604883d..1b749faf1b8b 100644 --- a/src/test/compile-fail/required-lang-item.rs +++ b/src/test/compile-fail/required-lang-item.rs @@ -11,7 +11,11 @@ #![feature(lang_items, no_std)] #![no_std] -#[lang="sized"] pub trait Sized {} +#[lang="phantom_fn"] +pub trait PhantomFn { } +impl PhantomFn for U { } + +#[lang="sized"] pub trait Sized : PhantomFn {} // error-pattern:requires `start` lang_item diff --git a/src/test/compile-fail/shadowed-type-parameter.rs b/src/test/compile-fail/shadowed-type-parameter.rs index 1a3d7821159c..1f72db1e894f 100644 --- a/src/test/compile-fail/shadowed-type-parameter.rs +++ b/src/test/compile-fail/shadowed-type-parameter.rs @@ -12,19 +12,21 @@ #![feature(box_syntax)] -struct Foo; +struct Foo(T); impl Foo { fn shadow_in_method(&self) {} //~^ ERROR type parameter `T` shadows another type parameter fn not_shadow_in_item(&self) { - struct Bar; // not a shadow, separate item + struct Bar(T,U); // not a shadow, separate item fn foo() {} // same } } trait Bar { + fn dummy(&self) -> T; + fn shadow_in_required(&self); //~^ ERROR type parameter `T` shadows another type parameter diff --git a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs index 1203d6223489..3c1c3796a246 100644 --- a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs +++ b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo(T); +use std::marker; + +struct Foo(T, marker::PhantomData); fn main() { - match Foo(1.1) { + match Foo(1.1, marker::PhantomData) { 1 => {} //~^ ERROR mismatched types //~| expected `Foo<_, _>` diff --git a/src/test/compile-fail/staticness-mismatch.rs b/src/test/compile-fail/staticness-mismatch.rs index bf4e46cace30..2dfc9b79ee20 100644 --- a/src/test/compile-fail/staticness-mismatch.rs +++ b/src/test/compile-fail/staticness-mismatch.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - trait foo { + fn dummy(&self) { } fn bar(); } diff --git a/src/test/compile-fail/trait-as-struct-constructor.rs b/src/test/compile-fail/trait-as-struct-constructor.rs index a1fcab002e13..fff144140947 100644 --- a/src/test/compile-fail/trait-as-struct-constructor.rs +++ b/src/test/compile-fail/trait-as-struct-constructor.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait TraitNotAStruct { } +trait TraitNotAStruct : ::std::marker::MarkerTrait { } fn main() { TraitNotAStruct{ value: 0 }; diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index 79174552ae09..3129dceffbb6 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -10,6 +10,7 @@ trait Foo { + fn dummy(&self) { } } fn a(_x: Box) { 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 477bd4f5be9a..34e06cc93658 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs @@ -11,7 +11,10 @@ // Make sure rustc checks the type parameter bounds in implementations of traits, // see #2687 -trait A {} +use std::marker; + +trait A : marker::PhantomFn { +} trait B: A {} @@ -62,15 +65,16 @@ impl Foo for isize { //~^ ERROR the requirement `T : C` appears on the impl } - -trait Getter { } +trait Getter { + fn get(&self) -> T { loop { } } +} trait Trait { - fn method>(); + fn method>(&self); } impl Trait for usize { - fn method>() {} + fn method>(&self) {} //~^ G : Getter` appears on the impl method but not on the corresponding trait method } 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 8ad19116e7bb..284c4fac953f 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs @@ -14,7 +14,9 @@ trait Iterator { fn next(&mut self) -> Option; } -trait IteratorUtil { +trait IteratorUtil + : ::std::marker::PhantomFn<(),A> +{ fn zip>(self, other: U) -> ZipIterator; } diff --git a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs index 434d803d718e..448b186f6a5c 100644 --- a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs +++ b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs @@ -9,6 +9,7 @@ // except according to those terms. trait Foo { + fn dummy(&self) { } } // This should emit the less confusing error, not the more confusing one. diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs index 118dfeb37c25..df44e847c50f 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Trait {} +trait Trait { + fn dummy(&self) { } +} struct Foo { x: T, diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs index d5369817e9ac..18871d0d386d 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Trait {} +trait Trait { + fn dummy(&self) { } +} struct Foo { x: T, diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs index 490ee0e8ad6f..8dfdb2f205d6 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Trait {} +use std::marker::MarkerTrait; + +trait Trait : MarkerTrait {} struct Foo { x: T, @@ -51,15 +53,15 @@ enum MoreBadness { EvenMoreBadness(Bar), } -trait PolyTrait { - fn whatever() {} +trait PolyTrait +{ + fn whatever(&self, t: T) {} } struct Struct; impl PolyTrait> for Struct { //~^ ERROR not implemented - fn whatever() {} } fn main() { diff --git a/src/test/compile-fail/trait-bounds-sugar.rs b/src/test/compile-fail/trait-bounds-sugar.rs index 3d264e681a3d..e4058a0943aa 100644 --- a/src/test/compile-fail/trait-bounds-sugar.rs +++ b/src/test/compile-fail/trait-bounds-sugar.rs @@ -10,8 +10,9 @@ // Tests for "default" bounds inferred for traits with no bounds list. +use std::marker::MarkerTrait; -trait Foo {} +trait Foo : MarkerTrait {} fn a(_x: Box) { } diff --git a/src/test/compile-fail/trait-impl-1.rs b/src/test/compile-fail/trait-impl-1.rs index dadcbd5bce71..2f4793b4d888 100644 --- a/src/test/compile-fail/trait-impl-1.rs +++ b/src/test/compile-fail/trait-impl-1.rs @@ -12,7 +12,9 @@ // trait impl is only applied to a trait object, not concrete types which implement // the trait. -trait T {} +use std::marker::MarkerTrait; + +trait T : MarkerTrait {} impl<'a> T+'a { fn foo(&self) {} diff --git a/src/test/compile-fail/trait-object-safety.rs b/src/test/compile-fail/trait-object-safety.rs index 761bcd4968ab..d45d13556e12 100644 --- a/src/test/compile-fail/trait-object-safety.rs +++ b/src/test/compile-fail/trait-object-safety.rs @@ -12,6 +12,7 @@ trait Tr { fn foo(); + fn bar(&self) { } } struct St; diff --git a/src/test/compile-fail/trait-static-method-generic-inference.rs b/src/test/compile-fail/trait-static-method-generic-inference.rs index 651f663fc991..0e357d9d4d53 100644 --- a/src/test/compile-fail/trait-static-method-generic-inference.rs +++ b/src/test/compile-fail/trait-static-method-generic-inference.rs @@ -16,6 +16,7 @@ mod base { pub trait HasNew { fn new() -> T; + fn dummy(&self) { } } pub struct Foo { diff --git a/src/test/compile-fail/typeck-negative-impls-builtin.rs b/src/test/compile-fail/typeck-negative-impls-builtin.rs index 9da79b11cf0b..557fb2f4f883 100644 --- a/src/test/compile-fail/typeck-negative-impls-builtin.rs +++ b/src/test/compile-fail/typeck-negative-impls-builtin.rs @@ -12,7 +12,9 @@ struct TestType; -trait TestTrait {} +trait TestTrait { + fn dummy(&self) { } +} impl !TestTrait for TestType {} //~^ ERROR negative impls are currently allowed just for `Send` and `Sync` diff --git a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs b/src/test/compile-fail/typeck_type_placeholder_mismatch.rs index a34be63ba6b3..1daea8f915b3 100644 --- a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs +++ b/src/test/compile-fail/typeck_type_placeholder_mismatch.rs @@ -11,14 +11,16 @@ // This test checks that genuine type errors with partial // type hints are understandable. -struct Foo; -struct Bar; +use std::marker::PhantomData; + +struct Foo(PhantomData); +struct Bar(PhantomData); pub fn main() { } fn test1() { - let x: Foo<_> = Bar::; + let x: Foo<_> = Bar::(PhantomData); //~^ ERROR mismatched types //~| expected `Foo<_>` //~| found `Bar` @@ -28,7 +30,7 @@ fn test1() { } fn test2() { - let x: Foo<_> = Bar::; + let x: Foo<_> = Bar::(PhantomData); //~^ ERROR mismatched types //~| expected `Foo<_>` //~| found `Bar` diff --git a/src/test/compile-fail/unboxed-closure-feature-gate.rs b/src/test/compile-fail/unboxed-closure-feature-gate.rs index 3536244f0116..74a6f869f63f 100644 --- a/src/test/compile-fail/unboxed-closure-feature-gate.rs +++ b/src/test/compile-fail/unboxed-closure-feature-gate.rs @@ -11,8 +11,12 @@ // Check that parenthetical notation is feature-gated except with the // `Fn` traits. +use std::marker; + trait Foo { type Output; + + fn dummy(&self, a: A) { } } fn main() { diff --git a/src/test/compile-fail/unboxed-closure-sugar-default.rs b/src/test/compile-fail/unboxed-closure-sugar-default.rs index 870377bc1add..831db98941c6 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-default.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-default.rs @@ -19,7 +19,7 @@ trait Foo { fn dummy(&self, t: T, v: V); } -trait Eq { } +trait Eq { fn same_types(&self, x: &X) -> bool { true } } impl Eq for X { } fn eq() where A : Eq { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs index dc5576aee650..6d315c1b7a99 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs @@ -16,12 +16,14 @@ #![feature(unboxed_closures)] #![allow(dead_code)] +use std::marker::PhantomFn; + trait Foo { type Output; fn dummy(&self, t: T, u: Self::Output); } -trait Eq { } +trait Eq : PhantomFn<(Self,X)> { } 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 d2f781bba11e..bd3530e6e302 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs @@ -16,12 +16,14 @@ #![feature(unboxed_closures)] #![allow(dead_code)] +use std::marker; + trait Foo { type Output; fn dummy(&self, t: T); } -trait Eq { } +trait Eq : marker::PhantomFn<(Self, X)> { } impl Eq for X { } fn eq>() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-region.rs b/src/test/compile-fail/unboxed-closure-sugar-region.rs index 75688e44e807..057b496bd43e 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-region.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-region.rs @@ -22,7 +22,7 @@ trait Foo<'a,T> { fn dummy(&'a self) -> &'a (T,Self::Output); } -trait Eq { } +trait Eq { fn is_of_eq_type(&self, x: &X) -> bool { true } } impl Eq for X { } fn eq>() { } diff --git a/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs b/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs index 215b2c6798e4..713b64b1349f 100644 --- a/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs +++ b/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs @@ -10,7 +10,7 @@ #![feature(core,unboxed_closures)] -use std::marker::CovariantType; +use std::marker::PhantomData; // A erroneous variant of `run-pass/unboxed_closures-infer-recursive-fn.rs` // where we attempt to perform mutation in the recursive function. This fails to compile @@ -18,12 +18,12 @@ use std::marker::CovariantType; struct YCombinator { func: F, - marker: CovariantType<(A,R)>, + marker: PhantomData<(A,R)>, } impl YCombinator { fn new(f: F) -> YCombinator { - YCombinator { func: f, marker: CovariantType } + YCombinator { func: f, marker: PhantomData } } } diff --git a/src/test/compile-fail/unnecessary-private.rs b/src/test/compile-fail/unnecessary-private.rs index e3707292f249..964db6e9a454 100644 --- a/src/test/compile-fail/unnecessary-private.rs +++ b/src/test/compile-fail/unnecessary-private.rs @@ -13,10 +13,10 @@ fn main() { pub struct A; //~ ERROR: visibility has no effect pub enum B {} //~ ERROR: visibility has no effect pub trait C { //~ ERROR: visibility has no effect - pub fn foo() {} //~ ERROR: visibility has no effect + pub fn foo(&self) {} //~ ERROR: visibility has no effect } impl A { - pub fn foo() {} //~ ERROR: visibility has no effect + pub fn foo(&self) {} //~ ERROR: visibility has no effect } struct D { diff --git a/src/test/compile-fail/unsized-inherent-impl-self-type.rs b/src/test/compile-fail/unsized-inherent-impl-self-type.rs index 8740346a2175..a03c76b12dd8 100644 --- a/src/test/compile-fail/unsized-inherent-impl-self-type.rs +++ b/src/test/compile-fail/unsized-inherent-impl-self-type.rs @@ -12,7 +12,7 @@ // impl - struct -struct S5; +struct S5(Y); impl S5 { //~ ERROR not implemented } diff --git a/src/test/compile-fail/unsized-trait-impl-self-type.rs b/src/test/compile-fail/unsized-trait-impl-self-type.rs index 3dd55b0ba7d2..08df1d9b7b8f 100644 --- a/src/test/compile-fail/unsized-trait-impl-self-type.rs +++ b/src/test/compile-fail/unsized-trait-impl-self-type.rs @@ -12,9 +12,10 @@ // impl - struct trait T3 { + fn foo(&self, z: &Z); } -struct S5; +struct S5(Y); impl T3 for S5 { //~ ERROR not implemented } diff --git a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs index ac8043d6852a..4723dfeaeb98 100644 --- a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs +++ b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs @@ -12,8 +12,9 @@ // impl - unbounded trait T2 { + fn foo(&self, z: Z); } -struct S4; +struct S4(Box); impl T2 for S4 { //~^ ERROR `core::marker::Sized` is not implemented for the type `X` } diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index 4fc76c99c60b..de1cbab82b28 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -10,6 +10,7 @@ // Test sized-ness checking in substitution within fn bodies.. +use std::marker; // Unbounded. fn f1(x: &X) { @@ -20,7 +21,9 @@ fn f2(x: &X) { } // Bounded. -trait T {} +trait T { + fn foo(&self) { } +} fn f3(x: &X) { f4::(x); //~^ ERROR the trait `core::marker::Sized` is not implemented diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index 217d1f44d846..f31a6ffdc0d7 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -10,8 +10,9 @@ // Test `?Sized` local variables. +use std::marker; -trait T {} +trait T : marker::MarkerTrait { } fn f1(x: &X) { let _: X; // <-- this is OK, no bindings created, no initializer. diff --git a/src/test/compile-fail/unsized7.rs b/src/test/compile-fail/unsized7.rs index 6fc547c0b8e8..6ea3d0720eee 100644 --- a/src/test/compile-fail/unsized7.rs +++ b/src/test/compile-fail/unsized7.rs @@ -10,13 +10,17 @@ // Test sized-ness checking in substitution in impls. -trait T {} +use std::marker::MarkerTrait; + +trait T : MarkerTrait {} // I would like these to fail eventually. // impl - bounded trait T1 { + fn dummy(&self) -> Z; } -struct S3; + +struct S3(Box); impl T1 for S3 { //~^ ERROR `core::marker::Sized` is not implemented for the type `X` } diff --git a/src/test/compile-fail/unused-attr.rs b/src/test/compile-fail/unused-attr.rs index 2d4bc0c857a9..af242b96a84a 100644 --- a/src/test/compile-fail/unused-attr.rs +++ b/src/test/compile-fail/unused-attr.rs @@ -52,9 +52,9 @@ struct Foo { #[foo] //~ ERROR unused attribute trait Baz { #[foo] //~ ERROR unused attribute - fn blah(); + fn blah(&self); #[foo] //~ ERROR unused attribute - fn blah2() {} + fn blah2(&self) {} } fn main() {} diff --git a/src/test/compile-fail/useless-priv.rs b/src/test/compile-fail/useless-priv.rs index d8531f4543df..b1120e54434e 100644 --- a/src/test/compile-fail/useless-priv.rs +++ b/src/test/compile-fail/useless-priv.rs @@ -12,12 +12,14 @@ struct A { pub i: isize } pub enum C { pub Variant } //~ ERROR: unnecessary `pub` pub trait E { - pub fn foo() {} //~ ERROR: unnecessary visibility + pub fn foo(&self) {} //~ ERROR: unnecessary visibility +} +trait F { + pub fn foo(&self) {} //~ ERROR: unnecessary visibility } -trait F { pub fn foo() {} } //~ ERROR: unnecessary visibility impl E for A { - pub fn foo() {} //~ ERROR: unnecessary visibility + pub fn foo(&self) {} //~ ERROR: unnecessary visibility } fn main() {} diff --git a/src/test/compile-fail/useless-priv2.rs b/src/test/compile-fail/useless-priv2.rs index 7125a66b294c..a404d09248f0 100644 --- a/src/test/compile-fail/useless-priv2.rs +++ b/src/test/compile-fail/useless-priv2.rs @@ -9,8 +9,10 @@ // except according to those terms. pub trait E { - pub fn foo(); //~ ERROR: unnecessary visibility + pub fn foo(&self); //~ ERROR: unnecessary visibility +} +trait F { + pub fn foo(&self); //~ ERROR: unnecessary visibility } -trait F { pub fn foo(); } //~ ERROR: unnecessary visibility fn main() {} diff --git a/src/test/compile-fail/variance-regions-direct.rs b/src/test/compile-fail/variance-regions-direct.rs index d70305d1106e..da4d6c75227f 100644 --- a/src/test/compile-fail/variance-regions-direct.rs +++ b/src/test/compile-fail/variance-regions-direct.rs @@ -60,6 +60,7 @@ struct Test6<'a, 'b> { //~ ERROR regions=[[-, o];[];[]] #[rustc_variance] struct Test7<'a> { //~ ERROR regions=[[*];[];[]] + //~^ ERROR parameter `'a` is never used x: isize } diff --git a/src/test/compile-fail/variance-regions-indirect.rs b/src/test/compile-fail/variance-regions-indirect.rs index 4bb329d6304c..9beb90d0b248 100644 --- a/src/test/compile-fail/variance-regions-indirect.rs +++ b/src/test/compile-fail/variance-regions-indirect.rs @@ -16,6 +16,7 @@ #[rustc_variance] enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]] + //~^ ERROR parameter `'d` is never used Test8A(extern "Rust" fn(&'a isize)), Test8B(&'b [isize]), Test8C(&'b mut &'c str), @@ -23,16 +24,19 @@ enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]] #[rustc_variance] struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[[*, o, -, +];[];[]] + //~^ ERROR parameter `'w` is never used f: Base<'z, 'y, 'x, 'w> } #[rustc_variance] // Combine - and + to yield o struct Derived2<'a, 'b:'a, 'c> { //~ ERROR regions=[[o, o, *];[];[]] + //~^ ERROR parameter `'c` is never used f: Base<'a, 'a, 'b, 'c> } #[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here) struct Derived3<'a:'b, 'b, 'c> { //~ ERROR regions=[[o, -, *];[];[]] + //~^ ERROR parameter `'c` is never used f: Base<'a, 'b, 'a, 'c> } diff --git a/src/test/compile-fail/variance-trait-object-bound.rs b/src/test/compile-fail/variance-trait-object-bound.rs index 965b9430a5e2..f0ca1edd5638 100644 --- a/src/test/compile-fail/variance-trait-object-bound.rs +++ b/src/test/compile-fail/variance-trait-object-bound.rs @@ -18,7 +18,7 @@ use std::mem; -trait T { fn foo(); } +trait T { fn foo(&self); } #[rustc_variance] struct TOption<'a> { //~ ERROR regions=[[-];[];[]] diff --git a/src/test/compile-fail/visible-private-types-generics.rs b/src/test/compile-fail/visible-private-types-generics.rs index 7ff18f8e0886..1f2205b5c719 100644 --- a/src/test/compile-fail/visible-private-types-generics.rs +++ b/src/test/compile-fail/visible-private-types-generics.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo { + fn dummy(&self) { } +} pub fn f< T diff --git a/src/test/compile-fail/visible-private-types-supertrait.rs b/src/test/compile-fail/visible-private-types-supertrait.rs index dc6d446154ac..9d9eae4a0759 100644 --- a/src/test/compile-fail/visible-private-types-supertrait.rs +++ b/src/test/compile-fail/visible-private-types-supertrait.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo { + fn dummy(&self) { } +} pub trait Bar : Foo {} //~ ERROR private trait in exported type diff --git a/src/test/compile-fail/where-clause-method-substituion.rs b/src/test/compile-fail/where-clause-method-substituion.rs index a5108f005dc0..bf614e6eb512 100644 --- a/src/test/compile-fail/where-clause-method-substituion.rs +++ b/src/test/compile-fail/where-clause-method-substituion.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo { + fn dummy(&self, t: T) { } +} trait Bar { fn method(&self) where A: Foo; diff --git a/src/test/compile-fail/where-clauses-not-parameter.rs b/src/test/compile-fail/where-clauses-not-parameter.rs index 313ae273c07f..7968cc37090a 100644 --- a/src/test/compile-fail/where-clauses-not-parameter.rs +++ b/src/test/compile-fail/where-clauses-not-parameter.rs @@ -21,7 +21,7 @@ fn test2() -> bool where Option : Eq {} #[derive(PartialEq)] //~^ ERROR cannot bound type `isize`, where clause bounds -enum Foo where isize : Eq { MkFoo } +enum Foo where isize : Eq { MkFoo(T) } //~^ ERROR cannot bound type `isize`, where clause bounds fn test3() -> bool where Option> : Eq {} @@ -31,7 +31,7 @@ fn test4() -> bool where Option> : Eq {} trait Baz where isize : Eq { //~^ ERROR cannot bound type `isize`, where clause bounds may only - fn baz() where String : Eq; //~ ERROR cannot bound type `collections::string::String` + fn baz(&self, t: T) where String : Eq; //~ ERROR cannot bound type `collections::string::String` //~^ ERROR cannot bound type `isize`, where clause } diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs index adc4711b49aa..cb1cf8c55579 100644 --- a/src/test/debuginfo/type-names.rs +++ b/src/test/debuginfo/type-names.rs @@ -177,10 +177,11 @@ #![omit_gdb_pretty_printer_section] use self::Enum1::{Variant1_1, Variant1_2}; +use std::marker::PhantomData; use std::ptr; struct Struct1; -struct GenericStruct; +struct GenericStruct(PhantomData<(T1,T2)>); enum Enum1 { Variant1_1, @@ -207,8 +208,8 @@ mod Mod1 { } } -trait Trait1 { } -trait Trait2 { } +trait Trait1 { fn dummy(&self) { } } +trait Trait2 { fn dummy(&self, _: T1, _:T2) { } } impl Trait1 for isize {} impl Trait2 for isize {} @@ -240,8 +241,10 @@ fn main() { // Structs let simple_struct = Struct1; - let generic_struct1: GenericStruct = GenericStruct; - let generic_struct2: GenericStruct usize> = GenericStruct; + let generic_struct1: GenericStruct = + GenericStruct(PhantomData); + let generic_struct2: GenericStruct usize> = + GenericStruct(PhantomData); let mod_struct = Mod1::Struct2; // Enums @@ -262,10 +265,10 @@ fn main() { // References let ref1 = (&Struct1, 0i32); - let ref2 = (&GenericStruct::, 0i32); + let ref2 = (&GenericStruct::(PhantomData), 0i32); let mut mut_struct1 = Struct1; - let mut mut_generic_struct = GenericStruct::; + let mut mut_generic_struct = GenericStruct::(PhantomData); let mut_ref1 = (&mut mut_struct1, 0i32); let mut_ref2 = (&mut mut_generic_struct, 0i32); diff --git a/src/test/pretty/empty-impl.rs b/src/test/pretty/empty-impl.rs index f22f1b409526..f5205de5c1fc 100644 --- a/src/test/pretty/empty-impl.rs +++ b/src/test/pretty/empty-impl.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait X { } +trait X { fn dummy(&self) { } } impl X for uint { } -trait Y { } +trait Y { fn dummy(&self) { } } impl Y for uint { } diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index e27a3365a410..9e1f2aa8bfe0 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -11,7 +11,9 @@ // pp-exact -trait Tr { } +trait Tr { + fn dummy(&self) { } +} impl Tr for int { } fn foo<'a>(x: Box) -> Box { x } diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs index e46564f80760..4ad81197286b 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -9,6 +9,9 @@ // except according to those terms. // error-pattern:quux + +use std::marker::PhantomData; + fn test00_start(ch: chan_t, message: int) { send(ch, message); } type task_id = int; @@ -17,6 +20,7 @@ type port_id = int; struct chan_t { task: task_id, port: port_id, + marker: PhantomData<*mut T>, } fn send(_ch: chan_t, _data: T) { panic!(); } diff --git a/src/test/run-make/rustdoc-json/foo.rs b/src/test/run-make/rustdoc-json/foo.rs index d57a7164cdbc..3bd56c14193a 100644 --- a/src/test/run-make/rustdoc-json/foo.rs +++ b/src/test/run-make/rustdoc-json/foo.rs @@ -21,5 +21,5 @@ pub mod bar { } /// *wow* - pub trait Doge { } + pub trait Doge { fn dummy(&self) { } } } diff --git a/src/test/run-make/rustdoc-negative-impl/foo.rs b/src/test/run-make/rustdoc-negative-impl/foo.rs index b5fcbf46c5c9..6c56bcc9be67 100644 --- a/src/test/run-make/rustdoc-negative-impl/foo.rs +++ b/src/test/run-make/rustdoc-negative-impl/foo.rs @@ -13,7 +13,7 @@ // @matches foo/struct.Alpha.html '//pre' "pub struct Alpha" pub struct Alpha; // @matches foo/struct.Bravo.html '//pre' "pub struct Bravo" -pub struct Bravo; +pub struct Bravo(B); // @matches foo/struct.Alpha.html '//*[@class="impl"]//code' "impl !Send for Alpha" impl !Send for Alpha {} diff --git a/src/test/run-make/rustdoc-search-index/index.rs b/src/test/run-make/rustdoc-search-index/index.rs index dd68f2d6f1de..42469a21f22d 100644 --- a/src/test/run-make/rustdoc-search-index/index.rs +++ b/src/test/run-make/rustdoc-search-index/index.rs @@ -21,6 +21,6 @@ mod private { } pub trait PrivateTrait { - fn trait_method() {} // @!has - priv_method + fn trait_method(&self) {} // @!has - priv_method } } diff --git a/src/test/run-make/rustdoc-smoke/foo.rs b/src/test/run-make/rustdoc-smoke/foo.rs index 0438c9aba359..f6b73021bebd 100644 --- a/src/test/run-make/rustdoc-smoke/foo.rs +++ b/src/test/run-make/rustdoc-smoke/foo.rs @@ -26,7 +26,7 @@ pub mod bar { /// *wow* // @has foo/bar/trait.Doge.html - pub trait Doge { } + pub trait Doge { fn dummy(&self) { } } // @has foo/bar/struct.Foo.html pub struct Foo { x: int, y: uint } diff --git a/src/test/run-make/rustdoc-viewpath-self/foo.rs b/src/test/run-make/rustdoc-viewpath-self/foo.rs index da8f73930239..6fd47d84c30f 100644 --- a/src/test/run-make/rustdoc-viewpath-self/foo.rs +++ b/src/test/run-make/rustdoc-viewpath-self/foo.rs @@ -9,7 +9,7 @@ // except according to those terms. pub mod io { - pub trait Reader { } + pub trait Reader { fn dummy(&self) { } } } pub enum Maybe { diff --git a/src/test/run-make/rustdoc-where/foo.rs b/src/test/run-make/rustdoc-where/foo.rs index 68fde60564e2..91a7e1c9fd4a 100644 --- a/src/test/run-make/rustdoc-where/foo.rs +++ b/src/test/run-make/rustdoc-where/foo.rs @@ -8,30 +8,33 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait MyTrait {} +pub trait MyTrait { fn dummy(&self) { } } // @has foo/struct.Alpha.html '//pre' "pub struct Alpha where A: MyTrait" -pub struct Alpha where A: MyTrait; +pub struct Alpha(A) where A: MyTrait; // @has foo/trait.Bravo.html '//pre' "pub trait Bravo where B: MyTrait" -pub trait Bravo where B: MyTrait {} +pub trait Bravo where B: MyTrait { fn get(&self, B: B); } // @has foo/fn.charlie.html '//pre' "pub fn charlie() where C: MyTrait" pub fn charlie() where C: MyTrait {} -pub struct Delta; +pub struct Delta(D); + // @has foo/struct.Delta.html '//*[@class="impl"]//code' \ // "impl Delta where D: MyTrait" impl Delta where D: MyTrait { pub fn delta() {} } -pub struct Echo; +pub struct Echo(E); + // @has foo/struct.Echo.html '//*[@class="impl"]//code' \ // "impl MyTrait for Echo where E: MyTrait" // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \ // "impl MyTrait for Echo where E: MyTrait" impl MyTrait for Echo where E: MyTrait {} -pub enum Foxtrot {} +pub enum Foxtrot { Foxtrot1(F) } + // @has foo/enum.Foxtrot.html '//*[@class="impl"]//code' \ // "impl MyTrait for Foxtrot where F: MyTrait" // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \ diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index d90219b4221e..ffadc57d1b08 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -99,6 +99,7 @@ struct some_fields { type SF = some_fields; trait SuperTrait { + fn dummy(&self) { } } trait SomeTrait: SuperTrait { diff --git a/src/test/run-make/simd-ffi/simd.rs b/src/test/run-make/simd-ffi/simd.rs index 834a2adf01fd..f418d5d1fb74 100755 --- a/src/test/run-make/simd-ffi/simd.rs +++ b/src/test/run-make/simd-ffi/simd.rs @@ -70,10 +70,14 @@ pub fn bar(a: i32x4, b: i32x4) -> i32x4 { } #[lang = "sized"] -trait Sized {} +pub trait Sized : PhantomFn {} #[lang = "copy"] -trait Copy {} +pub trait Copy : PhantomFn {} + +#[lang="phantom_fn"] +pub trait PhantomFn { } +impl PhantomFn for U { } mod core { pub mod marker { diff --git a/src/test/run-make/symbols-are-reasonable/lib.rs b/src/test/run-make/symbols-are-reasonable/lib.rs index 7cfebb31b229..474a6782b616 100644 --- a/src/test/run-make/symbols-are-reasonable/lib.rs +++ b/src/test/run-make/symbols-are-reasonable/lib.rs @@ -11,7 +11,7 @@ pub static X: &'static str = "foobarbaz"; pub static Y: &'static [u8] = include_bytes!("lib.rs"); -trait Foo {} +trait Foo { fn dummy(&self) { } } impl Foo for uint {} pub fn dummy() { diff --git a/src/test/run-make/target-specs/foo.rs b/src/test/run-make/target-specs/foo.rs index 365fc039a4ec..acda8705b19e 100644 --- a/src/test/run-make/target-specs/foo.rs +++ b/src/test/run-make/target-specs/foo.rs @@ -11,11 +11,15 @@ #![feature(lang_items, no_std)] #![no_std] +#[lang="phantom_fn"] +trait PhantomFn { } +impl PhantomFn for U { } + #[lang="copy"] -trait Copy { } +trait Copy : PhantomFn { } #[lang="sized"] -trait Sized { } +trait Sized : PhantomFn { } #[lang="start"] fn start(_main: *const u8, _argc: int, _argv: *const *const u8) -> int { 0 } diff --git a/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs b/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs index 195055f12d1e..aecec44f6fd3 100644 --- a/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs +++ b/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs @@ -25,7 +25,7 @@ impl Drop for Foo { } -trait Trait {} +trait Trait { fn dummy(&self) { } } impl Trait for Foo {} pub fn main() { diff --git a/src/test/run-pass-valgrind/dst-dtor-1.rs b/src/test/run-pass-valgrind/dst-dtor-1.rs index 47e2a18a9992..c49a684de945 100644 --- a/src/test/run-pass-valgrind/dst-dtor-1.rs +++ b/src/test/run-pass-valgrind/dst-dtor-1.rs @@ -19,7 +19,7 @@ impl Drop for Foo { } } -trait Trait {} +trait Trait { fn dummy(&self) { } } impl Trait for Foo {} struct Fat { diff --git a/src/test/run-pass/associated-types-basic.rs b/src/test/run-pass/associated-types-basic.rs index 3314b6132015..f5521f7da853 100644 --- a/src/test/run-pass/associated-types-basic.rs +++ b/src/test/run-pass/associated-types-basic.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait { type T; } diff --git a/src/test/run-pass/associated-types-conditional-dispatch.rs b/src/test/run-pass/associated-types-conditional-dispatch.rs index f21b7183d70c..aa65b0ed10ba 100644 --- a/src/test/run-pass/associated-types-conditional-dispatch.rs +++ b/src/test/run-pass/associated-types-conditional-dispatch.rs @@ -14,6 +14,7 @@ // `Target=[A]`, then the impl marked with `(*)` is seen to conflict // with all the others. +use std::marker::PhantomData; use std::ops::Deref; pub trait MyEq { @@ -41,7 +42,8 @@ impl<'a, A, B, Lhs> MyEq<[B; 0]> for Lhs } struct DerefWithHelper { - pub helper: H + pub helper: H, + pub marker: PhantomData, } trait Helper { @@ -63,7 +65,8 @@ impl> Deref for DerefWithHelper { } pub fn check(x: T, y: T) -> bool { - let d: DerefWithHelper, T> = DerefWithHelper { helper: Some(x) }; + let d: DerefWithHelper, T> = DerefWithHelper { helper: Some(x), + marker: PhantomData }; d.eq(&y) } diff --git a/src/test/run-pass/associated-types-issue-20371.rs b/src/test/run-pass/associated-types-issue-20371.rs index d35b7331d4db..40ef7f3531cb 100644 --- a/src/test/run-pass/associated-types-issue-20371.rs +++ b/src/test/run-pass/associated-types-issue-20371.rs @@ -11,6 +11,8 @@ // Test that we are able to have an impl that defines an associated type // before the actual trait. +use std::marker::MarkerTrait; + impl X for f64 { type Y = int; } -trait X {type Y; } +trait X : MarkerTrait { type Y; } fn main() {} diff --git a/src/test/run-pass/associated-types-issue-21212.rs b/src/test/run-pass/associated-types-issue-21212.rs index ced44250e4d3..3c91577362a7 100644 --- a/src/test/run-pass/associated-types-issue-21212.rs +++ b/src/test/run-pass/associated-types-issue-21212.rs @@ -20,7 +20,8 @@ pub trait Parser { panic!() } } -impl

Parser for P { + +impl

(&self, n: uint, pred: P) -> SplitsN> where P: FnMut(&T) -> bool { + fn splitn2

(&self, n: u32, pred: P) -> SplitsN> where P: FnMut(&T) -> bool { SliceExt2::split2(self, pred); loop {} } diff --git a/src/test/run-pass/associated-types-normalize-in-bounds.rs b/src/test/run-pass/associated-types-normalize-in-bounds.rs index 742bab0578e9..94cfcb836538 100644 --- a/src/test/run-pass/associated-types-normalize-in-bounds.rs +++ b/src/test/run-pass/associated-types-normalize-in-bounds.rs @@ -11,15 +11,17 @@ // Test that we normalize associated types that appear in bounds; if // we didn't, the call to `self.split2()` fails to type check. -struct Splits<'a, T, P>; -struct SplitsN; +use std::marker::PhantomData; + +struct Splits<'a, T, P>(PhantomData<(&'a(),T,P)>); +struct SplitsN(PhantomData); trait SliceExt2 { type Item; fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> where P: FnMut(&Self::Item) -> bool; - fn splitn2<'a, P>(&'a self, n: uint, pred: P) -> SplitsN> + fn splitn2<'a, P>(&'a self, n: usize, pred: P) -> SplitsN> where P: FnMut(&Self::Item) -> bool; } @@ -30,7 +32,7 @@ impl SliceExt2 for [T] { loop {} } - fn splitn2

(&self, n: uint, pred: P) -> SplitsN> where P: FnMut(&T) -> bool { + fn splitn2

(&self, n: usize, pred: P) -> SplitsN> where P: FnMut(&T) -> bool { self.split2(pred); loop {} } diff --git a/src/test/run-pass/associated-types-normalize-unifield-struct.rs b/src/test/run-pass/associated-types-normalize-unifield-struct.rs index 5aafe93067c1..2288e19aae0b 100644 --- a/src/test/run-pass/associated-types-normalize-unifield-struct.rs +++ b/src/test/run-pass/associated-types-normalize-unifield-struct.rs @@ -13,7 +13,10 @@ pub trait OffsetState: Sized {} -pub trait Offset { type State: OffsetState; } +pub trait Offset { + type State: OffsetState; + fn dummy(&self) { } +} #[derive(Copy)] pub struct X; impl Offset for X { type State = Y; } diff --git a/src/test/run-pass/associated-types-projection-from-known-type-in-impl.rs b/src/test/run-pass/associated-types-projection-from-known-type-in-impl.rs index 0a1a8589dec8..c65d2db9b0cf 100644 --- a/src/test/run-pass/associated-types-projection-from-known-type-in-impl.rs +++ b/src/test/run-pass/associated-types-projection-from-known-type-in-impl.rs @@ -13,6 +13,8 @@ trait Int { type T; + + fn dummy(&self) { } } trait NonZero diff --git a/src/test/run-pass/associated-types-projection-in-object-type.rs b/src/test/run-pass/associated-types-projection-in-object-type.rs index 44dd49b72976..a9c34a605ce1 100644 --- a/src/test/run-pass/associated-types-projection-in-object-type.rs +++ b/src/test/run-pass/associated-types-projection-in-object-type.rs @@ -18,6 +18,8 @@ use std::cell::RefCell; pub trait Subscriber { type Input; + + fn dummy(&self) { } } pub trait Publisher<'a> { diff --git a/src/test/run-pass/associated-types-projection-in-supertrait.rs b/src/test/run-pass/associated-types-projection-in-supertrait.rs index e6fec675b036..4d2358fae27b 100644 --- a/src/test/run-pass/associated-types-projection-in-supertrait.rs +++ b/src/test/run-pass/associated-types-projection-in-supertrait.rs @@ -14,6 +14,8 @@ trait A { type TA; + + fn dummy(&self) { } } trait B diff --git a/src/test/run-pass/associated-types-projection-in-where-clause.rs b/src/test/run-pass/associated-types-projection-in-where-clause.rs index 10a459f3c366..3f3f4fbd1d62 100644 --- a/src/test/run-pass/associated-types-projection-in-where-clause.rs +++ b/src/test/run-pass/associated-types-projection-in-where-clause.rs @@ -13,6 +13,8 @@ trait Int { type T; + + fn dummy(&self) { } } trait NonZero diff --git a/src/test/run-pass/associated-types-ref-in-struct-literal.rs b/src/test/run-pass/associated-types-ref-in-struct-literal.rs index 022c8f4cd013..67fe11d8fedd 100644 --- a/src/test/run-pass/associated-types-ref-in-struct-literal.rs +++ b/src/test/run-pass/associated-types-ref-in-struct-literal.rs @@ -12,6 +12,8 @@ pub trait Foo { type Bar; + + fn dummy(&self) { } } impl Foo for int { diff --git a/src/test/run-pass/associated-types-resolve-lifetime.rs b/src/test/run-pass/associated-types-resolve-lifetime.rs index e7a8061a3467..a4b0b1a6e03a 100644 --- a/src/test/run-pass/associated-types-resolve-lifetime.rs +++ b/src/test/run-pass/associated-types-resolve-lifetime.rs @@ -15,6 +15,8 @@ trait Get { trait Trait<'a> { type T: 'static; type U: Get<&'a int>; + + fn dummy(&'a self) { } } fn main() {} diff --git a/src/test/run-pass/associated-types-struct-field-named.rs b/src/test/run-pass/associated-types-struct-field-named.rs index 1ded34ff3ffe..8667f6c8430a 100644 --- a/src/test/run-pass/associated-types-struct-field-named.rs +++ b/src/test/run-pass/associated-types-struct-field-named.rs @@ -13,6 +13,8 @@ pub trait UnifyKey { type Value; + + fn dummy(&self) { } } pub struct Node { diff --git a/src/test/run-pass/associated-types-struct-field-numbered.rs b/src/test/run-pass/associated-types-struct-field-numbered.rs index 3669dec4fbdd..9503f78a71b9 100644 --- a/src/test/run-pass/associated-types-struct-field-numbered.rs +++ b/src/test/run-pass/associated-types-struct-field-numbered.rs @@ -13,6 +13,8 @@ pub trait UnifyKey { type Value; + + fn dummy(&self) { } } pub struct Node(K, K::Value); diff --git a/src/test/run-pass/associated-types-sugar-path.rs b/src/test/run-pass/associated-types-sugar-path.rs index ea1df6658fd0..b1878fa3558d 100644 --- a/src/test/run-pass/associated-types-sugar-path.rs +++ b/src/test/run-pass/associated-types-sugar-path.rs @@ -31,8 +31,9 @@ pub fn bar(a: T, x: T::A) -> T::A { // Using a type via an impl. trait C { fn f(); + fn g(&self) { } } -struct B; +struct B(X); impl C for B { fn f() { let x: T::A = panic!(); diff --git a/src/test/run-pass/borrowck-trait-lifetime.rs b/src/test/run-pass/borrowck-trait-lifetime.rs index b39f03a93c9f..be0c88f557cc 100644 --- a/src/test/run-pass/borrowck-trait-lifetime.rs +++ b/src/test/run-pass/borrowck-trait-lifetime.rs @@ -12,8 +12,11 @@ // to the same lifetime on a trait succeeds. See issue #10766. #![allow(dead_code)] + +use std::marker; + fn main() { - trait T {} + trait T : marker::MarkerTrait {} fn f<'a, V: T>(v: &'a V) -> &'a T { v as &'a T diff --git a/src/test/run-pass/bug-7295.rs b/src/test/run-pass/bug-7295.rs index ea711d78dd28..143ebfdabfac 100644 --- a/src/test/run-pass/bug-7295.rs +++ b/src/test/run-pass/bug-7295.rs @@ -9,10 +9,10 @@ // except according to those terms. pub trait Foo { - fn func1(&self, t: U); + fn func1(&self, t: U, w: T); - fn func2(&self, t: U) { - self.func1(t); + fn func2(&self, t: U, w: T) { + self.func1(t, w); } } diff --git a/src/test/run-pass/builtin-superkinds-in-metadata.rs b/src/test/run-pass/builtin-superkinds-in-metadata.rs index c115415bb9b7..7eaed910124d 100644 --- a/src/test/run-pass/builtin-superkinds-in-metadata.rs +++ b/src/test/run-pass/builtin-superkinds-in-metadata.rs @@ -16,6 +16,7 @@ extern crate trait_superkinds_in_metadata; use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare}; use trait_superkinds_in_metadata::{RequiresCopy}; +use std::marker; #[derive(Copy)] struct X(T); diff --git a/src/test/run-pass/builtin-superkinds-phantom-typaram.rs b/src/test/run-pass/builtin-superkinds-phantom-typaram.rs index 7e1b28219373..964c28dc9451 100644 --- a/src/test/run-pass/builtin-superkinds-phantom-typaram.rs +++ b/src/test/run-pass/builtin-superkinds-phantom-typaram.rs @@ -12,10 +12,12 @@ // super-builtin-kind of a trait, if the type parameter is never used, // the type can implement the trait anyway. +use std::marker; + trait Foo : Send { } -struct X(()); +struct X { marker: marker::PhantomData } -impl Foo for X { } +impl Foo for X { } pub fn main() { } diff --git a/src/test/run-pass/class-typarams.rs b/src/test/run-pass/class-typarams.rs index 9d4e73da8130..15e98519fbcd 100644 --- a/src/test/run-pass/class-typarams.rs +++ b/src/test/run-pass/class-typarams.rs @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker::PhantomData; + struct cat { meows : uint, - how_hungry : int, + m: PhantomData } impl cat { @@ -22,7 +24,8 @@ impl cat { fn cat(in_x : uint, in_y : int) -> cat { cat { meows: in_x, - how_hungry: in_y + how_hungry: in_y, + m: PhantomData } } diff --git a/src/test/run-pass/dst-coercions.rs b/src/test/run-pass/dst-coercions.rs index dbad546ce1ae..30ed0b8e4024 100644 --- a/src/test/run-pass/dst-coercions.rs +++ b/src/test/run-pass/dst-coercions.rs @@ -11,7 +11,7 @@ // Test coercions involving DST and/or raw pointers struct S; -trait T {} +trait T { fn dummy(&self) { } } impl T for S {} pub fn main() { diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs index 797c26556aaa..023376ce4736 100644 --- a/src/test/run-pass/enum-null-pointer-opt.rs +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -16,7 +16,7 @@ use std::mem::size_of; use std::rc::Rc; use std::sync::Arc; -trait Trait {} +trait Trait { fn dummy(&self) { } } fn main() { // Functions diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index 066a5f9580ac..382c5c58e92e 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -15,21 +15,19 @@ struct LM { resize_at: uint, size: uint } enum HashMap { - HashMap_(LM) + HashMap_(LM, Vec<(K,V)>) } -impl Copy for HashMap {} - fn linear_map() -> HashMap { HashMap::HashMap_(LM{ resize_at: 32, - size: 0}) + size: 0}, Vec::new()) } impl HashMap { pub fn len(&mut self) -> uint { match *self { - HashMap::HashMap_(l) => l.size + HashMap::HashMap_(ref l, _) => l.size } } } diff --git a/src/test/run-pass/export-non-interference.rs b/src/test/run-pass/export-non-interference.rs deleted file mode 100644 index 94652e30fe64..000000000000 --- a/src/test/run-pass/export-non-interference.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 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. - - -enum list_cell { cons(Box>), nil } - -pub fn main() { } diff --git a/src/test/run-pass/generic-default-type-params-cross-crate.rs b/src/test/run-pass/generic-default-type-params-cross-crate.rs index ed8c6e73255b..bf02b82d1a07 100644 --- a/src/test/run-pass/generic-default-type-params-cross-crate.rs +++ b/src/test/run-pass/generic-default-type-params-cross-crate.rs @@ -12,13 +12,13 @@ extern crate default_type_params_xc; -struct Vec; +struct Vec(Option<(T,A)>); struct Foo; fn main() { - let _a = Vec::; - let _b = Vec::; - let _c = default_type_params_xc::FakeVec::; - let _d = default_type_params_xc::FakeVec::; + let _a = Vec::(None); + let _b = Vec::(None); + let _c = default_type_params_xc::FakeVec:: { f: None }; + let _d = default_type_params_xc::FakeVec:: { f: None }; } diff --git a/src/test/run-pass/hrtb-opt-in-copy.rs b/src/test/run-pass/hrtb-opt-in-copy.rs index 9c9f95f61e9b..7b16bb867e79 100644 --- a/src/test/run-pass/hrtb-opt-in-copy.rs +++ b/src/test/run-pass/hrtb-opt-in-copy.rs @@ -18,7 +18,7 @@ #![allow(dead_code)] -use std::marker; +use std::marker::PhantomData; #[derive(Copy)] struct Foo { x: T } @@ -26,7 +26,7 @@ struct Foo { x: T } type Ty<'tcx> = &'tcx TyS<'tcx>; enum TyS<'tcx> { - Boop(marker::InvariantLifetime<'tcx>) + Boop(PhantomData<*mut &'tcx ()>) } #[derive(Copy)] diff --git a/src/test/run-pass/inner-static.rs b/src/test/run-pass/inner-static.rs index f9b430c1553d..e4026a8fd011 100644 --- a/src/test/run-pass/inner-static.rs +++ b/src/test/run-pass/inner-static.rs @@ -13,9 +13,9 @@ extern crate inner_static; pub fn main() { - let a = inner_static::A::<()>; - let b = inner_static::B::<()>; - let c = inner_static::test::A::<()>; + let a = inner_static::A::<()> { v: () }; + let b = inner_static::B::<()> { v: () }; + let c = inner_static::test::A::<()> { v: () }; assert_eq!(a.bar(), 2); assert_eq!(b.bar(), 4); assert_eq!(c.bar(), 6); diff --git a/src/test/run-pass/issue-10456.rs b/src/test/run-pass/issue-10456.rs index b714d87f4ef2..da73c4b27ac4 100644 --- a/src/test/run-pass/issue-10456.rs +++ b/src/test/run-pass/issue-10456.rs @@ -14,7 +14,9 @@ pub trait Bar { fn bar(&self); } -pub trait Baz {} +pub trait Baz { + fn baz(&self) { } +} impl Bar for T { fn bar(&self) {} diff --git a/src/test/run-pass/issue-10802.rs b/src/test/run-pass/issue-10802.rs index de2b4c51e52a..174a69e1135c 100644 --- a/src/test/run-pass/issue-10802.rs +++ b/src/test/run-pass/issue-10802.rs @@ -29,7 +29,7 @@ impl Drop for DroppableEnum { } } -trait MyTrait { } +trait MyTrait { fn dummy(&self) { } } impl MyTrait for Box {} impl MyTrait for Box {} diff --git a/src/test/run-pass/issue-10902.rs b/src/test/run-pass/issue-10902.rs index 324a1701b2fe..7fab6662ee01 100644 --- a/src/test/run-pass/issue-10902.rs +++ b/src/test/run-pass/issue-10902.rs @@ -9,7 +9,7 @@ // except according to those terms. pub mod two_tuple { - pub trait T {} + pub trait T { fn dummy(&self) { } } pub struct P<'a>(&'a (T + 'a), &'a (T + 'a)); pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { P(car, cdr) @@ -17,7 +17,7 @@ pub mod two_tuple { } pub mod two_fields { - pub trait T {} + pub trait T { fn dummy(&self) { } } pub struct P<'a> { car: &'a (T + 'a), cdr: &'a (T + 'a) } pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { P{ car: car, cdr: cdr } diff --git a/src/test/run-pass/issue-11205.rs b/src/test/run-pass/issue-11205.rs index d7c6c1b1bb2c..1325b51a54ff 100644 --- a/src/test/run-pass/issue-11205.rs +++ b/src/test/run-pass/issue-11205.rs @@ -12,7 +12,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -trait Foo {} +trait Foo { fn dummy(&self) { } } impl Foo for int {} fn foo(_: [&Foo; 2]) {} fn foos(_: &[&Foo]) {} diff --git a/src/test/run-pass/issue-11384.rs b/src/test/run-pass/issue-11384.rs index a511149b05e2..26634fabf5a1 100644 --- a/src/test/run-pass/issue-11384.rs +++ b/src/test/run-pass/issue-11384.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Common {} +trait Common { fn dummy(&self) { } } impl<'t, T> Common for (T, &'t T) {} diff --git a/src/test/run-pass/issue-11612.rs b/src/test/run-pass/issue-11612.rs index fa25d25df054..3c69377b375c 100644 --- a/src/test/run-pass/issue-11612.rs +++ b/src/test/run-pass/issue-11612.rs @@ -12,7 +12,7 @@ // We weren't updating the auto adjustments with all the resolved // type information after type check. -trait A {} +trait A { fn dummy(&self) { } } struct B<'a, T:'a> { f: &'a T diff --git a/src/test/run-pass/issue-11677.rs b/src/test/run-pass/issue-11677.rs index 6fa450586947..7cccac4483d4 100644 --- a/src/test/run-pass/issue-11677.rs +++ b/src/test/run-pass/issue-11677.rs @@ -14,13 +14,18 @@ // this code used to cause an ICE -trait X {} +use std::marker; + +trait X { + fn dummy(&self) -> T { panic!() } +} struct S {f: Box+'static>, g: Box+'static>} struct F; -impl X for F {} +impl X for F { +} fn main() { S {f: box F, g: box F}; diff --git a/src/test/run-pass/issue-13105.rs b/src/test/run-pass/issue-13105.rs index 7fab36bd64ec..64807dc44e06 100644 --- a/src/test/run-pass/issue-13105.rs +++ b/src/test/run-pass/issue-13105.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo { +use std::marker::MarkerTrait; + +trait Foo : MarkerTrait { fn quux(u8) {} } diff --git a/src/test/run-pass/issue-14399.rs b/src/test/run-pass/issue-14399.rs index 7e533c2cf86c..4f3db1352bbd 100644 --- a/src/test/run-pass/issue-14399.rs +++ b/src/test/run-pass/issue-14399.rs @@ -19,7 +19,7 @@ #[derive(Clone)] struct B1; -trait A {} +trait A : std::marker::MarkerTrait {} impl A for B1 {} fn main() { diff --git a/src/test/run-pass/issue-14589.rs b/src/test/run-pass/issue-14589.rs index d9763baa8265..71d88ee62151 100644 --- a/src/test/run-pass/issue-14589.rs +++ b/src/test/run-pass/issue-14589.rs @@ -17,17 +17,18 @@ fn main() { send::>(box Output(0)); Test::>::foo(box Output(0)); - Test::>.send(box Output(0)); + Test::>::new().send(box Output(0)); } fn send(_: T) {} -struct Test; +struct Test { marker: std::marker::PhantomData } impl Test { + fn new() -> Test { Test { marker: ::std::marker::PhantomData } } fn foo(_: T) {} fn send(&self, _: T) {} } -trait Foo {} +trait Foo { fn dummy(&self) { }} struct Output(int); impl Foo for Output {} diff --git a/src/test/run-pass/issue-14958.rs b/src/test/run-pass/issue-14958.rs index 814a743648d3..6335f79be6c7 100644 --- a/src/test/run-pass/issue-14958.rs +++ b/src/test/run-pass/issue-14958.rs @@ -10,7 +10,7 @@ #![feature(unboxed_closures)] -trait Foo {} +trait Foo { fn dummy(&self) { }} struct Bar; diff --git a/src/test/run-pass/issue-14959.rs b/src/test/run-pass/issue-14959.rs index 33281d7d78ff..53d0f7dae057 100644 --- a/src/test/run-pass/issue-14959.rs +++ b/src/test/run-pass/issue-14959.rs @@ -12,8 +12,8 @@ use std::ops::Fn; -trait Response {} -trait Request {} +trait Response { fn dummy(&self) { } } +trait Request { fn dummy(&self) { } } trait Ingot { fn enter(&mut self, _: &mut R, _: &mut S, a: &mut Alloy) -> Status; } @@ -21,7 +21,7 @@ trait Ingot { #[allow(dead_code)] struct HelloWorld; -struct SendFile<'a>; +struct SendFile; struct Alloy; enum Status { Continue @@ -33,7 +33,7 @@ impl Alloy { } } -impl<'a, 'b> Fn<(&'b mut (Response+'b),)> for SendFile<'a> { +impl<'b> Fn<(&'b mut (Response+'b),)> for SendFile { type Output = (); extern "rust-call" fn call(&self, (_res,): (&'b mut (Response+'b),)) {} diff --git a/src/test/run-pass/issue-15858.rs b/src/test/run-pass/issue-15858.rs index c75c67254612..6a4f78442d14 100644 --- a/src/test/run-pass/issue-15858.rs +++ b/src/test/run-pass/issue-15858.rs @@ -12,21 +12,21 @@ static mut DROP_RAN: bool = false; -trait Bar<'b> { +trait Bar { fn do_something(&mut self); } -struct BarImpl<'b>; +struct BarImpl; -impl<'b> Bar<'b> for BarImpl<'b> { +impl Bar for BarImpl { fn do_something(&mut self) {} } -struct Foo; +struct Foo(B); #[unsafe_destructor] -impl<'b, B: Bar<'b>> Drop for Foo { +impl Drop for Foo { fn drop(&mut self) { unsafe { DROP_RAN = true; @@ -37,7 +37,7 @@ impl<'b, B: Bar<'b>> Drop for Foo { fn main() { { - let _x: Foo = Foo; + let _x: Foo = Foo(BarImpl); } unsafe { assert_eq!(DROP_RAN, true); diff --git a/src/test/run-pass/issue-16596.rs b/src/test/run-pass/issue-16596.rs index e01de3a3262e..1ba7b142e5e1 100644 --- a/src/test/run-pass/issue-16596.rs +++ b/src/test/run-pass/issue-16596.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait MatrixRow {} +trait MatrixRow { fn dummy(&self) { }} struct Mat; diff --git a/src/test/run-pass/issue-16643.rs b/src/test/run-pass/issue-16643.rs index b118c9573cdc..4e57c55c5f75 100644 --- a/src/test/run-pass/issue-16643.rs +++ b/src/test/run-pass/issue-16643.rs @@ -13,5 +13,5 @@ extern crate "issue-16643" as i; pub fn main() { - i::TreeBuilder::.process_token(); + i::TreeBuilder { h: 3u }.process_token(); } diff --git a/src/test/run-pass/issue-17662.rs b/src/test/run-pass/issue-17662.rs index 34bcfeb10dec..196c148f1933 100644 --- a/src/test/run-pass/issue-17662.rs +++ b/src/test/run-pass/issue-17662.rs @@ -12,12 +12,14 @@ extern crate "issue-17662" as i; -struct Bar<'a>; +use std::marker; + +struct Bar<'a> { m: marker::PhantomData<&'a ()> } impl<'a> i::Foo<'a, uint> for Bar<'a> { fn foo(&self) -> uint { 5u } } pub fn main() { - assert_eq!(i::foo(&Bar), 5); + assert_eq!(i::foo(&Bar { m: marker::PhantomData }), 5); } diff --git a/src/test/run-pass/issue-17732.rs b/src/test/run-pass/issue-17732.rs index b4bd55da5975..de9611f25922 100644 --- a/src/test/run-pass/issue-17732.rs +++ b/src/test/run-pass/issue-17732.rs @@ -10,8 +10,9 @@ trait Person { type string; + fn dummy(&self) { } } -struct Someone; +struct Someone(std::marker::PhantomData

); fn main() {} diff --git a/src/test/run-pass/issue-17771.rs b/src/test/run-pass/issue-17771.rs index 1e9550acef4c..2f1b0342b8e0 100644 --- a/src/test/run-pass/issue-17771.rs +++ b/src/test/run-pass/issue-17771.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Aaa {} +trait Aaa { fn dummy(&self) { } } impl<'a> Aaa for &'a mut (Aaa + 'a) {} diff --git a/src/test/run-pass/issue-17816.rs b/src/test/run-pass/issue-17816.rs index f8fbd680dcb9..a976eccf89ec 100644 --- a/src/test/run-pass/issue-17816.rs +++ b/src/test/run-pass/issue-17816.rs @@ -10,9 +10,11 @@ #![feature(unboxed_closures)] +use std::marker::PhantomData; + fn main() { - struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F } + struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F, marker: PhantomData<&'a ()> } let f = |x: Vec<&str>| -> &str "foobar"; - let sym = Symbol { function: f }; + let sym = Symbol { function: f, marker: PhantomData }; (sym.function)(vec![]); } diff --git a/src/test/run-pass/issue-17904.rs b/src/test/run-pass/issue-17904.rs index 3ce347d67e3d..58a0872a5719 100644 --- a/src/test/run-pass/issue-17904.rs +++ b/src/test/run-pass/issue-17904.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo where T: Copy; +// Test that we can parse where clauses on various forms of tuple +// structs. + struct Bar(T) where T: Copy; struct Bleh(T, U) where T: Copy, U: Sized; struct Baz where T: Copy { diff --git a/src/test/run-pass/issue-18232.rs b/src/test/run-pass/issue-18232.rs index 15cf5870d40a..67b3239d3519 100644 --- a/src/test/run-pass/issue-18232.rs +++ b/src/test/run-pass/issue-18232.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Cursor<'a>; +struct Cursor<'a>(::std::marker::PhantomData<&'a ()>); trait CursorNavigator { fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool; @@ -23,7 +23,7 @@ impl CursorNavigator for SimpleNavigator { } fn main() { - let mut c = Cursor; + let mut c = Cursor(::std::marker::PhantomData); let n = SimpleNavigator; n.init_cursor(&mut c); } diff --git a/src/test/run-pass/issue-18906.rs b/src/test/run-pass/issue-18906.rs index 11ffb4198dad..16dd84315ed2 100644 --- a/src/test/run-pass/issue-18906.rs +++ b/src/test/run-pass/issue-18906.rs @@ -24,7 +24,7 @@ fn bar(k: &K, q: &Q) where K: Borrow, Q: Foo { q.foo(k.borrow()) } -struct MyTree; +struct MyTree(K); impl MyTree { // This caused a failure in #18906 diff --git a/src/test/run-pass/issue-19121.rs b/src/test/run-pass/issue-19121.rs index d95f74ef2a2b..222f67af437e 100644 --- a/src/test/run-pass/issue-19121.rs +++ b/src/test/run-pass/issue-19121.rs @@ -13,6 +13,8 @@ trait Foo { type A; + + fn dummy(&self) { } } fn bar(x: &Foo) {} diff --git a/src/test/run-pass/issue-19129-2.rs b/src/test/run-pass/issue-19129-2.rs index d6b3a1908b82..cf0f48e025a0 100644 --- a/src/test/run-pass/issue-19129-2.rs +++ b/src/test/run-pass/issue-19129-2.rs @@ -11,7 +11,7 @@ trait Trait { type Output; - fn method() -> bool { false } + fn method(&self, i: Input) -> bool { false } } fn main() {} diff --git a/src/test/run-pass/issue-19135.rs b/src/test/run-pass/issue-19135.rs index 031a63ba474c..5e6dd567d632 100644 --- a/src/test/run-pass/issue-19135.rs +++ b/src/test/run-pass/issue-19135.rs @@ -10,13 +10,15 @@ #![feature(unboxed_closures)] +use std::marker::PhantomData; + #[derive(Debug)] -struct LifetimeStruct<'a>; +struct LifetimeStruct<'a>(PhantomData<&'a ()>); fn main() { takes_hrtb_closure(|lts| println!("{:?}", lts)); } fn takes_hrtb_closureFnMut(LifetimeStruct<'a>)>(mut f: F) { - f(LifetimeStruct); + f(LifetimeStruct(PhantomData)); } diff --git a/src/test/run-pass/issue-19358.rs b/src/test/run-pass/issue-19358.rs index ff657376ecc1..8b5269ab92f0 100644 --- a/src/test/run-pass/issue-19358.rs +++ b/src/test/run-pass/issue-19358.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Trait {} +trait Trait { fn dummy(&self) { } } #[derive(Debug)] struct Foo { diff --git a/src/test/run-pass/issue-19398.rs b/src/test/run-pass/issue-19398.rs index 1196162568a9..e603167b26be 100644 --- a/src/test/run-pass/issue-19398.rs +++ b/src/test/run-pass/issue-19398.rs @@ -9,11 +9,11 @@ // except according to those terms. trait T { - unsafe extern "Rust" fn foo(); + unsafe extern "Rust" fn foo(&self); } impl T for () { - unsafe extern "Rust" fn foo() {} + unsafe extern "Rust" fn foo(&self) {} } fn main() {} diff --git a/src/test/run-pass/issue-19479.rs b/src/test/run-pass/issue-19479.rs index 91bc645b2d48..38a7af3a6959 100644 --- a/src/test/run-pass/issue-19479.rs +++ b/src/test/run-pass/issue-19479.rs @@ -8,12 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Base {} +trait Base { + fn dummy(&self) { } +} trait AssocA { type X: Base; + fn dummy(&self) { } } trait AssocB { type Y: Base; + fn dummy(&self) { } } impl AssocB for T { type Y = ::X; diff --git a/src/test/run-pass/issue-19631.rs b/src/test/run-pass/issue-19631.rs index 43116f63641d..7bb0d055b844 100644 --- a/src/test/run-pass/issue-19631.rs +++ b/src/test/run-pass/issue-19631.rs @@ -10,6 +10,7 @@ trait PoolManager { type C; + fn dummy(&self) { } } struct InnerPool { diff --git a/src/test/run-pass/issue-19632.rs b/src/test/run-pass/issue-19632.rs index 01a073a6889a..4339339d74c8 100644 --- a/src/test/run-pass/issue-19632.rs +++ b/src/test/run-pass/issue-19632.rs @@ -10,6 +10,7 @@ trait PoolManager { type C; + fn dummy(&self) { } } struct InnerPool { diff --git a/src/test/run-pass/issue-20055-box-trait.rs b/src/test/run-pass/issue-20055-box-trait.rs index 836e78b5b514..572a0d825282 100644 --- a/src/test/run-pass/issue-20055-box-trait.rs +++ b/src/test/run-pass/issue-20055-box-trait.rs @@ -16,7 +16,9 @@ // whichever arm is run, and subsequently dropped at the end of the // statement surrounding the `match`. -trait Boo { } +trait Boo { + fn dummy(&self) { } +} impl Boo for [i8; 1] { } impl Boo for [i8; 2] { } diff --git a/src/test/run-pass/issue-20343.rs b/src/test/run-pass/issue-20343.rs index 79034a4a4a6d..2f9e8feed248 100644 --- a/src/test/run-pass/issue-20343.rs +++ b/src/test/run-pass/issue-20343.rs @@ -16,7 +16,7 @@ struct B { b: u32 } struct C; struct D; -trait T {} +trait T { fn dummy(&self, a: A) { } } impl T for () {} impl B { diff --git a/src/test/run-pass/issue-20763-1.rs b/src/test/run-pass/issue-20763-1.rs index 911ee715da28..97c06ac98265 100644 --- a/src/test/run-pass/issue-20763-1.rs +++ b/src/test/run-pass/issue-20763-1.rs @@ -8,7 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait T0 { type O; } +trait T0 { + type O; + fn dummy(&self) { } +} struct S(A); impl T0 for S { type O = A; } diff --git a/src/test/run-pass/issue-20763-2.rs b/src/test/run-pass/issue-20763-2.rs index a17c7b6ade48..d97017635718 100644 --- a/src/test/run-pass/issue-20763-2.rs +++ b/src/test/run-pass/issue-20763-2.rs @@ -8,7 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait T0 { type O; } +trait T0 { + type O; + fn dummy(&self) { } +} struct S(A); impl T0 for S { type O = A; } diff --git a/src/test/run-pass/issue-21363.rs b/src/test/run-pass/issue-21363.rs index 2fc1d9fd6433..71bb3d39fe1d 100644 --- a/src/test/run-pass/issue-21363.rs +++ b/src/test/run-pass/issue-21363.rs @@ -12,6 +12,7 @@ trait Iterator { type Item; + fn dummy(&self) { } } impl<'a, T> Iterator for &'a mut (Iterator + 'a) { diff --git a/src/test/run-pass/issue-21909.rs b/src/test/run-pass/issue-21909.rs index 5bbc90b26063..55b61dd19455 100644 --- a/src/test/run-pass/issue-21909.rs +++ b/src/test/run-pass/issue-21909.rs @@ -8,11 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait A {} +trait A { + fn dummy(&self, arg: X); +} trait B { type X; type Y: A; + + fn dummy(&self); } fn main () { } diff --git a/src/test/run-pass/issue-2311-2.rs b/src/test/run-pass/issue-2311-2.rs index e0b98ab19652..5529d51b408c 100644 --- a/src/test/run-pass/issue-2311-2.rs +++ b/src/test/run-pass/issue-2311-2.rs @@ -8,7 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait clam { } +trait clam { + fn get(self) -> A; +} + struct foo { x: A, } diff --git a/src/test/run-pass/issue-2311.rs b/src/test/run-pass/issue-2311.rs index dc873ed08d70..b6b3114e2a48 100644 --- a/src/test/run-pass/issue-2311.rs +++ b/src/test/run-pass/issue-2311.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait clam { } +trait clam { fn get(self) -> A; } trait foo { fn bar>(&self, c: C) -> B; } diff --git a/src/test/run-pass/issue-2312.rs b/src/test/run-pass/issue-2312.rs index 8c597552d75a..3f273b56efd6 100644 --- a/src/test/run-pass/issue-2312.rs +++ b/src/test/run-pass/issue-2312.rs @@ -10,7 +10,7 @@ // Testing that the B's are resolved -trait clam { } +trait clam { fn get(self) -> A; } struct foo(int); diff --git a/src/test/run-pass/issue-2611-3.rs b/src/test/run-pass/issue-2611-3.rs index 2608c89d1556..c005699ce30b 100644 --- a/src/test/run-pass/issue-2611-3.rs +++ b/src/test/run-pass/issue-2611-3.rs @@ -12,7 +12,7 @@ // than the traits require. trait A { - fn b(x: C) -> C; + fn b(&self, x: C) -> C; } struct E { @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { panic!() } + fn b(&self, _x: F) -> F { panic!() } //~^ ERROR in method `b`, type parameter 0 has 1 bound, but } diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 7ca439a1a19d..a7b53db6b055 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -11,7 +11,9 @@ #![allow(unknown_features)] #![feature(box_syntax)] -trait hax { } +trait hax { + fn dummy(&self) { } +} impl hax for A { } fn perform_hax(x: Box) -> Box { diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index 962359537bf2..1594b94879ce 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -11,7 +11,9 @@ #![allow(unknown_features)] #![feature(box_syntax)] -trait hax { } +trait hax { + fn dummy(&self) { } +} impl hax for A { } fn perform_hax(x: Box) -> Box { diff --git a/src/test/run-pass/issue-4107.rs b/src/test/run-pass/issue-4107.rs index 2ed662e9f2d6..d660f300ada9 100644 --- a/src/test/run-pass/issue-4107.rs +++ b/src/test/run-pass/issue-4107.rs @@ -9,14 +9,14 @@ // except according to those terms. pub fn main() { - let _id: &Mat2 = &Matrix::identity(); + let _id: &Mat2 = &Matrix::identity(1.0); } -pub trait Index { } +pub trait Index { fn get(&self, Index) -> Result { panic!() } } pub trait Dimensional: Index { } -pub struct Mat2 { x: () } -pub struct Vec2 { x: () } +pub struct Mat2 { x: T } +pub struct Vec2 { x: T } impl Dimensional> for Mat2 { } impl Index> for Mat2 { } @@ -25,9 +25,9 @@ impl Dimensional for Vec2 { } impl Index for Vec2 { } pub trait Matrix: Dimensional { - fn identity() -> Self; + fn identity(t:T) -> Self; } impl Matrix> for Mat2 { - fn identity() -> Mat2 { Mat2{ x: () } } + fn identity(t:T) -> Mat2 { Mat2{ x: t } } } diff --git a/src/test/run-pass/issue-5192.rs b/src/test/run-pass/issue-5192.rs index bb79cd4d0466..a6f3771bf62b 100644 --- a/src/test/run-pass/issue-5192.rs +++ b/src/test/run-pass/issue-5192.rs @@ -12,6 +12,7 @@ #![feature(box_syntax)] pub trait EventLoop { + fn dummy(&self) { } } pub struct UvEventLoop { diff --git a/src/test/run-pass/issue-5708.rs b/src/test/run-pass/issue-5708.rs index fd39bcc6b612..59bca87bed0b 100644 --- a/src/test/run-pass/issue-5708.rs +++ b/src/test/run-pass/issue-5708.rs @@ -48,7 +48,9 @@ pub fn main() { // minimal -pub trait MyTrait { } +pub trait MyTrait { + fn dummy(&self, t: T) -> T { panic!() } +} pub struct MyContainer<'a, T> { foos: Vec<&'a (MyTrait+'a)> , diff --git a/src/test/run-pass/issue-6128.rs b/src/test/run-pass/issue-6128.rs index d96862b588f9..1746a6281dc2 100644 --- a/src/test/run-pass/issue-6128.rs +++ b/src/test/run-pass/issue-6128.rs @@ -17,6 +17,7 @@ use std::collections::HashMap; trait Graph { fn f(&self, Edge); + fn g(&self, Node); } @@ -24,6 +25,9 @@ impl Graph for HashMap { fn f(&self, _e: E) { panic!(); } + fn g(&self, _e: int) { + panic!(); + } } pub fn main() { diff --git a/src/test/run-pass/issue-6318.rs b/src/test/run-pass/issue-6318.rs index 1d8fe8bfce82..6e608d34bd57 100644 --- a/src/test/run-pass/issue-6318.rs +++ b/src/test/run-pass/issue-6318.rs @@ -15,7 +15,9 @@ pub enum Thing { A(Box) } -pub trait Foo {} +pub trait Foo { + fn dummy(&self) { } +} pub struct Struct; diff --git a/src/test/run-pass/issue-7575.rs b/src/test/run-pass/issue-7575.rs index 225213db6a42..77cfc7f0cf60 100644 --- a/src/test/run-pass/issue-7575.rs +++ b/src/test/run-pass/issue-7575.rs @@ -10,6 +10,7 @@ trait Foo { fn new() -> bool { false } + fn dummy(&self) { } } trait Bar { diff --git a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs index b6dfbb1ca42a..736860947f23 100644 --- a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs +++ b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs @@ -19,7 +19,10 @@ pub fn main() {} -trait A {} +trait A { + fn dummy(&self) { } +} + impl A for T {} fn owned2(a: Box) { a as Box; } diff --git a/src/test/run-pass/issue-7911.rs b/src/test/run-pass/issue-7911.rs index 86948ebcb91e..3eb593708bee 100644 --- a/src/test/run-pass/issue-7911.rs +++ b/src/test/run-pass/issue-7911.rs @@ -14,7 +14,9 @@ // with different mutability in macro in two methods #![allow(unused_variable)] // unused foobar_immut + foobar_mut -trait FooBar {} +trait FooBar { + fn dummy(&self) { } +} struct Bar(i32); struct Foo { bar: Bar } diff --git a/src/test/run-pass/issue-8248.rs b/src/test/run-pass/issue-8248.rs index 377b9ce262c7..7bc8dbe616ff 100644 --- a/src/test/run-pass/issue-8248.rs +++ b/src/test/run-pass/issue-8248.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait A {} +trait A { + fn dummy(&self) { } +} struct B; impl A for B {} diff --git a/src/test/run-pass/issue-8249.rs b/src/test/run-pass/issue-8249.rs index 44f07def531b..83c9e9bf4505 100644 --- a/src/test/run-pass/issue-8249.rs +++ b/src/test/run-pass/issue-8249.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait A {} +trait A { + fn dummy(&self) { } +} struct B; impl A for B {} diff --git a/src/test/run-pass/issue-9719.rs b/src/test/run-pass/issue-9719.rs index 8fc86eb49e76..aa1e65efaa41 100644 --- a/src/test/run-pass/issue-9719.rs +++ b/src/test/run-pass/issue-9719.rs @@ -13,7 +13,9 @@ mod a { A(T), } - pub trait X {} + pub trait X { + fn dummy(&self) { } + } impl X for int {} pub struct Z<'a>(Enum<&'a (X+'a)>); @@ -21,7 +23,9 @@ mod a { } mod b { - trait X {} + trait X { + fn dummy(&self) { } + } impl X for int {} struct Y<'a>{ x:Option<&'a (X+'a)>, diff --git a/src/test/run-pass/lint-cstack.rs b/src/test/run-pass/lint-cstack.rs index 2194453aac29..f180ffcd4e82 100644 --- a/src/test/run-pass/lint-cstack.rs +++ b/src/test/run-pass/lint-cstack.rs @@ -15,7 +15,7 @@ extern { } trait A { - fn foo() { + fn foo(&self) { unsafe { rust_get_test_int(); } diff --git a/src/test/run-pass/method-early-bound-lifetimes-on-self.rs b/src/test/run-pass/method-early-bound-lifetimes-on-self.rs index 25ce0d774ebc..cec9753a2fec 100644 --- a/src/test/run-pass/method-early-bound-lifetimes-on-self.rs +++ b/src/test/run-pass/method-early-bound-lifetimes-on-self.rs @@ -13,7 +13,11 @@ #![allow(dead_code)] -struct Cursor<'a>; +use std::marker; + +struct Cursor<'a> { + m: marker::PhantomData<&'a ()> +} trait CursorNavigator { fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool; @@ -28,7 +32,7 @@ impl CursorNavigator for SimpleNavigator { } fn main() { - let mut c = Cursor; + let mut c = Cursor { m: marker::PhantomData }; let n = SimpleNavigator; n.init_cursor(&mut c); } diff --git a/src/test/run-pass/method-recursive-blanket-impl.rs b/src/test/run-pass/method-recursive-blanket-impl.rs index 338bd89ab5cb..15eb2ae2e4b4 100644 --- a/src/test/run-pass/method-recursive-blanket-impl.rs +++ b/src/test/run-pass/method-recursive-blanket-impl.rs @@ -17,16 +17,16 @@ use std::marker::Sized; // Note: this must be generic for the problem to show up trait Foo { - fn foo(&self); + fn foo(&self, a: A); } impl Foo for [u8] { - fn foo(&self) {} + fn foo(&self, a: u8) {} } impl<'a, A, T> Foo for &'a T where T: Foo { - fn foo(&self) { - Foo::foo(*self) + fn foo(&self, a: A) { + Foo::foo(*self, a) } } diff --git a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs index eb17aa78bd9a..1164ef1a3c98 100644 --- a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs +++ b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::marker::MarkerTrait; -trait Serializer { +trait Serializer : MarkerTrait { } trait Serializable { diff --git a/src/test/run-pass/overloaded-autoderef-vtable.rs b/src/test/run-pass/overloaded-autoderef-vtable.rs index be2b309b8217..d50f2efe0e7b 100644 --- a/src/test/run-pass/overloaded-autoderef-vtable.rs +++ b/src/test/run-pass/overloaded-autoderef-vtable.rs @@ -11,7 +11,8 @@ use std::ops::Deref; struct DerefWithHelper { - helper: H + helper: H, + value: T } trait Helper { @@ -39,6 +40,7 @@ impl Foo { } pub fn main() { - let x: DerefWithHelper, Foo> = DerefWithHelper { helper: Some(Foo {x: 5}) }; + let x: DerefWithHelper, Foo> = + DerefWithHelper { helper: Some(Foo {x: 5}), value: Foo { x: 2 } }; assert!(x.foo() == 5); } diff --git a/src/test/run-pass/overloaded-calls-param-vtables.rs b/src/test/run-pass/overloaded-calls-param-vtables.rs index 2838909c1be6..2ef9e08134cf 100644 --- a/src/test/run-pass/overloaded-calls-param-vtables.rs +++ b/src/test/run-pass/overloaded-calls-param-vtables.rs @@ -12,10 +12,11 @@ #![feature(unboxed_closures)] +use std::marker::PhantomData; use std::ops::Fn; use std::ops::Add; -struct G; +struct G(PhantomData); impl<'a, A: Add> Fn<(A,)> for G { type Output = i32; @@ -27,5 +28,5 @@ impl<'a, A: Add> Fn<(A,)> for G { fn main() { // ICE trigger - G(1_i32); + (G(PhantomData))(1_i32); } diff --git a/src/test/run-pass/parameterized-trait-with-bounds.rs b/src/test/run-pass/parameterized-trait-with-bounds.rs index 840e58848a74..061c9168955a 100644 --- a/src/test/run-pass/parameterized-trait-with-bounds.rs +++ b/src/test/run-pass/parameterized-trait-with-bounds.rs @@ -11,12 +11,12 @@ #![allow(dead_code)] -trait A {} -trait B {} -trait C<'a, U> {} +trait A { fn get(self) -> T; } +trait B { fn get(self) -> (T,U); } +trait C<'a, U> { fn get(self) -> &'a U; } mod foo { - pub trait D<'a, T> {} + pub trait D<'a, T> { fn get(self) -> &'a T; } } fn foo1(_: &(A + Send)) {} diff --git a/src/test/run-pass/privacy-ns.rs b/src/test/run-pass/privacy-ns.rs index f3380352f5fa..e9b8e694d606 100644 --- a/src/test/run-pass/privacy-ns.rs +++ b/src/test/run-pass/privacy-ns.rs @@ -19,6 +19,7 @@ // public type, private value pub mod foo1 { pub trait Bar { + fn dummy(&self) { } } pub struct Baz; @@ -50,6 +51,7 @@ fn test_glob1() { // private type, public value pub mod foo2 { trait Bar { + fn dummy(&self) { } } pub struct Baz; @@ -81,6 +83,7 @@ fn test_glob2() { // public type, public value pub mod foo3 { pub trait Bar { + fn dummy(&self) { } } pub struct Baz; diff --git a/src/test/run-pass/regions-assoc-type-static-bound.rs b/src/test/run-pass/regions-assoc-type-static-bound.rs index 6b629a9035db..80ae371e5091 100644 --- a/src/test/run-pass/regions-assoc-type-static-bound.rs +++ b/src/test/run-pass/regions-assoc-type-static-bound.rs @@ -11,7 +11,10 @@ // Test that the compiler considers the 'static bound declared in the // trait. Issue #20890. -trait Foo { type Value: 'static; } +trait Foo { + type Value: 'static; + fn dummy(&self) { } +} fn require_static() {} diff --git a/src/test/run-pass/regions-bound-lists-feature-gate-2.rs b/src/test/run-pass/regions-bound-lists-feature-gate-2.rs index 0a95a89d57c3..a06e0f6da785 100644 --- a/src/test/run-pass/regions-bound-lists-feature-gate-2.rs +++ b/src/test/run-pass/regions-bound-lists-feature-gate-2.rs @@ -12,7 +12,9 @@ #![feature(issue_5723_bootstrap)] -trait Foo { } +trait Foo { + fn dummy(&self) { } +} fn foo<'a, 'b, 'c:'a+'b, 'd>() { } diff --git a/src/test/run-pass/regions-bound-lists-feature-gate.rs b/src/test/run-pass/regions-bound-lists-feature-gate.rs index c5baecf7272f..996583dc6de9 100644 --- a/src/test/run-pass/regions-bound-lists-feature-gate.rs +++ b/src/test/run-pass/regions-bound-lists-feature-gate.rs @@ -12,8 +12,9 @@ #![feature(issue_5723_bootstrap)] - -trait Foo { } +trait Foo { + fn dummy(&self) { } +} fn foo<'a>(x: Box) { } 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 978383c24478..bdc0d41c94e8 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 @@ -14,6 +14,8 @@ // lifetime parameters must be early bound in the type of the // associated item. +use std::marker; + pub enum Value<'v> { A(&'v str), B, @@ -23,7 +25,9 @@ pub trait Decoder<'v> { fn read(&mut self) -> Value<'v>; } -pub trait Decodable<'v, D: Decoder<'v>> { +pub trait Decodable<'v, D: Decoder<'v>> + : marker::PhantomFn<(), &'v int> +{ fn decode(d: &mut D) -> Self; } diff --git a/src/test/run-pass/regions-early-bound-trait-param.rs b/src/test/run-pass/regions-early-bound-trait-param.rs index 6fcfaf58a023..3f434a4838d4 100644 --- a/src/test/run-pass/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions-early-bound-trait-param.rs @@ -53,11 +53,11 @@ fn field_invoke2<'l, 'm, 'n>(x: &'n Struct2<'l,'m>) -> int { x.f.short() } -trait MakerTrait<'o> { +trait MakerTrait { fn mk() -> Self; } -fn make_val<'p, T:MakerTrait<'p>>() -> T { +fn make_val() -> T { MakerTrait::mk() } @@ -80,7 +80,7 @@ impl<'s> Trait<'s> for (int,int) { } } -impl<'t> MakerTrait<'t> for Box+'static> { +impl<'t> MakerTrait for Box+'static> { fn mk() -> Box+'static> { box() (4,5) as Box } } diff --git a/src/test/run-pass/regions-infer-bivariance.rs b/src/test/run-pass/regions-infer-bivariance.rs deleted file mode 100644 index a3288e2e1b90..000000000000 --- a/src/test/run-pass/regions-infer-bivariance.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 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. - -// Test that a type whose lifetime parameters is never used is -// inferred to be bivariant. - -use std::marker; - -struct Bivariant<'a>; - -fn use1<'short,'long>(c: Bivariant<'short>, - _where:Option<&'short &'long ()>) { - let _: Bivariant<'long> = c; -} - -fn use2<'short,'long>(c: Bivariant<'long>, - _where:Option<&'short &'long ()>) { - let _: Bivariant<'short> = c; -} - -pub fn main() {} diff --git a/src/test/run-pass/regions-no-bound-in-argument-cleanup.rs b/src/test/run-pass/regions-no-bound-in-argument-cleanup.rs index d3464f01203a..5964ac65d5f6 100644 --- a/src/test/run-pass/regions-no-bound-in-argument-cleanup.rs +++ b/src/test/run-pass/regions-no-bound-in-argument-cleanup.rs @@ -10,7 +10,9 @@ #![feature(unsafe_destructor)] -pub struct Foo; +use std::marker; + +pub struct Foo(marker::PhantomData); impl Iterator for Foo { type Item = T; diff --git a/src/test/run-pass/regions-no-variance-from-fn-generics.rs b/src/test/run-pass/regions-no-variance-from-fn-generics.rs index a35ab1bfc0ce..80c478afa644 100644 --- a/src/test/run-pass/regions-no-variance-from-fn-generics.rs +++ b/src/test/run-pass/regions-no-variance-from-fn-generics.rs @@ -12,7 +12,9 @@ // should not upset the variance inference for actual occurrences of // that lifetime in type expressions. -pub trait HasLife<'a> { } +pub trait HasLife<'a> { + fn dummy(&'a self) { } // just to induce a variance on 'a +} trait UseLife01 { fn refs<'a, H: HasLife<'a>>(&'a self) -> H; @@ -23,7 +25,11 @@ trait UseLife02 { } -pub trait HasType { } +pub trait HasType +{ + fn dummy(&self, t: T) -> T { panic!() } +} + trait UseLife03 { fn refs<'a, H: HasType<&'a T>>(&'a self) -> H; diff --git a/src/test/run-pass/self-impl.rs b/src/test/run-pass/self-impl.rs index 40a4dc52a70b..af2b2de8ab8b 100644 --- a/src/test/run-pass/self-impl.rs +++ b/src/test/run-pass/self-impl.rs @@ -29,6 +29,7 @@ pub struct Baz { trait Bar { fn bar(x: Self, y: &Self, z: Box) -> Self; + fn dummy(&self, x: X) { } } impl Bar for Box> { diff --git a/src/test/run-pass/simple-match-generic-tag.rs b/src/test/run-pass/simple-match-generic-tag.rs index 7ed8cb434caf..2217dddbd21f 100644 --- a/src/test/run-pass/simple-match-generic-tag.rs +++ b/src/test/run-pass/simple-match-generic-tag.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - -enum opt { none, } +enum opt { none, some(T) } pub fn main() { let x = opt::none::; - match x { opt::none:: => { println!("hello world"); } } + match x { + opt::none:: => { println!("hello world"); } + opt::some(_) => { } + } } diff --git a/src/test/run-pass/syntax-trait-polarity.rs b/src/test/run-pass/syntax-trait-polarity.rs index 3344844d49ff..340ad2a531a7 100644 --- a/src/test/run-pass/syntax-trait-polarity.rs +++ b/src/test/run-pass/syntax-trait-polarity.rs @@ -10,17 +10,17 @@ #![feature(optin_builtin_traits)] -use std::marker::Send; +use std::marker::{MarkerTrait, Send}; struct TestType; impl TestType {} -trait TestTrait {} +trait TestTrait : MarkerTrait {} impl !Send for TestType {} -struct TestType2; +struct TestType2(T); impl TestType2 {} diff --git a/src/test/run-pass/trailing-comma.rs b/src/test/run-pass/trailing-comma.rs index b5ae259bc630..76c62a83e758 100644 --- a/src/test/run-pass/trailing-comma.rs +++ b/src/test/run-pass/trailing-comma.rs @@ -12,7 +12,7 @@ fn f(_: T,) {} -struct Foo; +struct Foo(T); struct Bar; @@ -34,7 +34,7 @@ pub fn main() { let [_, _, .., _,] = [1, 1, 1, 1,]; let [_, _, _.., _,] = [1, 1, 1, 1,]; - let x: Foo = Foo::; + let x: Foo = Foo::(1); Bar::f(0,); Bar.g(0,); diff --git a/src/test/run-pass/trait-bounds-basic.rs b/src/test/run-pass/trait-bounds-basic.rs index d03496403ad2..ed25bf8b02e8 100644 --- a/src/test/run-pass/trait-bounds-basic.rs +++ b/src/test/run-pass/trait-bounds-basic.rs @@ -9,7 +9,7 @@ // except according to those terms. -trait Foo { +trait Foo : ::std::marker::MarkerTrait { } fn b(_x: Box) { diff --git a/src/test/run-pass/trait-bounds-on-structs-and-enums.rs b/src/test/run-pass/trait-bounds-on-structs-and-enums.rs index e3234f037547..976120908b27 100644 --- a/src/test/run-pass/trait-bounds-on-structs-and-enums.rs +++ b/src/test/run-pass/trait-bounds-on-structs-and-enums.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait U {} -trait T {} +trait U : ::std::marker::MarkerTrait {} +trait T { fn get(self) -> X; } -trait S2 { +trait S2 : ::std::marker::MarkerTrait { fn m(x: Box+'static>) {} } diff --git a/src/test/run-pass/trait-bounds-recursion.rs b/src/test/run-pass/trait-bounds-recursion.rs index 49f8999cd45e..7135dad7d190 100644 --- a/src/test/run-pass/trait-bounds-recursion.rs +++ b/src/test/run-pass/trait-bounds-recursion.rs @@ -10,17 +10,17 @@ trait I { fn i(&self) -> Self; } -trait A { +trait A : ::std::marker::MarkerTrait { fn id(x:T) -> T { x.i() } } -trait J { fn j(&self) -> Self; } +trait J { fn j(&self) -> T; } -trait B> { +trait B> : ::std::marker::MarkerTrait { fn id(x:T) -> T { x.j() } } -trait C { +trait C : ::std::marker::MarkerTrait { fn id>(x:T) -> T { x.j() } } diff --git a/src/test/run-pass/trait-default-method-bound-subst4.rs b/src/test/run-pass/trait-default-method-bound-subst4.rs index fdc42e58f8ca..c9165050b932 100644 --- a/src/test/run-pass/trait-default-method-bound-subst4.rs +++ b/src/test/run-pass/trait-default-method-bound-subst4.rs @@ -11,6 +11,7 @@ trait A { fn g(&self, x: uint) -> uint { x } + fn h(&self, x: T) { } } impl A for int { } diff --git a/src/test/run-pass/trait-impl.rs b/src/test/run-pass/trait-impl.rs index 16ef315c206d..bd2bf430a686 100644 --- a/src/test/run-pass/trait-impl.rs +++ b/src/test/run-pass/trait-impl.rs @@ -16,7 +16,8 @@ use traitimpl::Bar; static mut COUNT: uint = 1; -trait T {} +trait T : ::std::marker::MarkerTrait { +} impl<'a> T+'a { fn foo(&self) { diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs index 1e6e7227a067..f89eea46090d 100644 --- a/src/test/run-pass/trait-inheritance-num2.rs +++ b/src/test/run-pass/trait-inheritance-num2.rs @@ -14,8 +14,7 @@ use std::cmp::{PartialEq, PartialOrd}; use std::num::NumCast; -pub trait TypeExt {} - +pub trait TypeExt : ::std::marker::MarkerTrait { } impl TypeExt for u8 {} impl TypeExt for u16 {} diff --git a/src/test/run-pass/trait-inheritance-static2.rs b/src/test/run-pass/trait-inheritance-static2.rs index 3b454aad03e4..8f3b325a513f 100644 --- a/src/test/run-pass/trait-inheritance-static2.rs +++ b/src/test/run-pass/trait-inheritance-static2.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait MyEq { } +pub trait MyEq : ::std::marker::MarkerTrait { } -pub trait MyNum { +pub trait MyNum : ::std::marker::MarkerTrait { fn from_int(int) -> Self; } diff --git a/src/test/run-pass/trait-object-generics.rs b/src/test/run-pass/trait-object-generics.rs index 76352c799a0f..6f89490716f0 100644 --- a/src/test/run-pass/trait-object-generics.rs +++ b/src/test/run-pass/trait-object-generics.rs @@ -13,11 +13,14 @@ #![allow(unknown_features)] #![feature(box_syntax)] +use std::marker; + pub trait Trait2 { - fn doit(&self); + fn doit(&self) -> A; } pub struct Impl { + m1: marker::PhantomData<(A1,A2,A3)>, /* * With A2 we get the ICE: * task failed at 'index out of bounds: the len is 1 but the index is 1', @@ -28,13 +31,13 @@ pub struct Impl { impl Impl { pub fn step(&self) { - self.t.doit() + self.t.doit(); } } // test for #8601 -enum Type { Constant } +enum Type { Constant(T) } trait Trait { fn method(&self,Type<(K,V)>) -> int; @@ -46,5 +49,5 @@ impl Trait for () { pub fn main() { let a = box() () as Box>; - assert_eq!(a.method(Type::Constant), 0); + assert_eq!(a.method(Type::Constant((1u8, 2u8))), 0); } diff --git a/src/test/run-pass/trait-static-method-overwriting.rs b/src/test/run-pass/trait-static-method-overwriting.rs index a8cea24db0c0..10439d5c86aa 100644 --- a/src/test/run-pass/trait-static-method-overwriting.rs +++ b/src/test/run-pass/trait-static-method-overwriting.rs @@ -10,7 +10,7 @@ // except according to those terms. mod base { - pub trait HasNew { + pub trait HasNew { fn new() -> Self; } @@ -18,7 +18,7 @@ mod base { dummy: (), } - impl ::base::HasNew for Foo { + impl ::base::HasNew for Foo { fn new() -> Foo { println!("Foo"); Foo { dummy: () } @@ -29,7 +29,7 @@ mod base { dummy: (), } - impl ::base::HasNew for Bar { + impl ::base::HasNew for Bar { fn new() -> Bar { println!("Bar"); Bar { dummy: () } @@ -38,6 +38,6 @@ mod base { } pub fn main() { - let _f: base::Foo = base::HasNew::::new(); - let _b: base::Bar = base::HasNew::::new(); + let _f: base::Foo = base::HasNew::new(); + let _b: base::Bar = base::HasNew::new(); } diff --git a/src/test/run-pass/unboxed-closures-infer-recursive-fn.rs b/src/test/run-pass/unboxed-closures-infer-recursive-fn.rs index 1f9b821178c4..2d1ba7f39b27 100644 --- a/src/test/run-pass/unboxed-closures-infer-recursive-fn.rs +++ b/src/test/run-pass/unboxed-closures-infer-recursive-fn.rs @@ -10,7 +10,7 @@ #![feature(core,unboxed_closures)] -use std::marker::CovariantType; +use std::marker::PhantomData; // Test that we are able to infer a suitable kind for a "recursive" // closure. As far as I can tell, coding up a recursive closure @@ -20,12 +20,12 @@ use std::marker::CovariantType; struct YCombinator { func: F, - marker: CovariantType<(A,R)>, + marker: PhantomData<(A,R)>, } impl YCombinator { fn new(f: F) -> YCombinator { - YCombinator { func: f, marker: CovariantType } + YCombinator { func: f, marker: PhantomData } } } diff --git a/src/test/run-pass/unique-object-move.rs b/src/test/run-pass/unique-object-move.rs index cec523a06712..1d4eb0a75232 100644 --- a/src/test/run-pass/unique-object-move.rs +++ b/src/test/run-pass/unique-object-move.rs @@ -13,7 +13,7 @@ #![allow(unknown_features)] #![feature(box_syntax)] -pub trait EventLoop { } +pub trait EventLoop : ::std::marker::MarkerTrait { } pub struct UvEventLoop { uvio: int diff --git a/src/test/run-pass/unsized.rs b/src/test/run-pass/unsized.rs index e6dd8d46952e..ae175d27b0a4 100644 --- a/src/test/run-pass/unsized.rs +++ b/src/test/run-pass/unsized.rs @@ -12,17 +12,19 @@ // Test syntax checks for `?Sized` syntax. -trait T1 {} -pub trait T2 {} -trait T3 : T2 {} -trait T4 {} -trait T5 {} -trait T6 {} -trait T7 {} -trait T8 {} -trait T9 {} -struct S1; -enum E {} +use std::marker::{PhantomData, PhantomFn}; + +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)> {} +struct S1(PhantomData); +enum E { E1(PhantomData) } impl T1 for S1 {} fn f() {} type TT = T; diff --git a/src/test/run-pass/unsized2.rs b/src/test/run-pass/unsized2.rs index 285100dd7197..10b2f2fb7092 100644 --- a/src/test/run-pass/unsized2.rs +++ b/src/test/run-pass/unsized2.rs @@ -15,6 +15,8 @@ // Test sized-ness checking in substitution. +use std::marker; + // Unbounded. fn f1(x: &X) { f1::(x); @@ -25,7 +27,7 @@ fn f2(x: &X) { } // Bounded. -trait T {} +trait T { fn dummy(&self) { } } fn f3(x: &X) { f3::(x); } @@ -66,20 +68,24 @@ fn f7(x: &X) { } trait T4 { - fn m1(x: &T4); - fn m2(x: &T5); + fn dummy(&self) { } + fn m1(x: &T4, y: X); + fn m2(x: &T5, y: X); } trait T5 { + fn dummy(&self) { } // not an error (for now) fn m1(x: &T4); fn m2(x: &T5); } trait T6 { + fn dummy(&self) { } fn m1(x: &T4); fn m2(x: &T5); } trait T7 { + fn dummy(&self) { } // not an error (for now) fn m1(x: &T4); fn m2(x: &T5); diff --git a/src/test/run-pass/visible-private-types-feature-gate.rs b/src/test/run-pass/visible-private-types-feature-gate.rs index 9518671b4799..46e93b25697b 100644 --- a/src/test/run-pass/visible-private-types-feature-gate.rs +++ b/src/test/run-pass/visible-private-types-feature-gate.rs @@ -10,7 +10,7 @@ #![feature(visible_private_types)] -trait Foo {} +trait Foo { fn dummy(&self) { } } pub trait Bar : Foo {} diff --git a/src/test/run-pass/where-clause-bounds-inconsistency.rs b/src/test/run-pass/where-clause-bounds-inconsistency.rs index a1a61127f68e..3374f47ed5f8 100644 --- a/src/test/run-pass/where-clause-bounds-inconsistency.rs +++ b/src/test/run-pass/where-clause-bounds-inconsistency.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Bound {} +trait Bound { + fn dummy(&self) { } +} trait Trait { fn a(&self, T) where T: Bound; diff --git a/src/test/run-pass/where-clause-early-bound-lifetimes.rs b/src/test/run-pass/where-clause-early-bound-lifetimes.rs index cade99b83a2f..4a149d4d3df4 100644 --- a/src/test/run-pass/where-clause-early-bound-lifetimes.rs +++ b/src/test/run-pass/where-clause-early-bound-lifetimes.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait TheTrait { } +trait TheTrait { fn dummy(&self) { } } impl TheTrait for &'static int { } diff --git a/src/test/run-pass/where-clause-method-substituion.rs b/src/test/run-pass/where-clause-method-substituion.rs index b391df8500bb..ecc210ea579d 100644 --- a/src/test/run-pass/where-clause-method-substituion.rs +++ b/src/test/run-pass/where-clause-method-substituion.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -trait Foo {} +trait Foo { fn dummy(&self, arg: T) { } } trait Bar { fn method(&self) where A: Foo; @@ -19,7 +19,7 @@ struct X; impl Foo for X {} -impl Bar for int { +impl Bar for i32 { fn method(&self) where X: Foo { } } diff --git a/src/test/run-pass/where-for-self.rs b/src/test/run-pass/where-for-self.rs index 5d426793c2e3..1fd223b0dd3f 100644 --- a/src/test/run-pass/where-for-self.rs +++ b/src/test/run-pass/where-for-self.rs @@ -11,13 +11,19 @@ // Test that we can quantify lifetimes outside a constraint (i.e., including // the self type) in a where clause. +use std::marker::PhantomFn; + static mut COUNT: u32 = 1; -trait Bar<'a> { +trait Bar<'a> + : PhantomFn<&'a ()> +{ fn bar(&self); } -trait Baz<'a> { +trait Baz<'a> + : PhantomFn<&'a ()> +{ fn baz(&self); }

Parser for P { type Input = (); } diff --git a/src/test/run-pass/associated-types-nested-projections.rs b/src/test/run-pass/associated-types-nested-projections.rs index e3227613159d..2ee8ef0d3dda 100644 --- a/src/test/run-pass/associated-types-nested-projections.rs +++ b/src/test/run-pass/associated-types-nested-projections.rs @@ -10,11 +10,12 @@ // Test that we can resolve nested projection types. Issue #20666. +use std::marker::MarkerTrait; use std::slice; -trait Bound {} +trait Bound : MarkerTrait {} -impl<'a> Bound for &'a int {} +impl<'a> Bound for &'a i32 {} trait IntoIterator { type Iter: Iterator; diff --git a/src/test/run-pass/associated-types-normalize-in-bounds-binding.rs b/src/test/run-pass/associated-types-normalize-in-bounds-binding.rs index dd5814f875b0..de96af83f591 100644 --- a/src/test/run-pass/associated-types-normalize-in-bounds-binding.rs +++ b/src/test/run-pass/associated-types-normalize-in-bounds-binding.rs @@ -13,7 +13,9 @@ #![allow(dead_code)] -pub trait Integral { +use std::marker::MarkerTrait; + +pub trait Integral : MarkerTrait { type Opposite; } @@ -27,6 +29,8 @@ impl Integral for u32 { pub trait FnLike { type R; + + fn dummy(&self, a: A) -> Self::R { loop { } } } fn foo() diff --git a/src/test/run-pass/associated-types-normalize-in-bounds-ufcs.rs b/src/test/run-pass/associated-types-normalize-in-bounds-ufcs.rs index 1d264655bc47..8617750ca538 100644 --- a/src/test/run-pass/associated-types-normalize-in-bounds-ufcs.rs +++ b/src/test/run-pass/associated-types-normalize-in-bounds-ufcs.rs @@ -11,15 +11,17 @@ // Test that we normalize associated types that appear in bounds; if // we didn't, the call to `self.split2()` fails to type check. -struct Splits<'a, T, P>; -struct SplitsN; +use std::marker::PhantomData; + +struct Splits<'a, T:'a, P>(PhantomData<(&'a T, P)>); +struct SplitsN(PhantomData); trait SliceExt2 { type Item; fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> where P: FnMut(&Self::Item) -> bool; - fn splitn2<'a, P>(&'a self, n: uint, pred: P) -> SplitsN> + fn splitn2<'a, P>(&'a self, n: u32, pred: P) -> SplitsN> where P: FnMut(&Self::Item) -> bool; } @@ -30,7 +32,7 @@ impl SliceExt2 for [T] { loop {} } - fn splitn2