about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-12-22 11:06:16 +0000
committerbors <bors@rust-lang.org>2018-12-22 11:06:16 +0000
commit9966590422ed3e6bd97bc1967b7435a03cfb949b (patch)
tree1e25c60fe39a5d1a8a1c9823417f379d9052ad51 /src/test
parent9689ada83891f63164bf117af35cc0abc37daaf1 (diff)
parentc4fa1d2c4739acf03a0df991d1c28f725c2ba20f (diff)
Auto merge of #56862 - arielb1:fundamentally-clean, r=nikomatsakis
stop treating trait objects from #[fundamental] traits as fundamental

This is a [breaking-change] to code that exploits this functionality (which should be limited to code using `#![feature(fundamental)]`.

Fixes #56503.

r? @nikomatsakis
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs7
-rw-r--r--src/test/ui/coherence/coherence-fundamental-trait-objects.rs15
-rw-r--r--src/test/ui/coherence/coherence-fundamental-trait-objects.stderr12
3 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs b/src/test/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs
new file mode 100644
index 00000000000..21aaea47963
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/coherence_fundamental_trait_lib.rs
@@ -0,0 +1,7 @@
+#![crate_type = "rlib"]
+#![feature(fundamental)]
+
+pub trait Misc {}
+
+#[fundamental]
+pub trait Fundamental<T> {}
diff --git a/src/test/ui/coherence/coherence-fundamental-trait-objects.rs b/src/test/ui/coherence/coherence-fundamental-trait-objects.rs
new file mode 100644
index 00000000000..dd127bf7f4b
--- /dev/null
+++ b/src/test/ui/coherence/coherence-fundamental-trait-objects.rs
@@ -0,0 +1,15 @@
+// Check that trait objects from #[fundamental] traits are not
+// treated as #[fundamental] types - the 2 meanings of #[fundamental]
+// are distinct.
+
+// aux-build:coherence_fundamental_trait_lib.rs
+
+extern crate coherence_fundamental_trait_lib;
+
+use coherence_fundamental_trait_lib::{Fundamental, Misc};
+
+pub struct Local;
+impl Misc for dyn Fundamental<Local> {}
+//~^ ERROR E0117
+
+fn main() {}
diff --git a/src/test/ui/coherence/coherence-fundamental-trait-objects.stderr b/src/test/ui/coherence/coherence-fundamental-trait-objects.stderr
new file mode 100644
index 00000000000..cefcac2c517
--- /dev/null
+++ b/src/test/ui/coherence/coherence-fundamental-trait-objects.stderr
@@ -0,0 +1,12 @@
+error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
+  --> $DIR/coherence-fundamental-trait-objects.rs:12:1
+   |
+LL | impl Misc for dyn Fundamental<Local> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
+   |
+   = note: the impl does not reference any types defined in this crate
+   = note: define and implement a trait or new type instead
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0117`.