]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/trans/debuginfo.rs
remove unnecessary parentheses from range notation
[rust.git] / src / librustc_trans / trans / debuginfo.rs
index d5416ae0631fcde6dc36d96865031a0d1e4002bf..cda9110e02405be694fa4e0ce072d8822d061d80 100644 (file)
@@ -323,28 +323,26 @@ fn get_unique_type_id_as_string(&self, unique_type_id: UniqueTypeId) -> Rc<Strin
     fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
                                       type_: Ty<'tcx>) -> UniqueTypeId {
 
-        // basic type               -> {:name of the type:}
-        // tuple                    -> {tuple_(:param-uid:)*}
-        // struct                   -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
-        // enum                     -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
-        // enum variant             -> {variant_:variant-name:_:enum-uid:}
-        // reference (&)            -> {& :pointee-uid:}
-        // mut reference (&mut)     -> {&mut :pointee-uid:}
-        // ptr (*)                  -> {* :pointee-uid:}
-        // mut ptr (*mut)           -> {*mut :pointee-uid:}
-        // unique ptr (~)           -> {~ :pointee-uid:}
-        // @-ptr (@)                -> {@ :pointee-uid:}
-        // sized vec ([T; x])       -> {[:size:] :element-uid:}
-        // unsized vec ([T])        -> {[] :element-uid:}
-        // trait (T)                -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
-        // closure                  -> {<unsafe_> <once_> :store-sigil:
-        //                                  |(:param-uid:),* <,_...>| -> \
-        //                                  :return-type-uid: : (:bounds:)*}
-        // function                 -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
-        //                                  :return-type-uid:}
-        // unique vec box (~[])     -> {HEAP_VEC_BOX<:pointee-uid:>}
-        // gc box                   -> {GC_BOX<:pointee-uid:>}
-        // projection (<T as U>::V) -> {<:ty-uid: as :trait-uid:> :: :name-uid: }
+        // basic type           -> {:name of the type:}
+        // tuple                -> {tuple_(:param-uid:)*}
+        // struct               -> {struct_:svh: / :node-id:_<(:param-uid:),*> }
+        // enum                 -> {enum_:svh: / :node-id:_<(:param-uid:),*> }
+        // enum variant         -> {variant_:variant-name:_:enum-uid:}
+        // reference (&)        -> {& :pointee-uid:}
+        // mut reference (&mut) -> {&mut :pointee-uid:}
+        // ptr (*)              -> {* :pointee-uid:}
+        // mut ptr (*mut)       -> {*mut :pointee-uid:}
+        // unique ptr (~)       -> {~ :pointee-uid:}
+        // @-ptr (@)            -> {@ :pointee-uid:}
+        // sized vec ([T; x])   -> {[:size:] :element-uid:}
+        // unsized vec ([T])    -> {[] :element-uid:}
+        // trait (T)            -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
+        // closure              -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \
+        //                             :return-type-uid: : (:bounds:)*}
+        // function             -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
+        //                             :return-type-uid:}
+        // unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
+        // gc box               -> {GC_BOX<:pointee-uid:>}
 
         match self.type_to_unique_id.get(&type_).cloned() {
             Some(unique_type_id) => return unique_type_id,
@@ -437,25 +435,6 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
                                        principal.substs,
                                        &mut unique_type_id);
             },
-            ty::ty_projection(ref projection) => {
-                unique_type_id.push_str("<");
-
-                let self_ty = projection.trait_ref.self_ty();
-                let self_type_id = self.get_unique_type_id_of_type(cx, self_ty);
-                let self_type_id = self.get_unique_type_id_as_string(self_type_id);
-                unique_type_id.push_str(&self_type_id[]);
-
-                unique_type_id.push_str(" as ");
-
-                from_def_id_and_substs(self,
-                                       cx,
-                                       projection.trait_ref.def_id,
-                                       projection.trait_ref.substs,
-                                       &mut unique_type_id);
-
-                unique_type_id.push_str(">::");
-                unique_type_id.push_str(token::get_name(projection.item_name).get());
-            },
             ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
                 if unsafety == ast::Unsafety::Unsafe {
                     unique_type_id.push_str("unsafe ");
@@ -499,10 +478,7 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
                                                         closure_ty,
                                                         &mut unique_type_id);
             },
-            ty::ty_err |
-            ty::ty_infer(_) |
-            ty::ty_open(_) |
-            ty::ty_param(_) => {
+            _ => {
                 cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
                                       &ppaux::ty_to_string(cx.tcx(), type_)[],
                                       type_.sty)[])
@@ -878,7 +854,9 @@ pub fn create_global_var_metadata(cx: &CrateContext,
 /// local in `bcx.fcx.lllocals`.
 /// Adds the created metadata nodes directly to the crate's IR.
 pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
-    if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
+    if bcx.unreachable.get() ||
+       fn_should_be_ignored(bcx.fcx) ||
+       bcx.sess().opts.debuginfo != FullDebugInfo  {
         return;
     }
 
@@ -922,7 +900,9 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                                 env_index: uint,
                                                 captured_by_ref: bool,
                                                 span: Span) {
-    if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
+    if bcx.unreachable.get() ||
+       fn_should_be_ignored(bcx.fcx) ||
+       bcx.sess().opts.debuginfo != FullDebugInfo {
         return;
     }
 
@@ -1005,7 +985,9 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                                  variable_ident: ast::Ident,
                                                  binding: BindingInfo<'tcx>) {
-    if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
+    if bcx.unreachable.get() ||
+       fn_should_be_ignored(bcx.fcx) ||
+       bcx.sess().opts.debuginfo != FullDebugInfo {
         return;
     }
 
@@ -1045,7 +1027,9 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 /// argument in `bcx.fcx.lllocals`.
 /// Adds the created metadata nodes directly to the crate's IR.
 pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
-    if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
+    if bcx.unreachable.get() ||
+       fn_should_be_ignored(bcx.fcx) ||
+       bcx.sess().opts.debuginfo != FullDebugInfo {
         return;
     }
 
@@ -1099,7 +1083,9 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
 /// loop variable in `bcx.fcx.lllocals`.
 /// Adds the created metadata nodes directly to the crate's IR.
 pub fn create_for_loop_var_metadata(bcx: Block, pat: &ast::Pat) {
-    if bcx.unreachable.get() || fn_should_be_ignored(bcx.fcx) {
+    if bcx.unreachable.get() ||
+       fn_should_be_ignored(bcx.fcx) ||
+       bcx.sess().opts.debuginfo != FullDebugInfo {
         return;
     }
 
@@ -1177,7 +1163,7 @@ pub fn get_cleanup_debug_loc_for_ast_node<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         if let Some(code_snippet) = code_snippet {
             let bytes = code_snippet.as_bytes();
 
-            if bytes.len() > 0 && &bytes[(bytes.len()-1)..] == b"}" {
+            if bytes.len() > 0 && &bytes[bytes.len()-1..] == b"}" {
                 cleanup_span = Span {
                     lo: node_span.hi - codemap::BytePos(1),
                     hi: node_span.hi,
@@ -1464,18 +1450,15 @@ fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         let mut signature = Vec::with_capacity(fn_decl.inputs.len() + 1);
 
         // Return type -- llvm::DIBuilder wants this at index 0
-        match fn_decl.output {
-            ast::Return(ref ret_ty) if ret_ty.node == ast::TyTup(vec![]) =>
-                signature.push(ptr::null_mut()),
-            _ => {
-                assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
-
-                let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
-                let return_type = monomorphize::apply_param_substs(cx.tcx(),
-                                                                   param_substs,
-                                                                   &return_type);
-                signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
-            }
+        assert_type_for_node_id(cx, fn_ast_id, error_reporting_span);
+        let return_type = ty::node_id_to_type(cx.tcx(), fn_ast_id);
+        let return_type = monomorphize::apply_param_substs(cx.tcx(),
+                                                           param_substs,
+                                                           &return_type);
+        if ty::type_is_nil(return_type) {
+            signature.push(ptr::null_mut())
+        } else {
+            signature.push(type_metadata(cx, return_type, codemap::DUMMY_SP));
         }
 
         // Arguments types
@@ -1769,7 +1752,7 @@ fn file_metadata(cx: &CrateContext, full_path: &str) -> DIFile {
     let work_dir = cx.sess().working_dir.as_str().unwrap();
     let file_name =
         if full_path.starts_with(work_dir) {
-            &full_path[(work_dir.len() + 1u)..full_path.len()]
+            &full_path[work_dir.len() + 1u..full_path.len()]
         } else {
             full_path
         };
@@ -3880,22 +3863,10 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::ty_unboxed_closure(..) => {
             output.push_str("closure");
         }
-        ty::ty_projection(ref projection) => {
-            output.push_str("<");
-            let self_ty = projection.trait_ref.self_ty();
-            push_debuginfo_type_name(cx, self_ty, true, output);
-
-            output.push_str(" as ");
-
-            push_item_name(cx, projection.trait_ref.def_id, false, output);
-            push_type_params(cx, projection.trait_ref.substs, output);
-
-            output.push_str(">::");
-            output.push_str(token::get_name(projection.item_name).get());
-        }
         ty::ty_err |
         ty::ty_infer(_) |
         ty::ty_open(_) |
+        ty::ty_projection(..) |
         ty::ty_param(_) => {
             cx.sess().bug(&format!("debuginfo: Trying to create type name for \
                 unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t))[]);