-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #130437 - jder:issue-130372, r=compiler-errors
Avoid crashing on variadic functions when producing arg-mismatch errors Fixes #130372 by accommodating how variadic functions change the argument list length between HIR body and FnDecls. Also degrades the zip_eq to a debug_assert! to match other asserts in the area to avoid being disruptive to users. There is at least one other crash in this area I am working on in #130400 and also considering how we might refactor some of this code to hoist some of this logic up higher. r? `@compiler-errors`
- Loading branch information
Showing
6 changed files
with
44 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![feature(c_variadic)] | ||
|
||
// Regression test that covers all 3 cases of https://github.com/rust-lang/rust/issues/130372 | ||
|
||
unsafe extern "C" fn test_va_copy(_: u64, mut ap: ...) {} | ||
|
||
pub fn main() { | ||
unsafe { | ||
test_va_copy(); | ||
//~^ ERROR this function takes at least 1 argument but 0 arguments were supplied | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0060]: this function takes at least 1 argument but 0 arguments were supplied | ||
--> $DIR/mismatch-args-vargs-issue-130372.rs:9:9 | ||
| | ||
LL | test_va_copy(); | ||
| ^^^^^^^^^^^^-- argument #1 of type `u64` is missing | ||
| | ||
note: function defined here | ||
--> $DIR/mismatch-args-vargs-issue-130372.rs:5:22 | ||
| | ||
LL | unsafe extern "C" fn test_va_copy(_: u64, mut ap: ...) {} | ||
| ^^^^^^^^^^^^ ------ | ||
help: provide the argument | ||
| | ||
LL | test_va_copy(/* u64 */); | ||
| ~~~~~~~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0060`. |