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+
111use std:: fmt:: Write ;
212use std:: hash:: { Hash , Hasher } ;
313use std:: mem;
@@ -82,7 +92,8 @@ pub struct Frame<'mir, 'tcx: 'mir> {
8292 pub return_place : Place ,
8393
8494 /// 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.
8697 /// `None` represents a local that is currently dead, while a live local
8798 /// can either directly contain `Scalar` or refer to some part of an `Allocation`.
8899 pub locals : IndexVec < mir:: Local , LocalValue > ,
@@ -269,7 +280,9 @@ impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout
269280 }
270281}
271282
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+ {
273286 #[ inline]
274287 fn tcx < ' b > ( & ' b self ) -> TyCtxt < ' b , ' tcx , ' tcx > {
275288 * self . tcx
@@ -329,7 +342,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
329342
330343 pub ( crate ) fn with_fresh_body < F : FnOnce ( & mut Self ) -> R , R > ( & mut self , f : F ) -> R {
331344 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 ) ;
333347 let r = f ( self ) ;
334348 self . stack = stack;
335349 self . steps_since_detector_enabled = steps;
@@ -378,7 +392,11 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
378392 Ok ( Value :: new_slice ( Scalar :: Ptr ( ptr) , s. len ( ) as u64 , self . tcx . tcx ) )
379393 }
380394
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 > > {
382400 trace ! ( "resolve: {:?}, {:#?}" , def_id, substs) ;
383401 trace ! ( "substs: {:#?}" , self . substs( ) ) ;
384402 trace ! ( "param_env: {:#?}" , self . param_env) ;
@@ -405,7 +423,10 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
405423 ) -> EvalResult < ' tcx , & ' tcx mir:: Mir < ' tcx > > {
406424 // do not continue if typeck errors occurred (can only occur in local crate)
407425 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+ {
409430 return err ! ( TypeckError ) ;
410431 }
411432 trace ! ( "load mir {:?}" , instance) ;
@@ -614,7 +635,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
614635 match frame. return_to_block {
615636 StackPopCleanup :: MarkStatic ( mutable) => {
616637 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
618640 self . memory . mark_static_initialized (
619641 ptr. to_ptr ( ) ?. alloc_id ,
620642 mutable,
@@ -651,7 +673,8 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
651673 } else {
652674 self . param_env
653675 } ;
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 ( ) )
655678 }
656679
657680 #[ inline( always) ]
@@ -757,7 +780,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
757780 } else {
758781 last_span = Some ( span) ;
759782 }
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+ {
761786 "closure" . to_owned ( )
762787 } else {
763788 instance. to_string ( )
0 commit comments