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

Use fully-qualified name for size_of #3838

Merged
merged 2 commits into from
Jan 17, 2025

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-BenchCI 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-BenchCI Tag a PR to run benchmark CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants