-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Fix ICE when late-bound lifetimes don't appear in fn signature #147631
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
Closed
+113
−19
Closed
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 was deleted.
Oops, something went wrong.
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,29 @@ | ||
| // Regression test for issue #135845 | ||
| // Ensure we don't ICE when a lifetime parameter from a function | ||
| // is incorrectly used in an expression. | ||
|
|
||
| struct S<'a, T: ?Sized>(&'a T); | ||
|
|
||
| fn b<'a>() -> S<'static, _> { | ||
| //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types | ||
| S::<'a>(&0) | ||
| } | ||
|
|
||
| fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'a _ { | ||
| //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types | ||
| let (ref y, _z): (&'a u32, u32) = (&22, 44); | ||
| *y | ||
| } | ||
|
|
||
| fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'a _ { | ||
| //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types | ||
| match *maybestr { | ||
| None => "(none)", | ||
| Some(ref s) => { | ||
| let s: &'a str = s; | ||
| s | ||
| } | ||
| } | ||
| } | ||
|
|
||
| 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,39 @@ | ||
| error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types | ||
| --> $DIR/late-bound-misuse-issue-135845.rs:7:26 | ||
| | | ||
| LL | fn b<'a>() -> S<'static, _> { | ||
| | ^ not allowed in type signatures | ||
| | | ||
| help: replace with the correct return type | ||
| | | ||
| LL - fn b<'a>() -> S<'static, _> { | ||
| LL + fn b<'a>() -> S<'_, i32> { | ||
| | | ||
|
|
||
| error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types | ||
| --> $DIR/late-bound-misuse-issue-135845.rs:12:70 | ||
| | | ||
| LL | fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'a _ { | ||
| | ^ not allowed in type signatures | ||
| | | ||
| help: replace with the correct return type | ||
| | | ||
| LL - fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &'a _ { | ||
| LL + fn static_to_a_to_static_through_ref_in_tuple<'a>(x: &'a u32) -> &u32 { | ||
| | | ||
|
|
||
| error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types | ||
| --> $DIR/late-bound-misuse-issue-135845.rs:18:54 | ||
| | | ||
| LL | fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'a _ { | ||
| | ^ not allowed in type signatures | ||
| | | ||
| help: replace with the correct return type | ||
| | | ||
| LL - fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'a _ { | ||
| LL + fn opt_str2<'a>(maybestr: &'a Option<String>) -> &str { | ||
| | | ||
|
|
||
| error: aborting due to 3 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0121`. |
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.
Hmm, so. This seems incompatible with the
closure_lifetime_binderfeature?I think we should get @lcnr's thoughts on this, on why this switch was made (and if it's appropriate to go back to calling
for_each_late_bound_region_in_itemon everything).