1
Fork 0

better error for bad depth on macro metavar expr

This commit is contained in:
Michael Goulet 2022-07-17 00:04:30 +00:00
parent a289cfcfb3
commit dd109c8c10
5 changed files with 39 additions and 9 deletions

View file

@ -512,7 +512,18 @@ fn out_of_bounds_err<'a>(
span: Span,
ty: &str,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
cx.struct_span_err(span, &format!("{ty} depth must be less than {max}"))
let msg = if max == 0 {
format!(
"meta-variable expression `{ty}` with depth parameter \
must be called inside of a macro repetition"
)
} else {
format!(
"depth parameter on meta-variable expression `{ty}` \
must be less than {max}"
)
};
cx.struct_span_err(span, &msg)
}
fn transcribe_metavar_expr<'a>(