@@ -23,6 +23,7 @@ use rustc::hir;
23
23
use rustc:: hir:: def_id:: LocalDefId ;
24
24
use rustc:: mir:: { BorrowKind } ;
25
25
use syntax_pos:: Span ;
26
+ use syntax:: errors:: Applicability ;
26
27
27
28
impl < ' tcx > Mirror < ' tcx > for & ' tcx hir:: Expr {
28
29
type Output = Expr < ' tcx > ;
@@ -373,6 +374,17 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
373
374
// they can handle that kind of control-flow.
374
375
( hir:: BinOpKind :: And , hir:: Constness :: Const ) => {
375
376
cx. control_flow_destroyed = true ;
377
+ cx. tcx . sess . struct_span_warn (
378
+ op. span ,
379
+ "boolean short circuiting operators in constants do
380
+ not actually short circuit. Thus new const eval features
381
+ are not accessible in constants."
382
+ ) . span_suggestion_with_applicability (
383
+ op. span ,
384
+ "use a bit operator instead" ,
385
+ "&" . into ( ) ,
386
+ Applicability :: MachineApplicable ,
387
+ ) . emit ( ) ;
376
388
ExprKind :: Binary {
377
389
op : BinOp :: BitAnd ,
378
390
lhs : lhs. to_ref ( ) ,
@@ -381,6 +393,17 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
381
393
}
382
394
( hir:: BinOpKind :: Or , hir:: Constness :: Const ) => {
383
395
cx. control_flow_destroyed = true ;
396
+ cx. tcx . sess . struct_span_warn (
397
+ op. span ,
398
+ "boolean short circuiting operators in constants do
399
+ not actually short circuit. Thus new const eval features
400
+ are not accessible in constants."
401
+ ) . span_suggestion_with_applicability (
402
+ op. span ,
403
+ "use a bit operator instead" ,
404
+ "|" . into ( ) ,
405
+ Applicability :: MachineApplicable ,
406
+ ) . emit ( ) ;
384
407
ExprKind :: Binary {
385
408
op : BinOp :: BitOr ,
386
409
lhs : lhs. to_ref ( ) ,
0 commit comments