summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/new-solver
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/traits/new-solver')
-rw-r--r--tests/ui/traits/new-solver/fn-trait-closure.rs15
-rw-r--r--tests/ui/traits/new-solver/fn-trait.rs13
-rw-r--r--tests/ui/traits/new-solver/pointer-sized.rs12
-rw-r--r--tests/ui/traits/new-solver/pointer-sized.stderr24
4 files changed, 64 insertions, 0 deletions
diff --git a/tests/ui/traits/new-solver/fn-trait-closure.rs b/tests/ui/traits/new-solver/fn-trait-closure.rs
new file mode 100644
index 000000000..c0ecf1c91
--- /dev/null
+++ b/tests/ui/traits/new-solver/fn-trait-closure.rs
@@ -0,0 +1,15 @@
+// compile-flags: -Ztrait-solver=next
+// known-bug: unknown
+// failure-status: 101
+// dont-check-compiler-stderr
+
+// This test will fail until we fix `FulfillmentCtxt::relationships`. That's
+// because we create a type variable for closure upvar types, which is not
+// constrained until after we try to do fallback on diverging type variables.
+// Thus, we will call that function, which is unimplemented.
+
+fn require_fn(_: impl Fn() -> i32) {}
+
+fn main() {
+ require_fn(|| -> i32 { 1i32 });
+}
diff --git a/tests/ui/traits/new-solver/fn-trait.rs b/tests/ui/traits/new-solver/fn-trait.rs
new file mode 100644
index 000000000..d566ead10
--- /dev/null
+++ b/tests/ui/traits/new-solver/fn-trait.rs
@@ -0,0 +1,13 @@
+// compile-flags: -Ztrait-solver=next
+// check-pass
+
+fn require_fn(_: impl Fn() -> i32) {}
+
+fn f() -> i32 {
+ 1i32
+}
+
+fn main() {
+ require_fn(f);
+ require_fn(f as fn() -> i32);
+}
diff --git a/tests/ui/traits/new-solver/pointer-sized.rs b/tests/ui/traits/new-solver/pointer-sized.rs
new file mode 100644
index 000000000..15681cd13
--- /dev/null
+++ b/tests/ui/traits/new-solver/pointer-sized.rs
@@ -0,0 +1,12 @@
+#![feature(pointer_sized_trait)]
+
+use std::marker::PointerSized;
+
+fn require_pointer_sized(_: impl PointerSized) {}
+
+fn main() {
+ require_pointer_sized(1usize);
+ require_pointer_sized(1u16);
+ //~^ ERROR `u16` needs to be a pointer-sized type
+ require_pointer_sized(&1i16);
+}
diff --git a/tests/ui/traits/new-solver/pointer-sized.stderr b/tests/ui/traits/new-solver/pointer-sized.stderr
new file mode 100644
index 000000000..b250b1331
--- /dev/null
+++ b/tests/ui/traits/new-solver/pointer-sized.stderr
@@ -0,0 +1,24 @@
+error[E0277]: `u16` needs to be a pointer-sized type
+ --> $DIR/pointer-sized.rs:9:27
+ |
+LL | require_pointer_sized(1u16);
+ | --------------------- ^^^^ the trait `PointerSized` is not implemented for `u16`
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: the trait bound `u16: PointerSized` is not satisfied
+note: required by a bound in `require_pointer_sized`
+ --> $DIR/pointer-sized.rs:5:34
+ |
+LL | fn require_pointer_sized(_: impl PointerSized) {}
+ | ^^^^^^^^^^^^ required by this bound in `require_pointer_sized`
+help: consider borrowing here
+ |
+LL | require_pointer_sized(&1u16);
+ | +
+LL | require_pointer_sized(&mut 1u16);
+ | ++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.