1
Fork 0

Auto merge of #86164 - FabianWolff:issue-86053, r=davidtwco

Handle C-variadic arguments properly when reporting region errors

This pull request fixes #86053. The issue is that for a C-variadic function
```rust
#![feature(c_variadic)]
unsafe extern "C" fn foo(_: (), ...) {}
```
`foo`'s signature will contain only the first parameter (and have `c_variadic` set to `true`), whereas its body has a second argument (a `hir::Pat` for the `...`).

The code for reporting region errors iterates over the body's parameters and tries to fetch the corresponding parameter from the signature; this causes an out-of-bounds ICE for the `...` (though not in the example above, because there are no region errors to report).

I have simply restricted the iteration over the body parameters to exclude `...`, which is fine because `...` cannot cause a region error.
This commit is contained in:
bors 2021-06-17 06:34:12 +00:00
commit cb3c4ee718
10 changed files with 218 additions and 69 deletions

View file

@ -652,7 +652,7 @@ impl<'a> AstValidator<'a> {
self.err_handler()
.struct_span_err(
*span,
"only foreign or `unsafe extern \"C\" functions may be C-variadic",
"only foreign or `unsafe extern \"C\"` functions may be C-variadic",
)
.emit();
}