@@ -388,6 +388,7 @@ pub enum ErrKind {
388
388
ShiftRightWithOverflow ,
389
389
MissingStructField ,
390
390
NonConstPath ,
391
+ UnresolvedPath ,
391
392
ExpectedConstTuple ,
392
393
ExpectedConstStruct ,
393
394
TupleIndexOutOfBounds ,
@@ -424,7 +425,8 @@ impl ConstEvalErr {
424
425
ShiftLeftWithOverflow => "attempted left shift with overflow" . into_cow ( ) ,
425
426
ShiftRightWithOverflow => "attempted right shift with overflow" . into_cow ( ) ,
426
427
MissingStructField => "nonexistent struct field" . into_cow ( ) ,
427
- NonConstPath => "non-constant path in constant expr" . into_cow ( ) ,
428
+ NonConstPath => "non-constant path in constant expression" . into_cow ( ) ,
429
+ UnresolvedPath => "unresolved path in constant expression" . into_cow ( ) ,
428
430
ExpectedConstTuple => "expected constant tuple" . into_cow ( ) ,
429
431
ExpectedConstStruct => "expected constant struct" . into_cow ( ) ,
430
432
TupleIndexOutOfBounds => "tuple index out of bounds" . into_cow ( ) ,
@@ -916,7 +918,20 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
916
918
}
917
919
}
918
920
hir:: ExprPath ( ..) => {
919
- let opt_def = tcx. def_map . borrow ( ) . get ( & e. id ) . map ( |d| d. full_def ( ) ) ;
921
+ let opt_def = if let Some ( def) = tcx. def_map . borrow ( ) . get ( & e. id ) {
922
+ // After type-checking, def_map contains definition of the
923
+ // item referred to by the path. During type-checking, it
924
+ // can contain the raw output of path resolution, which
925
+ // might be a partially resolved path.
926
+ // FIXME: There's probably a better way to make sure we don't
927
+ // panic here.
928
+ if def. depth != 0 {
929
+ signal ! ( e, UnresolvedPath ) ;
930
+ }
931
+ Some ( def. full_def ( ) )
932
+ } else {
933
+ None
934
+ } ;
920
935
let ( const_expr, const_ty) = match opt_def {
921
936
Some ( def:: DefConst ( def_id) ) => {
922
937
if def_id. is_local ( ) {
0 commit comments