-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Defer tail call ret ty equality to check_tail_calls #144915
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { | |
let BodyTy::Fn(caller_sig) = self.thir.body_type else { | ||
span_bug!( | ||
call.span, | ||
"`become` outside of functions should have been disallowed by hit_typeck" | ||
"`become` outside of functions should have been disallowed by hir_typeck" | ||
) | ||
}; | ||
|
||
|
@@ -118,21 +118,7 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { | |
} | ||
|
||
if caller_sig.inputs_and_output != callee_sig.inputs_and_output { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please also add a test that we anonymize bound vars: |
||
if caller_sig.inputs() != callee_sig.inputs() { | ||
self.report_arguments_mismatch(expr.span, caller_sig, callee_sig); | ||
} | ||
|
||
// FIXME(explicit_tail_calls): this currently fails for cases where opaques are used. | ||
// e.g. | ||
// ``` | ||
// fn a() -> impl Sized { become b() } // ICE | ||
// fn b() -> u8 { 0 } | ||
// ``` | ||
// we should think what is the expected behavior here. | ||
// (we should probably just accept this by revealing opaques?) | ||
Comment on lines
-125
to
-132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you keep this fixme? (it doesn't ICE anymore, but doesn't work either...) |
||
if caller_sig.output() != callee_sig.output() { | ||
span_bug!(expr.span, "hir typeck should have checked the return type already"); | ||
} | ||
self.report_arguments_mismatch(expr.span, caller_sig, callee_sig); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the function should probably be renamed to |
||
} | ||
|
||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![feature(explicit_tail_calls)] | ||
#![allow(incomplete_features)] | ||
|
||
fn foo() -> for<'a> fn(&'a i32) { | ||
become bar(); | ||
//~^ ERROR mismatched signatures | ||
} | ||
|
||
fn bar() -> fn(&'static i32) { | ||
dummy | ||
} | ||
|
||
fn dummy(_: &i32) {} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: mismatched signatures | ||
--> $DIR/ret-ty-hr-mismatch.rs:5:5 | ||
| | ||
LL | become bar(); | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: `become` requires caller and callee to have matching signatures | ||
= note: caller signature: `fn() -> for<'a> fn(&'a i32)` | ||
= note: callee signature: `fn() -> fn(&i32)` | ||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we not printing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we erase regions. We could print the unerased signature, but this has nothing to do with static, and it is a preexisting issue with args. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. preexisting example:
error: mismatched signatures
--> src/main.rs:5:5
|
5 | become bar(dummy);
| ^^^^^^^^^^^^^^^^^
|
= note: `become` requires caller and callee to have matching signatures
= note: caller signature: `fn(fn(&()))`
= note: callee signature: `fn(for<'a> fn(&'a ()))` There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've opened #144957 so that we don't forget to return to this at some point |
||
|
||
error: aborting due to 1 previous error | ||
|
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.
isn't the point here that the function does not diverge (as its return type is not uninhabited), but we don't have a dest?
as in, the comment was correct
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.
hm... i think i see, but in that case i would call it non-diverging