@@ -64,7 +64,7 @@ pub const EXIT_FAILURE: i32 = 1;
64
64
const BUG_REPORT_URL : & str = "https://github.com/rust-lang/rust/issues/new\
65
65
?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md";
66
66
67
- const ICE_REPORT_COMPILER_FLAGS : & [ & str ] = & [ "Z" , "C" , "crate-type" ] ;
67
+ const ICE_REPORT_COMPILER_FLAGS : & [ & str ] = & [ "- Z" , "- C" , "-- crate-type" ] ;
68
68
69
69
const ICE_REPORT_COMPILER_FLAGS_EXCLUDE : & [ & str ] = & [ "metadata" , "extra-filename" ] ;
70
70
@@ -1108,31 +1108,31 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
1108
1108
/// debugging, since some ICEs only happens with non-default compiler flags
1109
1109
/// (and the users don't always report them).
1110
1110
fn 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 ( ) ;
1112
1112
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) ?;
1120
1113
let mut result = Vec :: new ( ) ;
1121
1114
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 ( )
1134
1124
} else {
1125
+ arg[ a. len ( ) ..] . to_string ( )
1126
+ } ;
1127
+ if ICE_REPORT_COMPILER_FLAGS_EXCLUDE . iter ( ) . any ( |exc| content. starts_with ( exc) ) {
1135
1128
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
+ }
1136
1136
}
1137
1137
}
1138
1138
}
0 commit comments