about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2020-06-28 16:46:02 +0100
committerMatthew Jasper <mjjasper1@gmail.com>2020-10-06 11:19:30 +0100
commit5b279c801635c2762c013c1d13a9bead3bcd9df4 (patch)
tree156749754f712a49b30eace463a579d3afc62ea7 /src
parentb3057f4d5fe7156aa85e1844d3638fa14ba48b79 (diff)
downloadrust-5b279c801635c2762c013c1d13a9bead3bcd9df4.tar.gz
rust-5b279c801635c2762c013c1d13a9bead3bcd9df4.zip
Check opaque types satisfy their bounds
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr1
-rw-r--r--src/test/ui/async-await/async-error-span.stderr3
-rw-r--r--src/test/ui/async-await/issue-64130-4-async-move.stderr1
-rw-r--r--src/test/ui/async-await/issue-70818.stderr1
-rw-r--r--src/test/ui/generator/type-mismatch-signature-deduction.stderr1
-rw-r--r--src/test/ui/impl-trait/bound-normalization-fail.stderr2
-rw-r--r--src/test/ui/impl-trait/issue-55872-1.stderr2
-rw-r--r--src/test/ui/issues-71798.stderr2
-rw-r--r--src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr5
-rw-r--r--src/test/ui/never_type/feature-gate-never_type_fallback.stderr5
-rw-r--r--src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/bounds-are-checked-2.rs19
-rw-r--r--src/test/ui/type-alias-impl-trait/bounds-are-checked-2.stderr14
-rw-r--r--src/test/ui/type-alias-impl-trait/bounds-are-checked.rs25
-rw-r--r--src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr26
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use10.rs4
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use7.rs4
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-60371.stderr1
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-63279.stderr1
-rw-r--r--src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs4
20 files changed, 90 insertions, 33 deletions
diff --git a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr
index 566e390a31e..b0e9e33a6c3 100644
--- a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr
+++ b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr
@@ -9,7 +9,6 @@ LL | fn baz() -> impl Bar<Item = i32> {
    |
    = note: expected associated type `<impl Bar as Foo>::Item`
                          found type `i32`
-   = note: the return type of a function must have a statically known size
 help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32`
    |
 LL | fn bar() -> impl Bar<Item = i32> {
diff --git a/src/test/ui/async-await/async-error-span.stderr b/src/test/ui/async-await/async-error-span.stderr
index d808a5939bb..8cd0e40c8cf 100644
--- a/src/test/ui/async-await/async-error-span.stderr
+++ b/src/test/ui/async-await/async-error-span.stderr
@@ -3,9 +3,6 @@ error[E0277]: `()` is not a future
    |
 LL | fn get_future() -> impl Future<Output = ()> {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future
-LL |
-LL |     panic!()
-   |     -------- this returned value is of type `!`
    |
    = help: the trait `Future` is not implemented for `()`
    = note: the return type of a function must have a statically known size
diff --git a/src/test/ui/async-await/issue-64130-4-async-move.stderr b/src/test/ui/async-await/issue-64130-4-async-move.stderr
index 440ea0a38e6..f5d023ab781 100644
--- a/src/test/ui/async-await/issue-64130-4-async-move.stderr
+++ b/src/test/ui/async-await/issue-64130-4-async-move.stderr
@@ -30,7 +30,6 @@ help: consider moving this into a `let` binding to create a shorter lived borrow
    |
 LL |         match client.status() {
    |               ^^^^^^^^^^^^^^^
-   = note: the return type of a function must have a statically known size
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/async-await/issue-70818.stderr b/src/test/ui/async-await/issue-70818.stderr
index 364194bea10..20ee22e448c 100644
--- a/src/test/ui/async-await/issue-70818.stderr
+++ b/src/test/ui/async-await/issue-70818.stderr
@@ -12,7 +12,6 @@ note: captured value is not `Send`
    |
 LL |     async { (ty, ty1) }
    |                  ^^^ has type `U` which is not `Send`
-   = note: the return type of a function must have a statically known size
 help: consider restricting type parameter `U`
    |
 LL | fn foo<T: Send, U: Send>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send {
diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.stderr b/src/test/ui/generator/type-mismatch-signature-deduction.stderr
index 260fbb2ec7e..8f6f87f78de 100644
--- a/src/test/ui/generator/type-mismatch-signature-deduction.stderr
+++ b/src/test/ui/generator/type-mismatch-signature-deduction.stderr
@@ -15,7 +15,6 @@ LL | fn foo() -> impl Generator<Return = i32> {
    |
    = note: expected enum `std::result::Result<{integer}, _>`
               found type `i32`
-   = note: the return type of a function must have a statically known size
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr
index 03aba10cc79..a7d06c71663 100644
--- a/src/test/ui/impl-trait/bound-normalization-fail.stderr
+++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr
@@ -15,7 +15,6 @@ LL |     fn foo_fail<T: Trait>() -> impl FooLike<Output=T::Assoc> {
    |
    = note:         expected type `()`
            found associated type `<T as impl_trait::Trait>::Assoc`
-   = note: the return type of a function must have a statically known size
 help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc` to `()`
    |
 LL |     fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output=T::Assoc> {
@@ -35,7 +34,6 @@ LL |     fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output=T::Assoc> {
    |
    = note:         expected type `()`
            found associated type `<T as lifetimes::Trait<'static>>::Assoc`
-   = note: the return type of a function must have a statically known size
 help: consider constraining the associated type `<T as lifetimes::Trait<'static>>::Assoc` to `()`
    |
 LL |     fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output=T::Assoc> {
diff --git a/src/test/ui/impl-trait/issue-55872-1.stderr b/src/test/ui/impl-trait/issue-55872-1.stderr
index db49d988bb8..64c536cf1fe 100644
--- a/src/test/ui/impl-trait/issue-55872-1.stderr
+++ b/src/test/ui/impl-trait/issue-55872-1.stderr
@@ -14,7 +14,6 @@ LL |     type E = impl Copy;
    |              ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S`
    |
    = note: required because it appears within the type `(S, T)`
-   = note: the return type of a function must have a statically known size
 help: consider further restricting this bound
    |
 LL | impl<S: Default + Copy> Bar for S {
@@ -27,7 +26,6 @@ LL |     type E = impl Copy;
    |              ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T`
    |
    = note: required because it appears within the type `(S, T)`
-   = note: the return type of a function must have a statically known size
 help: consider further restricting this bound
    |
 LL |     fn foo<T: Default + Copy>() -> Self::E {
diff --git a/src/test/ui/issues-71798.stderr b/src/test/ui/issues-71798.stderr
index 867f8f0496c..835d479f28f 100644
--- a/src/test/ui/issues-71798.stderr
+++ b/src/test/ui/issues-71798.stderr
@@ -9,8 +9,6 @@ error[E0277]: `u32` is not a future
    |
 LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `u32` is not a future
-LL |     *x
-   |     -- this returned value is of type `u32`
    |
    = help: the trait `Future` is not implemented for `u32`
    = note: the return type of a function must have a statically known size
diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr
index e43fb6d0edf..c3d597bec2e 100644
--- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr
+++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr
@@ -3,11 +3,6 @@ error[E0277]: the trait bound `std::result::Result<(), _>: Future` is not satisf
    |
 LL | fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Future` is not implemented for `std::result::Result<(), _>`
-LL |
-LL |     Ok(())
-   |     ------ this returned value is of type `std::result::Result<(), _>`
-   |
-   = note: the return type of a function must have a statically known size
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/never_type/feature-gate-never_type_fallback.stderr b/src/test/ui/never_type/feature-gate-never_type_fallback.stderr
index c652faafad4..670f76867ce 100644
--- a/src/test/ui/never_type/feature-gate-never_type_fallback.stderr
+++ b/src/test/ui/never_type/feature-gate-never_type_fallback.stderr
@@ -3,11 +3,6 @@ error[E0277]: the trait bound `(): T` is not satisfied
    |
 LL | fn should_ret_unit() -> impl T {
    |                         ^^^^^^ the trait `T` is not implemented for `()`
-LL |
-LL |     panic!()
-   |     -------- this returned value is of type `!`
-   |
-   = note: the return type of a function must have a statically known size
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr
index cc3a2b9419c..d826222a06a 100644
--- a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr
+++ b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr
@@ -5,8 +5,6 @@ LL | fn foo() -> impl Bar {
    |             ^^^^^^^^ the trait `Bar` is not implemented for `()`
 LL |     5;
    |      - consider removing this semicolon
-   |
-   = note: the return type of a function must have a statically known size
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.rs b/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.rs
new file mode 100644
index 00000000000..5566f40f960
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.rs
@@ -0,0 +1,19 @@
+// Make sure that we check that impl trait types implement the traits that they
+// claim to.
+
+#![feature(type_alias_impl_trait)]
+
+type X<T> = impl Clone;
+//~^ ERROR the trait bound `T: std::clone::Clone` is not satisfied
+
+fn f<T: Clone>(t: T) -> X<T> {
+    t
+}
+
+fn g<T>(o : Option<X<T>>) -> Option<X<T>> {
+    o.clone()
+}
+
+fn main() {
+    g(None::<X<&mut ()>>);
+}
diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.stderr b/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.stderr
new file mode 100644
index 00000000000..e20130007ee
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
+  --> $DIR/bounds-are-checked-2.rs:6:13
+   |
+LL | type X<T> = impl Clone;
+   |             ^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `T`
+   |
+help: consider restricting type parameter `T`
+   |
+LL | type X<T: std::clone::Clone> = impl Clone;
+   |         ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs b/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs
new file mode 100644
index 00000000000..759bf4f4f0d
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs
@@ -0,0 +1,25 @@
+// Make sure that we check that impl trait types implement the traits that they
+// claim to.
+
+#![feature(type_alias_impl_trait)]
+
+type X<'a> = impl Into<&'static str> + From<&'a str>;
+//~^ ERROR mismatched types
+
+fn f<'a: 'static>(t: &'a str) -> X<'a> {
+    //~^ WARNING unnecessary lifetime parameter
+    t
+}
+
+fn extend_lt<'a>(o: &'a str) -> &'static str {
+    X::<'_>::from(o).into()
+}
+
+fn main() {
+    let r =
+    {
+        let s = "abcdef".to_string();
+        extend_lt(&s)
+    };
+    println!("{}", r);
+}
diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr b/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr
new file mode 100644
index 00000000000..42468b91a62
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr
@@ -0,0 +1,26 @@
+warning: unnecessary lifetime parameter `'a`
+  --> $DIR/bounds-are-checked.rs:9:6
+   |
+LL | fn f<'a: 'static>(t: &'a str) -> X<'a> {
+   |      ^^^^^^^^^^^
+   |
+   = help: you can use the `'static` lifetime directly, in place of `'a`
+
+error[E0308]: mismatched types
+  --> $DIR/bounds-are-checked.rs:6:14
+   |
+LL | type X<'a> = impl Into<&'static str> + From<&'a str>;
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
+   |
+   = note: expected type `std::convert::From<&'a str>`
+              found type `std::convert::From<&'static str>`
+note: the lifetime `'a` as defined on the item at 6:8...
+  --> $DIR/bounds-are-checked.rs:6:8
+   |
+LL | type X<'a> = impl Into<&'static str> + From<&'a str>;
+   |        ^^
+   = note: ...does not necessarily outlive the static lifetime
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use10.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use10.rs
index 898dab1b0b9..c17d595dbb3 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use10.rs
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use10.rs
@@ -1,11 +1,11 @@
-// build-pass (FIXME(62277): could be check-pass?)
+// check-pass
 #![feature(type_alias_impl_trait)]
 
 use std::fmt::Debug;
 
 fn main() {}
 
-type Two<T, U> = impl Debug;
+type Two<T: Debug, U> = impl Debug;
 
 fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> {
     (t, 4u32)
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use7.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use7.rs
index 712a6539f01..feebf81eef2 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use7.rs
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use7.rs
@@ -1,11 +1,11 @@
-// build-pass (FIXME(62277): could be check-pass?)
+// check-pass
 #![feature(type_alias_impl_trait)]
 
 use std::fmt::Debug;
 
 fn main() {}
 
-type Two<A, B> = impl Debug;
+type Two<A: Debug, B> = impl Debug;
 
 fn two<T: Debug + Copy, U>(t: T, u: U) -> Two<T, U> {
     (t, t)
diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr
index bf2d612fcdb..905248fb337 100644
--- a/src/test/ui/type-alias-impl-trait/issue-60371.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr
@@ -15,7 +15,6 @@ LL |     type Item = impl Bug;
    |
    = help: the following implementations were found:
              <&() as Bug>
-   = note: the return type of a function must have a statically known size
 
 error: could not find defining uses
   --> $DIR/issue-60371.rs:8:17
diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.stderr b/src/test/ui/type-alias-impl-trait/issue-63279.stderr
index 9ad181b3684..8615b3f741b 100644
--- a/src/test/ui/type-alias-impl-trait/issue-63279.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-63279.stderr
@@ -6,7 +6,6 @@ LL | type Closure = impl FnOnce();
    |
    = note: expected opaque type `impl FnOnce<()>`
                 found unit type `()`
-   = note: the return type of a function must have a statically known size
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs
index 209134acf01..80192d19af9 100644
--- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs
+++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs
@@ -70,14 +70,14 @@ fn my_other_iter<U>(u: U) -> MyOtherIter<U> {
 }
 
 trait Trait {}
-type GenericBound<'a, T: Trait> = impl Sized + 'a;
+type GenericBound<'a, T: Trait + 'a> = impl Sized + 'a;
 
 fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> {
     t
 }
 
 mod pass_through {
-    pub type Passthrough<T> = impl Sized + 'static;
+    pub type Passthrough<T: 'static> = impl Sized + 'static;
 
     fn define_passthrough<T: 'static>(t: T) -> Passthrough<T> {
         t