38 changes: 20 additions & 18 deletions tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ enum E {
//~^ NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE `E` defined here
//~| NOTE not covered
//~| NOTE not covered
//~| NOTE not covered
Expand All @@ -41,37 +38,41 @@ fn by_val(e: E) {
E::A => {}
}

let E::A = e; //~ ERROR refutable pattern in local binding: `E::B` and `E::C` not covered
//~^ NOTE patterns `E::B` and `E::C` not covered
let E::A = e;
//~^ ERROR refutable pattern in local binding
//~| patterns `E::B` and `E::C` not covered
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
//~| NOTE the matched value is of type `E`
}

fn by_ref_once(e: &E) {
match e { //~ ERROR non-exhaustive patterns: `&E::B` and `&E::C` not covered
//~^ NOTE patterns `&E::B` and `&E::C` not covered
match e {
//~^ ERROR non-exhaustive patterns
//~| patterns `&E::B` and `&E::C` not covered
//~| NOTE the matched value is of type `&E`
E::A => {}
}

let E::A = e; //~ ERROR refutable pattern in local binding: `&E::B` and `&E::C` not covered
//~^ NOTE patterns `&E::B` and `&E::C` not covered
let E::A = e;
//~^ ERROR refutable pattern in local binding
//~| patterns `&E::B` and `&E::C` not covered
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
//~| NOTE the matched value is of type `&E`
}

fn by_ref_thrice(e: & &mut &E) {
match e { //~ ERROR non-exhaustive patterns: `&&mut &E::B` and `&&mut &E::C` not covered
//~^ NOTE patterns `&&mut &E::B` and `&&mut &E::C` not covered
match e {
//~^ ERROR non-exhaustive patterns
//~| patterns `&&mut &E::B` and `&&mut &E::C` not covered
//~| NOTE the matched value is of type `&&mut &E`
E::A => {}
}

let E::A = e;
//~^ ERROR refutable pattern in local binding: `&&mut &E::B` and `&&mut &E::C` not covered
//~| NOTE patterns `&&mut &E::B` and `&&mut &E::C` not covered
//~^ ERROR refutable pattern in local binding
//~| patterns `&&mut &E::B` and `&&mut &E::C` not covered
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
//~| NOTE the matched value is of type `&&mut &E`
Expand All @@ -83,20 +84,21 @@ enum Opt {
Some(u8),
None,
//~^ NOTE `Opt` defined here
//~| NOTE `Opt` defined here
//~| NOTE not covered
//~| NOTE not covered
}

fn ref_pat(e: Opt) {
match e {//~ ERROR non-exhaustive patterns: `Opt::None` not covered
//~^ NOTE pattern `Opt::None` not covered
match e {
//~^ ERROR non-exhaustive patterns
//~| pattern `Opt::None` not covered
//~| NOTE the matched value is of type `Opt`
Opt::Some(ref _x) => {}
}

let Opt::Some(ref _x) = e; //~ ERROR refutable pattern in local binding: `Opt::None` not covered
//~^ NOTE the matched value is of type `Opt`
let Opt::Some(ref _x) = e;
//~^ ERROR refutable pattern in local binding
//~| NOTE the matched value is of type `Opt`
//~| NOTE pattern `Opt::None` not covered
//~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
//~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
Expand Down
58 changes: 27 additions & 31 deletions tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0004]: non-exhaustive patterns: `E::B` and `E::C` not covered
--> $DIR/non-exhaustive-defined-here.rs:38:11
--> $DIR/non-exhaustive-defined-here.rs:35:11
|
LL | match e1 {
| ^^ patterns `E::B` and `E::C` not covered
Expand All @@ -22,33 +22,33 @@ LL ~ E::A => {}
LL + E::B | E::C => todo!()
|

error[E0005]: refutable pattern in local binding: `E::B` and `E::C` not covered
--> $DIR/non-exhaustive-defined-here.rs:44:9
error[E0005]: refutable pattern in local binding
--> $DIR/non-exhaustive-defined-here.rs:41:9
|
LL | let E::A = e;
| ^^^^ patterns `E::B` and `E::C` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `E` defined here
--> $DIR/non-exhaustive-defined-here.rs:14:5
--> $DIR/non-exhaustive-defined-here.rs:6:6
|
LL | enum E {
| -
| ^
...
LL | B,
| ^ not covered
| - not covered
...
LL | C
| ^ not covered
| - not covered
= note: the matched value is of type `E`
help: you might want to use `if let` to ignore the variants that aren't matched
|
LL | if let E::A = e { todo!() }
| ++ ~~~~~~~~~~~

error[E0004]: non-exhaustive patterns: `&E::B` and `&E::C` not covered
--> $DIR/non-exhaustive-defined-here.rs:52:11
--> $DIR/non-exhaustive-defined-here.rs:50:11
|
LL | match e {
| ^ patterns `&E::B` and `&E::C` not covered
Expand All @@ -71,25 +71,25 @@ LL ~ E::A => {}
LL + &E::B | &E::C => todo!()
|

error[E0005]: refutable pattern in local binding: `&E::B` and `&E::C` not covered
--> $DIR/non-exhaustive-defined-here.rs:58:9
error[E0005]: refutable pattern in local binding
--> $DIR/non-exhaustive-defined-here.rs:57:9
|
LL | let E::A = e;
| ^^^^ patterns `&E::B` and `&E::C` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `E` defined here
--> $DIR/non-exhaustive-defined-here.rs:14:5
--> $DIR/non-exhaustive-defined-here.rs:6:6
|
LL | enum E {
| -
| ^
...
LL | B,
| ^ not covered
| - not covered
...
LL | C
| ^ not covered
| - not covered
= note: the matched value is of type `&E`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand Down Expand Up @@ -120,25 +120,25 @@ LL ~ E::A => {}
LL + &&mut &E::B | &&mut &E::C => todo!()
|

error[E0005]: refutable pattern in local binding: `&&mut &E::B` and `&&mut &E::C` not covered
--> $DIR/non-exhaustive-defined-here.rs:72:9
error[E0005]: refutable pattern in local binding
--> $DIR/non-exhaustive-defined-here.rs:73:9
|
LL | let E::A = e;
| ^^^^ patterns `&&mut &E::B` and `&&mut &E::C` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `E` defined here
--> $DIR/non-exhaustive-defined-here.rs:14:5
--> $DIR/non-exhaustive-defined-here.rs:6:6
|
LL | enum E {
| -
| ^
...
LL | B,
| ^ not covered
| - not covered
...
LL | C
| ^ not covered
| - not covered
= note: the matched value is of type `&&mut &E`
help: you might want to use `if let` to ignore the variants that aren't matched
|
Expand All @@ -152,7 +152,7 @@ LL | match e {
| ^ pattern `Opt::None` not covered
|
note: `Opt` defined here
--> $DIR/non-exhaustive-defined-here.rs:84:5
--> $DIR/non-exhaustive-defined-here.rs:85:5
|
LL | enum Opt {
| ---
Expand All @@ -166,28 +166,24 @@ LL ~ Opt::Some(ref _x) => {}
LL + Opt::None => todo!()
|

error[E0005]: refutable pattern in local binding: `Opt::None` not covered
--> $DIR/non-exhaustive-defined-here.rs:98:9
error[E0005]: refutable pattern in local binding
--> $DIR/non-exhaustive-defined-here.rs:99:9
|
LL | let Opt::Some(ref _x) = e;
| ^^^^^^^^^^^^^^^^^ pattern `Opt::None` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Opt` defined here
--> $DIR/non-exhaustive-defined-here.rs:84:5
--> $DIR/non-exhaustive-defined-here.rs:81:6
|
LL | enum Opt {
| ---
| ^^^
...
LL | None,
| ^^^^ not covered
| ---- not covered
= note: the matched value is of type `Opt`
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | let _x = if let Opt::Some(ref _x) = e { _x } else { todo!() };
| +++++++++++ +++++++++++++++++++++++
help: alternatively, you might want to use let else to handle the variant that isn't matched
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Opt::Some(ref _x) = e else { todo!() };
| ++++++++++++++++
Expand Down
6 changes: 4 additions & 2 deletions tests/ui/pattern/usefulness/refutable-pattern-errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { }
//~^ ERROR refutable pattern in function argument: `(_, _)` not covered
//~^ ERROR refutable pattern in function argument
//~| `(_, _)` not covered

fn main() {
let (1, (Some(1), 2..=3)) = (1, (None, 2));
//~^ ERROR refutable pattern in local binding: `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered
//~^ ERROR refutable pattern in local binding
//~| `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered
}
6 changes: 3 additions & 3 deletions tests/ui/pattern/usefulness/refutable-pattern-errors.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0005]: refutable pattern in function argument: `(_, _)` not covered
error[E0005]: refutable pattern in function argument
--> $DIR/refutable-pattern-errors.rs:1:9
|
LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { }
| ^^^^^^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered
|
= note: the matched value is of type `(isize, (Option<isize>, isize))`

error[E0005]: refutable pattern in local binding: `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered
--> $DIR/refutable-pattern-errors.rs:5:9
error[E0005]: refutable pattern in local binding
--> $DIR/refutable-pattern-errors.rs:6:9
|
LL | let (1, (Some(1), 2..=3)) = (1, (None, 2));
| ^^^^^^^^^^^^^^^^^^^^^ patterns `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fn main() {
let f = |3: isize| println!("hello");
//~^ ERROR refutable pattern in function argument: `_` not covered
//~^ ERROR refutable pattern in function argument
//~| `_` not covered
f(4);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0005]: refutable pattern in function argument: `_` not covered
error[E0005]: refutable pattern in function argument
--> $DIR/refutable-pattern-in-fn-arg.rs:2:14
|
LL | let f = |3: isize| println!("hello");
Expand Down
1 change: 0 additions & 1 deletion tests/ui/pin-macro/cant_access_internals.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// edition:2018
#![feature(pin_macro)]

use core::{
marker::PhantomPinned,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/pin-macro/cant_access_internals.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: use of unstable library feature 'unsafe_pin_internals'
--> $DIR/cant_access_internals.rs:12:15
--> $DIR/cant_access_internals.rs:11:15
|
LL | mem::take(phantom_pinned.pointer);
| ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// edition:2018
#![feature(pin_macro)]

use core::{
convert::identity,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/lifetime_errors_on_promotion_misusage.rs:12:35
--> $DIR/lifetime_errors_on_promotion_misusage.rs:11:35
|
LL | let phantom_pinned = identity(pin!(PhantomPinned));
| ^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
Expand All @@ -13,7 +13,7 @@ LL | stuff(phantom_pinned)
= note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0716]: temporary value dropped while borrowed
--> $DIR/lifetime_errors_on_promotion_misusage.rs:19:30
--> $DIR/lifetime_errors_on_promotion_misusage.rs:18:30
|
LL | let phantom_pinned = {
| -------------- borrow later stored here
Expand Down
13 changes: 2 additions & 11 deletions tests/ui/recursion/recursive-types-are-not-uninhabited.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
error[E0005]: refutable pattern in local binding: `Err(_)` not covered
error[E0005]: refutable pattern in local binding
--> $DIR/recursive-types-are-not-uninhabited.rs:6:9
|
LL | let Ok(x) = res;
| ^^^^^ pattern `Err(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Result<u32, &R<'_>>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<u32, &R<'_>>`
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | let x = if let Ok(x) = res { x } else { todo!() };
| ++++++++++ ++++++++++++++++++++++
help: alternatively, you might want to use let else to handle the variant that isn't matched
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Ok(x) = res else { todo!() };
| ++++++++++++++++
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/resolve/privacy-enum-ctor.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,15 @@ error[E0308]: mismatched types
--> $DIR/privacy-enum-ctor.rs:27:20
|
LL | Fn(u8),
| -- fn(u8) -> Z {Z::Fn} defined here
| -- `Fn` defines an enum variant constructor here, which should be called
...
LL | let _: Z = Z::Fn;
| - ^^^^^ expected enum `Z`, found fn item
| - ^^^^^ expected enum `Z`, found enum constructor
| |
| expected due to this
|
= note: expected enum `Z`
found fn item `fn(u8) -> Z {Z::Fn}`
= note: expected enum `Z`
found enum constructor `fn(u8) -> Z {Z::Fn}`
help: use parentheses to construct this tuple variant
|
LL | let _: Z = Z::Fn(/* u8 */);
Expand Down Expand Up @@ -305,15 +305,15 @@ error[E0308]: mismatched types
--> $DIR/privacy-enum-ctor.rs:43:16
|
LL | Fn(u8),
| -- fn(u8) -> E {E::Fn} defined here
| -- `Fn` defines an enum variant constructor here, which should be called
...
LL | let _: E = m::E::Fn;
| - ^^^^^^^^ expected enum `E`, found fn item
| - ^^^^^^^^ expected enum `E`, found enum constructor
| |
| expected due to this
|
= note: expected enum `E`
found fn item `fn(u8) -> E {E::Fn}`
= note: expected enum `E`
found enum constructor `fn(u8) -> E {E::Fn}`
help: use parentheses to construct this tuple variant
|
LL | let _: E = m::E::Fn(/* u8 */);
Expand Down Expand Up @@ -346,15 +346,15 @@ error[E0308]: mismatched types
--> $DIR/privacy-enum-ctor.rs:51:16
|
LL | Fn(u8),
| -- fn(u8) -> E {E::Fn} defined here
| -- `Fn` defines an enum variant constructor here, which should be called
...
LL | let _: E = E::Fn;
| - ^^^^^ expected enum `E`, found fn item
| - ^^^^^ expected enum `E`, found enum constructor
| |
| expected due to this
|
= note: expected enum `E`
found fn item `fn(u8) -> E {E::Fn}`
= note: expected enum `E`
found enum constructor `fn(u8) -> E {E::Fn}`
help: use parentheses to construct this tuple variant
|
LL | let _: E = E::Fn(/* u8 */);
Expand Down
5 changes: 3 additions & 2 deletions tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
fn main() {
let A = 3;
//~^ ERROR refutable pattern in local binding: `i32::MIN..=1_i32` and
//~| interpreted as a constant pattern, not a new variable
//~^ ERROR refutable pattern in local binding
//~| patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered
//~| missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable
//~| HELP introduce a variable instead
//~| SUGGESTION a_var

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
error[E0005]: refutable pattern in local binding: `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered
error[E0005]: refutable pattern in local binding
--> $DIR/const-pat-non-exaustive-let-new-var.rs:2:9
|
LL | let A = 3;
| ^
| |
| interpreted as a constant pattern, not a new variable
| patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered
| missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable
| help: introduce a variable instead: `a_var`
...
LL | const A: i32 = 2;
Expand Down
44 changes: 22 additions & 22 deletions tests/ui/suggestions/fn-or-tuple-struct-without-args.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:29:20
|
LL | fn foo(a: usize, b: usize) -> usize { a }
| ----------------------------------- fn(usize, usize) -> usize {foo} defined here
| ----------------------------------- function `foo` defined here
...
LL | let _: usize = foo;
| ----- ^^^ expected `usize`, found fn item
Expand All @@ -20,15 +20,15 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:30:16
|
LL | struct S(usize, usize);
| -------- fn(usize, usize) -> S {S} defined here
| -------- `S` defines a struct constructor here, which should be called
...
LL | let _: S = S;
| - ^ expected struct `S`, found fn item
| - ^ expected struct `S`, found struct constructor
| |
| expected due to this
|
= note: expected struct `S`
found fn item `fn(usize, usize) -> S {S}`
= note: expected struct `S`
found struct constructor `fn(usize, usize) -> S {S}`
help: use parentheses to construct this tuple struct
|
LL | let _: S = S(/* usize */, /* usize */);
Expand All @@ -38,7 +38,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:31:20
|
LL | fn bar() -> usize { 42 }
| ----------------- fn() -> usize {bar} defined here
| ----------------- function `bar` defined here
...
LL | let _: usize = bar;
| ----- ^^^ expected `usize`, found fn item
Expand All @@ -56,15 +56,15 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:32:16
|
LL | struct V();
| -------- fn() -> V {V} defined here
| -------- `V` defines a struct constructor here, which should be called
...
LL | let _: V = V;
| - ^ expected struct `V`, found fn item
| - ^ expected struct `V`, found struct constructor
| |
| expected due to this
|
= note: expected struct `V`
found fn item `fn() -> V {V}`
= note: expected struct `V`
found struct constructor `fn() -> V {V}`
help: use parentheses to construct this tuple struct
|
LL | let _: V = V();
Expand All @@ -74,7 +74,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:33:20
|
LL | fn baz(x: usize, y: usize) -> usize { x }
| ----------------------------------- fn(usize, usize) -> usize {<_ as T>::baz} defined here
| ----------------------------------- associated function `baz` defined here
...
LL | let _: usize = T::baz;
| ----- ^^^^^^ expected `usize`, found fn item
Expand All @@ -92,7 +92,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:34:20
|
LL | fn bat(x: usize) -> usize { 42 }
| ------------------------- fn(usize) -> usize {<_ as T>::bat} defined here
| ------------------------- associated function `bat` defined here
...
LL | let _: usize = T::bat;
| ----- ^^^^^^ expected `usize`, found fn item
Expand All @@ -110,15 +110,15 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:35:16
|
LL | A(usize),
| - fn(usize) -> E {E::A} defined here
| - `A` defines an enum variant constructor here, which should be called
...
LL | let _: E = E::A;
| - ^^^^ expected enum `E`, found fn item
| - ^^^^ expected enum `E`, found enum constructor
| |
| expected due to this
|
= note: expected enum `E`
found fn item `fn(usize) -> E {E::A}`
= note: expected enum `E`
found enum constructor `fn(usize) -> E {E::A}`
help: use parentheses to construct this tuple variant
|
LL | let _: E = E::A(/* usize */);
Expand All @@ -134,7 +134,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:37:20
|
LL | fn baz(x: usize, y: usize) -> usize { x }
| ----------------------------------- fn(usize, usize) -> usize {<X as T>::baz} defined here
| ----------------------------------- associated function `baz` defined here
...
LL | let _: usize = X::baz;
| ----- ^^^^^^ expected `usize`, found fn item
Expand All @@ -152,7 +152,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:38:20
|
LL | fn bat(x: usize) -> usize { 42 }
| ------------------------- fn(usize) -> usize {<X as T>::bat} defined here
| ------------------------- associated function `bat` defined here
...
LL | let _: usize = X::bat;
| ----- ^^^^^^ expected `usize`, found fn item
Expand All @@ -170,7 +170,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:39:20
|
LL | fn bax(x: usize) -> usize { 42 }
| ------------------------- fn(usize) -> usize {<X as T>::bax} defined here
| ------------------------- associated function `bax` defined here
...
LL | let _: usize = X::bax;
| ----- ^^^^^^ expected `usize`, found fn item
Expand All @@ -188,7 +188,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:40:20
|
LL | fn bach(x: usize) -> usize;
| --------------------------- fn(usize) -> usize {<X as T>::bach} defined here
| --------------------------- associated function `bach` defined here
...
LL | let _: usize = X::bach;
| ----- ^^^^^^^ expected `usize`, found fn item
Expand All @@ -206,7 +206,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:41:20
|
LL | fn ban(&self) -> usize { 42 }
| ---------------------- for<'a> fn(&'a X) -> usize {<X as T>::ban} defined here
| ---------------------- associated function `ban` defined here
...
LL | let _: usize = X::ban;
| ----- ^^^^^^ expected `usize`, found fn item
Expand All @@ -224,7 +224,7 @@ error[E0308]: mismatched types
--> $DIR/fn-or-tuple-struct-without-args.rs:42:20
|
LL | fn bal(&self) -> usize;
| ----------------------- for<'a> fn(&'a X) -> usize {<X as T>::bal} defined here
| ----------------------- associated function `bal` defined here
...
LL | let _: usize = X::bal;
| ----- ^^^^^^ expected `usize`, found fn item
Expand Down
10 changes: 6 additions & 4 deletions tests/ui/suggestions/suggest-remove-refs-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ error[E0277]: `&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterator
--> $DIR/suggest-remove-refs-1.rs:6:19
|
LL | for (i, _) in &v.iter().enumerate() {
| -^^^^^^^^^^^^^^^^^^^^
| |
| `&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterator
| help: consider removing the leading `&`-reference
| ^^^^^^^^^^^^^^^^^^^^^ `&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterator
|
= help: the trait `Iterator` is not implemented for `&Enumerate<std::slice::Iter<'_, {integer}>>`
= note: required for `&Enumerate<std::slice::Iter<'_, {integer}>>` to implement `IntoIterator`
help: consider removing the leading `&`-reference
|
LL - for (i, _) in &v.iter().enumerate() {
LL + for (i, _) in v.iter().enumerate() {
|

error: aborting due to previous error

Expand Down
10 changes: 6 additions & 4 deletions tests/ui/suggestions/suggest-remove-refs-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ error[E0277]: `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterat
--> $DIR/suggest-remove-refs-2.rs:6:19
|
LL | for (i, _) in & & & & &v.iter().enumerate() {
| ---------^^^^^^^^^^^^^^^^^^^^
| |
| `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterator
| help: consider removing 5 leading `&`-references
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterator
|
= help: the trait `Iterator` is not implemented for `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>`
= note: required for `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` to implement `IntoIterator`
help: consider removing 5 leading `&`-references
|
LL - for (i, _) in & & & & &v.iter().enumerate() {
LL + for (i, _) in v.iter().enumerate() {
|

error: aborting due to previous error

Expand Down
20 changes: 11 additions & 9 deletions tests/ui/suggestions/suggest-remove-refs-3.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
error[E0277]: `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterator
--> $DIR/suggest-remove-refs-3.rs:6:19
|
LL | for (i, _) in & & &
| ____________________^
| | ___________________|
| ||
LL | || & &v
| ||___________- help: consider removing 5 leading `&`-references
LL | | .iter()
LL | | .enumerate() {
| |_____________________^ `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterator
LL | for (i, _) in & & &
| ___________________^
LL | | & &v
LL | | .iter()
LL | | .enumerate() {
| |____________________^ `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` is not an iterator
|
= help: the trait `Iterator` is not implemented for `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>`
= note: required for `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>` to implement `IntoIterator`
help: consider removing 5 leading `&`-references
|
LL - for (i, _) in & & &
LL + for (i, _) in v
|

error: aborting due to previous error

Expand Down
5 changes: 5 additions & 0 deletions tests/ui/suggestions/suggest-remove-refs-4.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// run-rustfix
fn main() {
let foo = [1,2,3].iter();
for _i in foo {} //~ ERROR E0277
}
5 changes: 5 additions & 0 deletions tests/ui/suggestions/suggest-remove-refs-4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// run-rustfix
fn main() {
let foo = &[1,2,3].iter();
for _i in &foo {} //~ ERROR E0277
}
17 changes: 17 additions & 0 deletions tests/ui/suggestions/suggest-remove-refs-4.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0277]: `&&std::slice::Iter<'_, {integer}>` is not an iterator
--> $DIR/suggest-remove-refs-4.rs:4:15
|
LL | for _i in &foo {}
| ^^^^ `&&std::slice::Iter<'_, {integer}>` is not an iterator
|
= help: the trait `Iterator` is not implemented for `&&std::slice::Iter<'_, {integer}>`
= note: required for `&&std::slice::Iter<'_, {integer}>` to implement `IntoIterator`
help: consider removing 2 leading `&`-references
|
LL ~ let foo = [1,2,3].iter();
LL ~ for _i in foo {}
|

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
8 changes: 8 additions & 0 deletions tests/ui/suggestions/suggest-remove-refs-5.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// run-rustfix
fn main() {
let v = &mut Vec::<i32>::new();
for _ in v {} //~ ERROR E0277

let v = &mut [1u8];
for _ in v {} //~ ERROR E0277
}
8 changes: 8 additions & 0 deletions tests/ui/suggestions/suggest-remove-refs-5.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// run-rustfix
fn main() {
let v = &mut &mut Vec::<i32>::new();
for _ in &mut &mut v {} //~ ERROR E0277

let v = &mut &mut [1u8];
for _ in &mut v {} //~ ERROR E0277
}
37 changes: 37 additions & 0 deletions tests/ui/suggestions/suggest-remove-refs-5.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
error[E0277]: `Vec<i32>` is not an iterator
--> $DIR/suggest-remove-refs-5.rs:4:14
|
LL | for _ in &mut &mut v {}
| ^^^^^^^^^^^ `Vec<i32>` is not an iterator; try calling `.into_iter()` or `.iter()`
|
= help: the trait `Iterator` is not implemented for `Vec<i32>`
= note: required for `&mut Vec<i32>` to implement `Iterator`
= note: 3 redundant requirements hidden
= note: required for `&mut &mut &mut &mut Vec<i32>` to implement `Iterator`
= note: required for `&mut &mut &mut &mut Vec<i32>` to implement `IntoIterator`
help: consider removing 3 leading `&`-references
|
LL ~ let v = &mut Vec::<i32>::new();
LL ~ for _ in v {}
|

error[E0277]: `[u8; 1]` is not an iterator
--> $DIR/suggest-remove-refs-5.rs:7:14
|
LL | for _ in &mut v {}
| ^^^^^^ `[u8; 1]` is not an iterator; try calling `.into_iter()` or `.iter()`
|
= help: the trait `Iterator` is not implemented for `[u8; 1]`
= note: required for `&mut [u8; 1]` to implement `Iterator`
= note: 2 redundant requirements hidden
= note: required for `&mut &mut &mut [u8; 1]` to implement `Iterator`
= note: required for `&mut &mut &mut [u8; 1]` to implement `IntoIterator`
help: consider removing 2 leading `&`-references
|
LL ~ let v = &mut [1u8];
LL ~ for _ in v {}
|

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
11 changes: 7 additions & 4 deletions tests/ui/typeck/issue-57404.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ error[E0277]: `&mut ()` is not a tuple
--> $DIR/issue-57404.rs:6:41
|
LL | handlers.unwrap().as_mut().call_mut(&mut ());
| -------- -^^^^^^
| | |
| | the trait `Tuple` is not implemented for `&mut ()`
| | help: consider removing the leading `&`-reference
| -------- ^^^^^^^ the trait `Tuple` is not implemented for `&mut ()`
| |
| required by a bound introduced by this call
|
note: required by a bound in `call_mut`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
help: consider removing the leading `&`-reference
|
LL - handlers.unwrap().as_mut().call_mut(&mut ());
LL + handlers.unwrap().as_mut().call_mut(());
|

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/typeck/issue-87181/empty-tuple-method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ impl Foo {
fn main() {
let thing = Bar { bar: Foo };
thing.bar.foo();
//~^ ERROR no method named `foo` found for fn item `fn() -> Foo {Foo}` in the current scope [E0599]
//~^ ERROR no method named `foo` found for struct constructor `fn() -> Foo {Foo}` in the current scope [E0599]
}
2 changes: 1 addition & 1 deletion tests/ui/typeck/issue-87181/empty-tuple-method.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `foo` found for fn item `fn() -> Foo {Foo}` in the current scope
error[E0599]: no method named `foo` found for struct constructor `fn() -> Foo {Foo}` in the current scope
--> $DIR/empty-tuple-method.rs:12:15
|
LL | thing.bar.foo();
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/typeck/issue-87181/enum-variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ impl Foo {
fn main() {
let thing = Bar { bar: Foo::Tup };
thing.bar.foo();
//~^ ERROR no method named `foo` found for fn item `fn() -> Foo {Foo::Tup}` in the current scope [E0599]
//~^ ERROR no method named `foo` found for enum constructor `fn() -> Foo {Foo::Tup}` in the current scope [E0599]
}
2 changes: 1 addition & 1 deletion tests/ui/typeck/issue-87181/enum-variant.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `foo` found for fn item `fn() -> Foo {Foo::Tup}` in the current scope
error[E0599]: no method named `foo` found for enum constructor `fn() -> Foo {Foo::Tup}` in the current scope
--> $DIR/enum-variant.rs:14:15
|
LL | thing.bar.foo();
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/typeck/issue-87181/tuple-method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ impl Foo {
fn main() {
let thing = Bar { bar: Foo };
thing.bar.foo();
//~^ ERROR no method named `foo` found for fn item `fn(u8, i32) -> Foo {Foo}` in the current scope [E0599]
//~^ ERROR no method named `foo` found for struct constructor `fn(u8, i32) -> Foo {Foo}` in the current scope [E0599]
}
2 changes: 1 addition & 1 deletion tests/ui/typeck/issue-87181/tuple-method.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `foo` found for fn item `fn(u8, i32) -> Foo {Foo}` in the current scope
error[E0599]: no method named `foo` found for struct constructor `fn(u8, i32) -> Foo {Foo}` in the current scope
--> $DIR/tuple-method.rs:12:15
|
LL | thing.bar.foo();
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/typeck/issue-96738.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `nonexistent_method` found for fn item `fn(_) -> Option<_> {Option::<_>::Some}` in the current scope
error[E0599]: no method named `nonexistent_method` found for enum constructor `fn(_) -> Option<_> {Option::<_>::Some}` in the current scope
--> $DIR/issue-96738.rs:2:10
|
LL | Some.nonexistent_method();
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/uninhabited/uninhabited-irrefutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ enum Foo {

fn main() {
let x: Foo = Foo::D(123, 456);
let Foo::D(_y, _z) = x; //~ ERROR refutable pattern in local binding: `Foo::A(_)` not covered
let Foo::D(_y, _z) = x;
//~^ ERROR refutable pattern in local binding
//~| `Foo::A(_)` not covered
}
14 changes: 5 additions & 9 deletions tests/ui/uninhabited/uninhabited-irrefutable.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0005]: refutable pattern in local binding: `Foo::A(_)` not covered
error[E0005]: refutable pattern in local binding
--> $DIR/uninhabited-irrefutable.rs:27:9
|
LL | let Foo::D(_y, _z) = x;
Expand All @@ -7,18 +7,14 @@ LL | let Foo::D(_y, _z) = x;
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Foo` defined here
--> $DIR/uninhabited-irrefutable.rs:19:5
--> $DIR/uninhabited-irrefutable.rs:18:6
|
LL | enum Foo {
| ---
| ^^^
LL | A(foo::SecretlyEmpty),
| ^ not covered
| - not covered
= note: the matched value is of type `Foo`
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | let (_y, _z) = if let Foo::D(_y, _z) = x { (_y, _z) } else { todo!() };
| +++++++++++++++++ +++++++++++++++++++++++++++++
help: alternatively, you might want to use let else to handle the variant that isn't matched
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Foo::D(_y, _z) = x else { todo!() };
| ++++++++++++++++
Expand Down
13 changes: 2 additions & 11 deletions tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,16 @@ LL ~ Ok(x) => x,
LL ~ Err(_) => todo!(),
|

error[E0005]: refutable pattern in local binding: `Err(_)` not covered
error[E0005]: refutable pattern in local binding
--> $DIR/uninhabited-matches-feature-gated.rs:37:9
|
LL | let Ok(x) = x;
| ^^^^^ pattern `Err(_)` not covered
|
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
= note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
note: `Result<u32, Void>` defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
::: $SRC_DIR/core/src/result.rs:LL:COL
|
= note: not covered
= note: the matched value is of type `Result<u32, Void>`
help: you might want to use `if let` to ignore the variant that isn't matched
|
LL | let x = if let Ok(x) = x { x } else { todo!() };
| ++++++++++ ++++++++++++++++++++++
help: alternatively, you might want to use let else to handle the variant that isn't matched
help: you might want to use `let else` to handle the variant that isn't matched
|
LL | let Ok(x) = x else { todo!() };
| ++++++++++++++++
Expand Down