@@ -1128,6 +1128,10 @@ pub fn create_function_debug_context(cx: &CrateContext,
11281128
11291129 let ( ident, fn_decl, generics, top_level_block, span, has_path) = match fnitem {
11301130 ast_map:: NodeItem ( ref item) => {
1131+ if contains_nodebug_attribute ( item. attrs . as_slice ( ) ) {
1132+ return FunctionDebugContext { repr : FunctionWithoutDebugInfo } ;
1133+ }
1134+
11311135 match item. node {
11321136 ast:: ItemFn ( fn_decl, _, _, ref generics, top_level_block) => {
11331137 ( item. ident , fn_decl, generics, top_level_block, item. span , true )
@@ -1141,6 +1145,12 @@ pub fn create_function_debug_context(cx: &CrateContext,
11411145 ast_map:: NodeImplItem ( ref item) => {
11421146 match * * item {
11431147 ast:: MethodImplItem ( ref method) => {
1148+ if contains_nodebug_attribute ( method. attrs . as_slice ( ) ) {
1149+ return FunctionDebugContext {
1150+ repr : FunctionWithoutDebugInfo
1151+ } ;
1152+ }
1153+
11441154 ( method. pe_ident ( ) ,
11451155 method. pe_fn_decl ( ) ,
11461156 method. pe_generics ( ) ,
@@ -1173,6 +1183,12 @@ pub fn create_function_debug_context(cx: &CrateContext,
11731183 ast_map:: NodeTraitItem ( ref trait_method) => {
11741184 match * * trait_method {
11751185 ast:: ProvidedMethod ( ref method) => {
1186+ if contains_nodebug_attribute ( method. attrs . as_slice ( ) ) {
1187+ return FunctionDebugContext {
1188+ repr : FunctionWithoutDebugInfo
1189+ } ;
1190+ }
1191+
11761192 ( method. pe_ident ( ) ,
11771193 method. pe_fn_decl ( ) ,
11781194 method. pe_generics ( ) ,
@@ -3169,6 +3185,16 @@ fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) {
31693185// Utility Functions
31703186//=-----------------------------------------------------------------------------
31713187
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+
31723198/// Return codemap::Loc corresponding to the beginning of the span
31733199fn span_start ( cx : & CrateContext , span : Span ) -> codemap:: Loc {
31743200 cx. sess ( ) . codemap ( ) . lookup_char_pos ( span. lo )
0 commit comments