@@ -6,7 +6,7 @@ use crate::{clip, is_direct_expn_of, sext, unsext};
6
6
use rustc_ast:: ast:: { self , LitFloatType , LitKind } ;
7
7
use rustc_data_structures:: sync:: Lrc ;
8
8
use rustc_hir:: def:: { DefKind , Res } ;
9
- use rustc_hir:: { BinOp , BinOpKind , Block , Expr , ExprKind , HirId , Item , ItemKind , Node , QPath , UnOp } ;
9
+ use rustc_hir:: { BinOp , BinOpKind , Block , ConstBlock , Expr , ExprKind , HirId , Item , ItemKind , Node , QPath , UnOp } ;
10
10
use rustc_lexer:: tokenize;
11
11
use rustc_lint:: LateContext ;
12
12
use rustc_middle:: mir:: interpret:: { alloc_range, Scalar } ;
@@ -412,7 +412,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
412
412
/// Simple constant folding: Insert an expression, get a constant or none.
413
413
pub fn expr ( & mut self , e : & Expr < ' _ > ) -> Option < Constant < ' tcx > > {
414
414
match e. kind {
415
- ExprKind :: ConstBlock ( e ) | ExprKind :: DropTemps ( e) => self . expr ( e) ,
415
+ ExprKind :: ConstBlock ( ConstBlock { body , .. } ) => self . expr ( self . lcx . tcx . hir ( ) . body ( body ) . value ) , ExprKind :: DropTemps ( e) => self . expr ( e) ,
416
416
ExprKind :: Path ( ref qpath) => {
417
417
self . fetch_path_and_apply ( qpath, e. hir_id , self . typeck_results . expr_ty ( e) , |this, result| {
418
418
let result = mir_to_const ( this. lcx , result) ?;
@@ -490,7 +490,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
490
490
/// leaves the local crate.
491
491
pub fn expr_is_empty ( & mut self , e : & Expr < ' _ > ) -> Option < bool > {
492
492
match e. kind {
493
- ExprKind :: ConstBlock ( e ) | ExprKind :: DropTemps ( e) => self . expr_is_empty ( e) ,
493
+ ExprKind :: ConstBlock ( ConstBlock { body , .. } ) => self . expr_is_empty ( self . lcx . tcx . hir ( ) . body ( body ) . value ) , ExprKind :: DropTemps ( e) => self . expr_is_empty ( e) ,
494
494
ExprKind :: Path ( ref qpath) => {
495
495
if !self
496
496
. typeck_results
0 commit comments