@@ -388,6 +388,7 @@ pub enum ErrKind {
388388 ShiftRightWithOverflow ,
389389 MissingStructField ,
390390 NonConstPath ,
391+ UnresolvedPath ,
391392 ExpectedConstTuple ,
392393 ExpectedConstStruct ,
393394 TupleIndexOutOfBounds ,
@@ -424,7 +425,8 @@ impl ConstEvalErr {
424425 ShiftLeftWithOverflow => "attempted left shift with overflow" . into_cow ( ) ,
425426 ShiftRightWithOverflow => "attempted right shift with overflow" . into_cow ( ) ,
426427 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 ( ) ,
428430 ExpectedConstTuple => "expected constant tuple" . into_cow ( ) ,
429431 ExpectedConstStruct => "expected constant struct" . into_cow ( ) ,
430432 TupleIndexOutOfBounds => "tuple index out of bounds" . into_cow ( ) ,
@@ -916,7 +918,20 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
916918 }
917919 }
918920 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+ } ;
920935 let ( const_expr, const_ty) = match opt_def {
921936 Some ( def:: DefConst ( def_id) ) => {
922937 if def_id. is_local ( ) {
0 commit comments