File tree 2 files changed +31
-2
lines changed
2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -2447,7 +2447,12 @@ impl Clean<Type> for hir::Ty {
2447
2447
let def_id = cx. tcx . hir . body_owner_def_id ( n) ;
2448
2448
let param_env = cx. tcx . param_env ( def_id) ;
2449
2449
let substs = Substs :: identity_for_item ( cx. tcx , def_id) ;
2450
- let n = cx. tcx . const_eval ( param_env. and ( ( def_id, substs) ) ) . unwrap ( ) ;
2450
+ let n = cx. tcx . const_eval ( param_env. and ( ( def_id, substs) ) ) . unwrap_or_else ( |_| {
2451
+ cx. tcx . mk_const ( ty:: Const {
2452
+ val : ConstVal :: Unevaluated ( def_id, substs) ,
2453
+ ty : cx. tcx . types . usize
2454
+ } )
2455
+ } ) ;
2451
2456
let n = if let ConstVal :: Integral ( ConstInt :: Usize ( n) ) = n. val {
2452
2457
n. to_string ( )
2453
2458
} else if let ConstVal :: Unevaluated ( def_id, _) = n. val {
@@ -2577,7 +2582,9 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
2577
2582
let mut n = cx. tcx . lift ( & n) . unwrap ( ) ;
2578
2583
if let ConstVal :: Unevaluated ( def_id, substs) = n. val {
2579
2584
let param_env = cx. tcx . param_env ( def_id) ;
2580
- n = cx. tcx . const_eval ( param_env. and ( ( def_id, substs) ) ) . unwrap ( )
2585
+ if let Ok ( new_n) = cx. tcx . const_eval ( param_env. and ( ( def_id, substs) ) ) {
2586
+ n = new_n;
2587
+ }
2581
2588
} ;
2582
2589
let n = if let ConstVal :: Integral ( ConstInt :: Usize ( n) ) = n. val {
2583
2590
n. to_string ( )
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Just check if we don't get an ICE for the _S type.
12
+
13
+ #![ feature( const_size_of) ]
14
+
15
+ use std:: cell:: Cell ;
16
+ use std:: mem;
17
+
18
+ pub struct S {
19
+ s : Cell < usize >
20
+ }
21
+
22
+ pub type _S = [ usize ; 0 - ( mem:: size_of :: < S > ( ) != 4 ) as usize ] ;
You can’t perform that action at this time.
0 commit comments