-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Tracking Issue for NUL-terminated file names with #[track_caller]
#141727
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
As a possible user of the feature, returning The only minor nuisance of storing a |
We need to store the length anyway for |
https://lore.kernel.org/qemu-devel/20250530080307.2055502-1-pbonzini@redhat.com --- From: Paolo Bonzini <pbonzini@redhat.com> To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org Subject: [PATCH v2 00/14] rust: bindings for Error Date: Fri, 30 May 2025 10:02:52 +0200 Message-ID: <20250530080307.2055502-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.902, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org As explained for v1, the impetus for this series is to remove BqlCell<> from HPETState::num_timers. However, it's also an important step for QAPI: error propagation is pretty central for example to QMP, and the series is also a first example of two-way conversion between C and native-Rust structs (i.e. not using bindgen-generated structs or their opaque wrappers). As an aside, support for NUL-terminated file is now scheduled for inclusion in Rust as "panic::Location::file_with_nul()", but it will be quite a while before QEMU can use it. For more information, see rust-lang/rust#141727. Paolo v1->v2: - patch "rust: make declaration of dependent crates more consistent" merged - change dependency name for anyhow to anyhow-1-rs - update scripts/archive-source.sh and scripts/make-release [Zhao] - update foreign to 0.3.1 instead of 0.2.0 - use %.*s to print non-NUL-terminated err->src [Markus] - make err->src_len an int instead of a size_t [Markus] - add doc comment for error module - remove #[derive(Default)] for Error [Markus] - rewrite ok_or_propagate in functional style [Markus] - clarify "validity" of Error** [Markus] - clarify that err_or_unit/err_or_else free the Error* [Markus] new patches: - hpet: adjust VMState for consistency with Rust version [Zhao] - rust: qemu-api: add tests for Error bindings - docs: update Rust module status Paolo Bonzini (13): subprojects: add the anyhow crate subprojects: add the foreign crate util/error: expose Error definition to Rust code util/error: allow non-NUL-terminated err->src util/error: make func optional rust: qemu-api: add bindings to Error rust: qemu-api: add tests for Error bindings rust: qdev: support returning errors from realize rust/hpet: change type of num_timers to usize hpet: adjust VMState for consistency with Rust version hpet: return errors from realize if properties are incorrect rust/hpet: return errors from realize if properties are incorrect docs: update Rust module status Zhao Liu (1): rust/hpet: Drop BqlCell wrapper for num_timers docs/devel/rust.rst | 2 +- include/qapi/error-internal.h | 27 ++ rust/wrapper.h | 1 + hw/timer/hpet.c | 21 +- util/error.c | 20 +- rust/Cargo.lock | 17 + rust/Cargo.toml | 1 + rust/hw/char/pl011/src/device.rs | 5 +- rust/hw/timer/hpet/src/device.rs | 62 ++- rust/hw/timer/hpet/src/fw_cfg.rs | 7 +- rust/meson.build | 4 + rust/qemu-api/Cargo.toml | 2 + rust/qemu-api/meson.build | 3 +- rust/qemu-api/src/error.rs | 403 ++++++++++++++++++ rust/qemu-api/src/lib.rs | 3 + rust/qemu-api/src/qdev.rs | 10 +- scripts/archive-source.sh | 5 +- scripts/make-release | 5 +- subprojects/.gitignore | 2 + subprojects/anyhow-1-rs.wrap | 7 + subprojects/foreign-0.3-rs.wrap | 7 + .../packagefiles/anyhow-1.0-rs/meson.build | 33 ++ .../packagefiles/foreign-0.3-rs/meson.build | 26 ++ 23 files changed, 602 insertions(+), 71 deletions(-) create mode 100644 include/qapi/error-internal.h create mode 100644 rust/qemu-api/src/error.rs create mode 100644 subprojects/anyhow-1-rs.wrap create mode 100644 subprojects/foreign-0.3-rs.wrap create mode 100644 subprojects/packagefiles/anyhow-1.0-rs/meson.build create mode 100644 subprojects/packagefiles/foreign-0.3-rs/meson.build -- 2.49.0 Signed-off-by: GitHub Actions Bot <bot@github.com>
Add Location::file_with_nul This is useful for C/C++ APIs which expect the const char* returned from __FILE__ or std::source_location::file_name. ACP: rust-lang/libs-team#466 Tracking issue: #141727
Add Location::file_with_nul This is useful for C/C++ APIs which expect the const char* returned from __FILE__ or std::source_location::file_name. ACP: rust-lang/libs-team#466 Tracking issue: #141727
Uh oh!
There was an error while loading. Please reload this page.
Feature gate:
#![feature(location_file_nul)]
This is a tracking issue for
Location::file_with_nul
.This feature allows you to obtain NUL-terminated file names from
core::panic::Location
when using#[track_caller]
. This allows for better error messages in projects performing interop with C/C++.Public API
Steps / History
(Remember to update the
S-tracking-*
label when checking boxes.)core::panic::Location::file
libs-team#466Related PRs:
core::panic::Location
file strings #117431Unresolved Questions
It's still unresolved whether the above API is preferred over returning a raw pointer:
Although this solution is less safe to use, it has the advantage that if we change
Location
to not store the length, then you can callLocation::file_ptr
without having to invokestrlen
to construct a&CStr
.Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: