fix: trailing ':' on empty inactive reasons

Fixes: #12615
This commit is contained in:
CuriousCorrelation 2022-06-23 22:10:27 +05:30
parent 19fad541bd
commit e0c17e8777

View file

@ -19,8 +19,14 @@ pub(crate) fn inactive_code(
let mut message = "code is inactive due to #[cfg] directives".to_string();
if let Some(inactive) = inactive {
let inactive_reasons = inactive.to_string();
if inactive_reasons.is_empty() {
format_to!(message);
} else {
format_to!(message, ": {}", inactive);
}
}
let res = Diagnostic::new(
"inactive-code",
@ -91,6 +97,9 @@ fn f() {
#[cfg(feature = "std")] use std;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: feature = "std" is disabled
#[cfg(any())] pub fn f() {}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives
"#,
);
}