about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-11-10 10:43:14 +0000
committerbors <bors@rust-lang.org>2020-11-10 10:43:14 +0000
commitcf9cf7c923eb01146971429044f216a3ca905e06 (patch)
tree3c062e157444df6991fc582cf36b48a8d83b7e2a /src/test/ui
parent25f6938da459a57b43bdf16ed6bdad3225b2a3ce (diff)
parentc150b933ac73a7a1102f1ee934e8f94bfe73be63 (diff)
Auto merge of #78904 - Dylan-DPC:rollup-8d2w3vu, r=Dylan-DPC
Rollup of 12 pull requests

Successful merges:

 - #74754 (Add `#[cfg(panic = '...')]`)
 - #76468 (Improve lifetime name annotations for closures & async functions)
 - #77016 (Test clippy on PR CI on changes)
 - #78480 (BTreeMap: fix pointer provenance rules)
 - #78502 (Update Chalk to 0.36.0)
 - #78513 (Infer the default host target from the host toolchain if possible)
 - #78566 (Enable LLVM Polly via llvm-args.)
 - #78580 (inliner: Break inlining cycles)
 - #78710 (rustc_ast: Do not panic by default when visiting macro calls)
 - #78746 (Demote i686-unknown-freebsd to tier 2 compiler target)
 - #78830 (fix `super_visit_with` for `Terminator`)
 - #78844 (Monomorphize a type argument of size-of operation during codegen)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/async-await/issue-74072-lifetime-name-annotations.rs37
-rw-r--r--src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr51
-rw-r--r--src/test/ui/async-await/issue-74497-lifetime-in-opaque.rs19
-rw-r--r--src/test/ui/async-await/issue-74497-lifetime-in-opaque.stderr11
-rw-r--r--src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr2
-rw-r--r--src/test/ui/cfg/cfg-panic-abort.rs16
-rw-r--r--src/test/ui/cfg/cfg-panic.rs18
-rw-r--r--src/test/ui/chalkify/arithmetic.rs20
-rw-r--r--src/test/ui/chalkify/trait-objects.rs13
-rw-r--r--src/test/ui/consts/control-flow/assert.const_panic.stderr (renamed from src/test/ui/consts/control-flow/assert.panic.stderr)0
-rw-r--r--src/test/ui/consts/control-flow/assert.rs6
-rw-r--r--src/test/ui/feature-gates/feature-gate-cfg-panic.rs11
-rw-r--r--src/test/ui/feature-gates/feature-gate-cfg-panic.stderr21
-rw-r--r--src/test/ui/fmt/format-args-capture.rs13
-rw-r--r--src/test/ui/issues/issue-68696-catch-during-unwind.rs4
-rw-r--r--src/test/ui/nll/issue-58053.stderr4
-rw-r--r--src/test/ui/parser/issue-65122-mac-invoc-in-mut-patterns.rs2
-rw-r--r--src/test/ui/test-attrs/test-allow-fail-attr.rs3
18 files changed, 237 insertions, 14 deletions
diff --git a/src/test/ui/async-await/issue-74072-lifetime-name-annotations.rs b/src/test/ui/async-await/issue-74072-lifetime-name-annotations.rs
new file mode 100644
index 00000000000..95683241aba
--- /dev/null
+++ b/src/test/ui/async-await/issue-74072-lifetime-name-annotations.rs
@@ -0,0 +1,37 @@
+// edition:2018
+#![feature(async_closure)]
+use std::future::Future;
+
+// test the quality of annotations giving lifetimes names (`'1`) when async constructs are involved
+
+pub async fn async_fn(x: &mut i32) -> &i32 {
+    let y = &*x;
+    *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
+    y
+}
+
+pub fn async_closure(x: &mut i32) -> impl Future<Output=&i32> {
+    (async move || {
+        let y = &*x;
+        *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
+        y
+    })()
+}
+
+pub fn async_closure_explicit_return_type(x: &mut i32) -> impl Future<Output=&i32> {
+    (async move || -> &i32 {
+        let y = &*x;
+        *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
+        y
+    })()
+}
+
+pub fn async_block(x: &mut i32) -> impl Future<Output=&i32> {
+    async move {
+        let y = &*x;
+        *x += 1; //~ ERROR cannot assign to `*x` because it is borrowed
+        y
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr b/src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr
new file mode 100644
index 00000000000..123c3192cff
--- /dev/null
+++ b/src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr
@@ -0,0 +1,51 @@
+error[E0506]: cannot assign to `*x` because it is borrowed
+  --> $DIR/issue-74072-lifetime-name-annotations.rs:9:5
+   |
+LL | pub async fn async_fn(x: &mut i32) -> &i32 {
+   |                                       - let's call the lifetime of this reference `'1`
+LL |     let y = &*x;
+   |             --- borrow of `*x` occurs here
+LL |     *x += 1;
+   |     ^^^^^^^ assignment to borrowed `*x` occurs here
+LL |     y
+   |     - returning this value requires that `*x` is borrowed for `'1`
+
+error[E0506]: cannot assign to `*x` because it is borrowed
+  --> $DIR/issue-74072-lifetime-name-annotations.rs:16:9
+   |
+LL |         let y = &*x;
+   |                 --- borrow of `*x` occurs here
+LL |         *x += 1;
+   |         ^^^^^^^ assignment to borrowed `*x` occurs here
+LL |         y
+   |         - returning this value requires that `*x` is borrowed for `'1`
+LL |     })()
+   |     - return type of async closure is &'1 i32
+
+error[E0506]: cannot assign to `*x` because it is borrowed
+  --> $DIR/issue-74072-lifetime-name-annotations.rs:24:9
+   |
+LL |     (async move || -> &i32 {
+   |                       - let's call the lifetime of this reference `'1`
+LL |         let y = &*x;
+   |                 --- borrow of `*x` occurs here
+LL |         *x += 1;
+   |         ^^^^^^^ assignment to borrowed `*x` occurs here
+LL |         y
+   |         - returning this value requires that `*x` is borrowed for `'1`
+
+error[E0506]: cannot assign to `*x` because it is borrowed
+  --> $DIR/issue-74072-lifetime-name-annotations.rs:32:9
+   |
+LL |         let y = &*x;
+   |                 --- borrow of `*x` occurs here
+LL |         *x += 1;
+   |         ^^^^^^^ assignment to borrowed `*x` occurs here
+LL |         y
+   |         - returning this value requires that `*x` is borrowed for `'1`
+LL |     }
+   |     - return type of async block is &'1 i32
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0506`.
diff --git a/src/test/ui/async-await/issue-74497-lifetime-in-opaque.rs b/src/test/ui/async-await/issue-74497-lifetime-in-opaque.rs
new file mode 100644
index 00000000000..2d765eb41be
--- /dev/null
+++ b/src/test/ui/async-await/issue-74497-lifetime-in-opaque.rs
@@ -0,0 +1,19 @@
+// edition:2018
+
+// test that names give to anonymous lifetimes in opaque types like `impl Future` are correctly
+// introduced in error messages
+
+use std::future::Future;
+
+pub async fn foo<F, T>(_: F)
+where
+    F: Fn(&u8) -> T,
+    T: Future<Output = ()>,
+{
+}
+
+pub async fn bar(_: &u8) {}
+
+fn main() {
+    let _ = foo(|x| bar(x)); //~ ERROR lifetime may not live long enough
+}
diff --git a/src/test/ui/async-await/issue-74497-lifetime-in-opaque.stderr b/src/test/ui/async-await/issue-74497-lifetime-in-opaque.stderr
new file mode 100644
index 00000000000..89fe1abb365
--- /dev/null
+++ b/src/test/ui/async-await/issue-74497-lifetime-in-opaque.stderr
@@ -0,0 +1,11 @@
+error: lifetime may not live long enough
+  --> $DIR/issue-74497-lifetime-in-opaque.rs:18:21
+   |
+LL |     let _ = foo(|x| bar(x));
+   |                  -- ^^^^^^ returning this value requires that `'1` must outlive `'2`
+   |                  ||
+   |                  |return type of closure `impl Future` contains a lifetime `'2`
+   |                  has type `&'1 u8`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr b/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr
index e8a026cfab9..a7c3b9eec73 100644
--- a/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr
+++ b/src/test/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr
@@ -4,7 +4,7 @@ error: lifetime may not live long enough
 LL |     let _action = move || {
    |                   -------
    |                   |     |
-   |                   |     return type of closure is [closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:15]
+   |                   |     return type of closure `[closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:15]` contains a lifetime `'2`
    |                   lifetime `'1` represents this closure's body
 LL |         || f() // The `nested` closure
    |         ^^^^^^ returning this value requires that `'1` must outlive `'2`
diff --git a/src/test/ui/cfg/cfg-panic-abort.rs b/src/test/ui/cfg/cfg-panic-abort.rs
new file mode 100644
index 00000000000..9b88eff12ed
--- /dev/null
+++ b/src/test/ui/cfg/cfg-panic-abort.rs
@@ -0,0 +1,16 @@
+// build-pass
+// compile-flags: -C panic=abort
+// no-prefer-dynamic
+#![feature(cfg_panic)]
+
+#[cfg(panic = "unwind")]
+pub fn bad() -> i32 { }
+
+#[cfg(not(panic = "abort"))]
+pub fn bad() -> i32 { }
+
+#[cfg(panic = "some_imaginary_future_panic_handler")]
+pub fn bad() -> i32 { }
+
+#[cfg(panic = "abort")]
+pub fn main() { }
diff --git a/src/test/ui/cfg/cfg-panic.rs b/src/test/ui/cfg/cfg-panic.rs
new file mode 100644
index 00000000000..dbb5932a9bb
--- /dev/null
+++ b/src/test/ui/cfg/cfg-panic.rs
@@ -0,0 +1,18 @@
+// build-pass
+// compile-flags: -C panic=unwind
+// ignore-emscripten no panic_unwind implementation
+// ignore-wasm32     no panic_unwind implementation
+// ignore-wasm64     no panic_unwind implementation
+#![feature(cfg_panic)]
+
+#[cfg(panic = "abort")]
+pub fn bad() -> i32 { }
+
+#[cfg(not(panic = "unwind"))]
+pub fn bad() -> i32 { }
+
+#[cfg(panic = "some_imaginary_future_panic_handler")]
+pub fn bad() -> i32 { }
+
+#[cfg(panic = "unwind")]
+pub fn main() { }
diff --git a/src/test/ui/chalkify/arithmetic.rs b/src/test/ui/chalkify/arithmetic.rs
new file mode 100644
index 00000000000..a20acce4c76
--- /dev/null
+++ b/src/test/ui/chalkify/arithmetic.rs
@@ -0,0 +1,20 @@
+// check-pass
+// compile-flags: -Z chalk
+
+fn main() {
+    1 + 2;
+    3 * 6;
+    2 - 5;
+    17 / 6;
+    23 % 11;
+    4 & 6;
+    7 | 15;
+    4 << 7;
+    123 >> 3;
+    1 == 2;
+    5 != 5;
+    6 < 2;
+    7 > 11;
+    3 <= 1;
+    9 >= 14;
+}
diff --git a/src/test/ui/chalkify/trait-objects.rs b/src/test/ui/chalkify/trait-objects.rs
new file mode 100644
index 00000000000..13d9e6a6578
--- /dev/null
+++ b/src/test/ui/chalkify/trait-objects.rs
@@ -0,0 +1,13 @@
+// check-pass
+// compile-flags: -Z chalk
+
+use std::fmt::Display;
+
+fn main() {
+    let d: &dyn Display = &mut 3;
+    // FIXME(chalk) should be able to call d.to_string() as well, but doing so
+    // requires Chalk to be able to prove trait object well-formed goals.
+    (&d).to_string();
+    let f: &dyn Fn(i32) -> _ = &|x| x + x;
+    f(2);
+}
diff --git a/src/test/ui/consts/control-flow/assert.panic.stderr b/src/test/ui/consts/control-flow/assert.const_panic.stderr
index 03662a35209..03662a35209 100644
--- a/src/test/ui/consts/control-flow/assert.panic.stderr
+++ b/src/test/ui/consts/control-flow/assert.const_panic.stderr
diff --git a/src/test/ui/consts/control-flow/assert.rs b/src/test/ui/consts/control-flow/assert.rs
index 30cd31ee8a7..90017fee193 100644
--- a/src/test/ui/consts/control-flow/assert.rs
+++ b/src/test/ui/consts/control-flow/assert.rs
@@ -1,14 +1,14 @@
 // Test that `assert` works when `const_panic` is enabled.
 
-// revisions: stock panic
+// revisions: stock const_panic
 
-#![cfg_attr(panic, feature(const_panic))]
+#![cfg_attr(const_panic, feature(const_panic))]
 
 const _: () = assert!(true);
 //[stock]~^ ERROR panicking in constants is unstable
 
 const _: () = assert!(false);
 //[stock]~^ ERROR panicking in constants is unstable
-//[panic]~^^ ERROR any use of this value will cause an error
+//[const_panic]~^^ ERROR any use of this value will cause an error
 
 fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-cfg-panic.rs b/src/test/ui/feature-gates/feature-gate-cfg-panic.rs
new file mode 100644
index 00000000000..1508374d942
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-cfg-panic.rs
@@ -0,0 +1,11 @@
+#[cfg(panic = "unwind")]
+//~^ ERROR `cfg(panic)` is experimental and subject to change
+fn foo() -> bool { true }
+#[cfg(not(panic = "unwind"))]
+//~^ ERROR `cfg(panic)` is experimental and subject to change
+fn foo() -> bool { false }
+
+
+fn main() {
+    assert!(foo());
+}
diff --git a/src/test/ui/feature-gates/feature-gate-cfg-panic.stderr b/src/test/ui/feature-gates/feature-gate-cfg-panic.stderr
new file mode 100644
index 00000000000..ea5cd54fa90
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-cfg-panic.stderr
@@ -0,0 +1,21 @@
+error[E0658]: `cfg(panic)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-panic.rs:1:7
+   |
+LL | #[cfg(panic = "unwind")]
+   |       ^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #77443 <https://github.com/rust-lang/rust/issues/77443> for more information
+   = help: add `#![feature(cfg_panic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(panic)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-panic.rs:4:11
+   |
+LL | #[cfg(not(panic = "unwind"))]
+   |           ^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #77443 <https://github.com/rust-lang/rust/issues/77443> for more information
+   = help: add `#![feature(cfg_panic)]` to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/fmt/format-args-capture.rs b/src/test/ui/fmt/format-args-capture.rs
index 7490632110c..9348bb46dfe 100644
--- a/src/test/ui/fmt/format-args-capture.rs
+++ b/src/test/ui/fmt/format-args-capture.rs
@@ -1,13 +1,16 @@
 // run-pass
-// ignore-wasm32
-// ignore-wasm64
 #![feature(format_args_capture)]
+#![feature(cfg_panic)]
 
 fn main() {
     named_argument_takes_precedence_to_captured();
-    panic_with_single_argument_does_not_get_formatted();
-    panic_with_multiple_arguments_is_formatted();
     formatting_parameters_can_be_captured();
+
+    #[cfg(panic = "unwind")]
+    {
+        panic_with_single_argument_does_not_get_formatted();
+        panic_with_multiple_arguments_is_formatted();
+    }
 }
 
 fn named_argument_takes_precedence_to_captured() {
@@ -22,6 +25,7 @@ fn named_argument_takes_precedence_to_captured() {
     assert_eq!(&s, "positional-named-captured");
 }
 
+#[cfg(panic = "unwind")]
 fn panic_with_single_argument_does_not_get_formatted() {
     // panic! with a single argument does not perform string formatting.
     // RFC #2795 suggests that this may need to change so that captured arguments are formatted.
@@ -34,6 +38,7 @@ fn panic_with_single_argument_does_not_get_formatted() {
     assert_eq!(msg.downcast_ref::<&str>(), Some(&"{foo}"))
 }
 
+#[cfg(panic = "unwind")]
 fn panic_with_multiple_arguments_is_formatted() {
     let foo = "captured";
 
diff --git a/src/test/ui/issues/issue-68696-catch-during-unwind.rs b/src/test/ui/issues/issue-68696-catch-during-unwind.rs
index d042bed225d..f25a78f59cd 100644
--- a/src/test/ui/issues/issue-68696-catch-during-unwind.rs
+++ b/src/test/ui/issues/issue-68696-catch-during-unwind.rs
@@ -4,8 +4,7 @@
 // entering the catch_unwind.
 //
 // run-pass
-// ignore-wasm       no panic support
-// ignore-emscripten no panic support
+#![feature(cfg_panic)]
 
 use std::panic::catch_unwind;
 
@@ -19,6 +18,7 @@ impl Drop for Guard {
 }
 
 fn main() {
+    #[cfg(panic = "unwind")]
     let _ = catch_unwind(|| {
         let _guard = Guard::default();
         panic!();
diff --git a/src/test/ui/nll/issue-58053.stderr b/src/test/ui/nll/issue-58053.stderr
index 297681ff403..e41ee8a8970 100644
--- a/src/test/ui/nll/issue-58053.stderr
+++ b/src/test/ui/nll/issue-58053.stderr
@@ -2,9 +2,9 @@ error: lifetime may not live long enough
   --> $DIR/issue-58053.rs:6:33
    |
 LL |     let f = |x: &i32| -> &i32 { x };
-   |                 -        ----   ^ returning this value requires that `'1` must outlive `'2`
+   |                 -        -      ^ returning this value requires that `'1` must outlive `'2`
    |                 |        |
-   |                 |        return type of closure is &'2 i32
+   |                 |        let's call the lifetime of this reference `'2`
    |                 let's call the lifetime of this reference `'1`
 
 error: lifetime may not live long enough
diff --git a/src/test/ui/parser/issue-65122-mac-invoc-in-mut-patterns.rs b/src/test/ui/parser/issue-65122-mac-invoc-in-mut-patterns.rs
index 97a405b6999..30f3781bf77 100644
--- a/src/test/ui/parser/issue-65122-mac-invoc-in-mut-patterns.rs
+++ b/src/test/ui/parser/issue-65122-mac-invoc-in-mut-patterns.rs
@@ -1,4 +1,4 @@
-// Regression test; used to ICE with 'visit_mac disabled by default' due to a
+// Regression test; used to ICE with 'visit_mac_call disabled by default' due to a
 // `MutVisitor` in `fn make_all_value_bindings_mutable` (`parse/parser/pat.rs`).
 
 macro_rules! mac1 {
diff --git a/src/test/ui/test-attrs/test-allow-fail-attr.rs b/src/test/ui/test-attrs/test-allow-fail-attr.rs
index 1a478460efc..29ce9f7c2e9 100644
--- a/src/test/ui/test-attrs/test-allow-fail-attr.rs
+++ b/src/test/ui/test-attrs/test-allow-fail-attr.rs
@@ -1,11 +1,12 @@
 // run-pass
-// ignore-wasm32-bare compiled with panic=abort by default
 // compile-flags: --test
 #![feature(allow_fail)]
+#![feature(cfg_panic)]
 
 #[test]
 #[allow_fail]
 fn test1() {
+    #[cfg(not(panic = "abort"))]
     panic!();
 }