forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#60449 - matthewjasper:impl-trait-outlives, …
…r=pnkfelix Constrain all regions in the concrete type for an opaque type `push_outlives_components` skips some regions in a type, notably the signature of a closure is ignored. Most of the time this is OK, but for opaque types the concrete type is used when checking auto-trait bounds in other functions. cc @nikomatsakis @pnkfelix Closes rust-lang#57464 Closes rust-lang#60127
- Loading branch information
Showing
6 changed files
with
129 additions
and
72 deletions.
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
19 changes: 19 additions & 0 deletions
19
src/test/ui/impl-trait/can-return-unconstrained-closure.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,19 @@ | ||
// Test that we are special casing "outlives" for opaque types. | ||
// | ||
// The return type of a closure is not required to outlive the closure. As such | ||
// the following code would not compile if we used a standard outlives check | ||
// when checking the return type, because the return type of the closure would | ||
// be `&ReEmpty i32`, and we don't allow `ReEmpty` to occur in the concrete | ||
// type used for an opaque type. | ||
// | ||
// However, opaque types are special cased to include check all regions in the | ||
// concrete type against the bound, which forces the return type to be | ||
// `&'static i32` here. | ||
|
||
// compile-pass | ||
|
||
fn make_identity() -> impl Sized { | ||
|x: &'static i32| x | ||
} | ||
|
||
fn main() {} |
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
11 changes: 0 additions & 11 deletions
11
src/test/ui/impl-trait/issue-55608-captures-empty-region.stderr
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
// Regression test for issue 57464. | ||
// | ||
// Closure are (surprisingly) allowed to outlive their signature. As such it | ||
// was possible to end up with `ReScope`s appearing in the concrete type of an | ||
// opaque type. As all regions are now required to outlive the bound in an | ||
// opaque type we avoid the issue here. | ||
|
||
// compile-pass | ||
|
||
struct A<F>(F); | ||
|
||
unsafe impl <'a, 'b, F: Fn(&'a i32) -> &'b i32> Send for A<F> {} | ||
|
||
fn wrapped_closure() -> impl Sized { | ||
let f = |x| x; | ||
f(&0); | ||
A(f) | ||
} | ||
|
||
fn main() { | ||
let x: Box<dyn Send> = Box::new(wrapped_closure()); | ||
} |
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