From e74e39a6990d4d66f52c44bb9d0d06e9e2202d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sat, 13 Nov 2021 00:00:00 +0000 Subject: [PATCH] Accumulate all values of `-C remark` option When `-C remark=...` option is specified multiple times, accumulate all values instead of using only the last one. --- compiler/rustc_session/src/config.rs | 7 +++++++ compiler/rustc_session/src/options.rs | 2 +- src/test/ui/optimization-remark.rs | 13 +++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index ab3c122053c..16b68d95858 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -833,6 +833,13 @@ impl Passes { Passes::All => false, } } + + pub fn extend(&mut self, passes: impl IntoIterator) { + match *self { + Passes::Some(ref mut v) => v.extend(passes), + Passes::All => {} + } + } } pub const fn default_lib_output() -> CrateType { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 4165e750df5..779f29e3dfe 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -567,7 +567,7 @@ mod parse { v => { let mut passes = vec![]; if parse_list(&mut passes, v) { - *slot = Passes::Some(passes); + slot.extend(passes); true } else { false diff --git a/src/test/ui/optimization-remark.rs b/src/test/ui/optimization-remark.rs index 7aedb09928b..36549cbc554 100644 --- a/src/test/ui/optimization-remark.rs +++ b/src/test/ui/optimization-remark.rs @@ -1,10 +1,19 @@ // build-pass // ignore-pass // no-system-llvm -// revisions: all inline -// compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2 +// revisions: all inline merge1 merge2 +// compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2 +// +// Check that remarks can be enabled individually or with "all": +// // [all] compile-flags: -Cremark=all // [inline] compile-flags: -Cremark=inline +// +// Check that values of -Cremark flag are accumulated: +// +// [merge1] compile-flags: -Cremark=all -Cremark=giraffe +// [merge2] compile-flags: -Cremark=inline -Cremark=giraffe +// // error-pattern: inline: f not inlined into g // dont-check-compiler-stderr