-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add regression tests for seemingly fixed issues #144910
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
ShoyuVanilla
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
ShoyuVanilla:add-regression-tests
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.
+73
−0
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
24 changes: 24 additions & 0 deletions
24
tests/ui/traits/const-traits/const-closure-issue-125866-error.rs
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,24 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(const_closures, const_trait_impl)] | ||
|
||
const fn create_array<const N: usize>(mut f: impl FnMut(usize) -> u32 + Copy) -> [u32; N] { | ||
let mut array = [0; N]; | ||
let mut i = 0; | ||
loop { | ||
array[i] = f(i); | ||
//~^ ERROR the trait bound `impl FnMut(usize) -> u32 + Copy: [const] FnMut(usize)` is not satisfied [E0277] | ||
i += 1; | ||
if i == N { | ||
break; | ||
} | ||
} | ||
array | ||
} | ||
|
||
fn main() { | ||
let x = create_array(const |i| 2 * i as u32); | ||
assert_eq!(x, [0, 2, 4, 6, 8]); | ||
|
||
let y = create_array(const |i| 2 * i as u32 + 1); | ||
assert_eq!(y, [1, 3, 5, 7, 9]); | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui/traits/const-traits/const-closure-issue-125866-error.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,11 @@ | ||
error[E0277]: the trait bound `impl FnMut(usize) -> u32 + Copy: [const] FnMut(usize)` is not satisfied | ||
--> $DIR/const-closure-issue-125866-error.rs:8:22 | ||
| | ||
LL | array[i] = f(i); | ||
| - ^ | ||
| | | ||
| required by a bound introduced by this call | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
25 changes: 25 additions & 0 deletions
25
tests/ui/traits/const-traits/const-closure-issue-125866-pass.rs
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,25 @@ | ||
//@ run-pass | ||
|
||
#![allow(incomplete_features)] | ||
#![feature(const_closures, const_trait_impl)] | ||
|
||
const fn create_array<const N: usize>(mut f: impl [const] FnMut(usize) -> u32 + Copy) -> [u32; N] { | ||
let mut array = [0; N]; | ||
let mut i = 0; | ||
loop { | ||
array[i] = f(i); | ||
i += 1; | ||
if i == N { | ||
break; | ||
} | ||
} | ||
array | ||
} | ||
|
||
fn main() { | ||
let x = create_array(const |i| 2 * i as u32); | ||
assert_eq!(x, [0, 2, 4, 6, 8]); | ||
|
||
let y = create_array(const |i| 2 * i as u32 + 1); | ||
assert_eq!(y, [1, 3, 5, 7, 9]); | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/ui/traits/const-traits/const-fn-trait-bound-issue-104314.rs
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,13 @@ | ||
//@ check-pass | ||
|
||
#![feature(const_trait_impl, const_destruct, const_clone)] | ||
|
||
use std::marker::Destruct; | ||
|
||
const fn f<T, F: [const] Fn(&T) -> T + [const] Destruct>(_: F) {} | ||
|
||
const fn g<T: [const] Clone>() { | ||
f(<T as Clone>::clone); | ||
} | ||
|
||
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.
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.
Why run-pass?
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.
The original example code in the issue doesn't compile due to a missing
[const]
bound. I simply thought that it would be helpful to verify that it runs correctly once that’s fixed 😅Would it make more sense to mark this with
//@ check-pass
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.
Did the ICE require codegen? If so build-pass is good, otherwise check-pass. But now this PR is in a rollup that may land soon, so let’s not modify this here.
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.
Since ICE happened before codegen,
check-pass
would be enough then. I'll fix this in another PR with other minor test fixes. Thanks for pointing this out!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.
Ok great, r me on the new PR then.