forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#116435 - compiler-errors:re-erased, r=lcnr
Handle `ReErased` in responses in new solver There are legitimate cases in the compiler where we return `ReErased` for lifetimes that are uncaptured in the hidden type of an opaque. For example, in the test committed below, we ignore ignore the bivariant lifetimes of an opaque when it's inferred as the hidden type of another opaque. This may result in a `type_of(Opaque)` call returning a type that references `ReErased`. Let's handle this gracefully in the new solver. Also added a `rustc_hidden_type_of_opaques` attr to print hidden types. This seems useful for opaques. r? lcnr
- Loading branch information
Showing
12 changed files
with
100 additions
and
9 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
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
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
14 changes: 14 additions & 0 deletions
14
tests/ui/impl-trait/erased-regions-in-hidden-ty.current.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,14 @@ | ||
error: {foo<ReEarlyBound(DefId(..), 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()} | ||
--> $DIR/erased-regions-in-hidden-ty.rs:11:36 | ||
| | ||
LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static { | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: Opaque(DefId(..), [ReErased]) | ||
--> $DIR/erased-regions-in-hidden-ty.rs:17:13 | ||
| | ||
LL | fn bar() -> impl Fn() + 'static { | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
14 changes: 14 additions & 0 deletions
14
tests/ui/impl-trait/erased-regions-in-hidden-ty.next.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,14 @@ | ||
error: {foo<ReEarlyBound(DefId(..), 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()} | ||
--> $DIR/erased-regions-in-hidden-ty.rs:11:36 | ||
| | ||
LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static { | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: Opaque(DefId(..), [ReErased]) | ||
--> $DIR/erased-regions-in-hidden-ty.rs:17:13 | ||
| | ||
LL | fn bar() -> impl Fn() + 'static { | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
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,23 @@ | ||
// revisions: current next | ||
// compile-flags: -Zverbose | ||
//[next] compile-flags: -Ztrait-solver=next | ||
// normalize-stderr-test "DefId\([^\)]+\)" -> "DefId(..)" | ||
|
||
#![feature(rustc_attrs)] | ||
#![rustc_hidden_type_of_opaques] | ||
|
||
// Make sure that the compiler can handle `ReErased` in the hidden type of an opaque. | ||
|
||
fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static { | ||
//~^ ERROR 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()} | ||
// Can't write whole type because of lack of path sanitization | ||
|| () | ||
} | ||
|
||
fn bar() -> impl Fn() + 'static { | ||
//~^ ERROR , [ReErased]) | ||
// Can't write whole type because of lack of path sanitization | ||
foo(&vec![]) | ||
} | ||
|
||
fn main() {} |