better error for bad depth on macro metavar expr
This commit is contained in:
parent
a289cfcfb3
commit
dd109c8c10
5 changed files with 39 additions and 9 deletions
|
@ -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>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue