@@ -64,7 +64,7 @@ pub const EXIT_FAILURE: i32 = 1;
6464const BUG_REPORT_URL : & str = "https://github.com/rust-lang/rust/issues/new\
6565 ?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md";
6666
67- const ICE_REPORT_COMPILER_FLAGS : & [ & str ] = & [ "Z" , "C" , "crate-type" ] ;
67+ const ICE_REPORT_COMPILER_FLAGS : & [ & str ] = & [ "- Z" , "- C" , "-- crate-type" ] ;
6868
6969const ICE_REPORT_COMPILER_FLAGS_EXCLUDE : & [ & str ] = & [ "metadata" , "extra-filename" ] ;
7070
@@ -1108,31 +1108,31 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
11081108/// debugging, since some ICEs only happens with non-default compiler flags
11091109/// (and the users don't always report them).
11101110fn extra_compiler_flags ( ) -> Option < ( Vec < String > , bool ) > {
1111- let args = env:: args_os ( ) . map ( |arg| arg. to_string_lossy ( ) . to_string ( ) ) . collect :: < Vec < _ > > ( ) ;
1111+ let mut args = env:: args_os ( ) . map ( |arg| arg. to_string_lossy ( ) . to_string ( ) ) . peekable ( ) ;
11121112
1113- // Avoid printing help because of empty args. This can suggest the compiler
1114- // itself is not the program root (consider RLS).
1115- if args. len ( ) < 2 {
1116- return None ;
1117- }
1118-
1119- let matches = handle_options ( & args) ?;
11201113 let mut result = Vec :: new ( ) ;
11211114 let mut excluded_cargo_defaults = false ;
1122- for flag in ICE_REPORT_COMPILER_FLAGS {
1123- let prefix = if flag. len ( ) == 1 { "-" } else { "--" } ;
1124-
1125- for content in & matches. opt_strs ( flag) {
1126- // Split always returns the first element
1127- let name = if let Some ( first) = content. split ( '=' ) . next ( ) { first } else { & content } ;
1128-
1129- let content =
1130- if ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE . contains ( & name) { name } else { content } ;
1131-
1132- if !ICE_REPORT_COMPILER_FLAGS_EXCLUDE . contains ( & name) {
1133- result. push ( format ! ( "{}{} {}" , prefix, flag, content) ) ;
1115+ while let Some ( arg) = args. next ( ) {
1116+ if let Some ( a) = ICE_REPORT_COMPILER_FLAGS . iter ( ) . find ( |a| arg. starts_with ( * a) ) {
1117+ let content = if arg. len ( ) == a. len ( ) {
1118+ match args. next ( ) {
1119+ Some ( arg) => arg. to_string ( ) ,
1120+ None => continue ,
1121+ }
1122+ } else if arg. get ( a. len ( ) ..a. len ( ) + 1 ) == Some ( "=" ) {
1123+ arg[ a. len ( ) + 1 ..] . to_string ( )
11341124 } else {
1125+ arg[ a. len ( ) ..] . to_string ( )
1126+ } ;
1127+ if ICE_REPORT_COMPILER_FLAGS_EXCLUDE . iter ( ) . any ( |exc| content. starts_with ( exc) ) {
11351128 excluded_cargo_defaults = true ;
1129+ } else {
1130+ result. push ( a. to_string ( ) ) ;
1131+ match ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE . iter ( ) . find ( |s| content. starts_with ( * s) )
1132+ {
1133+ Some ( s) => result. push ( s. to_string ( ) ) ,
1134+ None => result. push ( content) ,
1135+ }
11361136 }
11371137 }
11381138 }
0 commit comments