-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1063: Use field type from projection in encoding r=Aurel300 a=zgrannan In `mir_encoder/mod.rs` the type from a field of a closure was taken from `upvar_tys()`. However, it appears that the field does not necessarily correspond to an upvar. In particular the included test raised an internal error because obtaining the type from `upvar_tys()` returns the type of argument to `go` (i.e. `String`), rather than the type of a value returned by the closure (a variant of `ChainRequest`. It looks like the MIR already includes the field type in the `Field` projection, so this PR uses that instead. Co-authored-by: Zack Grannan <[email protected]> Co-authored-by: Aurel <[email protected]>
- Loading branch information
Showing
2 changed files
with
33 additions
and
34 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
prusti-tests/tests/verify/fail/unsupported/closure_ref_in_return.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,27 @@ | ||
pub enum TrackingId { | ||
Static(&'static str), | ||
} | ||
|
||
pub struct TrackedMsgs { | ||
pub msgs: u32, | ||
pub tracking_id: TrackingId | ||
} | ||
|
||
pub enum ChainRequest { | ||
SendMessagesAndWaitCheckTx { | ||
tracked_msgs: TrackedMsgs | ||
}, | ||
|
||
AddKey { | ||
key_name: String | ||
}, | ||
} | ||
|
||
|
||
fn go(key_name: String) -> () { | ||
|| ChainRequest::AddKey { //~ ERROR access to reference-typed fields is not supported | ||
key_name | ||
}; | ||
} | ||
|
||
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