Move tuple-index hint as diagnostic's help
This commit is contained in:
parent
168196f903
commit
5cf9742e5e
|
@ -26,7 +26,7 @@ impl ParseError {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn invalid_tuple_index(span: Span, index: u32, suffix: Option<String>) -> Self {
|
pub fn invalid_tuple_index(span: Span, index: u32, suffix: Option<String>) -> Self {
|
||||||
let hint = suffix.map(|suffix| format!("{index}{suffix}"));
|
let hint = suffix.map(|suffix| format!("Did you mean '{index}{suffix}'?"));
|
||||||
Self {
|
Self {
|
||||||
kind: ErrorKind::InvalidTupleIndex { hint },
|
kind: ErrorKind::InvalidTupleIndex { hint },
|
||||||
span,
|
span,
|
||||||
|
@ -94,8 +94,12 @@ pub enum ErrorKind {
|
||||||
},
|
},
|
||||||
#[error("No end branch")]
|
#[error("No end branch")]
|
||||||
NoEndBranch,
|
NoEndBranch,
|
||||||
#[error("Invalid tuple index{}", hint.as_ref().map(|s| format!("; did you mean '{s}' ?")).unwrap_or_default())]
|
#[error("Invalid tuple index")]
|
||||||
InvalidTupleIndex { hint: Option<String> },
|
#[diagnostic()]
|
||||||
|
InvalidTupleIndex {
|
||||||
|
#[help]
|
||||||
|
hint: Option<String>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Diagnostic, thiserror::Error)]
|
#[derive(Debug, PartialEq, Eq, Hash, Diagnostic, thiserror::Error)]
|
||||||
|
|
Loading…
Reference in New Issue