-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Do proper signature equality checking for tail calls #156007
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
Open
WaffleLapkin
wants to merge
4
commits into
rust-lang:main
Choose a base branch
from
WaffleLapkin:tail-call-proper-sig-eq
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
30 changes: 15 additions & 15 deletions
30
tests/ui/explicit-tail-calls/caller-lifetime-presence.stderr
This file contains hidden or 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 |
|---|---|---|
| @@ -1,32 +1,32 @@ | ||
| error: mismatched signatures | ||
| --> $DIR/caller-lifetime-presence.rs:16:5 | ||
| --> $DIR/caller-lifetime-presence.rs:19:5 | ||
| | | ||
| LL | become bar(dummy); | ||
| | ^^^^^^^^^^^^^^^^^ | ||
| LL | become bar(dummy, B); | ||
| | ^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: `become` requires caller and callee to have matching signatures | ||
| = note: caller signature: `fn(fn(&'a ()))` | ||
| = note: callee signature: `fn(for<'a> fn(&'a ()))` | ||
| = note: caller signature: `fn(fn(&'a ()), A)` | ||
| = note: callee signature: `fn(for<'a> fn(&'a ()), B)` | ||
|
|
||
| error: mismatched signatures | ||
| --> $DIR/caller-lifetime-presence.rs:28:5 | ||
| --> $DIR/caller-lifetime-presence.rs:31:5 | ||
| | | ||
| LL | become bar1(dummy2); | ||
| | ^^^^^^^^^^^^^^^^^^^ | ||
| LL | become bar2(dummy2, B); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: `become` requires caller and callee to have matching signatures | ||
| = note: caller signature: `fn(for<'a> fn(&'a ()))` | ||
| = note: callee signature: `fn(fn(&'a ()))` | ||
| = note: caller signature: `fn(for<'a> fn(&'a ()), A)` | ||
| = note: callee signature: `fn(fn(&'a ()), B)` | ||
|
|
||
| error: mismatched signatures | ||
| --> $DIR/caller-lifetime-presence.rs:40:5 | ||
| --> $DIR/caller-lifetime-presence.rs:43:5 | ||
| | | ||
| LL | become bar(dummy3); | ||
| | ^^^^^^^^^^^^^^^^^^ | ||
| LL | become bar3(dummy3, B); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: `become` requires caller and callee to have matching signatures | ||
| = note: caller signature: `fn(fn(&'static ()))` | ||
| = note: callee signature: `fn(for<'a> fn(&'a ()))` | ||
| = note: caller signature: `fn(fn(&'static ()), A)` | ||
| = note: callee signature: `fn(for<'a> fn(&'a ()), B)` | ||
|
|
||
| error: aborting due to 3 previous errors | ||
|
|
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| error: mismatched signatures | ||
| error[E0308]: mismatched types | ||
| --> $DIR/ret-ty-hr-mismatch.rs:5:5 | ||
| | | ||
| LL | become bar(); | ||
| | ^^^^^^^^^^^^ | ||
| | ^^^^^^^^^^^^ one type is more general than the other | ||
| | | ||
| = note: `become` requires caller and callee to have matching signatures | ||
| = note: caller signature: `fn() -> for<'a> fn(&'a i32)` | ||
| = note: callee signature: `fn() -> fn(&'static i32)` | ||
| = note: expected fn pointer `for<'a> fn(&'a _)` | ||
| found fn pointer `fn(&'static _)` | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0308`. |
2 changes: 1 addition & 1 deletion
2
tests/ui/explicit-tail-calls/rpit.stderr → ...i/explicit-tail-calls/rpit.current.stderr
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| // Checks that you can tail call functions with different unsafety | ||
| // | ||
| //@ check-pass | ||
| #![feature(explicit_tail_calls)] | ||
| #![expect(incomplete_features)] | ||
|
|
||
| fn a() { | ||
| unsafe { | ||
| become b(); | ||
| } | ||
| } | ||
|
|
||
| unsafe fn b() { | ||
| become c(); | ||
| } | ||
|
|
||
| fn c() {} | ||
|
|
||
| fn main() {} |
This file contains hidden or 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,28 @@ | ||
| // Check that signature comparison for tail calls allows subtyping. | ||
| // | ||
| //@ check-pass | ||
| #![expect(incomplete_features)] | ||
| #![feature(explicit_tail_calls)] | ||
|
|
||
| fn f<'short>( | ||
| a: &'static (), | ||
| b: &'short (), | ||
| c: fn(&'static ()), | ||
| d: for<'a> fn(&'a ()), | ||
| ) -> (&'short (), fn(&'static ()), for<'a> fn(&'a ())) { | ||
| become g(b, a, d, c); | ||
| } | ||
|
|
||
| fn g<'short>( | ||
| // swapped short/static | ||
| a: &'short (), | ||
| b: &'static (), | ||
| // swapped binder/non binder | ||
| c: for<'a> fn(&'a ()), | ||
| d: fn(&'static ()), | ||
| // 'short=>'static; non binder=>binder | ||
| ) -> (&'static (), for<'a> fn(&'a ()), for<'a> fn(&'a ())) { | ||
| (b, c, c) | ||
| } | ||
|
|
||
| fn main() {} |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
cc #144953
What exactly makes RPIT not work for the old trait solver?
View changes since the review
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.
I'm not quite sure (lcnr can probably explain better), but something something opaque types are more annoying to handle in the old solver and in this case they are not being revealed as their hidden type.