Skip to content

Commit 7ec7b57

Browse files
committed
Fix the -Zsanitizer_memory_track_origins error message.
Currently, if you give a bogus value like `-Zsanitizer-memory-track-origins=99` you get this incorrect error: ``` error: debugging option `sanitizer-memory-track-origins` takes no value ``` This commit fixes it so it gives this instead: ``` error: incorrect value `99` for debugging option `sanitizer-memory-track-origins` - 0, 1, or 2 was expected ``` The commit also makes `parse_sanitizer_memory_track_origins` more readable.
1 parent 0b92969 commit 7ec7b57

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/librustc_session/options.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ macro_rules! options {
259259
Some("one of: `address`, `leak`, `memory` or `thread`");
260260
pub const parse_sanitizer_list: Option<&str> =
261261
Some("comma separated list of sanitizers");
262-
pub const parse_sanitizer_memory_track_origins: Option<&str> = None;
262+
pub const parse_sanitizer_memory_track_origins: Option<&str> =
263+
Some("0, 1, or 2");
263264
pub const parse_cfguard: Option<&str> =
264265
Some("either `disabled`, `nochecks`, or `checks`");
265266
pub const parse_linker_flavor: Option<&str> =
@@ -491,18 +492,11 @@ macro_rules! options {
491492
}
492493

493494
fn parse_sanitizer_memory_track_origins(slot: &mut usize, v: Option<&str>) -> bool {
494-
match v.map(|s| s.parse()) {
495-
None => {
496-
*slot = 2;
497-
true
498-
}
499-
Some(Ok(i)) if i <= 2 => {
500-
*slot = i;
501-
true
502-
}
503-
_ => {
504-
false
505-
}
495+
match v {
496+
Some("2") | None => { *slot = 2; true }
497+
Some("1") => { *slot = 1; true }
498+
Some("0") => { *slot = 0; true }
499+
Some(_) => false,
506500
}
507501
}
508502

0 commit comments

Comments
 (0)