about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-08 20:52:54 +0000
committerbors <bors@rust-lang.org>2021-02-08 20:52:54 +0000
commit0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a (patch)
treeb772cfec476469c0839bdcc49ef177f0a5229ec5 /src/test
parent921ec4b3fca17cc777766c240038d7d50ba98e0d (diff)
parent9d1e8fe045d8512309fa3303d188ccbf06b9542f (diff)
downloadrust-0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a.tar.gz
rust-0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a.zip
Auto merge of #81889 - m-ou-se:rollup-k63log3, r=m-ou-se
Rollup of 9 pull requests

Successful merges:

 - #71531 (Move treat err as bug tests to ui)
 - #81356 (libtest: allow multiple filters)
 - #81735 (faster few span methods)
 - #81779 (improve error message for disallowed ptr-to-int casts in const eval)
 - #81817 (Add option to emit compiler stderr per bitwidth.)
 - #81828 (parse_format: treat r" as a literal)
 - #81840 (fix formatting of std::iter::Map)
 - #81861 (Show MIR bytes separately in -Zmeta-stats output)
 - #81865 (Clean up weird Option mapping)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-make-fulldeps/treat-err-as-bug/Makefile7
-rw-r--r--src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs4
-rw-r--r--src/test/run-make-fulldeps/treat-err-as-bug/err.rs3
-rw-r--r--src/test/ui/const-ptr/ptr_to_usize_cast.rs13
-rw-r--r--src/test/ui/const-ptr/ptr_to_usize_cast.stderr14
-rw-r--r--src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr2
-rw-r--r--src/test/ui/consts/issue-51559.stderr2
-rw-r--r--src/test/ui/consts/issue-52432.stderr2
-rw-r--r--src/test/ui/consts/miri_unleashed/ptr_arith.rs2
-rw-r--r--src/test/ui/consts/miri_unleashed/ptr_arith.stderr2
-rw-r--r--src/test/ui/consts/ptr_comparisons.rs4
-rw-r--r--src/test/ui/consts/ptr_comparisons.stderr4
-rw-r--r--src/test/ui/fmt/format-args-capture.rs11
-rw-r--r--src/test/ui/issues/issue-75307.stderr4
-rw-r--r--src/test/ui/test-attrs/test-filter-multiple.rs17
-rw-r--r--src/test/ui/test-attrs/test-filter-multiple.run.stdout7
-rw-r--r--src/test/ui/treat-err-as-bug/delay_span_bug.rs11
-rw-r--r--src/test/ui/treat-err-as-bug/delay_span_bug.stderr11
-rw-r--r--src/test/ui/treat-err-as-bug/err.rs11
-rw-r--r--src/test/ui/treat-err-as-bug/err.stderr12
20 files changed, 118 insertions, 25 deletions
diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/Makefile b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile
deleted file mode 100644
index 57cac76aec2..00000000000
--- a/src/test/run-make-fulldeps/treat-err-as-bug/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
--include ../tools.mk
-
-all:
-	$(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \
-	    | $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
-	$(RUSTC) delay_span_bug.rs -Z treat-err-as-bug 2>&1 \
-	    | $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'"
diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs b/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs
deleted file mode 100644
index dad33e498b5..00000000000
--- a/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-#![feature(rustc_attrs)]
-
-#[rustc_error(delay_span_bug_from_inside_query)]
-fn main() {}
diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/err.rs b/src/test/run-make-fulldeps/treat-err-as-bug/err.rs
deleted file mode 100644
index 136b2f30702..00000000000
--- a/src/test/run-make-fulldeps/treat-err-as-bug/err.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-#![crate_type="rlib"]
-
-pub static C: u32 = 0-1;
diff --git a/src/test/ui/const-ptr/ptr_to_usize_cast.rs b/src/test/ui/const-ptr/ptr_to_usize_cast.rs
new file mode 100644
index 00000000000..bf1e790b5dc
--- /dev/null
+++ b/src/test/ui/const-ptr/ptr_to_usize_cast.rs
@@ -0,0 +1,13 @@
+#![feature(const_raw_ptr_to_usize_cast)]
+
+fn main() {
+    const OK: usize = unsafe { 0 as *const i32 as usize };
+
+    const _ERROR: usize = unsafe { &0 as *const i32 as usize };
+    //~^ ERROR [const_err]
+    //~| NOTE cannot cast pointer to integer because it was not created by cast from integer
+    //~| NOTE
+    //~| NOTE `#[deny(const_err)]` on by default
+    //~| WARN this was previously accepted by the compiler but is being phased out
+    //~| NOTE see issue #71800
+}
diff --git a/src/test/ui/const-ptr/ptr_to_usize_cast.stderr b/src/test/ui/const-ptr/ptr_to_usize_cast.stderr
new file mode 100644
index 00000000000..48255860bb5
--- /dev/null
+++ b/src/test/ui/const-ptr/ptr_to_usize_cast.stderr
@@ -0,0 +1,14 @@
+error: any use of this value will cause an error
+  --> $DIR/ptr_to_usize_cast.rs:6:36
+   |
+LL |     const _ERROR: usize = unsafe { &0 as *const i32 as usize };
+   |     -------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^---
+   |                                    |
+   |                                    cannot cast pointer to integer because it was not created by cast from integer
+   |
+   = note: `#[deny(const_err)]` on by default
+   = 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 #71800 <https://github.com/rust-lang/rust/issues/71800>
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr
index f207674ac1d..df8b33a0898 100644
--- a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr
+++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr
@@ -4,7 +4,7 @@ error: any use of this value will cause an error
 LL | const Y2: usize = unsafe { &1 as *const i32 as usize + 1 };
    | ---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^-------
    |                            |
-   |                            "pointer-to-integer cast" needs an rfc before being allowed inside constants
+   |                            cannot cast pointer to integer because it was not created by cast from integer
    |
    = note: `#[deny(const_err)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
diff --git a/src/test/ui/consts/issue-51559.stderr b/src/test/ui/consts/issue-51559.stderr
index fbb40c890dd..d571eb54963 100644
--- a/src/test/ui/consts/issue-51559.stderr
+++ b/src/test/ui/consts/issue-51559.stderr
@@ -4,7 +4,7 @@ error: any use of this value will cause an error
 LL | pub const FOO: usize = unsafe { BAR as usize };
    | --------------------------------^^^^^^^^^^^^---
    |                                 |
-   |                                 "pointer-to-integer cast" needs an rfc before being allowed inside constants
+   |                                 cannot cast pointer to integer because it was not created by cast from integer
    |
    = note: `#[deny(const_err)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
diff --git a/src/test/ui/consts/issue-52432.stderr b/src/test/ui/consts/issue-52432.stderr
index e9539d24118..29998950552 100644
--- a/src/test/ui/consts/issue-52432.stderr
+++ b/src/test/ui/consts/issue-52432.stderr
@@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
   --> $DIR/issue-52432.rs:7:10
    |
 LL |     [(); &(static || {}) as *const _ as usize];
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot cast pointer to integer because it was not created by cast from integer
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/consts/miri_unleashed/ptr_arith.rs b/src/test/ui/consts/miri_unleashed/ptr_arith.rs
index 65fc49c0b27..aae6d837204 100644
--- a/src/test/ui/consts/miri_unleashed/ptr_arith.rs
+++ b/src/test/ui/consts/miri_unleashed/ptr_arith.rs
@@ -15,7 +15,7 @@ static INT_PTR_ARITH: () = unsafe {
     let x: usize = std::mem::transmute(&0);
     let _v = x + 0;
     //~^ ERROR could not evaluate static initializer
-    //~| NOTE pointer-to-integer cast
+    //~| NOTE cannot cast pointer to integer
 };
 
 fn main() {}
diff --git a/src/test/ui/consts/miri_unleashed/ptr_arith.stderr b/src/test/ui/consts/miri_unleashed/ptr_arith.stderr
index d782a3633b2..8ac4aa87f64 100644
--- a/src/test/ui/consts/miri_unleashed/ptr_arith.stderr
+++ b/src/test/ui/consts/miri_unleashed/ptr_arith.stderr
@@ -8,7 +8,7 @@ error[E0080]: could not evaluate static initializer
   --> $DIR/ptr_arith.rs:16:14
    |
 LL |     let _v = x + 0;
-   |              ^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
+   |              ^^^^^ cannot cast pointer to integer because it was not created by cast from integer
 
 warning: skipping const checks
    |
diff --git a/src/test/ui/consts/ptr_comparisons.rs b/src/test/ui/consts/ptr_comparisons.rs
index 0570d817fcc..0fbe55f972e 100644
--- a/src/test/ui/consts/ptr_comparisons.rs
+++ b/src/test/ui/consts/ptr_comparisons.rs
@@ -71,14 +71,14 @@ const _: *const u8 =
 
 const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 };
 //~^ ERROR any use of this value will cause an error
-//~| NOTE "pointer-to-integer cast" needs an rfc
+//~| NOTE cannot cast pointer to integer
 //~| NOTE
 //~| WARN this was previously accepted by the compiler but is being phased out
 //~| NOTE
 
 const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 };
 //~^ ERROR any use of this value will cause an error
-//~| NOTE "pointer-to-integer cast" needs an rfc
+//~| NOTE cannot cast pointer to integer
 //~| NOTE
 //~| WARN this was previously accepted by the compiler but is being phased out
 //~| NOTE
diff --git a/src/test/ui/consts/ptr_comparisons.stderr b/src/test/ui/consts/ptr_comparisons.stderr
index c6c13e54137..9ec009c55c4 100644
--- a/src/test/ui/consts/ptr_comparisons.stderr
+++ b/src/test/ui/consts/ptr_comparisons.stderr
@@ -36,7 +36,7 @@ error: any use of this value will cause an error
 LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 };
    | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
    |                           |
-   |                           "pointer-to-integer cast" needs an rfc before being allowed inside constants
+   |                           cannot cast pointer to integer because it was not created by cast from integer
    |
    = 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 #71800 <https://github.com/rust-lang/rust/issues/71800>
@@ -47,7 +47,7 @@ error: any use of this value will cause an error
 LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 };
    | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
    |                           |
-   |                           "pointer-to-integer cast" needs an rfc before being allowed inside constants
+   |                           cannot cast pointer to integer because it was not created by cast from integer
    |
    = 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 #71800 <https://github.com/rust-lang/rust/issues/71800>
diff --git a/src/test/ui/fmt/format-args-capture.rs b/src/test/ui/fmt/format-args-capture.rs
index d5886a13558..6c97a807b05 100644
--- a/src/test/ui/fmt/format-args-capture.rs
+++ b/src/test/ui/fmt/format-args-capture.rs
@@ -5,6 +5,7 @@
 fn main() {
     named_argument_takes_precedence_to_captured();
     formatting_parameters_can_be_captured();
+    capture_raw_strings_and_idents();
 
     #[cfg(panic = "unwind")]
     {
@@ -25,6 +26,16 @@ fn named_argument_takes_precedence_to_captured() {
     assert_eq!(&s, "positional-named-captured");
 }
 
+fn capture_raw_strings_and_idents() {
+    let r#type = "apple";
+    let s = format!(r#"The fruit is an {type}"#);
+    assert_eq!(&s, "The fruit is an apple");
+
+    let r#type = "orange";
+    let s = format!(r"The fruit is an {type}");
+    assert_eq!(&s, "The fruit is an orange");
+}
+
 #[cfg(panic = "unwind")]
 fn panic_with_single_argument_does_not_get_formatted() {
     // panic! with a single argument does not perform string formatting.
diff --git a/src/test/ui/issues/issue-75307.stderr b/src/test/ui/issues/issue-75307.stderr
index 4a5d997e00d..10c952006c2 100644
--- a/src/test/ui/issues/issue-75307.stderr
+++ b/src/test/ui/issues/issue-75307.stderr
@@ -1,8 +1,8 @@
 error: invalid reference to positional arguments 1 and 2 (there is 1 argument)
-  --> $DIR/issue-75307.rs:2:13
+  --> $DIR/issue-75307.rs:2:17
    |
 LL |     format!(r"{}{}{}", named_arg=1);
-   |             ^^^^^^^^^
+   |                 ^^^^
    |
    = note: positional arguments are zero-based
 
diff --git a/src/test/ui/test-attrs/test-filter-multiple.rs b/src/test/ui/test-attrs/test-filter-multiple.rs
new file mode 100644
index 00000000000..04dd83b7fd0
--- /dev/null
+++ b/src/test/ui/test-attrs/test-filter-multiple.rs
@@ -0,0 +1,17 @@
+// run-pass
+// compile-flags: --test
+// run-flags: --test-threads=1 test1 test2
+// check-run-results
+// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
+// ignore-emscripten no threads support
+
+#[test]
+fn test1() {}
+
+#[test]
+fn test2() {}
+
+#[test]
+fn test3() {
+    panic!("this should not run");
+}
diff --git a/src/test/ui/test-attrs/test-filter-multiple.run.stdout b/src/test/ui/test-attrs/test-filter-multiple.run.stdout
new file mode 100644
index 00000000000..1aa684ed507
--- /dev/null
+++ b/src/test/ui/test-attrs/test-filter-multiple.run.stdout
@@ -0,0 +1,7 @@
+
+running 2 tests
+test test1 ... ok
+test test2 ... ok
+
+test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in $TIME
+
diff --git a/src/test/ui/treat-err-as-bug/delay_span_bug.rs b/src/test/ui/treat-err-as-bug/delay_span_bug.rs
new file mode 100644
index 00000000000..67846336aca
--- /dev/null
+++ b/src/test/ui/treat-err-as-bug/delay_span_bug.rs
@@ -0,0 +1,11 @@
+// compile-flags: -Ztreat-err-as-bug
+// failure-status: 101
+// error-pattern: aborting due to `-Z treat-err-as-bug=1`
+// error-pattern: [trigger_delay_span_bug] trigger a delay span bug
+// normalize-stderr-test "note: .*\n\n" -> ""
+// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
+
+#![feature(rustc_attrs)]
+
+#[rustc_error(delay_span_bug_from_inside_query)]
+fn main() {}
diff --git a/src/test/ui/treat-err-as-bug/delay_span_bug.stderr b/src/test/ui/treat-err-as-bug/delay_span_bug.stderr
new file mode 100644
index 00000000000..ed65b69ebca
--- /dev/null
+++ b/src/test/ui/treat-err-as-bug/delay_span_bug.stderr
@@ -0,0 +1,11 @@
+error: internal compiler error: delayed span bug triggered by #[rustc_error(delay_span_bug_from_inside_query)]
+  --> $DIR/delay_span_bug.rs:11:1
+   |
+LL | fn main() {}
+   | ^^^^^^^^^
+
+error: internal compiler error: unexpected panic
+
+query stack during panic:
+#0 [trigger_delay_span_bug] trigger a delay span bug
+end of query stack
diff --git a/src/test/ui/treat-err-as-bug/err.rs b/src/test/ui/treat-err-as-bug/err.rs
new file mode 100644
index 00000000000..5442d858594
--- /dev/null
+++ b/src/test/ui/treat-err-as-bug/err.rs
@@ -0,0 +1,11 @@
+// compile-flags: -Ztreat-err-as-bug
+// failure-status: 101
+// error-pattern: aborting due to `-Z treat-err-as-bug=1`
+// error-pattern: [eval_to_allocation_raw] const-evaluating + checking `C`
+// normalize-stderr-test "note: .*\n\n" -> ""
+// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
+
+#![crate_type = "rlib"]
+
+pub static C: u32 = 0 - 1;
+//~^ ERROR could not evaluate static initializer
diff --git a/src/test/ui/treat-err-as-bug/err.stderr b/src/test/ui/treat-err-as-bug/err.stderr
new file mode 100644
index 00000000000..61eb85c40a1
--- /dev/null
+++ b/src/test/ui/treat-err-as-bug/err.stderr
@@ -0,0 +1,12 @@
+error[E0080]: could not evaluate static initializer
+  --> $DIR/err.rs:10:21
+   |
+LL | pub static C: u32 = 0 - 1;
+   |                     ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow
+
+error: internal compiler error: unexpected panic
+
+query stack during panic:
+#0 [eval_to_allocation_raw] const-evaluating + checking `C`
+#1 [eval_to_allocation_raw] const-evaluating + checking `C`
+end of query stack