about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs2
-rw-r--r--tests/run-make-fulldeps/obtain-borrowck/driver.rs2
-rw-r--r--tests/rustdoc-gui/src/test_docs/lib.rs3
-rw-r--r--tests/rustdoc-gui/warning-block.goml13
-rw-r--r--tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs19
-rw-r--r--tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.stderr14
-rw-r--r--tests/ui/drop/dynamic-drop.rs14
-rw-r--r--tests/ui/feature-gates/bench.stderr22
-rw-r--r--tests/ui/lint/expansion-time.stderr15
-rw-r--r--tests/ui/proc-macro/inner-attr-non-inline-mod.stderr11
-rw-r--r--tests/ui/proc-macro/proc-macro-gates.stderr11
-rw-r--r--tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs59
-rw-r--r--tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs19
-rw-r--r--tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs32
-rw-r--r--tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs24
-rw-r--r--tests/ui/thir-print/thir-tree-match.stdout12
16 files changed, 264 insertions, 8 deletions
diff --git a/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs
index 086ca0bdf37..9e0a7ba63d0 100644
--- a/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs
+++ b/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs
@@ -67,7 +67,7 @@ impl CodegenBackend for TheBackend {
         let crate_name = codegen_results.crate_info.local_crate_name;
         for &crate_type in sess.opts.crate_types.iter() {
             if crate_type != CrateType::Rlib {
-                sess.fatal(format!("Crate type is {:?}", crate_type));
+                sess.dcx().fatal(format!("Crate type is {:?}", crate_type));
             }
             let output_name = out_filename(sess, crate_type, &outputs, crate_name);
             match output_name {
diff --git a/tests/run-make-fulldeps/obtain-borrowck/driver.rs b/tests/run-make-fulldeps/obtain-borrowck/driver.rs
index 9cbe9e5900a..2e3bf70e144 100644
--- a/tests/run-make-fulldeps/obtain-borrowck/driver.rs
+++ b/tests/run-make-fulldeps/obtain-borrowck/driver.rs
@@ -61,7 +61,7 @@ impl rustc_driver::Callbacks for CompilerCalls {
         compiler: &Compiler,
         queries: &'tcx Queries<'tcx>,
     ) -> Compilation {
-        compiler.sess.abort_if_errors();
+        compiler.sess.dcx().abort_if_errors();
         queries.global_ctxt().unwrap().enter(|tcx| {
             // Collect definition ids of MIR bodies.
             let hir = tcx.hir();
diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs
index 0bc777230bf..7e34178e56f 100644
--- a/tests/rustdoc-gui/src/test_docs/lib.rs
+++ b/tests/rustdoc-gui/src/test_docs/lib.rs
@@ -85,6 +85,9 @@ impl AsRef<str> for Foo {
     }
 }
 
+/// <div id="doc-warning-0" class="warning">I have warnings!</div>
+pub struct WarningStruct;
+
 /// Just a normal enum.
 ///
 /// # title!
diff --git a/tests/rustdoc-gui/warning-block.goml b/tests/rustdoc-gui/warning-block.goml
index 8832b65c4d8..10e206049f5 100644
--- a/tests/rustdoc-gui/warning-block.goml
+++ b/tests/rustdoc-gui/warning-block.goml
@@ -2,6 +2,7 @@
 go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
 show-text: true
 
+store-value: (default_y_pos, 5)
 define-function: (
     "check-warning",
     (theme, color, border_color),
@@ -16,12 +17,18 @@ define-function: (
             "border-left": "2px solid " + |border_color|,
             "background-color": "transparent",
         })
+        store-position: ("#doc-warning-1", {"y": warn_div_y})
+        store-position: ("#doc-warning-1::before", {"y": warn_y})
+        assert: |warn_y| == |warn_div_y| + |default_y_pos|
         assert-css: ("#doc-warning-2", {
             "margin-bottom": "0px",
             "color": |color|,
             "border-left": "2px solid " + |border_color|,
             "background-color": "transparent",
         })
+        store-position: ("#doc-warning-2", {"y": warn_div_y})
+        store-position: ("#doc-warning-2::before", {"y": warn_y})
+        assert: |warn_y| == |warn_div_y| + |default_y_pos|
     },
 )
 
@@ -40,3 +47,9 @@ call-function: ("check-warning", {
     "color": "black",
     "border_color": "#ff8e00",
 })
+
+// We ensure that the warning element in the top doc is not overlaying the "[-]" button.
+go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WarningStruct.html"
+store-position: ("#doc-warning-0", {"y": warn_div_y})
+store-position: ("#doc-warning-0::before", {"y": warn_y})
+assert: |warn_y| == |warn_div_y| + |default_y_pos| + 15
diff --git a/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs
new file mode 100644
index 00000000000..03e91f2b3b1
--- /dev/null
+++ b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs
@@ -0,0 +1,19 @@
+// run-pass
+// Eventually this will be rejected (when the future-compat lints are turned into hard errors), and
+// then this test can be removed. But meanwhile we should ensure that this works and does not ICE.
+struct NoDerive(i32);
+
+#[derive(PartialEq)]
+struct WrapEmbedded(*const NoDerive);
+
+const WRAP_UNSAFE_EMBEDDED: &&WrapEmbedded = &&WrapEmbedded(std::ptr::null());
+
+fn main() {
+    let b = match WRAP_UNSAFE_EMBEDDED {
+        WRAP_UNSAFE_EMBEDDED => true,
+        //~^ WARN: must be annotated with `#[derive(PartialEq, Eq)]`
+        //~| previously accepted
+        _ => false,
+    };
+    assert!(b);
+}
diff --git a/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.stderr b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.stderr
new file mode 100644
index 00000000000..c186d349e72
--- /dev/null
+++ b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.stderr
@@ -0,0 +1,14 @@
+warning: to use a constant of type `WrapEmbedded` in a pattern, `WrapEmbedded` must be annotated with `#[derive(PartialEq, Eq)]`
+  --> $DIR/null-raw-ptr-issue-119270.rs:13:9
+   |
+LL |         WRAP_UNSAFE_EMBEDDED => true,
+   |         ^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
+   = note: the traits must be derived, manual `impl`s are not sufficient
+   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
+   = note: `#[warn(indirect_structural_match)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/drop/dynamic-drop.rs b/tests/ui/drop/dynamic-drop.rs
index 5bf2cc30e7f..d35913ed641 100644
--- a/tests/ui/drop/dynamic-drop.rs
+++ b/tests/ui/drop/dynamic-drop.rs
@@ -343,6 +343,17 @@ fn if_let_guard(a: &Allocator, c: bool, d: i32) {
     }
 }
 
+fn if_let_guard_2(a: &Allocator, num: i32) {
+    let d = a.alloc();
+    match num {
+        #[allow(irrefutable_let_patterns)]
+        1 | 2 if let Ptr(ref _idx, _) = a.alloc() => {
+            a.alloc();
+        }
+        _ => {}
+    }
+}
+
 fn panic_after_return(a: &Allocator) -> Ptr<'_> {
     // Panic in the drop of `p` or `q` can leak
     let exceptions = vec![8, 9];
@@ -514,6 +525,9 @@ fn main() {
     run_test(|a| if_let_guard(a, false, 0));
     run_test(|a| if_let_guard(a, false, 1));
     run_test(|a| if_let_guard(a, false, 2));
+    run_test(|a| if_let_guard_2(a, 0));
+    run_test(|a| if_let_guard_2(a, 1));
+    run_test(|a| if_let_guard_2(a, 2));
 
     run_test(|a| {
         panic_after_return(a);
diff --git a/tests/ui/feature-gates/bench.stderr b/tests/ui/feature-gates/bench.stderr
index 5f0aaf9251f..df935560fd6 100644
--- a/tests/ui/feature-gates/bench.stderr
+++ b/tests/ui/feature-gates/bench.stderr
@@ -19,3 +19,25 @@ LL | use bench as _;
 
 error: aborting due to 2 previous errors
 
+Future incompatibility report: Future breakage diagnostic:
+error: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable
+  --> $DIR/bench.rs:3:3
+   |
+LL | #[bench]
+   |   ^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
+   = note: `#[deny(soft_unstable)]` on by default
+
+Future breakage diagnostic:
+error: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable
+  --> $DIR/bench.rs:7:5
+   |
+LL | use bench as _;
+   |     ^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
+   = note: `#[deny(soft_unstable)]` on by default
+
diff --git a/tests/ui/lint/expansion-time.stderr b/tests/ui/lint/expansion-time.stderr
index 064ee5fadb1..626e51dd00c 100644
--- a/tests/ui/lint/expansion-time.stderr
+++ b/tests/ui/lint/expansion-time.stderr
@@ -54,3 +54,18 @@ LL | #[warn(incomplete_include)]
 
 warning: 4 warnings emitted
 
+Future incompatibility report: Future breakage diagnostic:
+warning: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable
+  --> $DIR/expansion-time.rs:14:7
+   |
+LL |     #[bench]
+   |       ^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
+note: the lint level is defined here
+  --> $DIR/expansion-time.rs:12:8
+   |
+LL | #[warn(soft_unstable)]
+   |        ^^^^^^^^^^^^^
+
diff --git a/tests/ui/proc-macro/inner-attr-non-inline-mod.stderr b/tests/ui/proc-macro/inner-attr-non-inline-mod.stderr
index 2d357d04d5c..36825e5a398 100644
--- a/tests/ui/proc-macro/inner-attr-non-inline-mod.stderr
+++ b/tests/ui/proc-macro/inner-attr-non-inline-mod.stderr
@@ -38,3 +38,14 @@ LL | #![rustfmt::skip]
 error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0658`.
+Future incompatibility report: Future breakage diagnostic:
+error: custom inner attributes are unstable
+  --> $DIR/module_with_attrs.rs:3:4
+   |
+LL | #![rustfmt::skip]
+   |    ^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
+   = note: `#[deny(soft_unstable)]` on by default
+
diff --git a/tests/ui/proc-macro/proc-macro-gates.stderr b/tests/ui/proc-macro/proc-macro-gates.stderr
index 3feb9b8290f..ab98784bfbd 100644
--- a/tests/ui/proc-macro/proc-macro-gates.stderr
+++ b/tests/ui/proc-macro/proc-macro-gates.stderr
@@ -89,3 +89,14 @@ LL |     #![test]
 error: aborting due to 10 previous errors
 
 For more information about this error, try `rustc --explain E0658`.
+Future incompatibility report: Future breakage diagnostic:
+error: inner macro attributes are unstable
+  --> $DIR/proc-macro-gates.rs:49:8
+   |
+LL |     #![test]
+   |        ^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
+   = note: `#[deny(soft_unstable)]` on by default
+
diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs
new file mode 100644
index 00000000000..9bb25a66f09
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs
@@ -0,0 +1,59 @@
+// check drop order of temporaries create in match guards.
+// For normal guards all temporaries are dropped before the body of the arm.
+// For let guards temporaries live until the end of the arm.
+
+// run-pass
+
+#![feature(if_let_guard)]
+#![allow(irrefutable_let_patterns)]
+
+use std::sync::Mutex;
+
+static A: Mutex<Vec<i32>> = Mutex::new(Vec::new());
+
+struct D(i32);
+
+fn make_d(x: i32) -> D {
+    A.lock().unwrap().push(x);
+    D(x)
+}
+
+impl Drop for D {
+    fn drop(&mut self) {
+        A.lock().unwrap().push(!self.0);
+    }
+}
+
+fn if_guard(num: i32) {
+    let _d = make_d(1);
+    match num {
+        1 | 2 if make_d(2).0 == 2 => {
+            make_d(3);
+        }
+        _ => {}
+    }
+}
+
+fn if_let_guard(num: i32) {
+    let _d = make_d(1);
+    match num {
+        1 | 2 if let D(ref _x) = make_d(2) => {
+            make_d(3);
+        }
+        _ => {}
+    }
+}
+
+fn main() {
+    if_guard(1);
+    if_guard(2);
+    if_let_guard(1);
+    if_let_guard(2);
+    let expected =  [
+        1, 2, !2, 3, !3, !1,
+        1, 2, !2, 3, !3, !1,
+        1, 2, 3, !3, !2, !1,
+        1, 2, 3, !3, !2, !1,
+    ];
+    assert_eq!(*A.lock().unwrap(), expected);
+}
diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs
new file mode 100644
index 00000000000..349a24579a4
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs
@@ -0,0 +1,19 @@
+// check-pass
+
+#![feature(if_let_guard)]
+
+fn split_last(_: &()) -> Option<(&i32, &i32)> {
+    None
+}
+
+fn assign_twice() {
+    loop {
+        match () {
+            #[allow(irrefutable_let_patterns)]
+            () if let _ = split_last(&()) => {}
+            _ => {}
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs
new file mode 100644
index 00000000000..86a170141f8
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs
@@ -0,0 +1,32 @@
+// Check that temporaries in if-let guards are correctly scoped.
+// Regression test for #116079.
+
+// build-pass
+// edition:2018
+// -Zvalidate-mir
+
+#![feature(if_let_guard)]
+
+static mut A: [i32; 5] = [1, 2, 3, 4, 5];
+
+async fn fun() {
+    unsafe {
+        match A {
+            _ => (),
+            i if let Some(1) = async { Some(1) }.await => (),
+            _ => (),
+        }
+    }
+}
+
+async fn funner() {
+    unsafe {
+        match A {
+            _ => (),
+            _ | _ if let Some(1) = async { Some(1) }.await => (),
+            _ => (),
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs
new file mode 100644
index 00000000000..37fe610637e
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs
@@ -0,0 +1,24 @@
+// Check that temporaries in if-let guards are correctly scoped.
+
+// build-pass
+// -Zvalidate-mir
+
+#![feature(if_let_guard)]
+
+fn fun() {
+    match 0 {
+        _ => (),
+        _ if let Some(s) = std::convert::identity(&Some(String::new())) => {}
+        _ => (),
+    }
+}
+
+fn funner() {
+    match 0 {
+        _ => (),
+        _ | _ if let Some(s) = std::convert::identity(&Some(String::new())) => {}
+        _ => (),
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/thir-print/thir-tree-match.stdout b/tests/ui/thir-print/thir-tree-match.stdout
index 60c9283abcf..e752e4a8702 100644
--- a/tests/ui/thir-print/thir-tree-match.stdout
+++ b/tests/ui/thir-print/thir-tree-match.stdout
@@ -124,7 +124,7 @@ body:
                                                                         body: 
                                                                             Expr {
                                                                                 ty: bool
-                                                                                temp_lifetime: Some(Node(13))
+                                                                                temp_lifetime: Some(Node(12))
                                                                                 span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0)
                                                                                 kind: 
                                                                                     Scope {
@@ -133,7 +133,7 @@ body:
                                                                                         value:
                                                                                             Expr {
                                                                                                 ty: bool
-                                                                                                temp_lifetime: Some(Node(13))
+                                                                                                temp_lifetime: Some(Node(12))
                                                                                                 span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0)
                                                                                                 kind: 
                                                                                                     Literal( lit: Spanned { node: Bool(true), span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0) }, neg: false)
@@ -176,7 +176,7 @@ body:
                                                                         body: 
                                                                             Expr {
                                                                                 ty: bool
-                                                                                temp_lifetime: Some(Node(19))
+                                                                                temp_lifetime: Some(Node(18))
                                                                                 span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0)
                                                                                 kind: 
                                                                                     Scope {
@@ -185,7 +185,7 @@ body:
                                                                                         value:
                                                                                             Expr {
                                                                                                 ty: bool
-                                                                                                temp_lifetime: Some(Node(19))
+                                                                                                temp_lifetime: Some(Node(18))
                                                                                                 span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0)
                                                                                                 kind: 
                                                                                                     Literal( lit: Spanned { node: Bool(false), span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0) }, neg: false)
@@ -220,7 +220,7 @@ body:
                                                                         body: 
                                                                             Expr {
                                                                                 ty: bool
-                                                                                temp_lifetime: Some(Node(24))
+                                                                                temp_lifetime: Some(Node(23))
                                                                                 span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0)
                                                                                 kind: 
                                                                                     Scope {
@@ -229,7 +229,7 @@ body:
                                                                                         value:
                                                                                             Expr {
                                                                                                 ty: bool
-                                                                                                temp_lifetime: Some(Node(24))
+                                                                                                temp_lifetime: Some(Node(23))
                                                                                                 span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0)
                                                                                                 kind: 
                                                                                                     Literal( lit: Spanned { node: Bool(true), span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0) }, neg: false)