-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix ICE in ParamConst::find_ty_from_env when handling None values #139333
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
Aditya-PS-05
wants to merge
1
commit into
rust-lang:master
from
Aditya-PS-05:fix-issue-139314-option-unwrap-none
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 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
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
15 changes: 15 additions & 0 deletions
15
tests/ui/async-await/issue-139314-option-unwrap-none-regression.rs
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,15 @@ | ||
// Test for issue #139314 | ||
// This test ensures that the compiler properly reports an error | ||
// instead of panicking with "called `Option::unwrap()` on a `None` value" | ||
// when processing async functions with const parameters. | ||
|
||
//@ edition:2018 | ||
//@ error-pattern: the trait bound | ||
|
||
async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
func(iter.map(|x| x + 1)) | ||
} | ||
|
||
fn main() { | ||
// Just make sure the function compiles, we don't need to call it | ||
} |
80 changes: 80 additions & 0 deletions
80
tests/ui/async-await/issue-139314-option-unwrap-none-regression.stderr
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,80 @@ | ||
error[E0277]: the trait bound `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-regression.rs:10:19: 10:22}>: Copy` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:10:10 | ||
| | ||
LL | func(iter.map(|x| x + 1)) | ||
| ---- ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Copy` is not implemented for `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-regression.rs:10:19: 10:22}>` | ||
note: required by a bound in `func` | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:9:40 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^ required by this bound in `func` | ||
help: consider removing this method call, as the receiver has type `T` and `T: Copy` trivially holds | ||
| | ||
LL - func(iter.map(|x| x + 1)) | ||
LL + func(iter) | ||
| | ||
|
||
error[E0277]: the trait bound `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-regression.rs:10:19: 10:22}>: Copy` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:10:5 | ||
| | ||
LL | func(iter.map(|x| x + 1)) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | ||
| | ||
= help: the trait `Copy` is not implemented for `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-regression.rs:10:19: 10:22}>` | ||
note: required by a bound in `func` | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:9:40 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^ required by this bound in `func` | ||
|
||
error[E0277]: the trait bound `impl Future<Output = impl Clone>: Clone` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:9:94 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ______________________________________________________________________________________________^ | ||
LL | | func(iter.map(|x| x + 1)) | ||
LL | | } | ||
| |_^ the trait `Clone` is not implemented for `impl Future<Output = impl Clone>` | ||
|
||
error[E0277]: the trait bound `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-regression.rs:10:19: 10:22}>: Copy` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:9:94 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ______________________________________________________________________________________________^ | ||
LL | | func(iter.map(|x| x + 1)) | ||
LL | | } | ||
| |_^ unsatisfied trait bound | ||
| | ||
= help: the trait `Copy` is not implemented for `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-regression.rs:10:19: 10:22}>` | ||
note: required by a bound in `func` | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:9:40 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^ required by this bound in `func` | ||
|
||
error[E0277]: the trait bound `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-regression.rs:10:19: 10:22}>: Copy` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:9:1 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | ||
| | ||
= help: the trait `Copy` is not implemented for `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-regression.rs:10:19: 10:22}>` | ||
note: required by a bound in `func` | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:9:40 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^ required by this bound in `func` | ||
|
||
error[E0277]: the trait bound `impl Future<Output = impl Clone>: Clone` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-regression.rs:9:74 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future<Output = impl Clone>` | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
16 changes: 16 additions & 0 deletions
16
tests/ui/async-await/issue-139314-option-unwrap-none-test.rs
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 @@ | ||
// Test for issue #139314 | ||
// This test ensures that the compiler doesn't panic with | ||
// "called `Option::unwrap()` on a `None` value" when processing | ||
// async functions with const parameters. | ||
|
||
//@ edition:2018 | ||
//@ error-pattern: the trait bound | ||
|
||
// This is a simplified version of the test case that caused the ICE | ||
async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
func(iter.map(|x| x + 1)) | ||
} | ||
|
||
fn main() { | ||
// Just make sure the function compiles, we don't need to call it | ||
} |
80 changes: 80 additions & 0 deletions
80
tests/ui/async-await/issue-139314-option-unwrap-none-test.stderr
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,80 @@ | ||
error[E0277]: the trait bound `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-test.rs:11:19: 11:22}>: Copy` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:11:10 | ||
| | ||
LL | func(iter.map(|x| x + 1)) | ||
| ---- ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Copy` is not implemented for `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-test.rs:11:19: 11:22}>` | ||
note: required by a bound in `func` | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:10:40 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^ required by this bound in `func` | ||
help: consider removing this method call, as the receiver has type `T` and `T: Copy` trivially holds | ||
| | ||
LL - func(iter.map(|x| x + 1)) | ||
LL + func(iter) | ||
| | ||
|
||
error[E0277]: the trait bound `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-test.rs:11:19: 11:22}>: Copy` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:11:5 | ||
| | ||
LL | func(iter.map(|x| x + 1)) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | ||
| | ||
= help: the trait `Copy` is not implemented for `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-test.rs:11:19: 11:22}>` | ||
note: required by a bound in `func` | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:10:40 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^ required by this bound in `func` | ||
|
||
error[E0277]: the trait bound `impl Future<Output = impl Clone>: Clone` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:10:94 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ______________________________________________________________________________________________^ | ||
LL | | func(iter.map(|x| x + 1)) | ||
LL | | } | ||
| |_^ the trait `Clone` is not implemented for `impl Future<Output = impl Clone>` | ||
|
||
error[E0277]: the trait bound `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-test.rs:11:19: 11:22}>: Copy` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:10:94 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ______________________________________________________________________________________________^ | ||
LL | | func(iter.map(|x| x + 1)) | ||
LL | | } | ||
| |_^ unsatisfied trait bound | ||
| | ||
= help: the trait `Copy` is not implemented for `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-test.rs:11:19: 11:22}>` | ||
note: required by a bound in `func` | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:10:40 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^ required by this bound in `func` | ||
|
||
error[E0277]: the trait bound `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-test.rs:11:19: 11:22}>: Copy` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:10:1 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | ||
| | ||
= help: the trait `Copy` is not implemented for `Map<T, {closure@$DIR/issue-139314-option-unwrap-none-test.rs:11:19: 11:22}>` | ||
note: required by a bound in `func` | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:10:40 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^ required by this bound in `func` | ||
|
||
error[E0277]: the trait bound `impl Future<Output = impl Clone>: Clone` is not satisfied | ||
--> $DIR/issue-139314-option-unwrap-none-test.rs:10:74 | ||
| | ||
LL | async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
| ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future<Output = impl Clone>` | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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,15 @@ | ||
// Test for issue #139314 | ||
// This test ensures that the compiler doesn't panic with | ||
// "called `Option::unwrap()` on a `None` value" when processing | ||
// async functions with const parameters. | ||
|
||
//@ edition:2018 | ||
//@ error-pattern: the trait bound | ||
|
||
async fn func<T: Iterator<Item = u8> + Copy, const N: usize>(iter: T) -> impl for<'a1> Clone { | ||
func(iter.map(|x| x + 1)) | ||
} | ||
|
||
fn main() { | ||
// Just make sure the function compiles, we don't need to call it | ||
} |
Oops, something went wrong.
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.
This is the opposite of our usual conventions: we do not qualify the unwrapping function in its name, instead we qualify the Option-returning variant of a function as
try
, for atry_something
.