Improve diagnostics for concat_bytes! with C string literals
Use the same error as other invalid types for `concat_bytes!`, rather than using `ConcatCStrLit` from `concat!`. Also add more information with a note about why this doesn't work, and a suggestion to use a null-terminated byte string instead.
This commit is contained in:
@@ -215,6 +215,8 @@ pub(crate) struct ConcatBytesInvalid {
|
||||
pub(crate) lit_kind: &'static str,
|
||||
#[subdiagnostic]
|
||||
pub(crate) sugg: Option<ConcatBytesInvalidSuggestion>,
|
||||
#[note(builtin_macros_c_str_note)]
|
||||
pub(crate) cs_note: Option<()>,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
@@ -239,6 +241,13 @@ pub(crate) enum ConcatBytesInvalidSuggestion {
|
||||
span: Span,
|
||||
snippet: String,
|
||||
},
|
||||
#[note(builtin_macros_c_str_note)]
|
||||
#[suggestion(builtin_macros_c_str, code = "{as_bstr}", applicability = "machine-applicable")]
|
||||
CStrLit {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
as_bstr: String,
|
||||
},
|
||||
#[suggestion(
|
||||
builtin_macros_number_array,
|
||||
code = "[{snippet}]",
|
||||
|
||||
Reference in New Issue
Block a user