]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Use pretty printer instead ofcall to open_memstream
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 11 Mar 2026 15:01:00 +0000 (16:01 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 14 Apr 2026 21:48:35 +0000 (23:48 +0200)
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 <andrew.pinski@oss.qualcomm.com>
gcc/rust/typecheck/rust-tyty.cc

index 161c15e7896044c06133ec250ad99403b010d47c..e27577e311d686617c60dacc6b93f9595a5bcc82 100644 (file)
@@ -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 ();