File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
compiler/rustc_codegen_llvm/src/debuginfo Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -1152,15 +1152,23 @@ fn build_closure_env_di_node<'ll, 'tcx>(
1152
1152
let containing_scope = get_namespace_for_item ( cx, def_id) ;
1153
1153
let type_name = compute_debuginfo_type_name ( cx. tcx , closure_env_type, false ) ;
1154
1154
1155
+ let closure_span = cx. tcx . def_span ( def_id) ;
1156
+ let ( file_metadata, line_number) = if !closure_span. is_dummy ( ) {
1157
+ let loc = cx. lookup_debug_loc ( closure_span. lo ( ) ) ;
1158
+ ( file_metadata ( cx, & loc. file ) , loc. line )
1159
+ } else {
1160
+ ( unknown_file_metadata ( cx) , UNKNOWN_LINE_NUMBER )
1161
+ } ;
1162
+
1155
1163
type_map:: build_type_with_children (
1156
1164
cx,
1157
1165
type_map:: stub (
1158
1166
cx,
1159
1167
Stub :: Struct ,
1160
1168
unique_type_id,
1161
1169
& type_name,
1162
- unknown_file_metadata ( cx ) ,
1163
- UNKNOWN_LINE_NUMBER ,
1170
+ file_metadata ,
1171
+ line_number ,
1164
1172
cx. size_and_align_of ( closure_env_type) ,
1165
1173
Some ( containing_scope) ,
1166
1174
DIFlags :: FlagZero ,
Original file line number Diff line number Diff line change 8
8
// CHECK: !DICompositeType({{.*"}}MyType{{".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
9
9
pub struct MyType ;
10
10
11
- pub fn foo ( _: MyType ) { }
11
+ pub fn foo ( _: MyType ) {
12
+ // CHECK: !DICompositeType({{.*"[{]}}closure_env#0{{[}]".*}}file: ![[#FILE]]{{.*}}line: [[# @LINE + 1]],
13
+ let closure = |x| x;
14
+ closure ( 0 ) ;
15
+ }
You can’t perform that action at this time.
0 commit comments