-
Notifications
You must be signed in to change notification settings - Fork 13.4k
tests/ui
: A New Order [14/N]
#142440
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
10
commits into
rust-lang:master
Choose a base branch
from
Kivooeo:tf14
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.
Open
tests/ui
: A New Order [14/N]
#142440
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d9df2a2
deleted | issue-15924.rs
Kivooeo fee8391
moved renamed docs formatted auxiliary | issue-16822.rs
Kivooeo 44031dc
moved renamed docs stderr | issues-71798.rs
Kivooeo 4d2a26d
moved renamed docs formatted | item-name-overload.rs
Kivooeo f35659c
moved renamed docs formatted auxiliary | kinds-in-metadata.rs
Kivooeo fead493
changed issue.txt
Kivooeo a10ae04
moved renamed docs formatted stderr | kinds-of-primitive-impl.rs
Kivooeo 7fc3d3b
moved renamed docs formatted | last-use-in-block.rs
Kivooeo 926759c
moved renamed docs formatted | last-use-in-cap-clause.rs
Kivooeo 9c787a1
moved renamed docs formatted | last-use-is-capture.rs
Kivooeo 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
4 changes: 4 additions & 0 deletions
4
tests/ui/issues-71798.rs → ...it/impl-future-escaping-bound-vars-ice.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
4 changes: 2 additions & 2 deletions
4
tests/ui/issues-71798.stderr → ...mpl-future-escaping-bound-vars-ice.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! Regression test for issue #1399 | ||
//! | ||
//! This test ensures that when a variable is used (via clone) and then later | ||
//! captured by a closure, the last-use analyzer doesn't incorrectly optimize | ||
//! the earlier use as a "last use" and perform an invalid move. | ||
//! | ||
//! The sequence being tested: | ||
//! 1. Create variable `k` | ||
//! 2. Use `k.clone()` for some purpose | ||
//! 3. Later capture `k` in a closure | ||
//! | ||
//! The analyzer must not treat step 2 as the "last use" since step 3 needs `k`. | ||
//! | ||
//! See: https://github.com/rust-lang/rust/issues/1399 | ||
|
||
//@ run-pass | ||
|
||
struct A { | ||
_a: Box<isize> | ||
} | ||
|
||
pub fn main() { | ||
fn invoke<F>(f: F) | ||
where | ||
F: FnOnce() | ||
{ | ||
f(); | ||
} | ||
|
||
let k: Box<_> = 22.into(); | ||
|
||
// This clone should NOT be treated as "last use" of k | ||
// even though k is not used again until the closure | ||
let _u = A { _a: k.clone() }; | ||
|
||
// Here k is actually captured by the closure | ||
// The last-use analyzer must have accounted for this when processing the clone above | ||
invoke(|| println!("{}", k.clone())); | ||
} |
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,33 @@ | ||
//! Regression test for issue #1818 | ||
//! last-use analysis in closures should allow moves instead of requiring copies. | ||
//! | ||
//! The original issue was that the compiler incorrectly flagged certain return values | ||
//! in anonymous functions/closures as requiring copies of non-copyable values, when | ||
//! they should have been treated as moves (since they were the last use of the value). | ||
//! | ||
//! See: https://github.com/rust-lang/rust/issues/1818 | ||
|
||
//@ run-pass | ||
|
||
fn apply<T, F>(s: String, mut f: F) -> T | ||
where | ||
F: FnMut(String) -> T | ||
{ | ||
fn g<T, F>(s: String, mut f: F) -> T | ||
where | ||
F: FnMut(String) -> T | ||
{ | ||
f(s) | ||
} | ||
|
||
g(s, |v| { | ||
let r = f(v); | ||
r // This should be a move, not requiring copy | ||
}) | ||
} | ||
|
||
pub fn main() { | ||
// Actually test the functionality | ||
let result = apply(String::from("test"), |s| s.len()); | ||
assert_eq!(result, 4); | ||
} |
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,32 @@ | ||
//! Regression test for issue #1399 | ||
//! | ||
//! This test ensures that the compiler's last-use analysis correctly handles variables | ||
//! that are captured by closures (upvars). The original issue was that the analyzer | ||
//! would incorrectly optimize variable usage as "last use" and perform moves, even when | ||
//! the variable was later needed by a closure that captured it. | ||
//! | ||
//! See: https://github.com/rust-lang/rust/issues/1399 | ||
|
||
//@ run-pass | ||
|
||
struct A { | ||
_a: Box<isize> | ||
} | ||
|
||
fn foo() -> Box<dyn FnMut() -> isize + 'static> { | ||
let k: Box<_> = Box::new(22); | ||
|
||
// This use of k.clone() should not be treated as a "last use" | ||
// even though the closure below doesn't actually capture k | ||
let _u = A { _a: k.clone() }; | ||
|
||
// The closure doesn't actually use k, but the analyzer needs to handle | ||
// the potential capture scenario correctly | ||
let result = || 22; | ||
|
||
Box::new(result) | ||
} | ||
|
||
pub fn main() { | ||
assert_eq!(foo()(), 22); | ||
} |
File renamed without changes.
File renamed without changes.
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/16822 | ||
// | ||
//! ICE when using RefCell::borrow_mut() | ||
//! inside match statement with cross-crate generics. | ||
//! | ||
//! The bug occurred when: | ||
//! - A library defines a generic struct with RefCell<T> and uses borrow_mut() in match | ||
//! - Main crate implements the library trait for its own type | ||
//! - Cross-crate generic constraint causes type inference issues | ||
//! | ||
//! The problematic match statement is in the auxiliary file, this file triggers it. | ||
//! Original error: assertion failed in ty.rs:2481 during type inference. | ||
|
||
//@ run-pass | ||
//@ aux-build:cross-crate-refcell-match.rs | ||
|
||
extern crate cross_crate_refcell_match as lib; | ||
|
||
use std::cell::RefCell; | ||
|
||
struct App { | ||
i: isize, | ||
} | ||
|
||
impl lib::Update for App { | ||
fn update(&mut self) { | ||
self.i += 1; | ||
} | ||
} | ||
|
||
fn main() { | ||
let app = App { i: 5 }; | ||
let window = lib::Window { | ||
data: RefCell::new(app), | ||
}; | ||
// This specific pattern (RefCell::borrow_mut in match with cross-crate generics) | ||
// caused the ICE in the original issue | ||
window.update(1); | ||
} |
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,12 @@ | ||
//! Test that trait information (like Copy) is correctly serialized in crate metadata | ||
|
||
//@ run-pass | ||
//@ aux-build:kinds_in_metadata.rs | ||
|
||
extern crate kinds_in_metadata; | ||
|
||
use kinds_in_metadata::f; | ||
|
||
pub fn main() { | ||
f::<isize>(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
question: i mistakenly deleted issue-15924.rs (#15924) thinking it didn't reproduce the original problem. Should I restore it?
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 only reason i'm asking is because of this comment #15924 (comment), seems like there is no way to reproduce this anymore because of "new interface scheme", making the regression test potentially obsolete
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.
In general, regression tests should err on the side of sticking around. Not being able to reproduce is a good thing - but just because the code is refactored doesn't mean a new design can't hit the same problems.
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.
so preferably to keep this test?
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.
IMO a solid choice when in doubt :)
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.
sure! thanks for the answer ;)