cx.control_flow_destroyed = true;
cx.tcx.sess.struct_span_warn(
op.span,
- "boolean short circuiting operators in constants do
- not actually short circuit. Thus new const eval features
+ "boolean short circuiting operators in constants do \
+ not actually short circuit. Thus new const eval features \
are not accessible in constants."
).span_suggestion_with_applicability(
op.span,
cx.control_flow_destroyed = true;
cx.tcx.sess.struct_span_warn(
op.span,
- "boolean short circuiting operators in constants do
- not actually short circuit. Thus new const eval features
+ "boolean short circuiting operators in constants do \
+ not actually short circuit. Thus new const eval features \
are not accessible in constants."
).span_suggestion_with_applicability(
op.span,
promote_consts::promote_candidates(mir, tcx, temps, candidates);
} else {
if mir.control_flow_destroyed {
- for local in mir.mut_vars_iter() {
+ for local in mir.vars_iter() {
let span = mir.local_decls[local].source_info.span;
tcx.sess.span_err(
span,
&format!(
- "Cannot have both mutable bindings and \
- short circuiting operators in {}",
+ "short circuiting operators do not actually short circuit in {}. \
+ Thus new features like let bindings are not permitted",
mode,
),
);
--- /dev/null
+#![feature(underscore_const_names)]
+
+const _: bool = false && false; //~ WARN boolean short circuiting operators in constants
+const _: bool = true && false; //~ WARN boolean short circuiting operators in constants
+const _: bool = {
+ let mut x = true && false; //~ WARN boolean short circuiting operators in constants
+ //~^ ERROR short circuiting operators do not actually short circuit in constant
+ x
+};
+const _: bool = {
+ let x = true && false; //~ WARN boolean short circuiting operators in constants
+ //~^ ERROR short circuiting operators do not actually short circuit in constant
+ x
+};
+
+fn main() {}
\ No newline at end of file
--- /dev/null
+warning: boolean short circuiting operators in constants do not actually short circuit. Thus new const eval features are not accessible in constants.
+ --> $DIR/const_short_circuit.rs:3:23
+ |
+LL | const _: bool = false && false; //~ WARN boolean short circuiting operators in constants
+ | ^^ help: use a bit operator instead: `&`
+
+warning: boolean short circuiting operators in constants do not actually short circuit. Thus new const eval features are not accessible in constants.
+ --> $DIR/const_short_circuit.rs:4:22
+ |
+LL | const _: bool = true && false; //~ WARN boolean short circuiting operators in constants
+ | ^^ help: use a bit operator instead: `&`
+
+warning: boolean short circuiting operators in constants do not actually short circuit. Thus new const eval features are not accessible in constants.
+ --> $DIR/const_short_circuit.rs:6:22
+ |
+LL | let mut x = true && false; //~ WARN boolean short circuiting operators in constants
+ | ^^ help: use a bit operator instead: `&`
+
+error: short circuiting operators do not actually short circuit in constant. Thus new features like let bindings are not permitted
+ --> $DIR/const_short_circuit.rs:6:9
+ |
+LL | let mut x = true && false; //~ WARN boolean short circuiting operators in constants
+ | ^^^^^
+
+warning: boolean short circuiting operators in constants do not actually short circuit. Thus new const eval features are not accessible in constants.
+ --> $DIR/const_short_circuit.rs:11:18
+ |
+LL | let x = true && false; //~ WARN boolean short circuiting operators in constants
+ | ^^ help: use a bit operator instead: `&`
+
+error: short circuiting operators do not actually short circuit in constant. Thus new features like let bindings are not permitted
+ --> $DIR/const_short_circuit.rs:11:9
+ |
+LL | let x = true && false; //~ WARN boolean short circuiting operators in constants
+ | ^
+
+error: aborting due to 2 previous errors
+