@@ -1128,6 +1128,10 @@ pub fn create_function_debug_context(cx: &CrateContext,
1128
1128
1129
1129
let ( ident, fn_decl, generics, top_level_block, span, has_path) = match fnitem {
1130
1130
ast_map:: NodeItem ( ref item) => {
1131
+ if contains_nodebug_attribute ( item. attrs . as_slice ( ) ) {
1132
+ return FunctionDebugContext { repr : FunctionWithoutDebugInfo } ;
1133
+ }
1134
+
1131
1135
match item. node {
1132
1136
ast:: ItemFn ( fn_decl, _, _, ref generics, top_level_block) => {
1133
1137
( item. ident , fn_decl, generics, top_level_block, item. span , true )
@@ -1141,6 +1145,12 @@ pub fn create_function_debug_context(cx: &CrateContext,
1141
1145
ast_map:: NodeImplItem ( ref item) => {
1142
1146
match * * item {
1143
1147
ast:: MethodImplItem ( ref method) => {
1148
+ if contains_nodebug_attribute ( method. attrs . as_slice ( ) ) {
1149
+ return FunctionDebugContext {
1150
+ repr : FunctionWithoutDebugInfo
1151
+ } ;
1152
+ }
1153
+
1144
1154
( method. pe_ident ( ) ,
1145
1155
method. pe_fn_decl ( ) ,
1146
1156
method. pe_generics ( ) ,
@@ -1173,6 +1183,12 @@ pub fn create_function_debug_context(cx: &CrateContext,
1173
1183
ast_map:: NodeTraitItem ( ref trait_method) => {
1174
1184
match * * trait_method {
1175
1185
ast:: ProvidedMethod ( ref method) => {
1186
+ if contains_nodebug_attribute ( method. attrs . as_slice ( ) ) {
1187
+ return FunctionDebugContext {
1188
+ repr : FunctionWithoutDebugInfo
1189
+ } ;
1190
+ }
1191
+
1176
1192
( method. pe_ident ( ) ,
1177
1193
method. pe_fn_decl ( ) ,
1178
1194
method. pe_generics ( ) ,
@@ -3169,6 +3185,16 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) {
3169
3185
// Utility Functions
3170
3186
//=-----------------------------------------------------------------------------
3171
3187
3188
+ fn contains_nodebug_attribute ( attributes : & [ ast:: Attribute ] ) -> bool {
3189
+ attributes. iter ( ) . any ( |attr| {
3190
+ let meta_item: & ast:: MetaItem = & * attr. node . value ;
3191
+ match meta_item. node {
3192
+ ast:: MetaWord ( ref value) => value. get ( ) == "no_debug" ,
3193
+ _ => false
3194
+ }
3195
+ } )
3196
+ }
3197
+
3172
3198
/// Return codemap::Loc corresponding to the beginning of the span
3173
3199
fn span_start ( cx : & CrateContext , span : Span ) -> codemap:: Loc {
3174
3200
cx. sess ( ) . codemap ( ) . lookup_char_pos ( span. lo )
0 commit comments