mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
Auto merge of #12626 - CuriousCorrelation:fix/empty-reasons, r=flodiebold
fix: trailing ':' on empty inactive reasons ## Description Fixes trailing ':' even when there is no explanation. e.g. ``` sh code is inactive due to #[cfg] directives: ``` ## Issue Fixes: #12615
This commit is contained in:
commit
7f9c054686
1 changed files with 10 additions and 1 deletions
|
@ -19,7 +19,13 @@ pub(crate) fn inactive_code(
|
||||||
let mut message = "code is inactive due to #[cfg] directives".to_string();
|
let mut message = "code is inactive due to #[cfg] directives".to_string();
|
||||||
|
|
||||||
if let Some(inactive) = inactive {
|
if let Some(inactive) = inactive {
|
||||||
format_to!(message, ": {}", inactive);
|
let inactive_reasons = inactive.to_string();
|
||||||
|
|
||||||
|
if inactive_reasons.is_empty() {
|
||||||
|
format_to!(message);
|
||||||
|
} else {
|
||||||
|
format_to!(message, ": {}", inactive);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = Diagnostic::new(
|
let res = Diagnostic::new(
|
||||||
|
@ -91,6 +97,9 @@ fn f() {
|
||||||
|
|
||||||
#[cfg(feature = "std")] use std;
|
#[cfg(feature = "std")] use std;
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: feature = "std" is disabled
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue