From: Andrew Pinski <[email protected]>

open_memstream is a POSIX call which is not available on mingw platform.

gcc/rust/ChangeLog:

        * typecheck/rust-tyty.cc (generate_tree_str): Remove opem_memstream
        and print_generic_stmt call with call to dump_generic_node.

Signed-off-by: Andrew Pinski <[email protected]>
---
 gcc/rust/typecheck/rust-tyty.cc | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 161c15e7896..e27577e311d 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -3517,18 +3517,9 @@ ParamType::is_implicit_self_trait () const
 static std::string
 generate_tree_str (tree value)
 {
-  char *buf = nullptr;
-  size_t size = 0;
-
-  FILE *stream = open_memstream (&buf, &size);
-  if (!stream)
-    return "<error>";
-
-  print_generic_stmt (stream, value, TDF_NONE);
-  fclose (stream);
-
-  std::string result = (buf ? std::string (buf, size) : "<error>");
-  free (buf);
+  pretty_printer pp;
+  dump_generic_node (&pp, value, 0, TDF_NONE, true);
+  std::string result = pp_formatted_text (&pp);
 
   if (!result.empty () && result.back () == '\n')
     result.pop_back ();
-- 
2.50.1

Reply via email to