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
+
1
11
use std:: fmt:: Write ;
2
12
use std:: hash:: { Hash , Hasher } ;
3
13
use std:: mem;
@@ -82,7 +92,8 @@ pub struct Frame<'mir, 'tcx: 'mir> {
82
92
pub return_place : Place ,
83
93
84
94
/// The list of locals for this stack frame, stored in order as
85
- /// `[return_ptr, arguments..., variables..., temporaries...]`. The locals are stored as `Option<Value>`s.
95
+ /// `[return_ptr, arguments..., variables..., temporaries...]`.
96
+ /// The locals are stored as `Option<Value>`s.
86
97
/// `None` represents a local that is currently dead, while a live local
87
98
/// can either directly contain `Scalar` or refer to some part of an `Allocation`.
88
99
pub locals : IndexVec < mir:: Local , LocalValue > ,
@@ -269,7 +280,9 @@ impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout
269
280
}
270
281
}
271
282
272
- impl < ' a , ' mir , ' tcx , M : Machine < ' mir , ' tcx > > layout:: HasTyCtxt < ' tcx > for & ' a EvalContext < ' a , ' mir , ' tcx , M > {
283
+ impl < ' a , ' mir , ' tcx , M > layout:: HasTyCtxt < ' tcx > for & ' a EvalContext < ' a , ' mir , ' tcx , M >
284
+ where M : Machine < ' mir , ' tcx >
285
+ {
273
286
#[ inline]
274
287
fn tcx < ' b > ( & ' b self ) -> TyCtxt < ' b , ' tcx , ' tcx > {
275
288
* self . tcx
@@ -329,7 +342,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
329
342
330
343
pub ( crate ) fn with_fresh_body < F : FnOnce ( & mut Self ) -> R , R > ( & mut self , f : F ) -> R {
331
344
let stack = mem:: replace ( & mut self . stack , Vec :: new ( ) ) ;
332
- let steps = mem:: replace ( & mut self . steps_since_detector_enabled , -STEPS_UNTIL_DETECTOR_ENABLED ) ;
345
+ let steps = mem:: replace ( & mut self . steps_since_detector_enabled ,
346
+ -STEPS_UNTIL_DETECTOR_ENABLED ) ;
333
347
let r = f ( self ) ;
334
348
self . stack = stack;
335
349
self . steps_since_detector_enabled = steps;
@@ -378,7 +392,11 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
378
392
Ok ( Value :: new_slice ( Scalar :: Ptr ( ptr) , s. len ( ) as u64 , self . tcx . tcx ) )
379
393
}
380
394
381
- pub ( super ) fn resolve ( & self , def_id : DefId , substs : & ' tcx Substs < ' tcx > ) -> EvalResult < ' tcx , ty:: Instance < ' tcx > > {
395
+ pub ( super ) fn resolve (
396
+ & self ,
397
+ def_id : DefId ,
398
+ substs : & ' tcx Substs < ' tcx >
399
+ ) -> EvalResult < ' tcx , ty:: Instance < ' tcx > > {
382
400
trace ! ( "resolve: {:?}, {:#?}" , def_id, substs) ;
383
401
trace ! ( "substs: {:#?}" , self . substs( ) ) ;
384
402
trace ! ( "param_env: {:#?}" , self . param_env) ;
@@ -405,7 +423,10 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
405
423
) -> EvalResult < ' tcx , & ' tcx mir:: Mir < ' tcx > > {
406
424
// do not continue if typeck errors occurred (can only occur in local crate)
407
425
let did = instance. def_id ( ) ;
408
- if did. is_local ( ) && self . tcx . has_typeck_tables ( did) && self . tcx . typeck_tables_of ( did) . tainted_by_errors {
426
+ if did. is_local ( )
427
+ && self . tcx . has_typeck_tables ( did)
428
+ && self . tcx . typeck_tables_of ( did) . tainted_by_errors
429
+ {
409
430
return err ! ( TypeckError ) ;
410
431
}
411
432
trace ! ( "load mir {:?}" , instance) ;
@@ -614,7 +635,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
614
635
match frame. return_to_block {
615
636
StackPopCleanup :: MarkStatic ( mutable) => {
616
637
if let Place :: Ptr ( MemPlace { ptr, .. } ) = frame. return_place {
617
- // FIXME: to_ptr()? might be too extreme here, static zsts might reach this under certain conditions
638
+ // FIXME: to_ptr()? might be too extreme here,
639
+ // static zsts might reach this under certain conditions
618
640
self . memory . mark_static_initialized (
619
641
ptr. to_ptr ( ) ?. alloc_id ,
620
642
mutable,
@@ -651,7 +673,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
651
673
} else {
652
674
self . param_env
653
675
} ;
654
- self . tcx . const_eval ( param_env. and ( gid) ) . map_err ( |err| EvalErrorKind :: ReferencedConstant ( err) . into ( ) )
676
+ self . tcx . const_eval ( param_env. and ( gid) )
677
+ . map_err ( |err| EvalErrorKind :: ReferencedConstant ( err) . into ( ) )
655
678
}
656
679
657
680
#[ inline( always) ]
@@ -757,7 +780,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
757
780
} else {
758
781
last_span = Some ( span) ;
759
782
}
760
- let location = if self . tcx . def_key ( instance. def_id ( ) ) . disambiguated_data . data == DefPathData :: ClosureExpr {
783
+ let location = if self . tcx . def_key ( instance. def_id ( ) ) . disambiguated_data . data
784
+ == DefPathData :: ClosureExpr
785
+ {
761
786
"closure" . to_owned ( )
762
787
} else {
763
788
instance. to_string ( )
0 commit comments