88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- use super :: FunctionDebugContext ;
11+ use super :: { FunctionDebugContext , FunctionDebugContextData } ;
1212use super :: metadata:: file_metadata;
1313use super :: utils:: { DIB , span_start} ;
1414
1515use llvm;
16- use llvm:: debuginfo:: { DIScope , DISubprogram } ;
16+ use llvm:: debuginfo:: DIScope ;
1717use common:: CrateContext ;
1818use rustc:: mir:: { Mir , VisibilityScope } ;
1919
@@ -53,8 +53,8 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
5353 } ;
5454 let mut scopes = IndexVec :: from_elem ( null_scope, & mir. visibility_scopes ) ;
5555
56- let fn_metadata = match * debug_context {
57- FunctionDebugContext :: RegularContext ( ref data) => data. fn_metadata ,
56+ let debug_context = match * debug_context {
57+ FunctionDebugContext :: RegularContext ( ref data) => data,
5858 FunctionDebugContext :: DebugInfoDisabled |
5959 FunctionDebugContext :: FunctionWithoutDebugInfo => {
6060 return scopes;
@@ -71,7 +71,7 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
7171 // Instantiate all scopes.
7272 for idx in 0 ..mir. visibility_scopes . len ( ) {
7373 let scope = VisibilityScope :: new ( idx) ;
74- make_mir_scope ( ccx, & mir, & has_variables, fn_metadata , scope, & mut scopes) ;
74+ make_mir_scope ( ccx, & mir, & has_variables, debug_context , scope, & mut scopes) ;
7575 }
7676
7777 scopes
@@ -80,7 +80,7 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
8080fn make_mir_scope ( ccx : & CrateContext ,
8181 mir : & Mir ,
8282 has_variables : & BitVector ,
83- fn_metadata : DISubprogram ,
83+ debug_context : & FunctionDebugContextData ,
8484 scope : VisibilityScope ,
8585 scopes : & mut IndexVec < VisibilityScope , MirDebugScope > ) {
8686 if scopes[ scope] . is_valid ( ) {
@@ -89,13 +89,13 @@ fn make_mir_scope(ccx: &CrateContext,
8989
9090 let scope_data = & mir. visibility_scopes [ scope] ;
9191 let parent_scope = if let Some ( parent) = scope_data. parent_scope {
92- make_mir_scope ( ccx, mir, has_variables, fn_metadata , parent, scopes) ;
92+ make_mir_scope ( ccx, mir, has_variables, debug_context , parent, scopes) ;
9393 scopes[ parent]
9494 } else {
9595 // The root is the function itself.
9696 let loc = span_start ( ccx, mir. span ) ;
9797 scopes[ scope] = MirDebugScope {
98- scope_metadata : fn_metadata,
98+ scope_metadata : debug_context . fn_metadata ,
9999 file_start_pos : loc. file . start_pos ,
100100 file_end_pos : loc. file . end_pos ,
101101 } ;
@@ -109,14 +109,17 @@ fn make_mir_scope(ccx: &CrateContext,
109109 // However, we don't skip creating a nested scope if
110110 // our parent is the root, because we might want to
111111 // put arguments in the root and not have shadowing.
112- if parent_scope. scope_metadata != fn_metadata {
112+ if parent_scope. scope_metadata != debug_context . fn_metadata {
113113 scopes[ scope] = parent_scope;
114114 return ;
115115 }
116116 }
117117
118118 let loc = span_start ( ccx, scope_data. span ) ;
119- let file_metadata = file_metadata ( ccx, & loc. file . name , & loc. file . abs_path ) ;
119+ let file_metadata = file_metadata ( ccx,
120+ & loc. file . name ,
121+ debug_context. defining_crate ) ;
122+
120123 let scope_metadata = unsafe {
121124 llvm:: LLVMRustDIBuilderCreateLexicalBlock (
122125 DIB ( ccx) ,
0 commit comments