summaryrefslogtreecommitdiffstats
path: root/tests/ui/specialization/defaultimpl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/specialization/defaultimpl')
-rw-r--r--tests/ui/specialization/defaultimpl/allowed-cross-crate.rs26
-rw-r--r--tests/ui/specialization/defaultimpl/allowed-cross-crate.stderr12
-rw-r--r--tests/ui/specialization/defaultimpl/auxiliary/go_trait.rs43
-rw-r--r--tests/ui/specialization/defaultimpl/out-of-order.rs19
-rw-r--r--tests/ui/specialization/defaultimpl/out-of-order.stderr12
-rw-r--r--tests/ui/specialization/defaultimpl/overlap-projection.rs25
-rw-r--r--tests/ui/specialization/defaultimpl/overlap-projection.stderr12
-rw-r--r--tests/ui/specialization/defaultimpl/projection.rs42
-rw-r--r--tests/ui/specialization/defaultimpl/projection.stderr12
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-feature-gate-default.rs11
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-feature-gate-default.stderr14
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-no-default.rs77
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-no-default.stderr68
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented-rpass.rs34
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented-rpass.stderr12
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented.rs23
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented.stderr22
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs24
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr44
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-wfcheck.rs10
-rw-r--r--tests/ui/specialization/defaultimpl/specialization-wfcheck.stderr29
-rw-r--r--tests/ui/specialization/defaultimpl/validation.rs16
-rw-r--r--tests/ui/specialization/defaultimpl/validation.stderr51
23 files changed, 638 insertions, 0 deletions
diff --git a/tests/ui/specialization/defaultimpl/allowed-cross-crate.rs b/tests/ui/specialization/defaultimpl/allowed-cross-crate.rs
new file mode 100644
index 000000000..5d67160eb
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/allowed-cross-crate.rs
@@ -0,0 +1,26 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_variables)]
+#![allow(unused_imports)]
+
+// aux-build:go_trait.rs
+
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+extern crate go_trait;
+
+use go_trait::{Go,GoMut};
+use std::fmt::Debug;
+use std::default::Default;
+
+struct MyThingy;
+
+impl Go for MyThingy {
+ fn go(&self, arg: isize) { }
+}
+
+impl GoMut for MyThingy {
+ fn go_mut(&mut self, arg: isize) { }
+}
+
+fn main() { }
diff --git a/tests/ui/specialization/defaultimpl/allowed-cross-crate.stderr b/tests/ui/specialization/defaultimpl/allowed-cross-crate.stderr
new file mode 100644
index 000000000..02f13d461
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/allowed-cross-crate.stderr
@@ -0,0 +1,12 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/allowed-cross-crate.rs:8:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/specialization/defaultimpl/auxiliary/go_trait.rs b/tests/ui/specialization/defaultimpl/auxiliary/go_trait.rs
new file mode 100644
index 000000000..c065593b4
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/auxiliary/go_trait.rs
@@ -0,0 +1,43 @@
+#![feature(specialization)]
+
+// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
+
+pub trait Go {
+ fn go(&self, arg: isize);
+}
+
+pub fn go<G:Go>(this: &G, arg: isize) {
+ this.go(arg)
+}
+
+pub trait GoMut {
+ fn go_mut(&mut self, arg: isize);
+}
+
+pub fn go_mut<G:GoMut>(this: &mut G, arg: isize) {
+ this.go_mut(arg)
+}
+
+pub trait GoOnce {
+ fn go_once(self, arg: isize);
+}
+
+pub fn go_once<G:GoOnce>(this: G, arg: isize) {
+ this.go_once(arg)
+}
+
+default impl<G> GoMut for G
+ where G : Go
+{
+ fn go_mut(&mut self, arg: isize) {
+ go(&*self, arg)
+ }
+}
+
+default impl<G> GoOnce for G
+ where G : GoMut
+{
+ fn go_once(mut self, arg: isize) {
+ go_mut(&mut self, arg)
+ }
+}
diff --git a/tests/ui/specialization/defaultimpl/out-of-order.rs b/tests/ui/specialization/defaultimpl/out-of-order.rs
new file mode 100644
index 000000000..13258ac8c
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/out-of-order.rs
@@ -0,0 +1,19 @@
+// run-pass
+
+// Test that you can list the more specific impl before the more general one.
+
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+trait Foo {
+ type Out;
+}
+
+impl Foo for bool {
+ type Out = ();
+}
+
+default impl<T> Foo for T {
+ type Out = bool;
+}
+
+fn main() {}
diff --git a/tests/ui/specialization/defaultimpl/out-of-order.stderr b/tests/ui/specialization/defaultimpl/out-of-order.stderr
new file mode 100644
index 000000000..2cf1ac909
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/out-of-order.stderr
@@ -0,0 +1,12 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/out-of-order.rs:5:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/specialization/defaultimpl/overlap-projection.rs b/tests/ui/specialization/defaultimpl/overlap-projection.rs
new file mode 100644
index 000000000..0add4d551
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/overlap-projection.rs
@@ -0,0 +1,25 @@
+// run-pass
+
+// Test that impls on projected self types can resolve overlap, even when the
+// projections involve specialization, so long as the associated type is
+// provided by the most specialized impl.
+
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+trait Assoc {
+ type Output;
+}
+
+default impl<T> Assoc for T {
+ type Output = bool;
+}
+
+impl Assoc for u8 { type Output = u8; }
+impl Assoc for u16 { type Output = u16; }
+
+trait Foo {}
+impl Foo for u32 {}
+impl Foo for <u8 as Assoc>::Output {}
+impl Foo for <u16 as Assoc>::Output {}
+
+fn main() {}
diff --git a/tests/ui/specialization/defaultimpl/overlap-projection.stderr b/tests/ui/specialization/defaultimpl/overlap-projection.stderr
new file mode 100644
index 000000000..75fdfafd9
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/overlap-projection.stderr
@@ -0,0 +1,12 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/overlap-projection.rs:7:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/specialization/defaultimpl/projection.rs b/tests/ui/specialization/defaultimpl/projection.rs
new file mode 100644
index 000000000..f19c55b04
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/projection.rs
@@ -0,0 +1,42 @@
+// run-pass
+#![allow(dead_code)]
+
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+// Make sure we *can* project non-defaulted associated types
+// cf ui/specialization/specialization-default-projection.rs
+
+// First, do so without any use of specialization
+
+trait Foo {
+ type Assoc;
+}
+
+impl<T> Foo for T {
+ type Assoc = ();
+}
+
+fn generic_foo<T>() -> <T as Foo>::Assoc {
+ ()
+}
+
+// Next, allow for one layer of specialization
+
+trait Bar {
+ type Assoc;
+}
+
+default impl<T> Bar for T {
+ type Assoc = ();
+}
+
+impl<T: Clone> Bar for T {
+ type Assoc = u8;
+}
+
+fn generic_bar_clone<T: Clone>() -> <T as Bar>::Assoc {
+ 0u8
+}
+
+fn main() {
+}
diff --git a/tests/ui/specialization/defaultimpl/projection.stderr b/tests/ui/specialization/defaultimpl/projection.stderr
new file mode 100644
index 000000000..cc3fe8237
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/projection.stderr
@@ -0,0 +1,12 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/projection.rs:4:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/specialization/defaultimpl/specialization-feature-gate-default.rs b/tests/ui/specialization/defaultimpl/specialization-feature-gate-default.rs
new file mode 100644
index 000000000..89158b65a
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-feature-gate-default.rs
@@ -0,0 +1,11 @@
+// Check that specialization must be ungated to use the `default` keyword
+
+trait Foo {
+ fn foo(&self);
+}
+
+default impl<T> Foo for T { //~ ERROR specialization is unstable
+ fn foo(&self) {}
+}
+
+fn main() {}
diff --git a/tests/ui/specialization/defaultimpl/specialization-feature-gate-default.stderr b/tests/ui/specialization/defaultimpl/specialization-feature-gate-default.stderr
new file mode 100644
index 000000000..64e14f580
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-feature-gate-default.stderr
@@ -0,0 +1,14 @@
+error[E0658]: specialization is unstable
+ --> $DIR/specialization-feature-gate-default.rs:7:1
+ |
+LL | / default impl<T> Foo for T {
+LL | | fn foo(&self) {}
+LL | | }
+ | |_^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: add `#![feature(specialization)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/specialization/defaultimpl/specialization-no-default.rs b/tests/ui/specialization/defaultimpl/specialization-no-default.rs
new file mode 100644
index 000000000..661724eef
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-no-default.rs
@@ -0,0 +1,77 @@
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+// Check a number of scenarios in which one impl tries to override another,
+// without correctly using `default`.
+
+// Test 1: one layer of specialization, multiple methods, missing `default`
+
+trait Foo {
+ fn foo(&self);
+ fn bar(&self);
+}
+
+impl<T> Foo for T {
+ fn foo(&self) {}
+ fn bar(&self) {}
+}
+
+impl Foo for u8 {}
+impl Foo for u16 {
+ fn foo(&self) {} //~ ERROR E0520
+}
+impl Foo for u32 {
+ fn bar(&self) {} //~ ERROR E0520
+}
+
+// Test 2: one layer of specialization, missing `default` on associated type
+
+trait Bar {
+ type T;
+}
+
+impl<T> Bar for T {
+ type T = u8;
+}
+
+impl Bar for u8 {
+ type T = (); //~ ERROR E0520
+}
+
+// Test 3a: multiple layers of specialization, missing interior `default`
+
+trait Baz {
+ fn baz(&self);
+}
+
+default impl<T> Baz for T {
+ fn baz(&self) {}
+}
+
+impl<T: Clone> Baz for T {
+ fn baz(&self) {}
+}
+
+impl Baz for i32 {
+ fn baz(&self) {} //~ ERROR E0520
+}
+
+// Test 3b: multiple layers of specialization, missing interior `default`,
+// redundant `default` in bottom layer.
+
+trait Redundant {
+ fn redundant(&self);
+}
+
+default impl<T> Redundant for T {
+ fn redundant(&self) {}
+}
+
+impl<T: Clone> Redundant for T {
+ fn redundant(&self) {}
+}
+
+default impl Redundant for i32 {
+ fn redundant(&self) {} //~ ERROR E0520
+}
+
+fn main() {}
diff --git a/tests/ui/specialization/defaultimpl/specialization-no-default.stderr b/tests/ui/specialization/defaultimpl/specialization-no-default.stderr
new file mode 100644
index 000000000..770be2af2
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-no-default.stderr
@@ -0,0 +1,68 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/specialization-no-default.rs:1:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
+ --> $DIR/specialization-no-default.rs:20:5
+ |
+LL | impl<T> Foo for T {
+ | ----------------- parent `impl` is here
+...
+LL | fn foo(&self) {}
+ | ^^^^^^^^^^^^^^^^ cannot specialize default item `foo`
+ |
+ = note: to specialize, `foo` in the parent `impl` must be marked `default`
+
+error[E0520]: `bar` specializes an item from a parent `impl`, but that item is not marked `default`
+ --> $DIR/specialization-no-default.rs:23:5
+ |
+LL | impl<T> Foo for T {
+ | ----------------- parent `impl` is here
+...
+LL | fn bar(&self) {}
+ | ^^^^^^^^^^^^^^^^ cannot specialize default item `bar`
+ |
+ = note: to specialize, `bar` in the parent `impl` must be marked `default`
+
+error[E0520]: `T` specializes an item from a parent `impl`, but that item is not marked `default`
+ --> $DIR/specialization-no-default.rs:37:5
+ |
+LL | impl<T> Bar for T {
+ | ----------------- parent `impl` is here
+...
+LL | type T = ();
+ | ^^^^^^^^^^^^ cannot specialize default item `T`
+ |
+ = note: to specialize, `T` in the parent `impl` must be marked `default`
+
+error[E0520]: `baz` specializes an item from a parent `impl`, but that item is not marked `default`
+ --> $DIR/specialization-no-default.rs:55:5
+ |
+LL | impl<T: Clone> Baz for T {
+ | ------------------------ parent `impl` is here
+...
+LL | fn baz(&self) {}
+ | ^^^^^^^^^^^^^^^^ cannot specialize default item `baz`
+ |
+ = note: to specialize, `baz` in the parent `impl` must be marked `default`
+
+error[E0520]: `redundant` specializes an item from a parent `impl`, but that item is not marked `default`
+ --> $DIR/specialization-no-default.rs:74:5
+ |
+LL | impl<T: Clone> Redundant for T {
+ | ------------------------------ parent `impl` is here
+...
+LL | fn redundant(&self) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `redundant`
+ |
+ = note: to specialize, `redundant` in the parent `impl` must be marked `default`
+
+error: aborting due to 5 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0520`.
diff --git a/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented-rpass.rs b/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented-rpass.rs
new file mode 100644
index 000000000..89fef5b5e
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented-rpass.rs
@@ -0,0 +1,34 @@
+// run-pass
+
+// Tests that we can combine a default impl that supplies one method with a
+// full impl that supplies the other, and they can invoke one another.
+
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+trait Foo {
+ fn foo_one(&self) -> &'static str;
+ fn foo_two(&self) -> &'static str;
+ fn foo_three(&self) -> &'static str;
+}
+
+struct MyStruct;
+
+default impl<T> Foo for T {
+ fn foo_one(&self) -> &'static str {
+ self.foo_three()
+ }
+}
+
+impl Foo for MyStruct {
+ fn foo_two(&self) -> &'static str {
+ self.foo_one()
+ }
+
+ fn foo_three(&self) -> &'static str {
+ "generic"
+ }
+}
+
+fn main() {
+ assert!(MyStruct.foo_two() == "generic");
+}
diff --git a/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented-rpass.stderr b/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented-rpass.stderr
new file mode 100644
index 000000000..407c1ab77
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented-rpass.stderr
@@ -0,0 +1,12 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/specialization-trait-item-not-implemented-rpass.rs:6:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented.rs b/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented.rs
new file mode 100644
index 000000000..3c5414469
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented.rs
@@ -0,0 +1,23 @@
+// Tests that default impls do not have to supply all items but regular impls do.
+
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+trait Foo {
+ fn foo_one(&self) -> &'static str;
+ fn foo_two(&self) -> &'static str;
+}
+
+struct MyStruct;
+
+default impl<T> Foo for T {
+ fn foo_one(&self) -> &'static str {
+ "generic"
+ }
+}
+
+impl Foo for MyStruct {}
+//~^ ERROR not all trait items implemented, missing: `foo_two` [E0046]
+
+fn main() {
+ println!("{}", MyStruct.foo_one());
+}
diff --git a/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented.stderr b/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented.stderr
new file mode 100644
index 000000000..f19975060
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-trait-item-not-implemented.stderr
@@ -0,0 +1,22 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/specialization-trait-item-not-implemented.rs:3:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0046]: not all trait items implemented, missing: `foo_two`
+ --> $DIR/specialization-trait-item-not-implemented.rs:18:1
+ |
+LL | fn foo_two(&self) -> &'static str;
+ | ---------------------------------- `foo_two` from trait
+...
+LL | impl Foo for MyStruct {}
+ | ^^^^^^^^^^^^^^^^^^^^^ missing `foo_two` in implementation
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs b/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs
new file mode 100644
index 000000000..6834d5736
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs
@@ -0,0 +1,24 @@
+// Tests that:
+// - default impls do not have to supply all items and
+// - a default impl does not count as an impl (in this case, an incomplete default impl).
+
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+trait Foo {
+ fn foo_one(&self) -> &'static str;
+ fn foo_two(&self) -> &'static str;
+}
+
+struct MyStruct;
+
+default impl<T> Foo for T {
+ fn foo_one(&self) -> &'static str {
+ "generic"
+ }
+}
+
+
+fn main() {
+ println!("{}", MyStruct.foo_one());
+ //~^ ERROR the method
+}
diff --git a/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr b/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr
new file mode 100644
index 000000000..37788612f
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr
@@ -0,0 +1,44 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/specialization-trait-not-implemented.rs:5:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0599]: the method `foo_one` exists for struct `MyStruct`, but its trait bounds were not satisfied
+ --> $DIR/specialization-trait-not-implemented.rs:22:29
+ |
+LL | struct MyStruct;
+ | ---------------
+ | |
+ | method `foo_one` not found for this struct
+ | doesn't satisfy `MyStruct: Foo`
+...
+LL | println!("{}", MyStruct.foo_one());
+ | ^^^^^^^ method cannot be called on `MyStruct` due to unsatisfied trait bounds
+ |
+note: trait bound `MyStruct: Foo` was not satisfied
+ --> $DIR/specialization-trait-not-implemented.rs:14:1
+ |
+LL | default impl<T> Foo for T {
+ | ^^^^^^^^^^^^^^^^---^^^^^-
+ | |
+ | unsatisfied trait bound introduced here
+note: the trait `Foo` must be implemented
+ --> $DIR/specialization-trait-not-implemented.rs:7:1
+ |
+LL | trait Foo {
+ | ^^^^^^^^^
+ = help: items from traits can only be used if the trait is implemented and in scope
+note: `Foo` defines an item `foo_one`, perhaps you need to implement it
+ --> $DIR/specialization-trait-not-implemented.rs:7:1
+ |
+LL | trait Foo {
+ | ^^^^^^^^^
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/specialization/defaultimpl/specialization-wfcheck.rs b/tests/ui/specialization/defaultimpl/specialization-wfcheck.rs
new file mode 100644
index 000000000..eb18d6eaa
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-wfcheck.rs
@@ -0,0 +1,10 @@
+// Tests that a default impl still has to have a WF trait ref.
+
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+trait Foo<'a, T: Eq + 'a> { }
+
+default impl<U> Foo<'static, U> for () {}
+//~^ ERROR the trait bound `U: Eq` is not satisfied
+
+fn main(){}
diff --git a/tests/ui/specialization/defaultimpl/specialization-wfcheck.stderr b/tests/ui/specialization/defaultimpl/specialization-wfcheck.stderr
new file mode 100644
index 000000000..e78016034
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/specialization-wfcheck.stderr
@@ -0,0 +1,29 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/specialization-wfcheck.rs:3:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+error[E0277]: the trait bound `U: Eq` is not satisfied
+ --> $DIR/specialization-wfcheck.rs:7:17
+ |
+LL | default impl<U> Foo<'static, U> for () {}
+ | ^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `U`
+ |
+note: required by a bound in `Foo`
+ --> $DIR/specialization-wfcheck.rs:5:18
+ |
+LL | trait Foo<'a, T: Eq + 'a> { }
+ | ^^ required by this bound in `Foo`
+help: consider restricting type parameter `U`
+ |
+LL | default impl<U: std::cmp::Eq> Foo<'static, U> for () {}
+ | ++++++++++++++
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/specialization/defaultimpl/validation.rs b/tests/ui/specialization/defaultimpl/validation.rs
new file mode 100644
index 000000000..8558a1efb
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/validation.rs
@@ -0,0 +1,16 @@
+#![feature(negative_impls)]
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+struct S;
+struct Z;
+
+default impl S {} //~ ERROR inherent impls cannot be `default`
+
+default unsafe impl Send for S {} //~ ERROR impls of auto traits cannot be default
+default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default
+ //~^ ERROR negative impls cannot be default impls
+
+trait Tr {}
+default impl !Tr for S {} //~ ERROR negative impls cannot be default impls
+
+fn main() {}
diff --git a/tests/ui/specialization/defaultimpl/validation.stderr b/tests/ui/specialization/defaultimpl/validation.stderr
new file mode 100644
index 000000000..eb6dc9355
--- /dev/null
+++ b/tests/ui/specialization/defaultimpl/validation.stderr
@@ -0,0 +1,51 @@
+error: inherent impls cannot be `default`
+ --> $DIR/validation.rs:7:14
+ |
+LL | default impl S {}
+ | ------- ^ inherent impl for this type
+ | |
+ | `default` because of this
+ |
+ = note: only trait implementations may be annotated with `default`
+
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/validation.rs:2:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+error: impls of auto traits cannot be default
+ --> $DIR/validation.rs:9:21
+ |
+LL | default unsafe impl Send for S {}
+ | ------- ^^^^ auto trait
+ | |
+ | default because of this
+
+error: impls of auto traits cannot be default
+ --> $DIR/validation.rs:10:15
+ |
+LL | default impl !Send for Z {}
+ | ------- ^^^^ auto trait
+ | |
+ | default because of this
+
+error[E0750]: negative impls cannot be default impls
+ --> $DIR/validation.rs:10:1
+ |
+LL | default impl !Send for Z {}
+ | ^^^^^^^ ^
+
+error[E0750]: negative impls cannot be default impls
+ --> $DIR/validation.rs:14:1
+ |
+LL | default impl !Tr for S {}
+ | ^^^^^^^ ^
+
+error: aborting due to 5 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0750`.