-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Tail call diagnostics to include lifetime info #145012
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
Kivooeo
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
Kivooeo:fun-problem-fun-fix
base: master
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.
+66
−1
Open
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! Regression test for: https://github.com/rust-lang/rust/issues/144957 | ||
//! | ||
//! This test ensures that lifetime information is included in diagnostics. | ||
//! | ||
//! Specifically, it checks that the `become` call produces an error with lifetimes shown | ||
//! in both caller and callee signatures. | ||
//! | ||
//! If the test fails: | ||
//! - Lifetimes may be missing (fix the diagnostic), or | ||
//! - The message format changed (update the test). | ||
|
||
#![feature(explicit_tail_calls)] | ||
#![allow(incomplete_features)] | ||
|
||
fn foo<'a>(_: fn(&'a ())) { | ||
become bar(dummy); | ||
//~^ ERROR mismatched signatures | ||
//~| NOTE `become` requires caller and callee to have matching signatures | ||
//~| NOTE caller signature: `fn(fn(&'a ()))` | ||
//~| NOTE callee signature: `fn(for<'a> fn(&'a ()))` | ||
} | ||
|
||
fn bar(_: fn(&())) {} | ||
|
||
fn dummy(_: &()) {} | ||
|
||
fn foo_(_: fn(&())) { | ||
become bar1(dummy2); | ||
//~^ ERROR mismatched signatures | ||
//~| NOTE `become` requires caller and callee to have matching signatures | ||
//~| NOTE caller signature: `fn(for<'a> fn(&'a ()))` | ||
//~| NOTE callee signature: `fn(fn(&'a ()))` | ||
} | ||
|
||
fn bar1<'a>(_: fn(&'a ())) {} | ||
|
||
fn dummy2(_: &()) {} | ||
|
||
fn main() {} |
22 changes: 22 additions & 0 deletions
22
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error: mismatched signatures | ||
--> $DIR/caller-lifetime-presence.rs:16:5 | ||
| | ||
LL | become bar(dummy); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `become` requires caller and callee to have matching signatures | ||
= note: caller signature: `fn(fn(&'a ()))` | ||
= note: callee signature: `fn(for<'a> fn(&'a ()))` | ||
|
||
error: mismatched signatures | ||
--> $DIR/caller-lifetime-presence.rs:28:5 | ||
| | ||
LL | become bar1(dummy2); | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `become` requires caller and callee to have matching signatures | ||
= note: caller signature: `fn(for<'a> fn(&'a ()))` | ||
= note: callee signature: `fn(fn(&'a ()))` | ||
|
||
error: aborting due to 2 previous errors | ||
|
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.
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 does not work for me
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.
oh, it's a binder, not an early binder. that should be liberated then probably, use
tcx.liberate_late_bound_regions
instead.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'd love to hear why current approach is not best just to learn things
Also about
'static
yes it shows, should I include this in test?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.
I did
tcx.liberate_late_bound_regions
it works but I did not found a better way to obtainDefId
rather than do thisUpdate
TailCallCkVisitor
with adding a field that will contain def idAnd create it like this
This might be a bad solution to pass
DefId
like this?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.
Hey @compiler-errors, when you have a moment, could you take another look and let me know which approach you think works better?