-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle C-variadic arguments properly when reporting region errors #86164
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Handle C-variadic arguments properly when reporting region errors
- Loading branch information
commit 7dccce07066ea58d7f8d1dd8462347e91e51c67a
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 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 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 @@ | ||
// Regression test for the ICE described in issue #86053. | ||
// error-pattern:unexpected `self` parameter in function | ||
// error-pattern:`...` must be the last argument of a C-variadic function | ||
// error-pattern:cannot find type `F` in this scope | ||
// error-pattern:in type `&'a &'b usize`, reference has a longer lifetime than the data it references | ||
|
||
#![feature(c_variadic)] | ||
#![crate_type="lib"] | ||
|
||
fn ordering4 < 'a , 'b > ( a : , self , self , self , | ||
self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
} | ||
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,101 @@ | ||
error: expected type, found `,` | ||
--> $DIR/issue-86053-1.rs:10:47 | ||
| | ||
LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ||
| ^ expected type | ||
|
||
error: unexpected `self` parameter in function | ||
--> $DIR/issue-86053-1.rs:10:51 | ||
| | ||
LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ||
| ^^^^ must be the first parameter of an associated function | ||
|
||
error: unexpected `self` parameter in function | ||
--> $DIR/issue-86053-1.rs:10:58 | ||
| | ||
LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ||
| ^^^^ must be the first parameter of an associated function | ||
|
||
error: unexpected `self` parameter in function | ||
--> $DIR/issue-86053-1.rs:10:67 | ||
| | ||
LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ||
| ^^^^ must be the first parameter of an associated function | ||
|
||
error: unexpected `self` parameter in function | ||
--> $DIR/issue-86053-1.rs:11:5 | ||
| | ||
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
| ^^^^ must be the first parameter of an associated function | ||
|
||
error: unexpected `self` parameter in function | ||
--> $DIR/issue-86053-1.rs:11:20 | ||
| | ||
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
| ^^^^ must be the first parameter of an associated function | ||
|
||
error: unexpected `self` parameter in function | ||
--> $DIR/issue-86053-1.rs:11:29 | ||
| | ||
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
| ^^^^ must be the first parameter of an associated function | ||
|
||
error: `...` must be the last argument of a C-variadic function | ||
--> $DIR/issue-86053-1.rs:11:12 | ||
| | ||
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
| ^^^^ | ||
|
||
error: only foreign or `unsafe extern "C"` functions may be C-variadic | ||
--> $DIR/issue-86053-1.rs:11:12 | ||
| | ||
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
| ^^^^ | ||
|
||
error: only foreign or `unsafe extern "C"` functions may be C-variadic | ||
--> $DIR/issue-86053-1.rs:11:36 | ||
| | ||
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
| ^^^^ | ||
|
||
error[E0412]: cannot find type `F` in this scope | ||
--> $DIR/issue-86053-1.rs:11:48 | ||
| | ||
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
| ^ | ||
| | ||
::: $SRC_DIR/core/src/ops/function.rs:LL:COL | ||
| | ||
LL | pub trait Fn<Args>: FnMut<Args> { | ||
| ------------------------------- similarly named trait `Fn` defined here | ||
| | ||
help: a trait with a similar name exists | ||
| | ||
LL | self , ... , self , self , ... ) where Fn : FnOnce ( & 'a & 'b usize ) { | ||
| ^^ | ||
help: you might be missing a type parameter | ||
| | ||
LL | fn ordering4 < 'a , 'b, F > ( a : , self , self , self , | ||
| ^^^ | ||
|
||
error[E0491]: in type `&'a &'b usize`, reference has a longer lifetime than the data it references | ||
--> $DIR/issue-86053-1.rs:11:52 | ||
| | ||
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the pointer is valid for the lifetime `'a` as defined on the function body at 10:16 | ||
--> $DIR/issue-86053-1.rs:10:16 | ||
| | ||
LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ||
| ^^ | ||
note: but the referenced data is only valid for the lifetime `'b` as defined on the function body at 10:21 | ||
--> $DIR/issue-86053-1.rs:10:21 | ||
| | ||
LL | fn ordering4 < 'a , 'b > ( a : , self , self , self , | ||
| ^^ | ||
|
||
error: aborting due to 12 previous errors | ||
|
||
Some errors have detailed explanations: E0412, E0491. | ||
For more information about an error, try `rustc --explain E0412`. |
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,11 @@ | ||
// Regression test for the ICE caused by the example in | ||
// /~https://github.com/rust-lang/rust/issues/86053#issuecomment-855672258 | ||
|
||
#![feature(c_variadic)] | ||
|
||
trait H<T> {} | ||
|
||
unsafe extern "C" fn ordering4<'a, F: H<&'static &'a ()>>(_: (), ...) {} | ||
//~^ ERROR: in type `&'static &'a ()`, reference has a longer lifetime than the data it references [E0491] | ||
|
||
fn main() {} |
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,16 @@ | ||
error[E0491]: in type `&'static &'a ()`, reference has a longer lifetime than the data it references | ||
--> $DIR/issue-86053-2.rs:8:39 | ||
| | ||
LL | unsafe extern "C" fn ordering4<'a, F: H<&'static &'a ()>>(_: (), ...) {} | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: the pointer is valid for the static lifetime | ||
note: but the referenced data is only valid for the lifetime `'a` as defined on the function body at 8:32 | ||
--> $DIR/issue-86053-2.rs:8:32 | ||
| | ||
LL | unsafe extern "C" fn ordering4<'a, F: H<&'static &'a ()>>(_: (), ...) {} | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0491`. |
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 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 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be formatted like this or can you run rustfmt on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't need to be, but since this is a regression test, I have tried to reproduce the example from #86053 as closely as possible (the line break had to happen in order to make
test tidy
happy).