8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- use super :: FunctionDebugContext ;
11
+ use super :: { FunctionDebugContext , FunctionDebugContextData } ;
12
12
use super :: metadata:: file_metadata;
13
13
use super :: utils:: { DIB , span_start} ;
14
14
15
15
use llvm;
16
- use llvm:: debuginfo:: { DIScope , DISubprogram } ;
16
+ use llvm:: debuginfo:: DIScope ;
17
17
use common:: CrateContext ;
18
18
use rustc:: mir:: { Mir , VisibilityScope } ;
19
19
@@ -53,8 +53,8 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
53
53
} ;
54
54
let mut scopes = IndexVec :: from_elem ( null_scope, & mir. visibility_scopes ) ;
55
55
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,
58
58
FunctionDebugContext :: DebugInfoDisabled |
59
59
FunctionDebugContext :: FunctionWithoutDebugInfo => {
60
60
return scopes;
@@ -71,7 +71,12 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
71
71
// Instantiate all scopes.
72
72
for idx in 0 ..mir. visibility_scopes . len ( ) {
73
73
let scope = VisibilityScope :: new ( idx) ;
74
- make_mir_scope ( ccx, & mir, & has_variables, fn_metadata, scope, & mut scopes) ;
74
+ make_mir_scope ( ccx,
75
+ & mir,
76
+ & has_variables,
77
+ debug_context,
78
+ scope,
79
+ & mut scopes) ;
75
80
}
76
81
77
82
scopes
@@ -80,7 +85,7 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
80
85
fn make_mir_scope ( ccx : & CrateContext ,
81
86
mir : & Mir ,
82
87
has_variables : & BitVector ,
83
- fn_metadata : DISubprogram ,
88
+ debug_context : & FunctionDebugContextData ,
84
89
scope : VisibilityScope ,
85
90
scopes : & mut IndexVec < VisibilityScope , MirDebugScope > ) {
86
91
if scopes[ scope] . is_valid ( ) {
@@ -89,13 +94,13 @@ fn make_mir_scope(ccx: &CrateContext,
89
94
90
95
let scope_data = & mir. visibility_scopes [ scope] ;
91
96
let parent_scope = if let Some ( parent) = scope_data. parent_scope {
92
- make_mir_scope ( ccx, mir, has_variables, fn_metadata , parent, scopes) ;
97
+ make_mir_scope ( ccx, mir, has_variables, debug_context , parent, scopes) ;
93
98
scopes[ parent]
94
99
} else {
95
100
// The root is the function itself.
96
101
let loc = span_start ( ccx, mir. span ) ;
97
102
scopes[ scope] = MirDebugScope {
98
- scope_metadata : fn_metadata,
103
+ scope_metadata : debug_context . fn_metadata ,
99
104
file_start_pos : loc. file . start_pos ,
100
105
file_end_pos : loc. file . end_pos ,
101
106
} ;
@@ -109,14 +114,14 @@ fn make_mir_scope(ccx: &CrateContext,
109
114
// However, we don't skip creating a nested scope if
110
115
// our parent is the root, because we might want to
111
116
// put arguments in the root and not have shadowing.
112
- if parent_scope. scope_metadata != fn_metadata {
117
+ if parent_scope. scope_metadata != debug_context . fn_metadata {
113
118
scopes[ scope] = parent_scope;
114
119
return ;
115
120
}
116
121
}
117
122
118
123
let loc = span_start ( ccx, scope_data. span ) ;
119
- let file_metadata = file_metadata ( ccx, & loc. file . name , & loc . file . abs_path ) ;
124
+ let file_metadata = file_metadata ( ccx, & loc. file . name , debug_context . defining_crate ) ;
120
125
let scope_metadata = unsafe {
121
126
llvm:: LLVMRustDIBuilderCreateLexicalBlock (
122
127
DIB ( ccx) ,
0 commit comments