@@ -328,6 +328,8 @@ Session::handle_cfg_option (std::string &input)
328328bool
329329Session::enable_dump (std::string arg)
330330{
331+ const std::string INTERNAL_DUMP_OPTION_TEXT = " internal" ;
332+
331333 if (arg.empty ())
332334 {
333335 rust_error_at (
@@ -383,21 +385,23 @@ Session::enable_dump (std::string arg)
383385 {
384386 options.enable_dump_option (CompileOptions::BIR_DUMP);
385387 }
386- else if (!arg.compare (0 , 8 , " internal" ))
388+ else if (!arg.compare (0 , INTERNAL_DUMP_OPTION_TEXT.size (),
389+ INTERNAL_DUMP_OPTION_TEXT))
387390 {
388- if (arg.size () == 8 )
391+ if (arg.size () == INTERNAL_DUMP_OPTION_TEXT. size () )
389392 {
390393 options.enable_dump_option (CompileOptions::INTERNAL_DUMP);
391394 }
392395 else
393396 {
394- if (arg[8 ] != ' :' )
397+ if (arg[INTERNAL_DUMP_OPTION_TEXT. size () ] != ' :' )
395398 {
396- rust_error_at (UNDEF_LOCATION,
397- " %qs malformated to specify Node to ignore when "
398- " dumping internal comment put a "
399- " %qs then all the Nodes separated by comma" ,
400- arg.c_str (), " :" );
399+ rust_error_at (UNDEF_LOCATION, " bad format for %qs" ,
400+ arg.c_str ());
401+ rust_inform (UNDEF_LOCATION,
402+ " to specify the nodes to ignore when "
403+ " dumping their description put a "
404+ " %<:%> then all the Nodes separated by comma" );
401405 return false ;
402406 }
403407 handle_excluded_node (arg);
@@ -409,9 +413,9 @@ Session::enable_dump (std::string arg)
409413 rust_error_at (
410414 UNDEF_LOCATION,
411415 " dump option %qs was unrecognised. choose %<lex%>, %<ast-pretty%>, "
412- " %<register_plugins %>, %<injection %>, "
413- " %<expansion %>, %<resolution %>, %<target_options %>, %<hir %>, "
414- " %<hir-pretty%>, or %<all%>" ,
416+ " %<internal[:ignore1,ignore2,...] %>, %<register_plugins %>, "
417+ " %<injection %>, %<expansion %>, %<resolution %>, %<target_options %>, "
418+ " %<hir%>, %<hir -pretty%>, or %<all%>" ,
415419 arg.c_str ());
416420 return false ;
417421 }
@@ -424,9 +428,9 @@ Session::enable_dump (std::string arg)
424428void
425429Session::handle_excluded_node (std::string arg)
426430{
427- const int size_node_string = 50 ;
428- std::istringstream blist_str (
429- arg.substr (arg. find ( " : " ) + 1 , size_node_string ));
431+ size_t colon = arg. find ( " : " ) ;
432+ size_t suffix_size = arg. size () - colon;
433+ std::istringstream blist_str ( arg.substr (colon + 1 , suffix_size ));
430434 std::string token;
431435 while (std::getline (blist_str, token, ' ,' ))
432436 {
0 commit comments