summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-04-09 00:11:27 +0000
committerbors <bors@rust-lang.org>2020-04-09 00:11:27 +0000
commitd249d756374737eb014079901ac132f1e1ed905e (patch)
treee40a76a168a79ea3db20a0671e7367756dbc93a3 /src/test
parent1edcfc83c6a08ddc5e63fc652b149baea0236e7c (diff)
parent5848209b64ad3403c155bc884f25500b178a5610 (diff)
downloadrust-d249d756374737eb014079901ac132f1e1ed905e.tar.gz
rust-d249d756374737eb014079901ac132f1e1ed905e.zip
Auto merge of #70936 - Dylan-DPC:rollup-2ng3e5h, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #70134 (add basic support of OsStrExt for HermitCore)
 - #70565 (Add inline attributes for functions used in the query system)
 - #70828 (rustdoc: Don't try to load source files from external crates)
 - #70870 (Fix abuses of tykind::err)
 - #70906 (Suggest move for closures and async blocks in more cases.)
 - #70912 (Do not suggest adding type param when `use` is already suggested)
 - #70930 (add tracking issue to `VecDeque::make_contiguous`)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test')
-rw-r--r--src/test/rustdoc/auxiliary/external-macro-src.rs15
-rw-r--r--src/test/rustdoc/external-macro-src.rs15
-rw-r--r--src/test/rustdoc/issue-26606.rs2
-rw-r--r--src/test/rustdoc/thread-local-src.rs6
-rw-r--r--src/test/ui/async-await/async-borrowck-escaping-block-error.fixed10
-rw-r--r--src/test/ui/async-await/async-borrowck-escaping-block-error.rs10
-rw-r--r--src/test/ui/async-await/async-borrowck-escaping-block-error.stderr31
-rw-r--r--src/test/ui/async-await/async-borrowck-escaping-closure-error.rs2
-rw-r--r--src/test/ui/impl-trait/does-not-live-long-enough.rs2
-rw-r--r--src/test/ui/impl-trait/does-not-live-long-enough.stderr26
-rw-r--r--src/test/ui/privacy/privacy-ns1.stderr4
-rw-r--r--src/test/ui/suggestions/no-extern-crate-in-type.stderr4
12 files changed, 93 insertions, 34 deletions
diff --git a/src/test/rustdoc/auxiliary/external-macro-src.rs b/src/test/rustdoc/auxiliary/external-macro-src.rs
new file mode 100644
index 00000000000..ce20ca5c91e
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/external-macro-src.rs
@@ -0,0 +1,15 @@
+// compile-flags:--remap-path-prefix={{src-base}}=/does-not-exist
+
+#![doc(html_root_url = "https://example.com/")]
+
+#[macro_export]
+macro_rules! make_foo {
+    () => {
+        pub struct Foo;
+        impl Foo {
+            pub fn new() -> Foo {
+                Foo
+            }
+        }
+    }
+}
diff --git a/src/test/rustdoc/external-macro-src.rs b/src/test/rustdoc/external-macro-src.rs
new file mode 100644
index 00000000000..4394415e5c7
--- /dev/null
+++ b/src/test/rustdoc/external-macro-src.rs
@@ -0,0 +1,15 @@
+// aux-build:external-macro-src.rs
+// ignore-tidy-linelength
+
+#![crate_name = "foo"]
+
+#[macro_use]
+extern crate external_macro_src;
+
+// @has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#4-15"]' '[src]'
+
+// @has foo/struct.Foo.html
+// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#8"]' '[src]'
+// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#9-13"]' '[src]'
+// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#10-12"]' '[src]'
+make_foo!();
diff --git a/src/test/rustdoc/issue-26606.rs b/src/test/rustdoc/issue-26606.rs
index d2aa4bbbd12..c8e9a63ea9f 100644
--- a/src/test/rustdoc/issue-26606.rs
+++ b/src/test/rustdoc/issue-26606.rs
@@ -7,5 +7,5 @@
 extern crate issue_26606_macro;
 
 // @has issue_26606/constant.FOO.html
-// @has - '//a/@href' '../src/issue_26606/auxiliary/issue-26606-macro.rs.html#3'
+// @has - '//a/@href' '../src/issue_26606_macro/issue-26606-macro.rs.html#3'
 make_item!(FOO);
diff --git a/src/test/rustdoc/thread-local-src.rs b/src/test/rustdoc/thread-local-src.rs
new file mode 100644
index 00000000000..022d81a4dbf
--- /dev/null
+++ b/src/test/rustdoc/thread-local-src.rs
@@ -0,0 +1,6 @@
+#![crate_name = "foo"]
+
+// @has foo/index.html '//a[@href="../src/foo/thread-local-src.rs.html#1-6"]' '[src]'
+
+// @has foo/constant.FOO.html '//a/@href' 'https://doc.rust-lang.org/nightly/src/std/'
+thread_local!(pub static FOO: bool = false);
diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.fixed b/src/test/ui/async-await/async-borrowck-escaping-block-error.fixed
index f004b4180dd..605cfdfe747 100644
--- a/src/test/ui/async-await/async-borrowck-escaping-block-error.fixed
+++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.fixed
@@ -1,12 +1,18 @@
 // edition:2018
 // run-rustfix
 
-fn foo() -> Box<impl std::future::Future<Output = u32>> {
+fn test_boxed() -> Box<impl std::future::Future<Output = u32>> {
     let x = 0u32;
     Box::new(async move { x } )
     //~^ ERROR E0373
 }
 
+fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
+    async move { *x }
+    //~^ ERROR E0373
+}
+
 fn main() {
-    let _foo = foo();
+    let _ = test_boxed();
+    let _ = test_ref(&0u32);
 }
diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.rs b/src/test/ui/async-await/async-borrowck-escaping-block-error.rs
index 4f35fd52ca3..ec752c15fa2 100644
--- a/src/test/ui/async-await/async-borrowck-escaping-block-error.rs
+++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.rs
@@ -1,12 +1,18 @@
 // edition:2018
 // run-rustfix
 
-fn foo() -> Box<impl std::future::Future<Output = u32>> {
+fn test_boxed() -> Box<impl std::future::Future<Output = u32>> {
     let x = 0u32;
     Box::new(async { x } )
     //~^ ERROR E0373
 }
 
+fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ {
+    async { *x }
+    //~^ ERROR E0373
+}
+
 fn main() {
-    let _foo = foo();
+    let _ = test_boxed();
+    let _ = test_ref(&0u32);
 }
diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr
index 0eb3971d14a..193026541d0 100644
--- a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr
+++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr
@@ -1,4 +1,4 @@
-error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
+error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
   --> $DIR/async-borrowck-escaping-block-error.rs:6:20
    |
 LL |     Box::new(async { x } )
@@ -7,16 +7,35 @@ LL |     Box::new(async { x } )
    |                    | `x` is borrowed here
    |                    may outlive borrowed value `x`
    |
-note: generator is returned here
-  --> $DIR/async-borrowck-escaping-block-error.rs:4:13
+note: async block is returned here
+  --> $DIR/async-borrowck-escaping-block-error.rs:4:20
    |
-LL | fn foo() -> Box<impl std::future::Future<Output = u32>> {
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | fn test_boxed() -> Box<impl std::future::Future<Output = u32>> {
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword
    |
 LL |     Box::new(async move { x } )
    |                    ^^^^^^^^^^
 
-error: aborting due to previous error
+error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function
+  --> $DIR/async-borrowck-escaping-block-error.rs:11:11
+   |
+LL |     async { *x }
+   |           ^^^-^^
+   |           |  |
+   |           |  `x` is borrowed here
+   |           may outlive borrowed value `x`
+   |
+note: async block is returned here
+  --> $DIR/async-borrowck-escaping-block-error.rs:11:5
+   |
+LL |     async { *x }
+   |     ^^^^^^^^^^^^
+help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword
+   |
+LL |     async move { *x }
+   |           ^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0373`.
diff --git a/src/test/ui/async-await/async-borrowck-escaping-closure-error.rs b/src/test/ui/async-await/async-borrowck-escaping-closure-error.rs
index d2fa5d0a3d0..e667b72aee5 100644
--- a/src/test/ui/async-await/async-borrowck-escaping-closure-error.rs
+++ b/src/test/ui/async-await/async-borrowck-escaping-closure-error.rs
@@ -1,5 +1,5 @@
 // edition:2018
-#![feature(async_closure,async_await)]
+#![feature(async_closure)]
 fn foo() -> Box<dyn std::future::Future<Output = u32>> {
     let x = 0u32;
     Box::new((async || x)())
diff --git a/src/test/ui/impl-trait/does-not-live-long-enough.rs b/src/test/ui/impl-trait/does-not-live-long-enough.rs
index 6179132b3f6..d2a345231eb 100644
--- a/src/test/ui/impl-trait/does-not-live-long-enough.rs
+++ b/src/test/ui/impl-trait/does-not-live-long-enough.rs
@@ -4,7 +4,7 @@ struct List {
 impl List {
     fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> {
         self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref())
-        //~^ ERROR does not live long enough
+        //~^ ERROR E0373
     }
 }
 
diff --git a/src/test/ui/impl-trait/does-not-live-long-enough.stderr b/src/test/ui/impl-trait/does-not-live-long-enough.stderr
index 9cff4bcd8b5..468c2f36629 100644
--- a/src/test/ui/impl-trait/does-not-live-long-enough.stderr
+++ b/src/test/ui/impl-trait/does-not-live-long-enough.stderr
@@ -1,21 +1,21 @@
-error[E0597]: `prefix` does not live long enough
-  --> $DIR/does-not-live-long-enough.rs:6:51
+error[E0373]: closure may outlive the current function, but it borrows `prefix`, which is owned by the current function
+  --> $DIR/does-not-live-long-enough.rs:6:33
    |
-LL |     fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> {
-   |                     -- lifetime `'a` defined here     --------------------------- opaque type requires that `prefix` is borrowed for `'a`
 LL |         self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref())
-   |                                 ---               ^^^^^^ borrowed value does not live long enough
+   |                                 ^^^               ------ `prefix` is borrowed here
    |                                 |
-   |                                 value captured here
-LL |
-LL |     }
-   |     - `prefix` dropped here while still borrowed
+   |                                 may outlive borrowed value `prefix`
+   |
+note: closure is returned here
+  --> $DIR/does-not-live-long-enough.rs:5:55
    |
-help: you can add a bound to the opaque type to make it last less than `'static` and match `'a`
+LL |     fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> {
+   |                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: to force the closure to take ownership of `prefix` (and any other referenced variables), use the `move` keyword
    |
-LL |     fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> + 'a {
-   |                                                                                   ^^^^
+LL |         self.data.iter().filter(move |s| s.starts_with(prefix)).map(|s| s.as_ref())
+   |                                 ^^^^^^^^
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0597`.
+For more information about this error, try `rustc --explain E0373`.
diff --git a/src/test/ui/privacy/privacy-ns1.stderr b/src/test/ui/privacy/privacy-ns1.stderr
index 66e9b78f676..45ca00f55ab 100644
--- a/src/test/ui/privacy/privacy-ns1.stderr
+++ b/src/test/ui/privacy/privacy-ns1.stderr
@@ -63,10 +63,6 @@ LL | use foo2::Bar;
    |
 LL | use foo3::Bar;
    |
-help: you might be missing a type parameter
-   |
-LL | fn test_glob3<Bar>() {
-   |              ^^^^^
 
 error[E0107]: wrong number of const arguments: expected 0, found 1
   --> $DIR/privacy-ns1.rs:35:17
diff --git a/src/test/ui/suggestions/no-extern-crate-in-type.stderr b/src/test/ui/suggestions/no-extern-crate-in-type.stderr
index 0a73a269134..22aad3b0a9f 100644
--- a/src/test/ui/suggestions/no-extern-crate-in-type.stderr
+++ b/src/test/ui/suggestions/no-extern-crate-in-type.stderr
@@ -8,10 +8,6 @@ help: possible candidate is found in another module, you can import it into scop
    |
 LL | use foo::Foo;
    |
-help: you might be missing a type parameter
-   |
-LL | type Output<Foo> = Option<Foo>;
-   |            ^^^^^
 
 error: aborting due to previous error