about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-04-12 21:48:24 +0000
committerbors <bors@rust-lang.org>2020-04-12 21:48:24 +0000
commit9fed36055070168e5238d6bf6e58a36f519fe427 (patch)
tree490e55838be3c4593b0528952e6fd9699d7ee961 /src/test
parent3712e11a828af2eea273a3e7300115e65833fbc5 (diff)
parent69862b74fab2a24230a9157c988bad50d8538fda (diff)
Auto merge of #71079 - Dylan-DPC:rollup-g7yh3sn, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #67766 (Fix warning for unused variables in or pattern (issue #67691))
 - #71013 (Pass the `PlaceElem::Index` local to `visit_local`)
 - #71064 (fix issue 69130)
 - #71069 (Remove some usage of `DUMMY_HIR_ID`)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/consts/miri_unleashed/mutable_const2.stderr2
-rw-r--r--src/test/ui/issues/issue-69130.rs7
-rw-r--r--src/test/ui/issues/issue-69130.stderr21
-rw-r--r--src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr12
-rw-r--r--src/test/ui/lint/issue-54180-unused-ref-field.stderr18
-rw-r--r--src/test/ui/lint/issue-67691-unused-field-in-or-pattern.rs86
-rw-r--r--src/test/ui/lint/issue-67691-unused-field-in-or-pattern.stderr74
-rw-r--r--src/test/ui/liveness/liveness-dead.stderr8
-rw-r--r--src/test/ui/liveness/liveness-unused.stderr8
9 files changed, 209 insertions, 27 deletions
diff --git a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr
index 1699223f74f..39027dd2b41 100644
--- a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr
+++ b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr
@@ -12,7 +12,7 @@ error: internal compiler error: mutable allocation in constant
 LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:363:17
+thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:366:17
 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 
 error: internal compiler error: unexpected panic
diff --git a/src/test/ui/issues/issue-69130.rs b/src/test/ui/issues/issue-69130.rs
new file mode 100644
index 00000000000..9552e8ec2a8
--- /dev/null
+++ b/src/test/ui/issues/issue-69130.rs
@@ -0,0 +1,7 @@
+// Issue 69130: character indexing bug in rustc_errors::CodeSuggestion::splice_lines().
+
+enum F {
+M (§& u8)}
+//~^ ERROR unknown start of token
+//~| missing lifetime specifier
+fn main() {}
diff --git a/src/test/ui/issues/issue-69130.stderr b/src/test/ui/issues/issue-69130.stderr
new file mode 100644
index 00000000000..a4700a5ed1d
--- /dev/null
+++ b/src/test/ui/issues/issue-69130.stderr
@@ -0,0 +1,21 @@
+error: unknown start of token: \u{a7}
+  --> $DIR/issue-69130.rs:4:4
+   |
+LL | M (§& u8)}
+   |    ^
+
+error[E0106]: missing lifetime specifier
+  --> $DIR/issue-69130.rs:4:5
+   |
+LL | M (§& u8)}
+   |     ^ expected named lifetime parameter
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL | enum F<'a> {
+LL | M (§&'a  u8)}
+   |
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0106`.
diff --git a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr
index 2ef655efdbd..3efd87f6a5f 100644
--- a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr
+++ b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr
@@ -12,16 +12,16 @@ LL | #![warn(unused)] // UI tests pass `-A unused` (#43896)
    = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
 
 warning: unused variable: `mut_unused_var`
-  --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:33:13
+  --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:33:9
    |
 LL |     let mut mut_unused_var = 1;
-   |             ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_mut_unused_var`
+   |         ^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_mut_unused_var`
 
 warning: unused variable: `var`
-  --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:14
+  --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:10
    |
 LL |     let (mut var, unused_var) = (1, 2);
-   |              ^^^ help: if this is intentional, prefix it with an underscore: `_var`
+   |          ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_var`
 
 warning: unused variable: `unused_var`
   --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:19
@@ -36,10 +36,10 @@ LL |     if let SoulHistory { corridors_of_light,
    |                          ^^^^^^^^^^^^^^^^^^ help: try ignoring the field: `corridors_of_light: _`
 
 warning: variable `hours_are_suns` is assigned to, but never used
-  --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:46:30
+  --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:46:26
    |
 LL |                          mut hours_are_suns,
-   |                              ^^^^^^^^^^^^^^
+   |                          ^^^^^^^^^^^^^^^^^^
    |
    = note: consider using `_hours_are_suns` instead
 
diff --git a/src/test/ui/lint/issue-54180-unused-ref-field.stderr b/src/test/ui/lint/issue-54180-unused-ref-field.stderr
index 840ecc0ce09..c501aa25f13 100644
--- a/src/test/ui/lint/issue-54180-unused-ref-field.stderr
+++ b/src/test/ui/lint/issue-54180-unused-ref-field.stderr
@@ -1,10 +1,8 @@
 error: unused variable: `field`
-  --> $DIR/issue-54180-unused-ref-field.rs:20:26
+  --> $DIR/issue-54180-unused-ref-field.rs:20:22
    |
 LL |         E::Variant { ref field } => (),
-   |                      ----^^^^^
-   |                      |
-   |                      help: try ignoring the field: `field: _`
+   |                      ^^^^^^^^^ help: try ignoring the field: `field: _`
    |
 note: the lint level is defined here
   --> $DIR/issue-54180-unused-ref-field.rs:3:9
@@ -20,20 +18,16 @@ LL |     let _: i32 = points.iter().map(|Point { x, y }| y).sum();
    |                                             ^ help: try ignoring the field: `x: _`
 
 error: unused variable: `f1`
-  --> $DIR/issue-54180-unused-ref-field.rs:26:17
+  --> $DIR/issue-54180-unused-ref-field.rs:26:13
    |
 LL |     let S { ref f1 } = s;
-   |             ----^^
-   |             |
-   |             help: try ignoring the field: `f1: _`
+   |             ^^^^^^ help: try ignoring the field: `f1: _`
 
 error: unused variable: `x`
-  --> $DIR/issue-54180-unused-ref-field.rs:32:28
+  --> $DIR/issue-54180-unused-ref-field.rs:32:20
    |
 LL |         Point { y, ref mut x } => y,
-   |                    --------^
-   |                    |
-   |                    help: try ignoring the field: `x: _`
+   |                    ^^^^^^^^^ help: try ignoring the field: `x: _`
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/lint/issue-67691-unused-field-in-or-pattern.rs b/src/test/ui/lint/issue-67691-unused-field-in-or-pattern.rs
new file mode 100644
index 00000000000..b21f1ef6b26
--- /dev/null
+++ b/src/test/ui/lint/issue-67691-unused-field-in-or-pattern.rs
@@ -0,0 +1,86 @@
+// FIXME: should be run-rustfix, but rustfix doesn't currently support multipart suggestions, see
+// #53934
+
+#![feature(or_patterns)]
+#![deny(unused)]
+
+pub enum MyEnum {
+    A { i: i32, j: i32 },
+    B { i: i32, j: i32 },
+}
+
+pub enum MixedEnum {
+    A { i: i32 },
+    B(i32),
+}
+
+pub fn no_ref(x: MyEnum) {
+    use MyEnum::*;
+
+    match x {
+        A { i, j } | B { i, j } => { //~ ERROR unused variable
+            println!("{}", i);
+        }
+    }
+}
+
+pub fn with_ref(x: MyEnum) {
+    use MyEnum::*;
+
+    match x {
+        A { i, ref j } | B { i, ref j } => { //~ ERROR unused variable
+            println!("{}", i);
+        }
+    }
+}
+
+pub fn inner_no_ref(x: Option<MyEnum>) {
+    use MyEnum::*;
+
+    match x {
+        Some(A { i, j } | B { i, j }) => { //~ ERROR unused variable
+            println!("{}", i);
+        }
+
+        _ => {}
+    }
+}
+
+pub fn inner_with_ref(x: Option<MyEnum>) {
+    use MyEnum::*;
+
+    match x {
+        Some(A { i, ref j } | B { i, ref j }) => { //~ ERROR unused variable
+            println!("{}", i);
+        }
+
+        _ => {}
+    }
+}
+
+pub fn mixed_no_ref(x: MixedEnum) {
+    match x {
+        MixedEnum::A { i } | MixedEnum::B(i) => { //~ ERROR unused variable
+            println!("match");
+        }
+    }
+}
+
+pub fn mixed_with_ref(x: MixedEnum) {
+    match x {
+        MixedEnum::A { ref i } | MixedEnum::B(ref i) => { //~ ERROR unused variable
+            println!("match");
+        }
+    }
+}
+
+pub fn main() {
+    no_ref(MyEnum::A { i: 1, j: 2 });
+    with_ref(MyEnum::A { i: 1, j: 2 });
+
+    inner_no_ref(Some(MyEnum::A { i: 1, j: 2 }));
+    inner_with_ref(Some(MyEnum::A { i: 1, j: 2 }));
+
+    mixed_no_ref(MixedEnum::B(5));
+    mixed_with_ref(MixedEnum::B(5));
+}
diff --git a/src/test/ui/lint/issue-67691-unused-field-in-or-pattern.stderr b/src/test/ui/lint/issue-67691-unused-field-in-or-pattern.stderr
new file mode 100644
index 00000000000..9cff2900908
--- /dev/null
+++ b/src/test/ui/lint/issue-67691-unused-field-in-or-pattern.stderr
@@ -0,0 +1,74 @@
+error: unused variable: `j`
+  --> $DIR/issue-67691-unused-field-in-or-pattern.rs:21:16
+   |
+LL |         A { i, j } | B { i, j } => {
+   |                ^            ^
+   |
+note: the lint level is defined here
+  --> $DIR/issue-67691-unused-field-in-or-pattern.rs:5:9
+   |
+LL | #![deny(unused)]
+   |         ^^^^^^
+   = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
+help: try ignoring the field
+   |
+LL |         A { i, j: _ } | B { i, j: _ } => {
+   |                ^^^^            ^^^^
+
+error: unused variable: `j`
+  --> $DIR/issue-67691-unused-field-in-or-pattern.rs:31:16
+   |
+LL |         A { i, ref j } | B { i, ref j } => {
+   |                ^^^^^            ^^^^^
+   |
+help: try ignoring the field
+   |
+LL |         A { i, j: _ } | B { i, j: _ } => {
+   |                ^^^^            ^^^^
+
+error: unused variable: `j`
+  --> $DIR/issue-67691-unused-field-in-or-pattern.rs:41:21
+   |
+LL |         Some(A { i, j } | B { i, j }) => {
+   |                     ^            ^
+   |
+help: try ignoring the field
+   |
+LL |         Some(A { i, j: _ } | B { i, j: _ }) => {
+   |                     ^^^^            ^^^^
+
+error: unused variable: `j`
+  --> $DIR/issue-67691-unused-field-in-or-pattern.rs:53:21
+   |
+LL |         Some(A { i, ref j } | B { i, ref j }) => {
+   |                     ^^^^^            ^^^^^
+   |
+help: try ignoring the field
+   |
+LL |         Some(A { i, j: _ } | B { i, j: _ }) => {
+   |                     ^^^^            ^^^^
+
+error: unused variable: `i`
+  --> $DIR/issue-67691-unused-field-in-or-pattern.rs:63:24
+   |
+LL |         MixedEnum::A { i } | MixedEnum::B(i) => {
+   |                        ^                  ^
+   |
+help: try ignoring the field
+   |
+LL |         MixedEnum::A { i: _ } | MixedEnum::B(_) => {
+   |                        ^^^^                  ^
+
+error: unused variable: `i`
+  --> $DIR/issue-67691-unused-field-in-or-pattern.rs:71:24
+   |
+LL |         MixedEnum::A { ref i } | MixedEnum::B(ref i) => {
+   |                        ^^^^^                  ^^^^^
+   |
+help: try ignoring the field
+   |
+LL |         MixedEnum::A { i: _ } | MixedEnum::B(_) => {
+   |                        ^^^^                  ^
+
+error: aborting due to 6 previous errors
+
diff --git a/src/test/ui/liveness/liveness-dead.stderr b/src/test/ui/liveness/liveness-dead.stderr
index 12680ab1156..e9d20cf981f 100644
--- a/src/test/ui/liveness/liveness-dead.stderr
+++ b/src/test/ui/liveness/liveness-dead.stderr
@@ -1,8 +1,8 @@
 error: value assigned to `x` is never read
-  --> $DIR/liveness-dead.rs:9:13
+  --> $DIR/liveness-dead.rs:9:9
    |
 LL |     let mut x: isize = 3;
-   |             ^
+   |         ^^^^^
    |
 note: the lint level is defined here
   --> $DIR/liveness-dead.rs:2:9
@@ -20,10 +20,10 @@ LL |     x = 4;
    = help: maybe it is overwritten before being read?
 
 error: value passed to `x` is never read
-  --> $DIR/liveness-dead.rs:20:11
+  --> $DIR/liveness-dead.rs:20:7
    |
 LL | fn f4(mut x: i32) {
-   |           ^
+   |       ^^^^^
    |
    = help: maybe it is overwritten before being read?
 
diff --git a/src/test/ui/liveness/liveness-unused.stderr b/src/test/ui/liveness/liveness-unused.stderr
index 4a6122681a9..2c5550ac47f 100644
--- a/src/test/ui/liveness/liveness-unused.stderr
+++ b/src/test/ui/liveness/liveness-unused.stderr
@@ -44,10 +44,10 @@ LL |     let x = 3;
    |         ^ help: if this is intentional, prefix it with an underscore: `_x`
 
 error: variable `x` is assigned to, but never used
-  --> $DIR/liveness-unused.rs:30:13
+  --> $DIR/liveness-unused.rs:30:9
    |
 LL |     let mut x = 3;
-   |             ^
+   |         ^^^^^
    |
    = note: consider using `_x` instead
 
@@ -65,10 +65,10 @@ LL | #![deny(unused_assignments)]
    = help: maybe it is overwritten before being read?
 
 error: variable `z` is assigned to, but never used
-  --> $DIR/liveness-unused.rs:37:13
+  --> $DIR/liveness-unused.rs:37:9
    |
 LL |     let mut z = 3;
-   |             ^
+   |         ^^^^^
    |
    = note: consider using `_z` instead