Skip to content
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

Complete and replace the unsized pointer cast implementation #88

Merged
merged 2 commits into from
Apr 21, 2021

Conversation

markrtuttle
Copy link
Contributor

Resolved issues:

resolves #33 (but see below)

Description of changes:

This pull requests gives a complete implementation of casting a sized pointer to an unsized pointer. This replaces the existing code in codegen_pointer_cast for the case PointerCast::Unsize.

Warning: This required removing one test in the regression test rust-tests/cbmc-reg/Closure/main.rs. See the issue Casting unit to a trait object for a discussion of the issue.

Warning: There is still an issue described in issue #87 with the regression test motivated by the issue #33 motivating this work on codegen_pointer_cast, but the issue has moved out of codegen_pointer_cast and into codegen_misc_cast.

This replaces pull request #84

Call-outs:

Testing:

How is this change tested?

Is this a refactor change?

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

rust-tests/cbmc-reg/Closure/main.rs Show resolved Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/typ.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/typ.rs Show resolved Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@danielsn danielsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think the from_iter approach is cleaner for constructing BTrees. But otherwise, the PR looks good to go :)

// TODO: Accept a Struct type, too, and not just a StructTag assumed below.
assert!(self.is_struct_tag());

let mut types: BTreeMap<String, Type> = BTreeMap::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you decide not to do the from_iter approach?

Comment on lines +996 to +1002
let mut map: BTreeMap<String, Ty<'tcx>> = BTreeMap::new();
map.extend(
fields.iter().map(|field| {
(field.ident.name.to_string(), field.ty(self.tcx, adt_substs))
}),
);
map
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BtreeMap::from_iter(fields.iter().map(...));

@markrtuttle markrtuttle merged commit 3b366d5 into main-151-2021-04-16 Apr 21, 2021
@markrtuttle markrtuttle deleted the new-fat-pointer-mrtuttle branch April 21, 2021 16:20
adpaco-aws pushed a commit that referenced this pull request Apr 26, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request May 5, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request May 10, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request May 26, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Jun 1, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Jun 7, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Jun 17, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Jun 23, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Jul 2, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Jul 9, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Jul 15, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Jul 26, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Aug 2, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
@zhassan-aws zhassan-aws mentioned this pull request Aug 6, 2021
4 tasks
adpaco-aws pushed a commit that referenced this pull request Aug 6, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Aug 17, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
adpaco-aws pushed a commit that referenced this pull request Aug 24, 2021
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 22, 2022
…hecking#88)

* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 25, 2022
…hecking#88)

* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
…hecking#88)

* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
tedinski pushed a commit that referenced this pull request Apr 27, 2022
* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
danielsn pushed a commit to danielsn/kani that referenced this pull request May 11, 2022
…hecking#88)

* Complete and replace the unsized pointer cast implementation

* Respond to code review of unsized pointer cast implementation

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Codegen issue: Cast to fat pointer
2 participants