Skip to content

Conversation

zhassan-aws
Copy link
Contributor

Add core::mem:: prefix to all uses of size_of.

Background: in some cases, I get errors of the form:

   Compiling kani_core v0.58.0 (https://github.com/model-checking/kani#35015dce)
error[E0425]: cannot find function `size_of` in this scope
  --> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/35015dc/library/kani/src/lib.rs:54:1
   |
54 | kani_core::kani_lib!(kani);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
   |
   = help: consider importing one of these items:
           core::mem::size_of
           crate::core_path::intrinsics::size_of
           crate::core_path::mem::size_of
           std::mem::size_of
   = note: this error originates in the macro `kani_core::ptr_generator` which comes from the expansion of the macro `kani_core::kani_lib` (in Nightly builds, run with -Z macro-backtrace for more info)

when adding the Kani library as a dependency. Adding core::mem:: fixes those issues.

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

@zhassan-aws zhassan-aws requested a review from a team as a code owner January 16, 2025 22:43
@github-actions github-actions bot added the Z-EndToEndBenchCI Tag a PR to run benchmark CI label Jan 16, 2025
@zhassan-aws
Copy link
Contributor Author

Here are steps to reproduce this issue:

  1. cargo new --edition 2021 kani-dep
  2. cd kani-dep
  3. cargo add kani_core kani --git https://github.com/model-checking/kani
  4. cargo +nightly-2024-05-20 build
    This produces:
   Compiling proc-macro2 v1.0.93
   Compiling unicode-ident v1.0.14
   Compiling kani_macros v0.58.0 (https://github.com/model-checking/kani#35015dce)
   Compiling kani v0.58.0 (https://github.com/model-checking/kani#35015dce)
   Compiling quote v1.0.38
   Compiling syn v2.0.96
   Compiling proc-macro-error-attr2 v2.0.0
   Compiling proc-macro-error2 v2.0.1
   Compiling kani_core v0.58.0 (https://github.com/model-checking/kani#35015dce)
error[E0425]: cannot find function `size_of` in this scope
  --> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/35015dc/library/kani/src/lib.rs:54:1
   |
54 | kani_core::kani_lib!(kani);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
   |
   = help: consider importing one of these items:
           core::mem::size_of
           crate::core_path::intrinsics::size_of
           crate::core_path::mem::size_of
           std::mem::size_of
   = note: this error originates in the macro `kani_core::ptr_generator` which comes from the expansion of the macro `kani_core::kani_lib` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `size_of` in this scope
  --> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/35015dc/library/kani/src/lib.rs:54:1
   |
54 | kani_core::kani_lib!(kani);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
   |
   = help: consider importing one of these items:
           core::mem::size_of
           crate::core_path::intrinsics::size_of
           crate::core_path::mem::size_of
           std::mem::size_of
   = note: this error originates in the macro `kani_core::ptr_generator_fn` which comes from the expansion of the macro `kani_core::kani_lib` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `size_of` in this scope
  --> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/35015dc/library/kani/src/lib.rs:54:1
   |
54 | kani_core::kani_lib!(kani);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
   |
   = help: consider importing one of these items:
           core::mem::size_of
           crate::core_path::intrinsics::size_of
           crate::core_path::mem::size_of
           std::mem::size_of
   = note: this error originates in the macro `kani_core::generate_models` which comes from the expansion of the macro `kani_core::kani_lib` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: use of unstable library feature 'strict_provenance'
  --> /home/ubuntu/.cargo/git/checkouts/kani-0ce0dacf5e98886d/35015dc/library/kani/src/lib.rs:54:1
   |
54 | kani_core::kani_lib!(kani);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information
   = help: add `#![feature(strict_provenance)]` to the crate attributes to enable
   = note: this compiler was built on 2024-05-19; consider upgrading it if it is out of date
   = note: this error originates in the macro `kani_core::generate_models` which comes from the expansion of the macro `kani_core::kani_lib` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0425, E0658.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `kani` (lib) due to 8 previous errors

@zhassan-aws zhassan-aws enabled auto-merge January 16, 2025 22:47
@zhassan-aws zhassan-aws added this pull request to the merge queue Jan 16, 2025
@celinval
Copy link
Contributor

Can you add a test for this?

@zhassan-aws zhassan-aws removed this pull request from the merge queue due to a manual request Jan 16, 2025
@zhassan-aws
Copy link
Contributor Author

I added a test, although it doesn't exhibit the issue without the changes in this PR. The issues only appear with earlier toolchains (e.g. nightly-2024-05-20). The test I added ensures that adding the Kani library as a dependency works, so it's useful regardless.

@zhassan-aws zhassan-aws added this pull request to the merge queue Jan 17, 2025
Merged via the queue into model-checking:main with commit 6f70c7d Jan 17, 2025
28 checks passed
@zhassan-aws zhassan-aws deleted the size-of branch January 17, 2025 02:18
github-merge-queue bot pushed a commit that referenced this pull request Feb 6, 2025
Github generated release notes:

## What's Changed
* Automatic toolchain upgrade to nightly-2025-01-08 by @github-actions
in #3821
* Automatic cargo update to 2025-01-13 by @github-actions in
#3824
* Automatic toolchain upgrade to nightly-2025-01-09 by @github-actions
in #3825
* Bump ncipollo/release-action from 1.14.0 to 1.15.0 by @dependabot in
#3826
* Bump tests/perf/s2n-quic from `ac52a48` to `adc7ba9` by @dependabot in
#3827
* Automatic toolchain upgrade to nightly-2025-01-10 by @github-actions
in #3828
* Automatic toolchain upgrade to nightly-2025-01-11 by @github-actions
in #3830
* Verify contracts/stubs for generic types with multiple inherent
implementations by @carolynzech in
#3829
* Update Charon submodule by @thanhnguyen-aws in
#3823
* Automatic toolchain upgrade to nightly-2025-01-12 by @github-actions
in #3831
* Automatic toolchain upgrade to nightly-2025-01-13 by @github-actions
in #3833
* Upgrade toolchain to 2025-01-15 by @tautschnig in
#3835
* Automatic toolchain upgrade to nightly-2025-01-16 by @github-actions
in #3836
* Add a regression test for `no_std` feature by @carolynzech in
#3837
* Use fully-qualified name for size_of by @zhassan-aws in
#3838
* Automatic cargo update to 2025-01-20 by @github-actions in
#3842
* Bump tests/perf/s2n-quic from `adc7ba9` to `f0649f9` by @dependabot in
#3844
* Upgrade toolchain to nightly-2025-01-22 by @tautschnig in
#3843
* Remove `DefKind::Ctor` from filtering crate items by @carolynzech in
#3845
* Enable valid_ptr post_condition harnesses by @tautschnig in
#3847
* Update build command in docs to use release mode by @zhassan-aws in
#3846
* Automatic toolchain upgrade to nightly-2025-01-23 by @github-actions
in #3848
* Automatic toolchain upgrade to nightly-2025-01-24 by @github-actions
in #3850
* Remove the openssl-devel package from dependencies by @zhassan-aws in
#3852
* Fix validity checks for `char` by @celinval in
#3853
* Bump tests/perf/s2n-quic from `f0649f9` to `4500593` by @dependabot in
#3857
* Automatic cargo update to 2025-01-27 by @github-actions in
#3856
* Deprecate `--enable-unstable` and `--restrict-vtable` by @celinval in
#3859
* Stub linker to avoid missing symbols errors by @celinval in
#3858
* Toolchain upgrade to nightly-2025-01-28 by @feliperodri in
#3855
* Allow multiple annotations, but check for duplicate targets. by
@remi-delmas-3000 in #3808
* Move documentation of kani_core modules to right places by @qinheping
in #3851
* Fix missing function declaration issue by @celinval in
#3862
* Fix transmute codegen when sizes are different by @celinval in
#3861
* Remove symtab2gb from bundle by @zhassan-aws in
#3865
* Update the rustc hack for CLion / RustRover by @celinval in
#3868
* Bump tests/perf/s2n-quic from `4500593` to `82dd0b5` by @dependabot in
#3872
* Automatic cargo update to 2025-02-03 by @github-actions in
#3869
* Add reference for loop contracts by @qinheping in
#3849
* remove flag float-overflow-check by @rajath-mk in
#3873

## New Contributors
* @rajath-mk made their first contribution in
#3873

**Full Changelog**:
kani-0.58.0...kani-0.59.0



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

---------

Co-authored-by: Zyad Hassan <88045115+zhassan-aws@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-EndToEndBenchCI Tag a PR to run benchmark CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants