commit | 48b1e1a280284766ab50720cb71a27451c8a512b | [log] [tgz] |
---|---|---|
author | Matthias Krüger <matthias.krueger@famsik.de> | Thu May 09 06:04:40 2024 +0200 |
committer | GitHub <noreply@github.com> | Thu May 09 06:04:40 2024 +0200 |
tree | 10d47ba6a33fc3857dfc987b593ee1955bafd3fe | |
parent | c49436df4c7d59af58a11b9bf30292853ef48008 [diff] | |
parent | 0ca1a94b2bd58d19a1bd492300abd5bffe5263fb [diff] |
Rollup merge of #124908 - saethlin:ref-casting_bigger_place_projection, r=fee1-dead Handle field projections like slice indexing in invalid_reference_casting r? `@Urgau` I saw the implementation in https://github.com/rust-lang/rust/pull/124761, and I was wondering if we also need to handle field access. We do. Without this PR, we get this errant diagnostic: ``` error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused --> /home/ben/rust/tests/ui/lint/reference_casting.rs:262:18 | LL | let r = &mut v.0; | --- backing allocation comes from here LL | let ptr = r as *mut i32 as *mut Vec3<i32>; | ------------------------------- casting happend here LL | unsafe { *ptr = Vec3(0, 0, 0) } | ^^^^^^^^^^^^^^^^^^^^ | = note: casting from `i32` (4 bytes) to `Vec3<i32>` (12 bytes) ```
Website | Getting started | Learn | Documentation | Contributing
This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.
Performance: Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrate with other languages.
Reliability: Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.
Productivity: Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool (Cargo), auto-formatter (rustfmt), linter (Clippy) and editor support (rust-analyzer).
Read “Installation” from The Book.
If you really want to install from source (though this is not recommended), see INSTALL.md.
See https://www.rust-lang.org/community for a list of chat platforms and forums.
See CONTRIBUTING.md.
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.
The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the “Rust Trademarks”).
If you want to use these names or brands, please read the media guide.
Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.