Stabilize underscore_const_names.
This commit is contained in:
parent
61a60ce7d3
commit
56d71c2910
9 changed files with 12 additions and 69 deletions
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(underscore_const_names)]
|
||||
|
||||
const _: bool = false && false;
|
||||
const _: bool = true && false;
|
||||
const _: bool = {
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
error: new features like let bindings are not permitted in constants which also use short circuiting operators
|
||||
--> $DIR/const_short_circuit.rs:6:9
|
||||
--> $DIR/const_short_circuit.rs:4:9
|
||||
|
|
||||
LL | let mut x = true && false;
|
||||
| ^^^^^
|
||||
|
|
||||
note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See https://github.com/rust-lang/rust/issues/49146 for more information.
|
||||
--> $DIR/const_short_circuit.rs:6:22
|
||||
--> $DIR/const_short_circuit.rs:4:22
|
||||
|
|
||||
LL | let mut x = true && false;
|
||||
| ^^
|
||||
|
||||
error: new features like let bindings are not permitted in constants which also use short circuiting operators
|
||||
--> $DIR/const_short_circuit.rs:11:9
|
||||
--> $DIR/const_short_circuit.rs:9:9
|
||||
|
|
||||
LL | let x = true && false;
|
||||
| ^
|
||||
|
|
||||
note: use of `&&` operator here does not actually short circuit due to the const evaluator presently not being able to do control flow. See https://github.com/rust-lang/rust/issues/49146 for more information.
|
||||
--> $DIR/const_short_circuit.rs:11:18
|
||||
--> $DIR/const_short_circuit.rs:9:18
|
||||
|
|
||||
LL | let x = true && false;
|
||||
| ^^
|
||||
|
|
|
|||
31
src/test/ui/consts/underscore_const_names.rs
Normal file
31
src/test/ui/consts/underscore_const_names.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// compile-pass
|
||||
|
||||
#![deny(unused)]
|
||||
|
||||
trait Trt {}
|
||||
pub struct Str {}
|
||||
impl Trt for Str {}
|
||||
|
||||
macro_rules! check_impl {
|
||||
($struct:ident,$trait:ident) => {
|
||||
const _ : () = {
|
||||
use std::marker::PhantomData;
|
||||
struct ImplementsTrait<T: $trait>(PhantomData<T>);
|
||||
let _ = ImplementsTrait::<$struct>(PhantomData);
|
||||
()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const _ : () = ();
|
||||
|
||||
const _ : i32 = 42;
|
||||
const _ : Str = Str{};
|
||||
|
||||
check_impl!(Str, Trt);
|
||||
check_impl!(Str, Trt);
|
||||
|
||||
fn main() {
|
||||
check_impl!(Str, Trt);
|
||||
check_impl!(Str, Trt);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue