Update tests

This commit is contained in:
Dylan MacKenzie 2020-06-25 17:43:48 -07:00
parent 7c46e42512
commit d84f0c8d32
47 changed files with 105 additions and 415 deletions

View File

@ -1,11 +1,11 @@
fn main() { fn main() {
[(); & { loop { continue } } ]; //~ ERROR mismatched types [(); & { loop { continue } } ]; //~ ERROR mismatched types
//~^ ERROR `loop` is not allowed in a `const`
[(); loop { break }]; //~ ERROR mismatched types [(); loop { break }]; //~ ERROR mismatched types
//~^ ERROR `loop` is not allowed in a `const`
[(); {while true {break}; 0}]; [(); {while true {break}; 0}];
//~^ ERROR `while` is not allowed in a `const` //~^ WARN denote infinite loops with
//~| WARN denote infinite loops with
[(); { for _ in 0usize.. {}; 0}]; [(); { for _ in 0usize.. {}; 0}];
//~^ ERROR `for` is not allowed in a `const` //~^ ERROR `for` is not allowed in a `const`
//~| ERROR calls in constants are limited to constant functions //~| ERROR calls in constants are limited to constant functions

View File

@ -4,7 +4,6 @@ async fn fun() {
[1; ().await]; [1; ().await];
//~^ error: `await` is only allowed inside `async` functions and blocks //~^ error: `await` is only allowed inside `async` functions and blocks
//~| error: `.await` is not allowed in a `const` //~| error: `.await` is not allowed in a `const`
//~| error: `loop` is not allowed in a `const`
//~| error: `.await` is not allowed in a `const` //~| error: `.await` is not allowed in a `const`
//~| error: `()` is not a future //~| error: `()` is not a future
} }

View File

@ -12,15 +12,6 @@ error[E0744]: `.await` is not allowed in a `const`
LL | [1; ().await]; LL | [1; ().await];
| ^^^^^^^^ | ^^^^^^^^
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/issue-70594.rs:4:9
|
LL | [1; ().await];
| ^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0744]: `.await` is not allowed in a `const` error[E0744]: `.await` is not allowed in a `const`
--> $DIR/issue-70594.rs:4:9 --> $DIR/issue-70594.rs:4:9
| |
@ -36,7 +27,7 @@ LL | [1; ().await];
= help: the trait `std::future::Future` is not implemented for `()` = help: the trait `std::future::Future` is not implemented for `()`
= note: required by `std::future::Future::poll` = note: required by `std::future::Future::poll`
error: aborting due to 5 previous errors error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0658, E0728, E0744. Some errors have detailed explanations: E0277, E0728, E0744.
For more information about an error, try `rustc --explain E0277`. For more information about an error, try `rustc --explain E0277`.

View File

@ -1,7 +1,6 @@
fn main() { fn main() {
[(); &(&'static: loop { |x| {}; }) as *const _ as usize] [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
//~^ ERROR: invalid label name `'static` //~^ ERROR: invalid label name `'static`
//~| ERROR: `loop` is not allowed in a `const`
//~| ERROR: type annotations needed //~| ERROR: type annotations needed
//~| ERROR mismatched types //~| ERROR mismatched types
} }

View File

@ -4,15 +4,6 @@ error: invalid label name `'static`
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
| ^^^^^^^ | ^^^^^^^
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/issue-52437.rs:2:13
|
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0282]: type annotations needed error[E0282]: type annotations needed
--> $DIR/issue-52437.rs:2:30 --> $DIR/issue-52437.rs:2:30
| |
@ -27,7 +18,7 @@ LL | fn main() {
LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize] LL | [(); &(&'static: loop { |x| {}; }) as *const _ as usize]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[(); _]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found array `[(); _]`
error: aborting due to 4 previous errors error: aborting due to 3 previous errors
Some errors have detailed explanations: E0282, E0308, E0658. Some errors have detailed explanations: E0282, E0308.
For more information about an error, try `rustc --explain E0282`. For more information about an error, try `rustc --explain E0282`.

View File

@ -4,7 +4,6 @@ fn main() {
let _ = [(); { let _ = [(); {
let mut n = 113383; // #20 in https://oeis.org/A006884 let mut n = 113383; // #20 in https://oeis.org/A006884
while n != 0 { while n != 0 {
//~^ ERROR `while` is not allowed in a `const`
n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
//~^ ERROR evaluation of constant value failed //~^ ERROR evaluation of constant value failed
} }

View File

@ -1,23 +1,9 @@
error[E0658]: `while` is not allowed in a `const`
--> $DIR/infinite_loop.rs:6:9
|
LL | / while n != 0 {
LL | |
LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
LL | |
LL | | }
| |_________^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/infinite_loop.rs:8:17 --> $DIR/infinite_loop.rs:7:17
| |
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
error: aborting due to 2 previous errors error: aborting due to previous error
Some errors have detailed explanations: E0080, E0658. For more information about this error, try `rustc --explain E0080`.
For more information about an error, try `rustc --explain E0080`.

View File

@ -1,6 +1,5 @@
fn main() { fn main() {
[(); { &loop { break } as *const _ as usize } ]; [(); { &loop { break } as *const _ as usize } ];
//~^ ERROR `loop` is not allowed in a `const` //~^ ERROR casting pointers to integers in constants is unstable
//~| ERROR casting pointers to integers in constants is unstable
//~| ERROR evaluation of constant value failed //~| ERROR evaluation of constant value failed
} }

View File

@ -1,12 +1,3 @@
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/issue-52442.rs:2:14
|
LL | [(); { &loop { break } as *const _ as usize } ];
| ^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: casting pointers to integers in constants is unstable error[E0658]: casting pointers to integers in constants is unstable
--> $DIR/issue-52442.rs:2:13 --> $DIR/issue-52442.rs:2:13
| |
@ -22,7 +13,7 @@ error[E0080]: evaluation of constant value failed
LL | [(); { &loop { break } as *const _ as usize } ]; LL | [(); { &loop { break } as *const _ as usize } ];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
error: aborting due to 3 previous errors error: aborting due to 2 previous errors
Some errors have detailed explanations: E0080, E0658. Some errors have detailed explanations: E0080, E0658.
For more information about an error, try `rustc --explain E0080`. For more information about an error, try `rustc --explain E0080`.

View File

@ -3,7 +3,6 @@ fn main() {
let mut x = &0; let mut x = &0;
let mut n = 0; let mut n = 0;
while n < 5 { while n < 5 {
//~^ ERROR `while` is not allowed in a `const`
n = (n + 1) % 5; //~ ERROR evaluation of constant value failed n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
x = &0; // Materialize a new AllocId x = &0; // Materialize a new AllocId
} }

View File

@ -1,23 +1,9 @@
error[E0658]: `while` is not allowed in a `const`
--> $DIR/issue-52475.rs:5:9
|
LL | / while n < 5 {
LL | |
LL | | n = (n + 1) % 5;
LL | | x = &0; // Materialize a new AllocId
LL | | }
| |_________^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/issue-52475.rs:7:17 --> $DIR/issue-52475.rs:6:17
| |
LL | n = (n + 1) % 5; LL | n = (n + 1) % 5;
| ^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) | ^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
error: aborting due to 2 previous errors error: aborting due to previous error
Some errors have detailed explanations: E0080, E0658. For more information about this error, try `rustc --explain E0080`.
For more information about an error, try `rustc --explain E0080`.

View File

@ -1,11 +0,0 @@
// `loop`s unconditionally-broken-from used to be allowed in constants, but are now forbidden by
// the HIR const-checker.
//
// See https://github.com/rust-lang/rust/pull/66170 and
// https://github.com/rust-lang/rust/issues/62272.
const FOO: () = loop { break; }; //~ ERROR `loop` is not allowed in a `const`
fn main() {
[FOO; { let x; loop { x = 5; break; } x }]; //~ ERROR `loop` is not allowed in a `const`
}

View File

@ -1,21 +0,0 @@
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/issue-62272.rs:7:17
|
LL | const FOO: () = loop { break; };
| ^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/issue-62272.rs:10:20
|
LL | [FOO; { let x; loop { x = 5; break; } x }];
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,5 +1,3 @@
#![feature(const_loop)]
static _X: () = loop {}; //~ ERROR could not evaluate static initializer static _X: () = loop {}; //~ ERROR could not evaluate static initializer
fn main() {} fn main() {}

View File

@ -1,5 +1,5 @@
error[E0080]: could not evaluate static initializer error[E0080]: could not evaluate static initializer
--> $DIR/issue-70723.rs:3:17 --> $DIR/issue-70723.rs:1:17
| |
LL | static _X: () = loop {}; LL | static _X: () = loop {};
| ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) | ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)

View File

@ -1,6 +1,3 @@
#![feature(const_if_match)]
#![feature(const_loop)]
const _: Option<Vec<i32>> = { const _: Option<Vec<i32>> = {
let mut never_returned = Some(Vec::new()); let mut never_returned = Some(Vec::new());
let mut always_returned = None; //~ ERROR destructors cannot be evaluated at compile-time let mut always_returned = None; //~ ERROR destructors cannot be evaluated at compile-time

View File

@ -1,5 +1,5 @@
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/livedrop.rs:6:9 --> $DIR/livedrop.rs:3:9
| |
LL | let mut always_returned = None; LL | let mut always_returned = None;
| ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors | ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors

View File

@ -1,12 +1,11 @@
// run-pass
// Using labeled break in a while loop has caused an illegal instruction being // Using labeled break in a while loop has caused an illegal instruction being
// generated, and an ICE later. // generated, and an ICE later.
// //
// See https://github.com/rust-lang/rust/issues/51350 for more information. // See https://github.com/rust-lang/rust/issues/51350 for more information.
//
// It is now forbidden by the HIR const-checker.
//
// See https://github.com/rust-lang/rust/pull/66170.
const CRASH: () = 'a: while break 'a {}; //~ ERROR `while` is not allowed in a `const` #[allow(unreachable_code)]
const _: () = 'a: while break 'a {};
fn main() {} fn main() {}

View File

@ -1,12 +0,0 @@
error[E0658]: `while` is not allowed in a `const`
--> $DIR/const-labeled-break.rs:10:19
|
LL | const CRASH: () = 'a: while break 'a {};
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,7 +1,6 @@
// check-pass // check-pass
#![feature(const_eval_limit)] #![feature(const_eval_limit)]
#![feature(const_loop)]
// This needs to be higher than the number of loop iterations since each pass through the loop may // This needs to be higher than the number of loop iterations since each pass through the loop may
// hit more than one terminator. // hit more than one terminator.

View File

@ -1,5 +1,4 @@
#![feature(const_eval_limit)] #![feature(const_eval_limit)]
#![feature(const_loop)]
#![const_eval_limit = "500"] #![const_eval_limit = "500"]
const X: usize = { const X: usize = {

View File

@ -1,5 +1,5 @@
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_eval_limit_reached.rs:7:11 --> $DIR/const_eval_limit_reached.rs:6:5
| |
LL | / const X: usize = { LL | / const X: usize = {
LL | | let mut x = 0; LL | | let mut x = 0;

View File

@ -3,7 +3,6 @@
// run-pass // run-pass
#![feature(const_panic)] #![feature(const_panic)]
#![feature(const_loop)]
#![feature(const_fn)] #![feature(const_fn)]
const X: u32 = 4; const X: u32 = 4;

View File

@ -1,11 +1,11 @@
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:9:9 --> $DIR/drop-fail.rs:8:9
| |
LL | let x = Some(Vec::new()); LL | let x = Some(Vec::new());
| ^ constants cannot evaluate destructors | ^ constants cannot evaluate destructors
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:40:9 --> $DIR/drop-fail.rs:39:9
| |
LL | let mut tmp = None; LL | let mut tmp = None;
| ^^^^^^^ constants cannot evaluate destructors | ^^^^^^^ constants cannot evaluate destructors

View File

@ -1,6 +1,5 @@
// revisions: stock precise // revisions: stock precise
#![feature(const_loop)]
#![cfg_attr(precise, feature(const_precise_live_drops))] #![cfg_attr(precise, feature(const_precise_live_drops))]
// `x` is *not* always moved into the final value and may be dropped inside the initializer. // `x` is *not* always moved into the final value and may be dropped inside the initializer.

View File

@ -1,5 +1,5 @@
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:9:9 --> $DIR/drop-fail.rs:8:9
| |
LL | let x = Some(Vec::new()); LL | let x = Some(Vec::new());
| ^ constants cannot evaluate destructors | ^ constants cannot evaluate destructors
@ -8,7 +8,7 @@ LL | };
| - value is dropped here | - value is dropped here
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:22:9 --> $DIR/drop-fail.rs:21:9
| |
LL | let vec_tuple = (Vec::new(),); LL | let vec_tuple = (Vec::new(),);
| ^^^^^^^^^ constants cannot evaluate destructors | ^^^^^^^^^ constants cannot evaluate destructors
@ -17,7 +17,7 @@ LL | };
| - value is dropped here | - value is dropped here
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:30:9 --> $DIR/drop-fail.rs:29:9
| |
LL | let x: Result<_, Vec<i32>> = Ok(Vec::new()); LL | let x: Result<_, Vec<i32>> = Ok(Vec::new());
| ^ constants cannot evaluate destructors | ^ constants cannot evaluate destructors
@ -26,7 +26,7 @@ LL | };
| - value is dropped here | - value is dropped here
error[E0493]: destructors cannot be evaluated at compile-time error[E0493]: destructors cannot be evaluated at compile-time
--> $DIR/drop-fail.rs:40:9 --> $DIR/drop-fail.rs:39:9
| |
LL | let mut tmp = None; LL | let mut tmp = None;
| ^^^^^^^ constants cannot evaluate destructors | ^^^^^^^ constants cannot evaluate destructors

View File

@ -1,7 +1,6 @@
// run-pass // run-pass
// revisions: stock precise // revisions: stock precise
#![feature(const_loop)]
#![cfg_attr(precise, feature(const_precise_live_drops))] #![cfg_attr(precise, feature(const_precise_live_drops))]
// `x` is always moved into the final value and is not dropped inside the initializer. // `x` is always moved into the final value and is not dropped inside the initializer.

View File

@ -1,7 +1,6 @@
// run-pass // run-pass
// gate-test-const_precise_live_drops // gate-test-const_precise_live_drops
#![feature(const_loop)]
#![feature(const_precise_live_drops)] #![feature(const_precise_live_drops)]
const _: Vec<i32> = { const _: Vec<i32> = {

View File

@ -1,8 +1,6 @@
// Ensure that *any* assignment to the return place of a value with interior mutability // Ensure that *any* assignment to the return place of a value with interior mutability
// disqualifies it from promotion. // disqualifies it from promotion.
#![feature(const_loop)]
use std::cell::Cell; use std::cell::Cell;
const X: Option<Cell<i32>> = { const X: Option<Cell<i32>> = {

View File

@ -1,5 +1,5 @@
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/interior-mutability.rs:42:26 --> $DIR/interior-mutability.rs:40:26
| |
LL | let x: &'static _ = &X; LL | let x: &'static _ = &X;
| ---------- ^ creates a temporary which is freed while still in use | ---------- ^ creates a temporary which is freed while still in use
@ -10,7 +10,7 @@ LL | }
| - temporary value is freed at the end of this statement | - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/interior-mutability.rs:43:26 --> $DIR/interior-mutability.rs:41:26
| |
LL | let y: &'static _ = &Y; LL | let y: &'static _ = &Y;
| ---------- ^ creates a temporary which is freed while still in use | ---------- ^ creates a temporary which is freed while still in use
@ -21,7 +21,7 @@ LL | }
| - temporary value is freed at the end of this statement | - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed error[E0716]: temporary value dropped while borrowed
--> $DIR/interior-mutability.rs:44:26 --> $DIR/interior-mutability.rs:42:26
| |
LL | let z: &'static _ = &Z; LL | let z: &'static _ = &Z;
| ---------- ^ creates a temporary which is freed while still in use | ---------- ^ creates a temporary which is freed while still in use

View File

@ -1,29 +1,22 @@
// Ensure that loops are forbidden in a const context unless `#![feature(const_loop)]` is enabled. const _: () = loop { break (); };
// gate-test-const_loop static FOO: i32 = loop { break 4; };
// revisions: stock loop_
#![cfg_attr(loop_, feature(const_loop))]
const _: () = loop {}; //[stock]~ ERROR `loop` is not allowed in a `const`
static FOO: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `static`
const fn foo() { const fn foo() {
loop {} //[stock]~ ERROR `loop` is not allowed in a `const fn` loop {}
} }
pub trait Foo { pub trait Foo {
const BAR: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `const` const BAR: i32 = loop { break 4; };
} }
impl Foo for () { impl Foo for () {
const BAR: i32 = loop { break 4; }; //[stock]~ ERROR `loop` is not allowed in a `const` const BAR: i32 = loop { break 4; };
} }
fn non_const_outside() { fn non_const_outside() {
const fn const_inside() { const fn const_inside() {
loop {} //[stock]~ ERROR `loop` is not allowed in a `const fn` loop {}
} }
} }
@ -36,7 +29,6 @@ const fn const_outside() {
fn main() { fn main() {
let x = [0; { let x = [0; {
while false {} while false {}
//[stock]~^ ERROR `while` is not allowed in a `const`
4 4
}]; }];
} }
@ -44,11 +36,11 @@ fn main() {
const _: i32 = { const _: i32 = {
let mut x = 0; let mut x = 0;
while x < 4 { //[stock]~ ERROR `while` is not allowed in a `const` while x < 4 {
x += 1; x += 1;
} }
while x < 8 { //[stock]~ ERROR `while` is not allowed in a `const` while x < 8 {
x += 1; x += 1;
} }
@ -58,11 +50,11 @@ const _: i32 = {
const _: i32 = { const _: i32 = {
let mut x = 0; let mut x = 0;
for i in 0..4 { //[stock,loop_]~ ERROR `for` is not allowed in a `const` for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
x += i; x += i;
} }
for i in 0..4 { //[stock,loop_]~ ERROR `for` is not allowed in a `const` for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
x += i; x += i;
} }
@ -72,14 +64,14 @@ const _: i32 = {
const _: i32 = { const _: i32 = {
let mut x = 0; let mut x = 0;
loop { //[stock]~ ERROR `loop` is not allowed in a `const` loop {
x += 1; x += 1;
if x == 4 { if x == 4 {
break; break;
} }
} }
loop { //[stock]~ ERROR `loop` is not allowed in a `const` loop {
x += 1; x += 1;
if x == 8 { if x == 8 {
break; break;
@ -91,7 +83,7 @@ const _: i32 = {
const _: i32 = { const _: i32 = {
let mut x = 0; let mut x = 0;
while let None = Some(x) { } //[stock]~ ERROR `while` is not allowed in a `const` while let None = Some(x) { }
while let None = Some(x) { } //[stock]~ ERROR `while` is not allowed in a `const` while let None = Some(x) { }
x x
}; };

View File

@ -1,5 +1,5 @@
error[E0744]: `for` is not allowed in a `const` error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:61:5 --> $DIR/loop.rs:53:5
| |
LL | / for i in 0..4 { LL | / for i in 0..4 {
LL | | x += i; LL | | x += i;
@ -7,7 +7,7 @@ LL | | }
| |_____^ | |_____^
error[E0744]: `for` is not allowed in a `const` error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:65:5 --> $DIR/loop.rs:57:5
| |
LL | / for i in 0..4 { LL | / for i in 0..4 {
LL | | x += i; LL | | x += i;

View File

@ -1,151 +0,0 @@
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:8:15
|
LL | const _: () = loop {};
| ^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `static`
--> $DIR/loop.rs:10:19
|
LL | static FOO: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const fn`
--> $DIR/loop.rs:13:5
|
LL | loop {}
| ^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const fn`
--> $DIR/loop.rs:26:9
|
LL | loop {}
| ^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:38:9
|
LL | while false {}
| ^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:47:5
|
LL | / while x < 4 {
LL | | x += 1;
LL | | }
| |_____^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:51:5
|
LL | / while x < 8 {
LL | | x += 1;
LL | | }
| |_____^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:61:5
|
LL | / for i in 0..4 {
LL | | x += i;
LL | | }
| |_____^
error[E0744]: `for` is not allowed in a `const`
--> $DIR/loop.rs:65:5
|
LL | / for i in 0..4 {
LL | | x += i;
LL | | }
| |_____^
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:75:5
|
LL | / loop {
LL | | x += 1;
LL | | if x == 4 {
LL | | break;
LL | | }
LL | | }
| |_____^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:82:5
|
LL | / loop {
LL | | x += 1;
LL | | if x == 8 {
LL | | break;
LL | | }
LL | | }
| |_____^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:94:5
|
LL | while let None = Some(x) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `while` is not allowed in a `const`
--> $DIR/loop.rs:95:5
|
LL | while let None = Some(x) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:17:22
|
LL | const BAR: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0658]: `loop` is not allowed in a `const`
--> $DIR/loop.rs:21:22
|
LL | const BAR: i32 = loop { break 4; };
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error: aborting due to 15 previous errors
Some errors have detailed explanations: E0658, E0744.
For more information about an error, try `rustc --explain E0658`.

View File

@ -1,5 +0,0 @@
const fn foo() {
loop {} //~ ERROR `loop` is not allowed in a `const fn`
}
fn main() {}

View File

@ -1,12 +0,0 @@
error[E0658]: `loop` is not allowed in a `const fn`
--> $DIR/loop_ice.rs:2:5
|
LL | loop {}
| ^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,12 +1,14 @@
// Don't allow unstable features in stable functions without `allow_internal_unstable`.
#![stable(feature = "rust1", since = "1.0.0")] #![stable(feature = "rust1", since = "1.0.0")]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(const_loop, const_fn)] #![feature(const_transmute, const_fn)]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "rust1", since = "1.0.0")]
const fn foo() -> i32 { pub const fn foo() -> i32 {
loop { return 42; } //~ ERROR `loop` is not allowed in a `const fn` unsafe { std::mem::transmute(4u32) } //~ ERROR is not stable as `const fn`
} }
fn main() {} fn main() {}

View File

@ -1,9 +1,12 @@
error[E0744]: `loop` is not allowed in a `const fn` error[E0723]: can only call other `const fn` within a `const fn`, but `const std::intrinsics::transmute::<u32, i32>` is not stable as `const fn`
--> $DIR/internal-unstable-const.rs:9:5 --> $DIR/internal-unstable-const.rs:11:14
| |
LL | loop { return 42; } LL | unsafe { std::mem::transmute(4u32) }
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0744`. For more information about this error, try `rustc --explain E0723`.

View File

@ -10,5 +10,4 @@ fn main() {
[(); return while let Some(n) = Some(0) {}]; [(); return while let Some(n) = Some(0) {}];
//~^ ERROR return statement outside of function body //~^ ERROR return statement outside of function body
//~| ERROR `while` is not allowed in a `const`
} }

View File

@ -1,12 +1,3 @@
error[E0658]: `while` is not allowed in a `const`
--> $DIR/issue-51714.rs:11:17
|
LL | [(); return while let Some(n) = Some(0) {}];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error[E0572]: return statement outside of function body error[E0572]: return statement outside of function body
--> $DIR/issue-51714.rs:2:14 --> $DIR/issue-51714.rs:2:14
| |
@ -31,7 +22,6 @@ error[E0572]: return statement outside of function body
LL | [(); return while let Some(n) = Some(0) {}]; LL | [(); return while let Some(n) = Some(0) {}];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors error: aborting due to 4 previous errors
Some errors have detailed explanations: E0572, E0658. For more information about this error, try `rustc --explain E0572`.
For more information about an error, try `rustc --explain E0572`.

View File

@ -4,12 +4,13 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
pub trait MyTrait { pub trait MyTrait {
fn method(&self); fn method(&self) -> Option<()>;
} }
impl const MyTrait for () { impl const MyTrait for () {
fn method(&self) { fn method(&self) -> Option<()> {
loop {} //~ ERROR `loop` is not allowed in a `const fn` Some(())?; //~ ERROR `?` is not allowed in a `const fn`
None
} }
} }

View File

@ -1,12 +1,9 @@
error[E0658]: `loop` is not allowed in a `const fn` error[E0744]: `?` is not allowed in a `const fn`
--> $DIR/hir-const-check.rs:12:9 --> $DIR/hir-const-check.rs:12:9
| |
LL | loop {} LL | Some(())?;
| ^^^^^^^ | ^^^^^^^^^
|
= note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information
= help: add `#![feature(const_loop)]` to the crate attributes to enable
error: aborting due to previous error error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0744`.

View File

@ -1,7 +1,5 @@
// run-rustfix // run-rustfix
#![feature(const_if_match)]
#![feature(const_loop)]
#![warn(clippy::all)] #![warn(clippy::all)]
#![warn(clippy::redundant_pattern_matching)] #![warn(clippy::redundant_pattern_matching)]
#![allow(clippy::unit_arg, unused_must_use, clippy::needless_bool, deprecated)] #![allow(clippy::unit_arg, unused_must_use, clippy::needless_bool, deprecated)]

View File

@ -1,7 +1,5 @@
// run-rustfix // run-rustfix
#![feature(const_if_match)]
#![feature(const_loop)]
#![warn(clippy::all)] #![warn(clippy::all)]
#![warn(clippy::redundant_pattern_matching)] #![warn(clippy::redundant_pattern_matching)]
#![allow(clippy::unit_arg, unused_must_use, clippy::needless_bool, deprecated)] #![allow(clippy::unit_arg, unused_must_use, clippy::needless_bool, deprecated)]

View File

@ -1,5 +1,5 @@
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching.rs:10:12 --> $DIR/redundant_pattern_matching.rs:8:12
| |
LL | if let Ok(_) = Ok::<i32, i32>(42) {} LL | if let Ok(_) = Ok::<i32, i32>(42) {}
| -------^^^^^--------------------- help: try this: `if Ok::<i32, i32>(42).is_ok()` | -------^^^^^--------------------- help: try this: `if Ok::<i32, i32>(42).is_ok()`
@ -7,67 +7,67 @@ LL | if let Ok(_) = Ok::<i32, i32>(42) {}
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/redundant_pattern_matching.rs:12:12 --> $DIR/redundant_pattern_matching.rs:10:12
| |
LL | if let Err(_) = Err::<i32, i32>(42) {} LL | if let Err(_) = Err::<i32, i32>(42) {}
| -------^^^^^^---------------------- help: try this: `if Err::<i32, i32>(42).is_err()` | -------^^^^^^---------------------- help: try this: `if Err::<i32, i32>(42).is_err()`
error: redundant pattern matching, consider using `is_none()` error: redundant pattern matching, consider using `is_none()`
--> $DIR/redundant_pattern_matching.rs:14:12 --> $DIR/redundant_pattern_matching.rs:12:12
| |
LL | if let None = None::<()> {} LL | if let None = None::<()> {}
| -------^^^^------------- help: try this: `if None::<()>.is_none()` | -------^^^^------------- help: try this: `if None::<()>.is_none()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:16:12 --> $DIR/redundant_pattern_matching.rs:14:12
| |
LL | if let Some(_) = Some(42) {} LL | if let Some(_) = Some(42) {}
| -------^^^^^^^----------- help: try this: `if Some(42).is_some()` | -------^^^^^^^----------- help: try this: `if Some(42).is_some()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:18:12 --> $DIR/redundant_pattern_matching.rs:16:12
| |
LL | if let Some(_) = Some(42) { LL | if let Some(_) = Some(42) {
| -------^^^^^^^----------- help: try this: `if Some(42).is_some()` | -------^^^^^^^----------- help: try this: `if Some(42).is_some()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:24:15 --> $DIR/redundant_pattern_matching.rs:22:15
| |
LL | while let Some(_) = Some(42) {} LL | while let Some(_) = Some(42) {}
| ----------^^^^^^^----------- help: try this: `while Some(42).is_some()` | ----------^^^^^^^----------- help: try this: `while Some(42).is_some()`
error: redundant pattern matching, consider using `is_none()` error: redundant pattern matching, consider using `is_none()`
--> $DIR/redundant_pattern_matching.rs:26:15 --> $DIR/redundant_pattern_matching.rs:24:15
| |
LL | while let None = Some(42) {} LL | while let None = Some(42) {}
| ----------^^^^----------- help: try this: `while Some(42).is_none()` | ----------^^^^----------- help: try this: `while Some(42).is_none()`
error: redundant pattern matching, consider using `is_none()` error: redundant pattern matching, consider using `is_none()`
--> $DIR/redundant_pattern_matching.rs:28:15 --> $DIR/redundant_pattern_matching.rs:26:15
| |
LL | while let None = None::<()> {} LL | while let None = None::<()> {}
| ----------^^^^------------- help: try this: `while None::<()>.is_none()` | ----------^^^^------------- help: try this: `while None::<()>.is_none()`
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching.rs:30:15 --> $DIR/redundant_pattern_matching.rs:28:15
| |
LL | while let Ok(_) = Ok::<i32, i32>(10) {} LL | while let Ok(_) = Ok::<i32, i32>(10) {}
| ----------^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_ok()` | ----------^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_ok()`
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/redundant_pattern_matching.rs:32:15 --> $DIR/redundant_pattern_matching.rs:30:15
| |
LL | while let Err(_) = Ok::<i32, i32>(10) {} LL | while let Err(_) = Ok::<i32, i32>(10) {}
| ----------^^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_err()` | ----------^^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_err()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:35:15 --> $DIR/redundant_pattern_matching.rs:33:15
| |
LL | while let Some(_) = v.pop() { LL | while let Some(_) = v.pop() {
| ----------^^^^^^^---------- help: try this: `while v.pop().is_some()` | ----------^^^^^^^---------- help: try this: `while v.pop().is_some()`
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching.rs:51:5 --> $DIR/redundant_pattern_matching.rs:49:5
| |
LL | / match Ok::<i32, i32>(42) { LL | / match Ok::<i32, i32>(42) {
LL | | Ok(_) => true, LL | | Ok(_) => true,
@ -76,7 +76,7 @@ LL | | };
| |_____^ help: try this: `Ok::<i32, i32>(42).is_ok()` | |_____^ help: try this: `Ok::<i32, i32>(42).is_ok()`
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/redundant_pattern_matching.rs:56:5 --> $DIR/redundant_pattern_matching.rs:54:5
| |
LL | / match Ok::<i32, i32>(42) { LL | / match Ok::<i32, i32>(42) {
LL | | Ok(_) => false, LL | | Ok(_) => false,
@ -85,7 +85,7 @@ LL | | };
| |_____^ help: try this: `Ok::<i32, i32>(42).is_err()` | |_____^ help: try this: `Ok::<i32, i32>(42).is_err()`
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/redundant_pattern_matching.rs:61:5 --> $DIR/redundant_pattern_matching.rs:59:5
| |
LL | / match Err::<i32, i32>(42) { LL | / match Err::<i32, i32>(42) {
LL | | Ok(_) => false, LL | | Ok(_) => false,
@ -94,7 +94,7 @@ LL | | };
| |_____^ help: try this: `Err::<i32, i32>(42).is_err()` | |_____^ help: try this: `Err::<i32, i32>(42).is_err()`
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching.rs:66:5 --> $DIR/redundant_pattern_matching.rs:64:5
| |
LL | / match Err::<i32, i32>(42) { LL | / match Err::<i32, i32>(42) {
LL | | Ok(_) => true, LL | | Ok(_) => true,
@ -103,7 +103,7 @@ LL | | };
| |_____^ help: try this: `Err::<i32, i32>(42).is_ok()` | |_____^ help: try this: `Err::<i32, i32>(42).is_ok()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:71:5 --> $DIR/redundant_pattern_matching.rs:69:5
| |
LL | / match Some(42) { LL | / match Some(42) {
LL | | Some(_) => true, LL | | Some(_) => true,
@ -112,7 +112,7 @@ LL | | };
| |_____^ help: try this: `Some(42).is_some()` | |_____^ help: try this: `Some(42).is_some()`
error: redundant pattern matching, consider using `is_none()` error: redundant pattern matching, consider using `is_none()`
--> $DIR/redundant_pattern_matching.rs:76:5 --> $DIR/redundant_pattern_matching.rs:74:5
| |
LL | / match None::<()> { LL | / match None::<()> {
LL | | Some(_) => false, LL | | Some(_) => false,
@ -121,7 +121,7 @@ LL | | };
| |_____^ help: try this: `None::<()>.is_none()` | |_____^ help: try this: `None::<()>.is_none()`
error: redundant pattern matching, consider using `is_none()` error: redundant pattern matching, consider using `is_none()`
--> $DIR/redundant_pattern_matching.rs:81:13 --> $DIR/redundant_pattern_matching.rs:79:13
| |
LL | let _ = match None::<()> { LL | let _ = match None::<()> {
| _____________^ | _____________^
@ -131,61 +131,61 @@ LL | | };
| |_____^ help: try this: `None::<()>.is_none()` | |_____^ help: try this: `None::<()>.is_none()`
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching.rs:86:20 --> $DIR/redundant_pattern_matching.rs:84:20
| |
LL | let _ = if let Ok(_) = Ok::<usize, ()>(4) { true } else { false }; LL | let _ = if let Ok(_) = Ok::<usize, ()>(4) { true } else { false };
| -------^^^^^--------------------- help: try this: `if Ok::<usize, ()>(4).is_ok()` | -------^^^^^--------------------- help: try this: `if Ok::<usize, ()>(4).is_ok()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:89:20 --> $DIR/redundant_pattern_matching.rs:87:20
| |
LL | let x = if let Some(_) = opt { true } else { false }; LL | let x = if let Some(_) = opt { true } else { false };
| -------^^^^^^^------ help: try this: `if opt.is_some()` | -------^^^^^^^------ help: try this: `if opt.is_some()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:95:20 --> $DIR/redundant_pattern_matching.rs:93:20
| |
LL | let _ = if let Some(_) = gen_opt() { LL | let _ = if let Some(_) = gen_opt() {
| -------^^^^^^^------------ help: try this: `if gen_opt().is_some()` | -------^^^^^^^------------ help: try this: `if gen_opt().is_some()`
error: redundant pattern matching, consider using `is_none()` error: redundant pattern matching, consider using `is_none()`
--> $DIR/redundant_pattern_matching.rs:97:19 --> $DIR/redundant_pattern_matching.rs:95:19
| |
LL | } else if let None = gen_opt() { LL | } else if let None = gen_opt() {
| -------^^^^------------ help: try this: `if gen_opt().is_none()` | -------^^^^------------ help: try this: `if gen_opt().is_none()`
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching.rs:99:19 --> $DIR/redundant_pattern_matching.rs:97:19
| |
LL | } else if let Ok(_) = gen_res() { LL | } else if let Ok(_) = gen_res() {
| -------^^^^^------------ help: try this: `if gen_res().is_ok()` | -------^^^^^------------ help: try this: `if gen_res().is_ok()`
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/redundant_pattern_matching.rs:101:19 --> $DIR/redundant_pattern_matching.rs:99:19
| |
LL | } else if let Err(_) = gen_res() { LL | } else if let Err(_) = gen_res() {
| -------^^^^^^------------ help: try this: `if gen_res().is_err()` | -------^^^^^^------------ help: try this: `if gen_res().is_err()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:134:19 --> $DIR/redundant_pattern_matching.rs:132:19
| |
LL | while let Some(_) = r#try!(result_opt()) {} LL | while let Some(_) = r#try!(result_opt()) {}
| ----------^^^^^^^----------------------- help: try this: `while r#try!(result_opt()).is_some()` | ----------^^^^^^^----------------------- help: try this: `while r#try!(result_opt()).is_some()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:135:16 --> $DIR/redundant_pattern_matching.rs:133:16
| |
LL | if let Some(_) = r#try!(result_opt()) {} LL | if let Some(_) = r#try!(result_opt()) {}
| -------^^^^^^^----------------------- help: try this: `if r#try!(result_opt()).is_some()` | -------^^^^^^^----------------------- help: try this: `if r#try!(result_opt()).is_some()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:141:12 --> $DIR/redundant_pattern_matching.rs:139:12
| |
LL | if let Some(_) = m!() {} LL | if let Some(_) = m!() {}
| -------^^^^^^^------- help: try this: `if m!().is_some()` | -------^^^^^^^------- help: try this: `if m!().is_some()`
error: redundant pattern matching, consider using `is_some()` error: redundant pattern matching, consider using `is_some()`
--> $DIR/redundant_pattern_matching.rs:142:15 --> $DIR/redundant_pattern_matching.rs:140:15
| |
LL | while let Some(_) = m!() {} LL | while let Some(_) = m!() {}
| ----------^^^^^^^------- help: try this: `while m!().is_some()` | ----------^^^^^^^------- help: try this: `while m!().is_some()`

View File

@ -1,7 +1,5 @@
// run-rustfix // run-rustfix
#![feature(const_if_match)]
#![feature(const_loop)]
#![feature(const_result)] #![feature(const_result)]
#![warn(clippy::redundant_pattern_matching)] #![warn(clippy::redundant_pattern_matching)]
#![allow(unused)] #![allow(unused)]

View File

@ -1,7 +1,5 @@
// run-rustfix // run-rustfix
#![feature(const_if_match)]
#![feature(const_loop)]
#![feature(const_result)] #![feature(const_result)]
#![warn(clippy::redundant_pattern_matching)] #![warn(clippy::redundant_pattern_matching)]
#![allow(unused)] #![allow(unused)]

View File

@ -1,5 +1,5 @@
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching_const_result.rs:12:12 --> $DIR/redundant_pattern_matching_const_result.rs:10:12
| |
LL | if let Ok(_) = Ok::<i32, i32>(42) {} LL | if let Ok(_) = Ok::<i32, i32>(42) {}
| -------^^^^^--------------------- help: try this: `if Ok::<i32, i32>(42).is_ok()` | -------^^^^^--------------------- help: try this: `if Ok::<i32, i32>(42).is_ok()`
@ -7,25 +7,25 @@ LL | if let Ok(_) = Ok::<i32, i32>(42) {}
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/redundant_pattern_matching_const_result.rs:14:12 --> $DIR/redundant_pattern_matching_const_result.rs:12:12
| |
LL | if let Err(_) = Err::<i32, i32>(42) {} LL | if let Err(_) = Err::<i32, i32>(42) {}
| -------^^^^^^---------------------- help: try this: `if Err::<i32, i32>(42).is_err()` | -------^^^^^^---------------------- help: try this: `if Err::<i32, i32>(42).is_err()`
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching_const_result.rs:16:15 --> $DIR/redundant_pattern_matching_const_result.rs:14:15
| |
LL | while let Ok(_) = Ok::<i32, i32>(10) {} LL | while let Ok(_) = Ok::<i32, i32>(10) {}
| ----------^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_ok()` | ----------^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_ok()`
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/redundant_pattern_matching_const_result.rs:18:15 --> $DIR/redundant_pattern_matching_const_result.rs:16:15
| |
LL | while let Err(_) = Ok::<i32, i32>(10) {} LL | while let Err(_) = Ok::<i32, i32>(10) {}
| ----------^^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_err()` | ----------^^^^^^--------------------- help: try this: `while Ok::<i32, i32>(10).is_err()`
error: redundant pattern matching, consider using `is_ok()` error: redundant pattern matching, consider using `is_ok()`
--> $DIR/redundant_pattern_matching_const_result.rs:20:5 --> $DIR/redundant_pattern_matching_const_result.rs:18:5
| |
LL | / match Ok::<i32, i32>(42) { LL | / match Ok::<i32, i32>(42) {
LL | | Ok(_) => true, LL | | Ok(_) => true,
@ -34,7 +34,7 @@ LL | | };
| |_____^ help: try this: `Ok::<i32, i32>(42).is_ok()` | |_____^ help: try this: `Ok::<i32, i32>(42).is_ok()`
error: redundant pattern matching, consider using `is_err()` error: redundant pattern matching, consider using `is_err()`
--> $DIR/redundant_pattern_matching_const_result.rs:25:5 --> $DIR/redundant_pattern_matching_const_result.rs:23:5
| |
LL | / match Err::<i32, i32>(42) { LL | / match Err::<i32, i32>(42) {
LL | | Ok(_) => false, LL | | Ok(_) => false,