Auto merge of #57542 - Centril:rollup, r=Centril
Rollup of 26 pull requests Successful merges: - #56425 (Redo the docs for Vec::set_len) - #56906 (Issue #56905) - #57042 (Don't call `FieldPlacement::count` when count is too large) - #57175 (Stabilize `let` bindings and destructuring in constants and const fn) - #57192 (Change std::error::Error trait documentation to talk about `source` instead of `cause`) - #57296 (Fixed the link to the ? operator) - #57368 (Use CMAKE_{C,CXX}_COMPILER_LAUNCHER for ccache) - #57400 (Rustdoc: update Source Serif Pro and replace Heuristica italic) - #57417 (rustdoc: use text-based doctest parsing if a macro is wrapping main) - #57433 (Add link destination for `read-ownership`) - #57434 (Remove `CrateNum::Invalid`.) - #57441 (Supporting backtrace for x86_64-fortanix-unknown-sgx.) - #57450 (actually take a slice in this example) - #57459 (Reference tracking issue for inherent associated types in diagnostic) - #57463 (docs: Fix some 'second-edition' links) - #57466 (Remove outdated comment) - #57493 (use structured suggestion when casting a reference) - #57498 (make note of one more normalization that Paths do) - #57499 (note that FromStr does not work for borrowed types) - #57505 (Remove submodule step from README) - #57510 (Add a profiles section to the manifest) - #57511 (Fix undefined behavior) - #57519 (Correct RELEASES.md for 1.32.0) - #57522 (don't unwrap unexpected tokens in `format!`) - #57530 (Fixing a typographical error.) - #57535 (Stabilise irrefutable if-let and while-let patterns) Failed merges: r? @ghost
This commit is contained in:
commit
d6525ef539
170 changed files with 1007 additions and 1493 deletions
|
|
@ -1,9 +1,9 @@
|
|||
// Test associated types are forbidden in inherent impls.
|
||||
// Test associated types are, until #8995 is implemented, forbidden in inherent impls.
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
type Bar = isize; //~ERROR associated types are not allowed in inherent impls
|
||||
type Bar = isize; //~ERROR associated types are not yet supported in inherent impls (see #8995)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error[E0202]: associated types are not allowed in inherent impls
|
||||
error[E0202]: associated types are not yet supported in inherent impls (see #8995)
|
||||
--> $DIR/assoc-inherent.rs:6:5
|
||||
|
|
||||
LL | type Bar = isize; //~ERROR associated types are not allowed in inherent impls
|
||||
LL | type Bar = isize; //~ERROR associated types are not yet supported in inherent impls (see #8995)
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
|
|
@ -13,44 +13,80 @@ error[E0010]: allocations are not allowed in statics
|
|||
LL | static STATIC11: Box<MyOwned> = box MyOwned;
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:79:37
|
||||
|
|
||||
LL | static STATIC11: Box<MyOwned> = box MyOwned;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
|
||||
--> $DIR/check-static-values-constraints.rs:89:32
|
||||
--> $DIR/check-static-values-constraints.rs:90:32
|
||||
|
|
||||
LL | field2: SafeEnum::Variant4("str".to_string())
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:94:5
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:95:5
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:95:9
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:99:6
|
||||
--> $DIR/check-static-values-constraints.rs:97:5
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:97:9
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:102:6
|
||||
|
|
||||
LL | &box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:102:10
|
||||
|
|
||||
LL | &box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:100:6
|
||||
--> $DIR/check-static-values-constraints.rs:104:6
|
||||
|
|
||||
LL | &box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:104:10
|
||||
|
|
||||
LL | &box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:106:5
|
||||
--> $DIR/check-static-values-constraints.rs:111:5
|
||||
|
|
||||
LL | box 3;
|
||||
| ^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:111:9
|
||||
|
|
||||
LL | box 3;
|
||||
| ^
|
||||
|
||||
error[E0507]: cannot move out of static item
|
||||
--> $DIR/check-static-values-constraints.rs:110:45
|
||||
--> $DIR/check-static-values-constraints.rs:116:45
|
||||
|
|
||||
LL | let y = { static x: Box<isize> = box 3; x };
|
||||
| ^
|
||||
|
|
@ -59,12 +95,18 @@ LL | let y = { static x: Box<isize> = box 3; x };
|
|||
| help: consider borrowing here: `&x`
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:110:38
|
||||
--> $DIR/check-static-values-constraints.rs:116:38
|
||||
|
|
||||
LL | let y = { static x: Box<isize> = box 3; x };
|
||||
| ^^^^^ allocation not allowed in statics
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:116:42
|
||||
|
|
||||
LL | let y = { static x: Box<isize> = box 3; x };
|
||||
| ^
|
||||
|
||||
Some errors occurred: E0010, E0015, E0493, E0507.
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
Some errors occurred: E0010, E0015, E0019, E0493, E0507.
|
||||
For more information about an error, try `rustc --explain E0010`.
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ struct MyOwned;
|
|||
|
||||
static STATIC11: Box<MyOwned> = box MyOwned;
|
||||
//~^ ERROR allocations are not allowed in statics
|
||||
//~| ERROR static contains unimplemented expression type
|
||||
|
||||
static mut STATIC12: UnsafeStruct = UnsafeStruct;
|
||||
|
||||
|
|
@ -92,12 +93,16 @@ static mut STATIC14: SafeStruct = SafeStruct {
|
|||
|
||||
static STATIC15: &'static [Box<MyOwned>] = &[
|
||||
box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
//~| ERROR contains unimplemented expression
|
||||
box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
//~| ERROR contains unimplemented expression
|
||||
];
|
||||
|
||||
static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = (
|
||||
&box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
//~| ERROR contains unimplemented expression
|
||||
&box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
//~| ERROR contains unimplemented expression
|
||||
);
|
||||
|
||||
static mut STATIC17: SafeEnum = SafeEnum::Variant1;
|
||||
|
|
@ -105,9 +110,11 @@ static mut STATIC17: SafeEnum = SafeEnum::Variant1;
|
|||
static STATIC19: Box<isize> =
|
||||
box 3;
|
||||
//~^ ERROR allocations are not allowed in statics
|
||||
//~| ERROR contains unimplemented expression
|
||||
|
||||
pub fn main() {
|
||||
let y = { static x: Box<isize> = box 3; x };
|
||||
//~^ ERROR allocations are not allowed in statics
|
||||
//~^^ ERROR cannot move out of static item
|
||||
//~| ERROR cannot move out of static item
|
||||
//~| ERROR contains unimplemented expression
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,55 +13,97 @@ error[E0010]: allocations are not allowed in statics
|
|||
LL | static STATIC11: Box<MyOwned> = box MyOwned;
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:79:37
|
||||
|
|
||||
LL | static STATIC11: Box<MyOwned> = box MyOwned;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
|
||||
--> $DIR/check-static-values-constraints.rs:89:32
|
||||
--> $DIR/check-static-values-constraints.rs:90:32
|
||||
|
|
||||
LL | field2: SafeEnum::Variant4("str".to_string())
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:94:5
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:95:5
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:95:9
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:99:6
|
||||
--> $DIR/check-static-values-constraints.rs:97:5
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:97:9
|
||||
|
|
||||
LL | box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:102:6
|
||||
|
|
||||
LL | &box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:102:10
|
||||
|
|
||||
LL | &box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:100:6
|
||||
--> $DIR/check-static-values-constraints.rs:104:6
|
||||
|
|
||||
LL | &box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:104:10
|
||||
|
|
||||
LL | &box MyOwned, //~ ERROR allocations are not allowed in statics
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:106:5
|
||||
--> $DIR/check-static-values-constraints.rs:111:5
|
||||
|
|
||||
LL | box 3;
|
||||
| ^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:111:9
|
||||
|
|
||||
LL | box 3;
|
||||
| ^
|
||||
|
||||
error[E0507]: cannot move out of static item
|
||||
--> $DIR/check-static-values-constraints.rs:110:45
|
||||
--> $DIR/check-static-values-constraints.rs:116:45
|
||||
|
|
||||
LL | let y = { static x: Box<isize> = box 3; x };
|
||||
| ^ cannot move out of static item
|
||||
|
||||
error[E0010]: allocations are not allowed in statics
|
||||
--> $DIR/check-static-values-constraints.rs:110:38
|
||||
--> $DIR/check-static-values-constraints.rs:116:38
|
||||
|
|
||||
LL | let y = { static x: Box<isize> = box 3; x };
|
||||
| ^^^^^ allocation not allowed in statics
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/check-static-values-constraints.rs:116:42
|
||||
|
|
||||
LL | let y = { static x: Box<isize> = box 3; x };
|
||||
| ^
|
||||
|
||||
Some errors occurred: E0010, E0015, E0493, E0507.
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
Some errors occurred: E0010, E0015, E0019, E0493, E0507.
|
||||
For more information about an error, try `rustc --explain E0010`.
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
const A: usize = { 1; 2 };
|
||||
//~^ ERROR statements in constants are unstable
|
||||
|
||||
const B: usize = { { } 2 };
|
||||
//~^ ERROR statements in constants are unstable
|
||||
|
||||
macro_rules! foo {
|
||||
() => (()) //~ ERROR statements in constants are unstable
|
||||
}
|
||||
const C: usize = { foo!(); 2 };
|
||||
|
||||
const D: usize = { let x = 4; 2 };
|
||||
//~^ ERROR let bindings in constants are unstable
|
||||
//~| ERROR statements in constants are unstable
|
||||
//~| ERROR let bindings in constants are unstable
|
||||
//~| ERROR statements in constants are unstable
|
||||
|
||||
pub fn main() {}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-2.rs:1:20
|
||||
|
|
||||
LL | const A: usize = { 1; 2 };
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-2.rs:4:20
|
||||
|
|
||||
LL | const B: usize = { { } 2 };
|
||||
| ^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-2.rs:8:12
|
||||
|
|
||||
LL | () => (()) //~ ERROR statements in constants are unstable
|
||||
| ^^
|
||||
LL | }
|
||||
LL | const C: usize = { foo!(); 2 };
|
||||
| ------- in this macro invocation
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-2.rs:12:28
|
||||
|
|
||||
LL | const D: usize = { let x = 4; 2 };
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-2.rs:12:28
|
||||
|
|
||||
LL | const D: usize = { let x = 4; 2 };
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-2.rs:12:1
|
||||
|
|
||||
LL | const D: usize = { let x = 4; 2 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-2.rs:12:1
|
||||
|
|
||||
LL | const D: usize = { let x = 4; 2 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
type Array = [u32; { let x = 2; 5 }];
|
||||
//~^ ERROR let bindings in constants are unstable
|
||||
//~| ERROR statements in constants are unstable
|
||||
//~| ERROR let bindings in constants are unstable
|
||||
//~| ERROR statements in constants are unstable
|
||||
|
||||
pub fn main() {}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-3.rs:1:31
|
||||
|
|
||||
LL | type Array = [u32; { let x = 2; 5 }];
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-3.rs:1:31
|
||||
|
|
||||
LL | type Array = [u32; { let x = 2; 5 }];
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-3.rs:1:20
|
||||
|
|
||||
LL | type Array = [u32; { let x = 2; 5 }];
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement-3.rs:1:20
|
||||
|
|
||||
LL | type Array = [u32; { let x = 2; 5 }];
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,9 +1,23 @@
|
|||
// compile-pass
|
||||
|
||||
enum Foo {
|
||||
Bar = { let x = 1; 3 }
|
||||
//~^ ERROR let bindings in constants are unstable
|
||||
//~| ERROR statements in constants are unstable
|
||||
//~| ERROR let bindings in constants are unstable
|
||||
//~| ERROR statements in constants are unstable
|
||||
}
|
||||
|
||||
|
||||
const A: usize = { 1; 2 };
|
||||
|
||||
const B: usize = { { } 2 };
|
||||
|
||||
macro_rules! foo {
|
||||
() => (())
|
||||
}
|
||||
|
||||
const C: usize = { foo!(); 2 };
|
||||
|
||||
const D: usize = { let x = 4; 2 };
|
||||
|
||||
type Array = [u32; { let x = 2; 5 }];
|
||||
type Array2 = [u32; { let mut x = 2; x = 3; x}];
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement.rs:2:21
|
||||
|
|
||||
LL | Bar = { let x = 1; 3 }
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement.rs:2:21
|
||||
|
|
||||
LL | Bar = { let x = 1; 3 }
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement.rs:2:11
|
||||
|
|
||||
LL | Bar = { let x = 1; 3 }
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/const-block-non-item-statement.rs:2:11
|
||||
|
|
||||
LL | Bar = { let x = 1; 3 }
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
// The test should never compile successfully
|
||||
|
||||
#![feature(const_raw_ptr_deref)]
|
||||
#![feature(const_let)]
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/assign-to-static-within-other-static-2.rs:17:5
|
||||
--> $DIR/assign-to-static-within-other-static-2.rs:16:5
|
||||
|
|
||||
LL | *FOO.0.get() = 5; //~ ERROR contains unimplemented expression type
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// The test should never compile successfully
|
||||
|
||||
#![feature(const_raw_ptr_deref)]
|
||||
#![feature(const_let)]
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: cannot mutate statics in the initializer of another static
|
||||
--> $DIR/assign-to-static-within-other-static.rs:11:5
|
||||
--> $DIR/assign-to-static-within-other-static.rs:10:5
|
||||
|
|
||||
LL | FOO = 5; //~ ERROR cannot mutate statics in the initializer of another static
|
||||
| ^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
fn main() {}
|
||||
|
||||
struct FakeNeedsDrop;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/const_let.rs:15:55
|
||||
--> $DIR/const_let.rs:13:55
|
||||
|
|
||||
LL | const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x };
|
||||
| ^
|
||||
|
||||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/const_let.rs:19:35
|
||||
--> $DIR/const_let.rs:17:35
|
||||
|
|
||||
LL | const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); };
|
||||
| ^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
fn main() {
|
||||
// Tests the Collatz conjecture with an incorrect base case (0 instead of 1).
|
||||
// The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/infinite_loop.rs:9:9
|
||||
--> $DIR/infinite_loop.rs:7:9
|
||||
|
|
||||
LL | / while n != 0 { //~ ERROR constant contains unimplemented expression type
|
||||
LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
|
|
@ -8,7 +8,7 @@ LL | | }
|
|||
| |_________^
|
||||
|
||||
warning: Constant evaluating a complex constant, this might take some time
|
||||
--> $DIR/infinite_loop.rs:6:18
|
||||
--> $DIR/infinite_loop.rs:4:18
|
||||
|
|
||||
LL | let _ = [(); {
|
||||
| __________________^
|
||||
|
|
@ -21,7 +21,7 @@ LL | | }];
|
|||
| |_____^
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/infinite_loop.rs:10:20
|
||||
--> $DIR/infinite_loop.rs:8:20
|
||||
|
|
||||
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
| ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
fn main() {
|
||||
let _ = [(); {
|
||||
//~^ WARNING Constant evaluating a complex constant, this might take some time
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/issue-52475.rs:8:9
|
||||
--> $DIR/issue-52475.rs:6:9
|
||||
|
|
||||
LL | / while n < 5 { //~ ERROR constant contains unimplemented expression type
|
||||
LL | | n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
|
||||
|
|
@ -8,7 +8,7 @@ LL | | }
|
|||
| |_________^
|
||||
|
||||
warning: Constant evaluating a complex constant, this might take some time
|
||||
--> $DIR/issue-52475.rs:4:18
|
||||
--> $DIR/issue-52475.rs:2:18
|
||||
|
|
||||
LL | let _ = [(); {
|
||||
| __________________^
|
||||
|
|
@ -21,7 +21,7 @@ LL | | }];
|
|||
| |_____^
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/issue-52475.rs:9:17
|
||||
--> $DIR/issue-52475.rs:7:17
|
||||
|
|
||||
LL | n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
|
||||
| ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// The test should never compile successfully
|
||||
|
||||
#![feature(const_raw_ptr_deref)]
|
||||
#![feature(const_let)]
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/mod-static-with-const-fn.rs:19:5
|
||||
--> $DIR/mod-static-with-const-fn.rs:18:5
|
||||
|
|
||||
LL | *FOO.0.get() = 5;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
|
||||
--> $DIR/mod-static-with-const-fn.rs:22:5
|
||||
--> $DIR/mod-static-with-const-fn.rs:21:5
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^^^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(const_transmute,const_let)]
|
||||
#![feature(const_transmute)]
|
||||
#![allow(const_err)] // make sure we cannot allow away the errors tested here
|
||||
|
||||
use std::mem;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,7 @@
|
|||
// test that certain things are disallowed in constant functions
|
||||
// compile-pass
|
||||
|
||||
#![feature(const_fn)]
|
||||
|
||||
// no destructuring
|
||||
const fn i((
|
||||
a,
|
||||
//~^ ERROR arguments of constant functions can only be immutable by-value bindings
|
||||
b
|
||||
//~^ ERROR arguments of constant functions can only be immutable by-value bindings
|
||||
): (u32, u32)) -> u32 {
|
||||
const fn i((a, b): (u32, u32)) -> u32 {
|
||||
a + b
|
||||
//~^ ERROR let bindings in constant functions are unstable
|
||||
//~| ERROR let bindings in constant functions are unstable
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
error[E0658]: arguments of constant functions can only be immutable by-value bindings (see issue #48821)
|
||||
--> $DIR/const-fn-destructuring-arg.rs:7:13
|
||||
|
|
||||
LL | a,
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: arguments of constant functions can only be immutable by-value bindings (see issue #48821)
|
||||
--> $DIR/const-fn-destructuring-arg.rs:9:13
|
||||
|
|
||||
LL | b
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constant functions are unstable (see issue #48821)
|
||||
--> $DIR/const-fn-destructuring-arg.rs:12:5
|
||||
|
|
||||
LL | a + b
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constant functions are unstable (see issue #48821)
|
||||
--> $DIR/const-fn-destructuring-arg.rs:12:9
|
||||
|
|
||||
LL | a + b
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -27,13 +27,9 @@ const fn get_Y_addr() -> &'static u32 {
|
|||
}
|
||||
|
||||
const fn get() -> u32 {
|
||||
let x = 22; //~ ERROR let bindings in constant functions are unstable
|
||||
//~^ ERROR statements in constant functions
|
||||
let y = 44; //~ ERROR let bindings in constant functions are unstable
|
||||
//~^ ERROR statements in constant functions
|
||||
let x = 22;
|
||||
let y = 44;
|
||||
x + y
|
||||
//~^ ERROR let bindings in constant functions are unstable
|
||||
//~| ERROR let bindings in constant functions are unstable
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -16,55 +16,7 @@ error[E0013]: constant functions cannot refer to statics, use a constant instead
|
|||
LL | &Y
|
||||
| ^^
|
||||
|
||||
error[E0658]: let bindings in constant functions are unstable (see issue #48821)
|
||||
--> $DIR/const-fn-not-safe-for-const.rs:30:13
|
||||
|
|
||||
LL | let x = 22; //~ ERROR let bindings in constant functions are unstable
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
error[E0658]: statements in constant functions are unstable (see issue #48821)
|
||||
--> $DIR/const-fn-not-safe-for-const.rs:30:13
|
||||
|
|
||||
LL | let x = 22; //~ ERROR let bindings in constant functions are unstable
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constant functions are unstable (see issue #48821)
|
||||
--> $DIR/const-fn-not-safe-for-const.rs:32:13
|
||||
|
|
||||
LL | let y = 44; //~ ERROR let bindings in constant functions are unstable
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constant functions are unstable (see issue #48821)
|
||||
--> $DIR/const-fn-not-safe-for-const.rs:32:13
|
||||
|
|
||||
LL | let y = 44; //~ ERROR let bindings in constant functions are unstable
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constant functions are unstable (see issue #48821)
|
||||
--> $DIR/const-fn-not-safe-for-const.rs:34:5
|
||||
|
|
||||
LL | x + y
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constant functions are unstable (see issue #48821)
|
||||
--> $DIR/const-fn-not-safe-for-const.rs:34:9
|
||||
|
|
||||
LL | x + y
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
Some errors occurred: E0013, E0015, E0658.
|
||||
Some errors occurred: E0013, E0015.
|
||||
For more information about an error, try `rustc --explain E0013`.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
// compile-pass
|
||||
|
||||
#![feature(const_let)]
|
||||
|
||||
struct S(i32);
|
||||
|
||||
const A: () = {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
// compile-pass
|
||||
|
||||
#![feature(const_let)]
|
||||
#![feature(const_fn)]
|
||||
|
||||
pub struct AA {
|
||||
pub data: [u8; 10],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
#![feature(const_fn)]
|
||||
|
||||
struct S {
|
||||
|
|
@ -18,6 +17,15 @@ const FOO: S = {
|
|||
s
|
||||
};
|
||||
|
||||
type Array = [u32; {
|
||||
let mut x = 2;
|
||||
let y = &mut x;
|
||||
//~^ ERROR references in constants may only refer to immutable values
|
||||
*y = 42;
|
||||
//~^ ERROR constant contains unimplemented expression type
|
||||
*y
|
||||
}];
|
||||
|
||||
fn main() {
|
||||
assert_eq!(FOO.state, 3);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,28 @@
|
|||
error[E0019]: constant function contains unimplemented expression type
|
||||
--> $DIR/const_let_assign3.rs:10:9
|
||||
--> $DIR/const_let_assign3.rs:9:9
|
||||
|
|
||||
LL | self.state = x;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0017]: references in constants may only refer to immutable values
|
||||
--> $DIR/const_let_assign3.rs:17:5
|
||||
--> $DIR/const_let_assign3.rs:16:5
|
||||
|
|
||||
LL | s.foo(3); //~ ERROR references in constants may only refer to immutable values
|
||||
| ^ constants require immutable values
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0017]: references in constants may only refer to immutable values
|
||||
--> $DIR/const_let_assign3.rs:22:13
|
||||
|
|
||||
LL | let y = &mut x;
|
||||
| ^^^^^^ constants require immutable values
|
||||
|
||||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/const_let_assign3.rs:24:5
|
||||
|
|
||||
LL | *y = 42;
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors occurred: E0017, E0019.
|
||||
For more information about an error, try `rustc --explain E0017`.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let, const_fn)]
|
||||
|
||||
// run-pass
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// compile-pass
|
||||
|
||||
#![feature(const_let, const_fn)]
|
||||
#![feature(const_fn)]
|
||||
|
||||
struct Foo<T>(T);
|
||||
struct Bar<T> { x: T }
|
||||
|
|
|
|||
11
src/test/ui/consts/const_let_irrefutable.rs
Normal file
11
src/test/ui/consts/const_let_irrefutable.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// compile-pass
|
||||
|
||||
fn main() {}
|
||||
|
||||
const fn tup((a, b): (i32, i32)) -> i32 {
|
||||
a + b
|
||||
}
|
||||
|
||||
const fn array([a, b]: [i32; 2]) -> i32 {
|
||||
a + b
|
||||
}
|
||||
5
src/test/ui/consts/const_let_refutable.rs
Normal file
5
src/test/ui/consts/const_let_refutable.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {}
|
||||
|
||||
const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument
|
||||
a + b
|
||||
}
|
||||
9
src/test/ui/consts/const_let_refutable.stderr
Normal file
9
src/test/ui/consts/const_let_refutable.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0005]: refutable pattern in function argument: `&[]` not covered
|
||||
--> $DIR/const_let_refutable.rs:3:16
|
||||
|
|
||||
LL | const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument
|
||||
| ^^^^^^ pattern `&[]` not covered
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0005`.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(underscore_const_names, const_let)]
|
||||
#![feature(underscore_const_names)]
|
||||
|
||||
const _: bool = false && false;
|
||||
const _: bool = true && false;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
// https://github.com/rust-lang/rust/issues/55223
|
||||
|
||||
#![feature(const_let)]
|
||||
|
||||
union Foo<'a> {
|
||||
y: &'a (),
|
||||
long_live_the_unit: &'static (),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: any use of this value will cause an error
|
||||
--> $DIR/dangling-alloc-id-ice.rs:10:1
|
||||
--> $DIR/dangling-alloc-id-ice.rs:8:1
|
||||
|
|
||||
LL | / const FOO: &() = { //~ ERROR any use of this value will cause an error
|
||||
LL | | let y = ();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
const FOO: *const u32 = { //~ ERROR any use of this value will cause an error
|
||||
let x = 42;
|
||||
&x
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: any use of this value will cause an error
|
||||
--> $DIR/dangling_raw_ptr.rs:3:1
|
||||
--> $DIR/dangling_raw_ptr.rs:1:1
|
||||
|
|
||||
LL | / const FOO: *const u32 = { //~ ERROR any use of this value will cause an error
|
||||
LL | | let x = 42;
|
||||
|
|
|
|||
|
|
@ -112,12 +112,6 @@ error: `if`, `match`, `&&` and `||` are not stable in const fn
|
|||
LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: local variables in const fn are unstable
|
||||
--> $DIR/min_const_fn.rs:99:34
|
||||
|
|
||||
LL | const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn
|
||||
| ^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:100:44
|
||||
|
|
||||
|
|
@ -220,7 +214,7 @@ error: function pointers in const fn are unstable
|
|||
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 35 previous errors
|
||||
error: aborting due to 34 previous errors
|
||||
|
||||
Some errors occurred: E0493, E0515.
|
||||
For more information about an error, try `rustc --explain E0493`.
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ const fn foo30_2(x: *mut u32) -> usize { x as usize }
|
|||
const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
|
||||
//~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
|
||||
const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn
|
||||
const fn foo30_6() -> bool { let x = true; x }
|
||||
const fn foo36(a: bool, b: bool) -> bool { a && b }
|
||||
//~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
const fn foo37(a: bool, b: bool) -> bool { a || b }
|
||||
|
|
|
|||
|
|
@ -112,12 +112,6 @@ error: `if`, `match`, `&&` and `||` are not stable in const fn
|
|||
LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: local variables in const fn are unstable
|
||||
--> $DIR/min_const_fn.rs:99:34
|
||||
|
|
||||
LL | const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn
|
||||
| ^
|
||||
|
||||
error: `if`, `match`, `&&` and `||` are not stable in const fn
|
||||
--> $DIR/min_const_fn.rs:100:44
|
||||
|
|
||||
|
|
@ -208,6 +202,6 @@ error: function pointers in const fn are unstable
|
|||
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 35 previous errors
|
||||
error: aborting due to 34 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0493`.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const fn mutable_ref_in_const() -> u8 {
|
||||
let mut a = 0; //~ ERROR local variables in const fn
|
||||
let b = &mut a;
|
||||
let mut a = 0;
|
||||
let b = &mut a; //~ ERROR mutable references in const fn
|
||||
*b
|
||||
}
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct X;
|
|||
|
||||
impl X {
|
||||
const fn inherent_mutable_ref_in_const() -> u8 {
|
||||
let mut a = 0; //~ ERROR local variables in const fn
|
||||
let b = &mut a;
|
||||
let mut a = 0;
|
||||
let b = &mut a; //~ ERROR mutable references in const fn
|
||||
*b
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
error: local variables in const fn are unstable
|
||||
--> $DIR/mutable_borrow.rs:2:9
|
||||
error: mutable references in const fn are unstable
|
||||
--> $DIR/mutable_borrow.rs:3:9
|
||||
|
|
||||
LL | let mut a = 0; //~ ERROR local variables in const fn
|
||||
| ^^^^^
|
||||
LL | let b = &mut a; //~ ERROR mutable references in const fn
|
||||
| ^
|
||||
|
||||
error: local variables in const fn are unstable
|
||||
--> $DIR/mutable_borrow.rs:11:13
|
||||
error: mutable references in const fn are unstable
|
||||
--> $DIR/mutable_borrow.rs:12:13
|
||||
|
|
||||
LL | let mut a = 0; //~ ERROR local variables in const fn
|
||||
| ^^^^^
|
||||
LL | let b = &mut a; //~ ERROR mutable references in const fn
|
||||
| ^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
const FOO: &(Cell<usize>, bool) = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
--> $DIR/partial_qualif.rs:8:5
|
||||
--> $DIR/partial_qualif.rs:6:5
|
||||
|
|
||||
LL | &{a} //~ ERROR cannot borrow a constant which may contain interior mutability
|
||||
| ^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
const FOO: &u32 = {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
error[E0017]: references in constants may only refer to immutable values
|
||||
--> $DIR/projection_qualif.rs:8:27
|
||||
--> $DIR/projection_qualif.rs:6:27
|
||||
|
|
||||
LL | let b: *mut u32 = &mut a; //~ ERROR may only refer to immutable values
|
||||
| ^^^^^^ constants require immutable values
|
||||
|
||||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/projection_qualif.rs:9:18
|
||||
--> $DIR/projection_qualif.rs:7:18
|
||||
|
|
||||
LL | unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
|
||||
| ^^^^^^
|
||||
|
||||
error[E0658]: dereferencing raw pointers in constants is unstable (see issue #51911)
|
||||
--> $DIR/projection_qualif.rs:9:18
|
||||
--> $DIR/projection_qualif.rs:7:18
|
||||
|
|
||||
LL | unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
|
||||
| ^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/promote_const_let.rs:6:9
|
||||
--> $DIR/promote_const_let.rs:4:9
|
||||
|
|
||||
LL | let x: &'static u32 = {
|
||||
| ------------ type annotation requires that `y` is borrowed for `'static`
|
||||
|
|
@ -9,6 +9,21 @@ LL | &y //~ ERROR does not live long enough
|
|||
LL | };
|
||||
| - `y` dropped here while still borrowed
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promote_const_let.rs:6:28
|
||||
|
|
||||
LL | let x: &'static u32 = &{ //~ ERROR does not live long enough
|
||||
| ____________------------____^
|
||||
| | |
|
||||
| | type annotation requires that borrow lasts for `'static`
|
||||
LL | | let y = 42;
|
||||
LL | | y
|
||||
LL | | };
|
||||
| |_____^ creates a temporary which is freed while still in use
|
||||
LL | }
|
||||
| - temporary value is freed at the end of this statement
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0597, E0716.
|
||||
For more information about an error, try `rustc --explain E0597`.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
fn main() {
|
||||
let x: &'static u32 = {
|
||||
let y = 42;
|
||||
&y //~ ERROR does not live long enough
|
||||
};
|
||||
let x: &'static u32 = &{ //~ ERROR does not live long enough
|
||||
let y = 42;
|
||||
y
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/promote_const_let.rs:6:10
|
||||
--> $DIR/promote_const_let.rs:4:10
|
||||
|
|
||||
LL | &y //~ ERROR does not live long enough
|
||||
| ^ borrowed value does not live long enough
|
||||
|
|
@ -8,6 +8,20 @@ LL | };
|
|||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
--> $DIR/promote_const_let.rs:6:28
|
||||
|
|
||||
LL | let x: &'static u32 = &{ //~ ERROR does not live long enough
|
||||
| ____________________________^
|
||||
LL | | let y = 42;
|
||||
LL | | y
|
||||
LL | | };
|
||||
| |_____^ temporary value does not live long enough
|
||||
LL | }
|
||||
| - temporary value only lives until here
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
// this is overly conservative. The reset to `None` should clear `a` of all qualifications
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
--> $DIR/qualif_overwrite.rs:12:5
|
||||
--> $DIR/qualif_overwrite.rs:10:5
|
||||
|
|
||||
LL | &{a} //~ ERROR cannot borrow a constant which may contain interior mutability
|
||||
| ^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
// const qualification is not smart enough to know about fields and always assumes that there might
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
|
||||
--> $DIR/qualif_overwrite_2.rs:10:5
|
||||
--> $DIR/qualif_overwrite_2.rs:8:5
|
||||
|
|
||||
LL | &{a.0} //~ ERROR cannot borrow a constant which may contain interior mutability
|
||||
| ^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
static mut STDERR_BUFFER_SPACE: u8 = 0;
|
||||
|
||||
pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0017]: references in statics may only refer to immutable values
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:5:46
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:3:46
|
||||
|
|
||||
LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:5:45
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:3:45
|
||||
|
|
||||
LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
static mut FOO: (u8, u8) = (42, 43);
|
||||
|
||||
static mut BAR: () = unsafe { FOO.0 = 99; };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/static_mut_containing_mut_ref3.rs:5:31
|
||||
--> $DIR/static_mut_containing_mut_ref3.rs:3:31
|
||||
|
|
||||
LL | static mut BAR: () = unsafe { FOO.0 = 99; };
|
||||
| ^^^^^^^^^^ tried to modify a static's initial value from another static's initializer
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@
|
|||
#![allow(warnings)]
|
||||
|
||||
const CON : Box<i32> = box 0; //~ ERROR E0010
|
||||
//~^ ERROR constant contains unimplemented expression type
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,16 @@ LL | const CON : Box<i32> = box 0; //~ ERROR E0010
|
|||
|
|
||||
= note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time.
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/E0010-teach.rs:6:28
|
||||
|
|
||||
LL | const CON : Box<i32> = box 0; //~ ERROR E0010
|
||||
| ^
|
||||
|
|
||||
= note: A function call isn't allowed in the const's initialization expression because the expression's value must be known at compile-time.
|
||||
= note: Remember: you can't use a function call inside a const's initialization expression! However, you can use it anywhere else.
|
||||
|
||||
For more information about this error, try `rustc --explain E0010`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0010, E0019.
|
||||
For more information about an error, try `rustc --explain E0010`.
|
||||
|
|
|
|||
|
|
@ -2,5 +2,6 @@
|
|||
#![allow(warnings)]
|
||||
|
||||
const CON : Box<i32> = box 0; //~ ERROR E0010
|
||||
//~^ ERROR constant contains unimplemented expression type
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,13 @@ error[E0010]: allocations are not allowed in constants
|
|||
LL | const CON : Box<i32> = box 0; //~ ERROR E0010
|
||||
| ^^^^^ allocation not allowed in constants
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/E0010.rs:4:28
|
||||
|
|
||||
LL | const CON : Box<i32> = box 0; //~ ERROR E0010
|
||||
| ^
|
||||
|
||||
For more information about this error, try `rustc --explain E0010`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0010, E0019.
|
||||
For more information about an error, try `rustc --explain E0010`.
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
struct Irrefutable(i32);
|
||||
|
||||
fn main() {
|
||||
let irr = Irrefutable(0);
|
||||
if let Irrefutable(x) = irr { //~ ERROR E0162
|
||||
println!("{}", x);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0162]: irrefutable if-let pattern
|
||||
--> $DIR/E0162.rs:5:12
|
||||
|
|
||||
LL | if let Irrefutable(x) = irr { //~ ERROR E0162
|
||||
| ^^^^^^^^^^^^^^ irrefutable pattern
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0162`.
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
struct Irrefutable(i32);
|
||||
|
||||
fn main() {
|
||||
let irr = Irrefutable(0);
|
||||
while let Irrefutable(x) = irr { //~ ERROR E0165
|
||||
//~| irrefutable pattern
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0165]: irrefutable while-let pattern
|
||||
--> $DIR/E0165.rs:5:15
|
||||
|
|
||||
LL | while let Irrefutable(x) = irr { //~ ERROR E0165
|
||||
| ^^^^^^^^^^^^^^ irrefutable pattern
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0165`.
|
||||
|
|
@ -2,13 +2,10 @@ error[E0606]: casting `&u8` as `u8` is invalid
|
|||
--> $DIR/E0606.rs:2:5
|
||||
|
|
||||
LL | &0u8 as u8; //~ ERROR E0606
|
||||
| ^^^^^^^^^^ cannot cast `&u8` as `u8`
|
||||
|
|
||||
help: did you mean `*&0u8`?
|
||||
--> $DIR/E0606.rs:2:5
|
||||
|
|
||||
LL | &0u8 as u8; //~ ERROR E0606
|
||||
| ^^^^
|
||||
| ----^^^^^^
|
||||
| |
|
||||
| cannot cast `&u8` as `u8`
|
||||
| help: dereference the expression: `*&0u8`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -60,13 +60,10 @@ error[E0606]: casting `&u8` as `u32` is invalid
|
|||
--> $DIR/error-festival.rs:37:18
|
||||
|
|
||||
LL | let y: u32 = x as u32;
|
||||
| ^^^^^^^^ cannot cast `&u8` as `u32`
|
||||
|
|
||||
help: did you mean `*x`?
|
||||
--> $DIR/error-festival.rs:37:18
|
||||
|
|
||||
LL | let y: u32 = x as u32;
|
||||
| ^
|
||||
| -^^^^^^^
|
||||
| |
|
||||
| cannot cast `&u8` as `u32`
|
||||
| help: dereference the expression: `*x`
|
||||
|
||||
error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]`
|
||||
--> $DIR/error-festival.rs:41:5
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
// Test use of const let without feature gate.
|
||||
|
||||
const FOO: usize = {
|
||||
//~^ ERROR statements in constants are unstable
|
||||
//~| ERROR: let bindings in constants are unstable
|
||||
let x = 42;
|
||||
//~^ ERROR statements in constants are unstable
|
||||
//~| ERROR: let bindings in constants are unstable
|
||||
42
|
||||
};
|
||||
|
||||
static BAR: usize = {
|
||||
//~^ ERROR statements in statics are unstable
|
||||
//~| ERROR: let bindings in statics are unstable
|
||||
let x = 42;
|
||||
//~^ ERROR statements in statics are unstable
|
||||
//~| ERROR: let bindings in statics are unstable
|
||||
42
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/feature-gate-const_let.rs:6:13
|
||||
|
|
||||
LL | let x = 42;
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/feature-gate-const_let.rs:6:13
|
||||
|
|
||||
LL | let x = 42;
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/feature-gate-const_let.rs:3:1
|
||||
|
|
||||
LL | / const FOO: usize = {
|
||||
LL | | //~^ ERROR statements in constants are unstable
|
||||
LL | | //~| ERROR: let bindings in constants are unstable
|
||||
LL | | let x = 42;
|
||||
... |
|
||||
LL | | 42
|
||||
LL | | };
|
||||
| |__^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/feature-gate-const_let.rs:3:1
|
||||
|
|
||||
LL | / const FOO: usize = {
|
||||
LL | | //~^ ERROR statements in constants are unstable
|
||||
LL | | //~| ERROR: let bindings in constants are unstable
|
||||
LL | | let x = 42;
|
||||
... |
|
||||
LL | | 42
|
||||
LL | | };
|
||||
| |__^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in statics are unstable (see issue #48821)
|
||||
--> $DIR/feature-gate-const_let.rs:15:13
|
||||
|
|
||||
LL | let x = 42;
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in statics are unstable (see issue #48821)
|
||||
--> $DIR/feature-gate-const_let.rs:15:13
|
||||
|
|
||||
LL | let x = 42;
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in statics are unstable (see issue #48821)
|
||||
--> $DIR/feature-gate-const_let.rs:12:1
|
||||
|
|
||||
LL | / static BAR: usize = {
|
||||
LL | | //~^ ERROR statements in statics are unstable
|
||||
LL | | //~| ERROR: let bindings in statics are unstable
|
||||
LL | | let x = 42;
|
||||
... |
|
||||
LL | | 42
|
||||
LL | | };
|
||||
| |__^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in statics are unstable (see issue #48821)
|
||||
--> $DIR/feature-gate-const_let.rs:12:1
|
||||
|
|
||||
LL | / static BAR: usize = {
|
||||
LL | | //~^ ERROR statements in statics are unstable
|
||||
LL | | //~| ERROR: let bindings in statics are unstable
|
||||
LL | | let x = 42;
|
||||
... |
|
||||
LL | | 42
|
||||
LL | | };
|
||||
| |__^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
trait Trt {}
|
||||
struct Str {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0658]: naming constants with `_` is unstable (see issue #54912)
|
||||
--> $DIR/feature-gate-underscore_const_names.rs:8:1
|
||||
--> $DIR/feature-gate-underscore_const_names.rs:6:1
|
||||
|
|
||||
LL | / const _ : () = {
|
||||
LL | | //~^ ERROR is unstable
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
// gate-test-irrefutable_let_patterns
|
||||
|
||||
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
fn main() {
|
||||
if let _ = 5 {}
|
||||
//~^ ERROR irrefutable if-let pattern [E0162]
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0162]: irrefutable if-let pattern
|
||||
--> $DIR/feature-gate-without_gate_irrefutable_pattern.rs:6:12
|
||||
|
|
||||
LL | if let _ = 5 {}
|
||||
| ^ irrefutable pattern
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0162`.
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// compile-pass
|
||||
|
||||
fn macros() {
|
||||
macro_rules! foo{
|
||||
($p:pat, $e:expr, $b:block) => {{
|
||||
|
|
@ -10,20 +12,20 @@ fn macros() {
|
|||
}}
|
||||
}
|
||||
|
||||
foo!(a, 1, { //~ ERROR irrefutable if-let
|
||||
foo!(a, 1, { //~ WARN irrefutable if-let
|
||||
println!("irrefutable pattern");
|
||||
});
|
||||
bar!(a, 1, { //~ ERROR irrefutable if-let
|
||||
bar!(a, 1, { //~ WARN irrefutable if-let
|
||||
println!("irrefutable pattern");
|
||||
});
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
if let a = 1 { //~ ERROR irrefutable if-let
|
||||
if let a = 1 { //~ WARN irrefutable if-let
|
||||
println!("irrefutable pattern");
|
||||
}
|
||||
|
||||
if let a = 1 { //~ ERROR irrefutable if-let
|
||||
if let a = 1 { //~ WARN irrefutable if-let
|
||||
println!("irrefutable pattern");
|
||||
} else if true {
|
||||
println!("else-if in irrefutable if-let");
|
||||
|
|
@ -33,13 +35,13 @@ pub fn main() {
|
|||
|
||||
if let 1 = 2 {
|
||||
println!("refutable pattern");
|
||||
} else if let a = 1 { //~ ERROR irrefutable if-let
|
||||
} else if let a = 1 { //~ WARN irrefutable if-let
|
||||
println!("irrefutable pattern");
|
||||
}
|
||||
|
||||
if true {
|
||||
println!("if");
|
||||
} else if let a = 1 { //~ ERROR irrefutable if-let
|
||||
} else if let a = 1 { //~ WARN irrefutable if-let
|
||||
println!("irrefutable pattern");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,62 @@
|
|||
error[E0162]: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:13:10
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:6:13
|
||||
|
|
||||
LL | foo!(a, 1, { //~ ERROR irrefutable if-let
|
||||
| ^ irrefutable pattern
|
||||
|
||||
error[E0162]: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:16:10
|
||||
LL | if let $p = $e $b
|
||||
| ^^
|
||||
...
|
||||
LL | / foo!(a, 1, { //~ WARN irrefutable if-let
|
||||
LL | | println!("irrefutable pattern");
|
||||
LL | | });
|
||||
| |_______- in this macro invocation
|
||||
|
|
||||
LL | bar!(a, 1, { //~ ERROR irrefutable if-let
|
||||
| ^ irrefutable pattern
|
||||
= note: #[warn(irrefutable_let_patterns)] on by default
|
||||
|
||||
error[E0162]: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:22:12
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:6:13
|
||||
|
|
||||
LL | if let a = 1 { //~ ERROR irrefutable if-let
|
||||
| ^ irrefutable pattern
|
||||
LL | if let $p = $e $b
|
||||
| ^^
|
||||
...
|
||||
LL | / bar!(a, 1, { //~ WARN irrefutable if-let
|
||||
LL | | println!("irrefutable pattern");
|
||||
LL | | });
|
||||
| |_______- in this macro invocation
|
||||
|
||||
error[E0162]: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:26:12
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:24:5
|
||||
|
|
||||
LL | if let a = 1 { //~ ERROR irrefutable if-let
|
||||
| ^ irrefutable pattern
|
||||
LL | / if let a = 1 { //~ WARN irrefutable if-let
|
||||
LL | | println!("irrefutable pattern");
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error[E0162]: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:36:19
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:28:5
|
||||
|
|
||||
LL | } else if let a = 1 { //~ ERROR irrefutable if-let
|
||||
| ^ irrefutable pattern
|
||||
LL | / if let a = 1 { //~ WARN irrefutable if-let
|
||||
LL | | println!("irrefutable pattern");
|
||||
LL | | } else if true {
|
||||
LL | | println!("else-if in irrefutable if-let");
|
||||
LL | | } else {
|
||||
LL | | println!("else in irrefutable if-let");
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error[E0162]: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:42:19
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:38:12
|
||||
|
|
||||
LL | } else if let a = 1 { //~ ERROR irrefutable if-let
|
||||
| ^ irrefutable pattern
|
||||
LL | } else if let a = 1 { //~ WARN irrefutable if-let
|
||||
| ____________^
|
||||
LL | | println!("irrefutable pattern");
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
warning: irrefutable if-let pattern
|
||||
--> $DIR/if-let.rs:44:12
|
||||
|
|
||||
LL | } else if let a = 1 { //~ WARN irrefutable if-let
|
||||
| ____________^
|
||||
LL | | println!("irrefutable pattern");
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
For more information about this error, try `rustc --explain E0162`.
|
||||
|
|
|
|||
|
|
@ -1,68 +1,14 @@
|
|||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:5:17
|
||||
|
|
||||
LL | let p = 3;
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:5:17
|
||||
|
|
||||
LL | let p = 3;
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:8:9
|
||||
|
|
||||
LL | &p //~ ERROR `p` does not live long enough
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:2:5
|
||||
|
|
||||
LL | / const z: &'static isize = {
|
||||
LL | | //~^ ERROR let bindings in constants are unstable
|
||||
LL | | //~| ERROR statements in constants are unstable
|
||||
LL | | let p = 3;
|
||||
... |
|
||||
LL | | //~^ ERROR let bindings in constants are unstable
|
||||
LL | | };
|
||||
| |______^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:2:5
|
||||
|
|
||||
LL | / const z: &'static isize = {
|
||||
LL | | //~^ ERROR let bindings in constants are unstable
|
||||
LL | | //~| ERROR statements in constants are unstable
|
||||
LL | | let p = 3;
|
||||
... |
|
||||
LL | | //~^ ERROR let bindings in constants are unstable
|
||||
LL | | };
|
||||
| |______^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0597]: `p` does not live long enough
|
||||
--> $DIR/issue-18118.rs:8:9
|
||||
--> $DIR/issue-18118.rs:4:9
|
||||
|
|
||||
LL | &p //~ ERROR `p` does not live long enough
|
||||
| ^^
|
||||
| |
|
||||
| borrowed value does not live long enough
|
||||
| using this value as a constant requires that `p` is borrowed for `'static`
|
||||
LL | //~^ ERROR let bindings in constants are unstable
|
||||
LL | };
|
||||
| - `p` dropped here while still borrowed
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
Some errors occurred: E0597, E0658.
|
||||
For more information about an error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
pub fn main() {
|
||||
const z: &'static isize = {
|
||||
//~^ ERROR let bindings in constants are unstable
|
||||
//~| ERROR statements in constants are unstable
|
||||
let p = 3;
|
||||
//~^ ERROR let bindings in constants are unstable
|
||||
//~| ERROR statements in constants are unstable
|
||||
&p //~ ERROR `p` does not live long enough
|
||||
//~^ ERROR let bindings in constants are unstable
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,67 +1,13 @@
|
|||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:5:17
|
||||
|
|
||||
LL | let p = 3;
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:5:17
|
||||
|
|
||||
LL | let p = 3;
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:8:9
|
||||
|
|
||||
LL | &p //~ ERROR `p` does not live long enough
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: let bindings in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:2:5
|
||||
|
|
||||
LL | / const z: &'static isize = {
|
||||
LL | | //~^ ERROR let bindings in constants are unstable
|
||||
LL | | //~| ERROR statements in constants are unstable
|
||||
LL | | let p = 3;
|
||||
... |
|
||||
LL | | //~^ ERROR let bindings in constants are unstable
|
||||
LL | | };
|
||||
| |______^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-18118.rs:2:5
|
||||
|
|
||||
LL | / const z: &'static isize = {
|
||||
LL | | //~^ ERROR let bindings in constants are unstable
|
||||
LL | | //~| ERROR statements in constants are unstable
|
||||
LL | | let p = 3;
|
||||
... |
|
||||
LL | | //~^ ERROR let bindings in constants are unstable
|
||||
LL | | };
|
||||
| |______^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0597]: `p` does not live long enough
|
||||
--> $DIR/issue-18118.rs:8:10
|
||||
--> $DIR/issue-18118.rs:4:10
|
||||
|
|
||||
LL | &p //~ ERROR `p` does not live long enough
|
||||
| ^ borrowed value does not live long enough
|
||||
LL | //~^ ERROR let bindings in constants are unstable
|
||||
LL | };
|
||||
| - borrowed value only lives until here
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
Some errors occurred: E0597, E0658.
|
||||
For more information about an error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
#![feature(const_fn)]
|
||||
|
||||
const bad : u32 = {
|
||||
{
|
||||
5;
|
||||
//~^ ERROR statements in constants are unstable
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -13,8 +10,7 @@ const bad : u32 = {
|
|||
const bad_two : u32 = {
|
||||
{
|
||||
invalid();
|
||||
//~^ ERROR statements in constants are unstable
|
||||
//~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||
//~^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -22,7 +18,6 @@ const bad_two : u32 = {
|
|||
const bad_three : u32 = {
|
||||
{
|
||||
valid();
|
||||
//~^ ERROR statements in constants are unstable
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -30,7 +25,6 @@ const bad_three : u32 = {
|
|||
static bad_four : u32 = {
|
||||
{
|
||||
5;
|
||||
//~^ ERROR statements in statics are unstable
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -39,7 +33,6 @@ static bad_five : u32 = {
|
|||
{
|
||||
invalid();
|
||||
//~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
|
||||
//~| ERROR statements in statics are unstable
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -47,7 +40,6 @@ static bad_five : u32 = {
|
|||
static bad_six : u32 = {
|
||||
{
|
||||
valid();
|
||||
//~^ ERROR statements in statics are unstable
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -55,7 +47,6 @@ static bad_six : u32 = {
|
|||
static mut bad_seven : u32 = {
|
||||
{
|
||||
5;
|
||||
//~^ ERROR statements in statics are unstable
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -63,8 +54,7 @@ static mut bad_seven : u32 = {
|
|||
static mut bad_eight : u32 = {
|
||||
{
|
||||
invalid();
|
||||
//~^ ERROR statements in statics are unstable
|
||||
//~| ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
|
||||
//~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
@ -72,7 +62,6 @@ static mut bad_eight : u32 = {
|
|||
static mut bad_nine : u32 = {
|
||||
{
|
||||
valid();
|
||||
//~^ ERROR statements in statics are unstable
|
||||
0
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,94 +1,21 @@
|
|||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:7:9
|
||||
|
|
||||
LL | 5;
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||
--> $DIR/issue-32829-2.rs:15:9
|
||||
--> $DIR/issue-32829-2.rs:12:9
|
||||
|
|
||||
LL | invalid();
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:15:9
|
||||
|
|
||||
LL | invalid();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in constants are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:24:9
|
||||
|
|
||||
LL | valid();
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in statics are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:32:9
|
||||
|
|
||||
LL | 5;
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
|
||||
--> $DIR/issue-32829-2.rs:40:9
|
||||
--> $DIR/issue-32829-2.rs:34:9
|
||||
|
|
||||
LL | invalid();
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0658]: statements in statics are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:40:9
|
||||
|
|
||||
LL | invalid();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in statics are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:49:9
|
||||
|
|
||||
LL | valid();
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: statements in statics are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:57:9
|
||||
|
|
||||
LL | 5;
|
||||
| ^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
|
||||
--> $DIR/issue-32829-2.rs:65:9
|
||||
--> $DIR/issue-32829-2.rs:56:9
|
||||
|
|
||||
LL | invalid();
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0658]: statements in statics are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:65:9
|
||||
|
|
||||
LL | invalid();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
error[E0658]: statements in statics are unstable (see issue #48821)
|
||||
--> $DIR/issue-32829-2.rs:74:9
|
||||
|
|
||||
LL | valid();
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: add #![feature(const_let)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
Some errors occurred: E0015, E0658.
|
||||
For more information about an error, try `rustc --explain E0015`.
|
||||
For more information about this error, try `rustc --explain E0015`.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const fn x() {
|
||||
let t = true; //~ ERROR local variables in const fn
|
||||
let x = || t;
|
||||
let t = true;
|
||||
let x = || t; //~ ERROR function pointers in const fn are unstable
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: local variables in const fn are unstable
|
||||
--> $DIR/issue-37550.rs:2:9
|
||||
error: function pointers in const fn are unstable
|
||||
--> $DIR/issue-37550.rs:3:9
|
||||
|
|
||||
LL | let t = true; //~ ERROR local variables in const fn
|
||||
LL | let x = || t; //~ ERROR function pointers in const fn are unstable
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ fn main() {
|
|||
|
||||
[(); return while let Some(n) = Some(0) {}];
|
||||
//~^ ERROR return statement outside of function body
|
||||
//~^^ ERROR irrefutable while-let pattern
|
||||
//~^^ WARN irrefutable while-let pattern
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,13 +22,14 @@ error[E0572]: return statement outside of function body
|
|||
LL | [(); return while let Some(n) = Some(0) {}];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0165]: irrefutable while-let pattern
|
||||
--> $DIR/issue-51714.rs:11:27
|
||||
warning: irrefutable while-let pattern
|
||||
--> $DIR/issue-51714.rs:11:17
|
||||
|
|
||||
LL | [(); return while let Some(n) = Some(0) {}];
|
||||
| ^^^^^^^ irrefutable pattern
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(irrefutable_let_patterns)] on by default
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors occurred: E0165, E0572.
|
||||
For more information about an error, try `rustc --explain E0165`.
|
||||
For more information about this error, try `rustc --explain E0572`.
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@ use std::cell::RefCell;
|
|||
static boxed: Box<RefCell<isize>> = box RefCell::new(0);
|
||||
//~^ ERROR allocations are not allowed in statics
|
||||
//~| ERROR `std::cell::RefCell<isize>` cannot be shared between threads safely [E0277]
|
||||
//~| ERROR static contains unimplemented expression type
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ error[E0010]: allocations are not allowed in statics
|
|||
LL | static boxed: Box<RefCell<isize>> = box RefCell::new(0);
|
||||
| ^^^^^^^^^^^^^^^^^^^ allocation not allowed in statics
|
||||
|
||||
error[E0019]: static contains unimplemented expression type
|
||||
--> $DIR/issue-7364.rs:6:41
|
||||
|
|
||||
LL | static boxed: Box<RefCell<isize>> = box RefCell::new(0);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `std::cell::RefCell<isize>` cannot be shared between threads safely
|
||||
--> $DIR/issue-7364.rs:6:1
|
||||
|
|
||||
|
|
@ -15,7 +21,7 @@ LL | static boxed: Box<RefCell<isize>> = box RefCell::new(0);
|
|||
= note: required because it appears within the type `std::boxed::Box<std::cell::RefCell<isize>>`
|
||||
= note: shared static variables must have a type that implements `Sync`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0010, E0277.
|
||||
Some errors occurred: E0010, E0019, E0277.
|
||||
For more information about an error, try `rustc --explain E0010`.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ fn main() {
|
|||
format!(); //~ ERROR requires at least a format string argument
|
||||
format!(struct); //~ ERROR expected expression
|
||||
format!("s", name =); //~ ERROR expected expression
|
||||
format!("s", foo = foo, bar); //~ ERROR expected `=`
|
||||
format!("s", foo = struct); //~ ERROR expected expression
|
||||
format!("s", struct); //~ ERROR expected expression
|
||||
|
||||
|
|
|
|||
|
|
@ -18,20 +18,26 @@ error: expected expression, found `<eof>`
|
|||
LL | format!("s", name =); //~ ERROR expected expression
|
||||
| ^ expected expression
|
||||
|
||||
error: expected `=`, found `<eof>`
|
||||
--> $DIR/format-parse-errors.rs:5:29
|
||||
|
|
||||
LL | format!("s", foo = foo, bar); //~ ERROR expected `=`
|
||||
| ^^^ expected `=`
|
||||
|
||||
error: expected expression, found keyword `struct`
|
||||
--> $DIR/format-parse-errors.rs:5:24
|
||||
--> $DIR/format-parse-errors.rs:6:24
|
||||
|
|
||||
LL | format!("s", foo = struct); //~ ERROR expected expression
|
||||
| ^^^^^^ expected expression
|
||||
|
||||
error: expected expression, found keyword `struct`
|
||||
--> $DIR/format-parse-errors.rs:6:18
|
||||
--> $DIR/format-parse-errors.rs:7:18
|
||||
|
|
||||
LL | format!("s", struct); //~ ERROR expected expression
|
||||
| ^^^^^^ expected expression
|
||||
|
||||
error: format argument must be a string literal
|
||||
--> $DIR/format-parse-errors.rs:9:13
|
||||
--> $DIR/format-parse-errors.rs:10:13
|
||||
|
|
||||
LL | format!(123); //~ ERROR format argument must be a string literal
|
||||
| ^^^
|
||||
|
|
@ -40,5 +46,5 @@ help: you might be missing a string literal to format with
|
|||
LL | format!("{}", 123); //~ ERROR format argument must be a string literal
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -240,13 +240,10 @@ error[E0606]: casting `&{float}` as `f32` is invalid
|
|||
--> $DIR/cast-rfc0401.rs:71:30
|
||||
|
|
||||
LL | vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>(); //~ ERROR is invalid
|
||||
| ^^^^^^^^ cannot cast `&{float}` as `f32`
|
||||
|
|
||||
help: did you mean `*s`?
|
||||
--> $DIR/cast-rfc0401.rs:71:30
|
||||
|
|
||||
LL | vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>(); //~ ERROR is invalid
|
||||
| ^
|
||||
| -^^^^^^^
|
||||
| |
|
||||
| cannot cast `&{float}` as `f32`
|
||||
| help: dereference the expression: `*s`
|
||||
|
||||
error: aborting due to 34 previous errors
|
||||
|
||||
|
|
|
|||
9
src/test/ui/pattern/deny-irrefutable-let-patterns.rs
Normal file
9
src/test/ui/pattern/deny-irrefutable-let-patterns.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#![deny(irrefutable_let_patterns)]
|
||||
|
||||
fn main() {
|
||||
if let _ = 5 {} //~ ERROR irrefutable if-let pattern
|
||||
|
||||
while let _ = 5 { //~ ERROR irrefutable while-let pattern
|
||||
break;
|
||||
}
|
||||
}
|
||||
22
src/test/ui/pattern/deny-irrefutable-let-patterns.stderr
Normal file
22
src/test/ui/pattern/deny-irrefutable-let-patterns.stderr
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
error: irrefutable if-let pattern
|
||||
--> $DIR/deny-irrefutable-let-patterns.rs:4:5
|
||||
|
|
||||
LL | if let _ = 5 {} //~ ERROR irrefutable if-let pattern
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/deny-irrefutable-let-patterns.rs:1:9
|
||||
|
|
||||
LL | #![deny(irrefutable_let_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: irrefutable while-let pattern
|
||||
--> $DIR/deny-irrefutable-let-patterns.rs:6:5
|
||||
|
|
||||
LL | / while let _ = 5 { //~ ERROR irrefutable while-let pattern
|
||||
LL | | break;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
43
src/test/ui/pattern/enum-variant-generic-args.rs
Normal file
43
src/test/ui/pattern/enum-variant-generic-args.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(type_alias_enum_variants)]
|
||||
|
||||
#![allow(irrefutable_let_patterns)]
|
||||
|
||||
#[allow(dead_code)]
|
||||
enum Enum<T> { TSVariant(T), SVariant { v: T } }
|
||||
type Alias<T> = Enum<T>;
|
||||
type AliasFixed = Enum<()>;
|
||||
|
||||
macro_rules! is_variant {
|
||||
(TSVariant, $expr:expr) => (is_variant!(@check TSVariant, (_), $expr));
|
||||
(SVariant, $expr:expr) => (is_variant!(@check SVariant, { v: _ }, $expr));
|
||||
(@check $variant:ident, $matcher:tt, $expr:expr) => (
|
||||
assert!(if let Enum::$variant::<()> $matcher = $expr { true } else { false },
|
||||
"expr does not have correct type");
|
||||
);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Tuple struct variant
|
||||
|
||||
is_variant!(TSVariant, Enum::TSVariant(()));
|
||||
is_variant!(TSVariant, Enum::TSVariant::<()>(()));
|
||||
is_variant!(TSVariant, Enum::<()>::TSVariant(()));
|
||||
|
||||
is_variant!(TSVariant, Alias::TSVariant(()));
|
||||
is_variant!(TSVariant, Alias::<()>::TSVariant(()));
|
||||
|
||||
is_variant!(TSVariant, AliasFixed::TSVariant(()));
|
||||
|
||||
// Struct variant
|
||||
|
||||
is_variant!(SVariant, Enum::SVariant { v: () });
|
||||
is_variant!(SVariant, Enum::SVariant::<()> { v: () });
|
||||
is_variant!(SVariant, Enum::<()>::SVariant { v: () });
|
||||
|
||||
is_variant!(SVariant, Alias::SVariant { v: () });
|
||||
is_variant!(SVariant, Alias::<()>::SVariant { v: () });
|
||||
|
||||
is_variant!(SVariant, AliasFixed::SVariant { v: () });
|
||||
}
|
||||
11
src/test/ui/pattern/irrefutable-let-patterns.rs
Normal file
11
src/test/ui/pattern/irrefutable-let-patterns.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// run-pass
|
||||
|
||||
#![allow(irrefutable_let_patterns)]
|
||||
|
||||
fn main() {
|
||||
if let _ = 5 {}
|
||||
|
||||
while let _ = 5 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
// Enabling `ireffutable_let_patterns` isn't necessary for what this tests, but it makes coming up
|
||||
// with examples easier.
|
||||
#![feature(irrefutable_let_patterns)]
|
||||
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: ambiguous use of `&&`
|
||||
--> $DIR/syntax-ambiguity-2015.rs:11:47
|
||||
--> $DIR/syntax-ambiguity-2015.rs:10:47
|
||||
|
|
||||
LL | if let Range { start: _, end: _ } = true..true && false { }
|
||||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)`
|
||||
|
|
@ -8,7 +8,7 @@ LL | if let Range { start: _, end: _ } = true..true && false { }
|
|||
= note: see rust-lang/rust#53668 for more information
|
||||
|
||||
error: ambiguous use of `||`
|
||||
--> $DIR/syntax-ambiguity-2015.rs:14:47
|
||||
--> $DIR/syntax-ambiguity-2015.rs:13:47
|
||||
|
|
||||
LL | if let Range { start: _, end: _ } = true..true || false { }
|
||||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)`
|
||||
|
|
@ -17,7 +17,7 @@ LL | if let Range { start: _, end: _ } = true..true || false { }
|
|||
= note: see rust-lang/rust#53668 for more information
|
||||
|
||||
error: ambiguous use of `&&`
|
||||
--> $DIR/syntax-ambiguity-2015.rs:17:50
|
||||
--> $DIR/syntax-ambiguity-2015.rs:16:50
|
||||
|
|
||||
LL | while let Range { start: _, end: _ } = true..true && false { }
|
||||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)`
|
||||
|
|
@ -26,7 +26,7 @@ LL | while let Range { start: _, end: _ } = true..true && false { }
|
|||
= note: see rust-lang/rust#53668 for more information
|
||||
|
||||
error: ambiguous use of `||`
|
||||
--> $DIR/syntax-ambiguity-2015.rs:20:50
|
||||
--> $DIR/syntax-ambiguity-2015.rs:19:50
|
||||
|
|
||||
LL | while let Range { start: _, end: _ } = true..true || false { }
|
||||
| ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)`
|
||||
|
|
@ -35,7 +35,7 @@ LL | while let Range { start: _, end: _ } = true..true || false { }
|
|||
= note: see rust-lang/rust#53668 for more information
|
||||
|
||||
error: ambiguous use of `&&`
|
||||
--> $DIR/syntax-ambiguity-2015.rs:23:19
|
||||
--> $DIR/syntax-ambiguity-2015.rs:22:19
|
||||
|
|
||||
LL | if let true = false && false { }
|
||||
| ^^^^^^^^^^^^^^ help: consider adding parentheses: `(false && false)`
|
||||
|
|
@ -44,7 +44,7 @@ LL | if let true = false && false { }
|
|||
= note: see rust-lang/rust#53668 for more information
|
||||
|
||||
error: ambiguous use of `&&`
|
||||
--> $DIR/syntax-ambiguity-2015.rs:26:22
|
||||
--> $DIR/syntax-ambiguity-2015.rs:25:22
|
||||
|
|
||||
LL | while let true = (1 == 2) && false { }
|
||||
| ^^^^^^^^^^^^^^^^^ help: consider adding parentheses: `((1 == 2) && false)`
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue