about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-06-24 15:47:22 +0000
committerbors <bors@rust-lang.org>2020-06-24 15:47:22 +0000
commitd8ed1b03c202d77248eb0d335062f46026fc29c4 (patch)
treed5a33e2cd87696a4b55cf789a903d1af3554bf69 /src/test
parent0b66a89735305ebac93894461559576495ab920e (diff)
parentbe8f381c8a76c5c7e6d2c41a092edf173b23344a (diff)
downloadrust-d8ed1b03c202d77248eb0d335062f46026fc29c4.tar.gz
rust-d8ed1b03c202d77248eb0d335062f46026fc29c4.zip
Auto merge of #73692 - Dylan-DPC:rollup-ehzsbfw, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #73638 (Remove unused crate imports in 2018 edition crates)
 - #73639 (Change heuristic for determining range literal)
 - #73646 (Add some regression tests)
 - #73652 (Add re-exports to use suggestions)
 - #73667 (Update BTreeMap::new() doc)
 - #73675 (Update books)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/glob-resolve1.rs4
-rw-r--r--src/test/ui/glob-resolve1.stderr5
-rw-r--r--src/test/ui/impl-trait/issue-69840.rs16
-rw-r--r--src/test/ui/namespace/namespace-mix.stderr8
-rw-r--r--src/test/ui/never_type/issue-51506.rs41
-rw-r--r--src/test/ui/never_type/issue-51506.stderr14
-rw-r--r--src/test/ui/range/issue-73553-misinterp-range-literal.rs16
-rw-r--r--src/test/ui/range/issue-73553-misinterp-range-literal.stderr27
-rw-r--r--src/test/ui/resolve/issue-21221-2.stderr4
-rw-r--r--src/test/ui/resolve/privacy-enum-ctor.stderr8
-rw-r--r--src/test/ui/specialization/issue-44861.rs40
-rw-r--r--src/test/ui/specialization/issue-44861.stderr12
-rw-r--r--src/test/ui/specialization/issue-59435.rs17
-rw-r--r--src/test/ui/specialization/issue-59435.stderr12
14 files changed, 215 insertions, 9 deletions
diff --git a/src/test/ui/glob-resolve1.rs b/src/test/ui/glob-resolve1.rs
index 63c435cc206..32660fdb418 100644
--- a/src/test/ui/glob-resolve1.rs
+++ b/src/test/ui/glob-resolve1.rs
@@ -29,3 +29,7 @@ fn main() {
     foo::<C>(); //~ ERROR: cannot find type `C` in this scope
     foo::<D>(); //~ ERROR: cannot find type `D` in this scope
 }
+
+mod other {
+    pub fn import() {}
+}
diff --git a/src/test/ui/glob-resolve1.stderr b/src/test/ui/glob-resolve1.stderr
index 995da6cc1f9..3c818f3ae48 100644
--- a/src/test/ui/glob-resolve1.stderr
+++ b/src/test/ui/glob-resolve1.stderr
@@ -42,6 +42,11 @@ error[E0425]: cannot find function `import` in this scope
    |
 LL |     import();
    |     ^^^^^^ not found in this scope
+   |
+help: consider importing this function
+   |
+LL | use other::import;
+   |
 
 error[E0412]: cannot find type `A` in this scope
   --> $DIR/glob-resolve1.rs:28:11
diff --git a/src/test/ui/impl-trait/issue-69840.rs b/src/test/ui/impl-trait/issue-69840.rs
new file mode 100644
index 00000000000..b270f88b688
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-69840.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+#![feature(impl_trait_in_bindings)]
+#![allow(incomplete_features)]
+
+struct A<'a>(&'a ());
+
+trait Trait<T> {}
+
+impl<T> Trait<T> for () {}
+
+pub fn foo<'a>() {
+    let _x: impl Trait<A<'a>> = ();
+}
+
+fn main() {}
diff --git a/src/test/ui/namespace/namespace-mix.stderr b/src/test/ui/namespace/namespace-mix.stderr
index c80055f00d7..ee730910ee4 100644
--- a/src/test/ui/namespace/namespace-mix.stderr
+++ b/src/test/ui/namespace/namespace-mix.stderr
@@ -16,7 +16,7 @@ help: consider importing one of these items instead
    |
 LL | use m2::S;
    |
-LL | use namespace_mix::xm2::S;
+LL | use xm2::S;
    |
 
 error[E0423]: expected value, found type alias `xm1::S`
@@ -39,7 +39,7 @@ help: consider importing one of these items instead
    |
 LL | use m2::S;
    |
-LL | use namespace_mix::xm2::S;
+LL | use xm2::S;
    |
 
 error[E0423]: expected value, found struct variant `m7::V`
@@ -61,7 +61,7 @@ help: consider importing one of these items instead
    |
 LL | use m8::V;
    |
-LL | use namespace_mix::xm8::V;
+LL | use xm8::V;
    |
 
 error[E0423]: expected value, found struct variant `xm7::V`
@@ -83,7 +83,7 @@ help: consider importing one of these items instead
    |
 LL | use m8::V;
    |
-LL | use namespace_mix::xm8::V;
+LL | use xm8::V;
    |
 
 error[E0277]: the trait bound `c::Item: Impossible` is not satisfied
diff --git a/src/test/ui/never_type/issue-51506.rs b/src/test/ui/never_type/issue-51506.rs
new file mode 100644
index 00000000000..d0fe6a0f59a
--- /dev/null
+++ b/src/test/ui/never_type/issue-51506.rs
@@ -0,0 +1,41 @@
+#![feature(never_type, specialization)]
+#![allow(incomplete_features)]
+
+use std::iter::{self, Empty};
+
+trait Trait {
+    type Out: Iterator<Item = u32>;
+
+    fn f(&self) -> Option<Self::Out>;
+}
+
+impl<T> Trait for T {
+    default type Out = !; //~ ERROR: `!` is not an iterator
+
+    default fn f(&self) -> Option<Self::Out> {
+        None
+    }
+}
+
+struct X;
+
+impl Trait for X {
+    type Out = Empty<u32>;
+
+    fn f(&self) -> Option<Self::Out> {
+        Some(iter::empty())
+    }
+}
+
+fn f<T: Trait>(a: T) {
+    if let Some(iter) = a.f() {
+        println!("Some");
+        for x in iter {
+            println!("x = {}", x);
+        }
+    }
+}
+
+pub fn main() {
+    f(10);
+}
diff --git a/src/test/ui/never_type/issue-51506.stderr b/src/test/ui/never_type/issue-51506.stderr
new file mode 100644
index 00000000000..73865a9b5a0
--- /dev/null
+++ b/src/test/ui/never_type/issue-51506.stderr
@@ -0,0 +1,14 @@
+error[E0277]: `!` is not an iterator
+  --> $DIR/issue-51506.rs:13:5
+   |
+LL |     type Out: Iterator<Item = u32>;
+   |     ------------------------------- required by `Trait::Out`
+...
+LL |     default type Out = !;
+   |     ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator
+   |
+   = help: the trait `std::iter::Iterator` is not implemented for `!`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/range/issue-73553-misinterp-range-literal.rs b/src/test/ui/range/issue-73553-misinterp-range-literal.rs
new file mode 100644
index 00000000000..e65dba0a038
--- /dev/null
+++ b/src/test/ui/range/issue-73553-misinterp-range-literal.rs
@@ -0,0 +1,16 @@
+type Range = std::ops::Range<usize>;
+
+fn demo(r: &Range) {
+    println!("{:?}", r);
+}
+
+fn tell(x: usize) -> usize {
+    x
+}
+
+fn main() {
+    demo(tell(1)..tell(10));
+    //~^ ERROR mismatched types
+    demo(1..10);
+    //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/range/issue-73553-misinterp-range-literal.stderr b/src/test/ui/range/issue-73553-misinterp-range-literal.stderr
new file mode 100644
index 00000000000..5167b87fd27
--- /dev/null
+++ b/src/test/ui/range/issue-73553-misinterp-range-literal.stderr
@@ -0,0 +1,27 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-73553-misinterp-range-literal.rs:12:10
+   |
+LL |     demo(tell(1)..tell(10));
+   |          ^^^^^^^^^^^^^^^^^
+   |          |
+   |          expected reference, found struct `std::ops::Range`
+   |          help: consider borrowing here: `&(tell(1)..tell(10))`
+   |
+   = note: expected reference `&std::ops::Range<usize>`
+                 found struct `std::ops::Range<usize>`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-73553-misinterp-range-literal.rs:14:10
+   |
+LL |     demo(1..10);
+   |          ^^^^^
+   |          |
+   |          expected reference, found struct `std::ops::Range`
+   |          help: consider borrowing here: `&(1..10)`
+   |
+   = note: expected reference `&std::ops::Range<usize>`
+                 found struct `std::ops::Range<{integer}>`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/resolve/issue-21221-2.stderr b/src/test/ui/resolve/issue-21221-2.stderr
index f9263d2af50..d4fd7cb1257 100644
--- a/src/test/ui/resolve/issue-21221-2.stderr
+++ b/src/test/ui/resolve/issue-21221-2.stderr
@@ -4,7 +4,9 @@ error[E0405]: cannot find trait `T` in this scope
 LL | impl T for Foo { }
    |      ^ not found in this scope
    |
-help: consider importing this trait
+help: consider importing one of these items
+   |
+LL | use baz::T;
    |
 LL | use foo::bar::T;
    |
diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr
index d9b1b9c5955..16baa6c9b62 100644
--- a/src/test/ui/resolve/privacy-enum-ctor.stderr
+++ b/src/test/ui/resolve/privacy-enum-ctor.stderr
@@ -132,7 +132,7 @@ LL |     let _: E = m::n::Z;
    |            ^
 help: consider importing this enum
    |
-LL | use m::n::Z;
+LL | use m::Z;
    |
 
 error[E0423]: expected value, found enum `m::n::Z`
@@ -165,7 +165,7 @@ LL |     let _: E = m::n::Z::Fn;
    |            ^
 help: consider importing this enum
    |
-LL | use m::n::Z;
+LL | use m::Z;
    |
 
 error[E0412]: cannot find type `Z` in this scope
@@ -183,7 +183,7 @@ LL |     let _: E = m::n::Z::Struct;
    |            ^
 help: consider importing this enum
    |
-LL | use m::n::Z;
+LL | use m::Z;
    |
 
 error[E0423]: expected value, found struct variant `m::n::Z::Struct`
@@ -212,7 +212,7 @@ LL |     let _: E = m::n::Z::Unit {};
    |            ^
 help: consider importing this enum
    |
-LL | use m::n::Z;
+LL | use m::Z;
    |
 
 error[E0603]: enum `Z` is private
diff --git a/src/test/ui/specialization/issue-44861.rs b/src/test/ui/specialization/issue-44861.rs
new file mode 100644
index 00000000000..c37a6273de3
--- /dev/null
+++ b/src/test/ui/specialization/issue-44861.rs
@@ -0,0 +1,40 @@
+#![crate_type = "lib"]
+#![feature(specialization)]
+#![feature(unsize, coerce_unsized)]
+#![allow(incomplete_features)]
+
+use std::ops::CoerceUnsized;
+
+pub struct SmartassPtr<A: Smartass+?Sized>(A::Data);
+
+pub trait Smartass {
+    type Data;
+    type Data2: CoerceUnsized<*const [u8]>;
+}
+
+pub trait MaybeObjectSafe {}
+
+impl MaybeObjectSafe for () {}
+
+impl<T> Smartass for T {
+    type Data = <Self as Smartass>::Data2;
+    default type Data2 = ();
+    //~^ ERROR: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied
+}
+
+impl Smartass for () {
+    type Data2 = *const [u8; 1];
+}
+
+impl Smartass for dyn MaybeObjectSafe {
+    type Data = *const [u8];
+    type Data2 = *const [u8; 0];
+}
+
+impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U>
+    where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data>
+{}
+
+pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<dyn MaybeObjectSafe> {
+    s
+}
diff --git a/src/test/ui/specialization/issue-44861.stderr b/src/test/ui/specialization/issue-44861.stderr
new file mode 100644
index 00000000000..b41b17e76a6
--- /dev/null
+++ b/src/test/ui/specialization/issue-44861.stderr
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied
+  --> $DIR/issue-44861.rs:21:5
+   |
+LL |     type Data2: CoerceUnsized<*const [u8]>;
+   |     --------------------------------------- required by `Smartass::Data2`
+...
+LL |     default type Data2 = ();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::CoerceUnsized<*const [u8]>` is not implemented for `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/specialization/issue-59435.rs b/src/test/ui/specialization/issue-59435.rs
new file mode 100644
index 00000000000..47323d3096f
--- /dev/null
+++ b/src/test/ui/specialization/issue-59435.rs
@@ -0,0 +1,17 @@
+#![feature(specialization)]
+#![allow(incomplete_features)]
+
+struct MyStruct {}
+
+trait MyTrait {
+    type MyType: Default;
+}
+
+impl MyTrait for i32 {
+    default type MyType = MyStruct;
+    //~^ ERROR: the trait bound `MyStruct: std::default::Default` is not satisfied
+}
+
+fn main() {
+    let _x: <i32 as MyTrait>::MyType = <i32 as MyTrait>::MyType::default();
+}
diff --git a/src/test/ui/specialization/issue-59435.stderr b/src/test/ui/specialization/issue-59435.stderr
new file mode 100644
index 00000000000..fd512a539a3
--- /dev/null
+++ b/src/test/ui/specialization/issue-59435.stderr
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `MyStruct: std::default::Default` is not satisfied
+  --> $DIR/issue-59435.rs:11:5
+   |
+LL |     type MyType: Default;
+   |     --------------------- required by `MyTrait::MyType`
+...
+LL |     default type MyType = MyStruct;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `MyStruct`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.