Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f0aceed

Browse files
committedJun 22, 2024
Auto merge of #126817 - workingjubilee:rollup-0rg0k55, r=workingjubilee
Rollup of 7 pull requests Successful merges: - #126530 (Add `f16` inline ASM support for RISC-V) - #126712 (Migrate `relocation-model`, `error-writing-dependencies` and `crate-name-priority` `run-make` tests to rmake) - #126722 (Add method to get `FnAbi` of function pointer) - #126787 (Add direct accessors for memory addresses in `Machine` (for Miri)) - #126798 ([fuchsia-test-runner] Remove usage of kw_only) - #126809 (Remove stray `.` from error message) - #126811 (Add a tidy rule to check that fluent messages and attrs don't end in `.`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 10e1f5d + 1916b3d commit f0aceed

File tree

51 files changed

+412
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+412
-128
lines changed
 

‎compiler/rustc_metadata/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ metadata_rustc_lib_required =
248248
.help = try adding `extern crate rustc_driver;` at the top level of this crate
249249
250250
metadata_stable_crate_id_collision =
251-
found crates (`{$crate_name0}` and `{$crate_name1}`) with colliding StableCrateId values.
251+
found crates (`{$crate_name0}` and `{$crate_name1}`) with colliding StableCrateId values
252252
253253
metadata_std_required =
254254
`std` is required by `{$current_crate}` because it does not declare `#![no_std]`
255255
256256
metadata_symbol_conflicts_current =
257-
the current crate is indistinguishable from one of its dependencies: it has the same crate-name `{$crate_name}` and was compiled with the same `-C metadata` arguments. This will result in symbol conflicts between the two.
257+
the current crate is indistinguishable from one of its dependencies: it has the same crate-name `{$crate_name}` and was compiled with the same `-C metadata` arguments, so this will result in symbol conflicts between the two
258258
259259
metadata_target_no_std_support =
260260
the `{$locator_triple}` target may not support the standard library

‎compiler/rustc_middle/src/mir/interpret/allocation.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ pub trait AllocBytes: Clone + fmt::Debug + Deref<Target = [u8]> + DerefMut<Targe
4040
/// Gives direct access to the raw underlying storage.
4141
///
4242
/// Crucially this pointer is compatible with:
43-
/// - other pointers retunred by this method, and
43+
/// - other pointers returned by this method, and
4444
/// - references returned from `deref()`, as long as there was no write.
4545
fn as_mut_ptr(&mut self) -> *mut u8;
46+
47+
/// Gives direct access to the raw underlying storage.
48+
///
49+
/// Crucially this pointer is compatible with:
50+
/// - other pointers returned by this method, and
51+
/// - references returned from `deref()`, as long as there was no write.
52+
fn as_ptr(&self) -> *const u8;
4653
}
4754

4855
/// Default `bytes` for `Allocation` is a `Box<u8>`.
@@ -62,6 +69,11 @@ impl AllocBytes for Box<[u8]> {
6269
// Carefully avoiding any intermediate references.
6370
ptr::addr_of_mut!(**self).cast()
6471
}
72+
73+
fn as_ptr(&self) -> *const u8 {
74+
// Carefully avoiding any intermediate references.
75+
ptr::addr_of!(**self).cast()
76+
}
6577
}
6678

6779
/// This type represents an Allocation in the Miri/CTFE core engine.
@@ -490,19 +502,27 @@ impl<Prov: Provenance, Extra, Bytes: AllocBytes> Allocation<Prov, Extra, Bytes>
490502
self.provenance.clear(range, cx)?;
491503

492504
assert!(range.end().bytes_usize() <= self.bytes.len()); // need to do our own bounds-check
493-
// Cruciall, we go via `AllocBytes::as_mut_ptr`, not `AllocBytes::deref_mut`.
505+
// Crucially, we go via `AllocBytes::as_mut_ptr`, not `AllocBytes::deref_mut`.
494506
let begin_ptr = self.bytes.as_mut_ptr().wrapping_add(range.start.bytes_usize());
495507
let len = range.end().bytes_usize() - range.start.bytes_usize();
496508
Ok(ptr::slice_from_raw_parts_mut(begin_ptr, len))
497509
}
498510

499511
/// This gives direct mutable access to the entire buffer, just exposing their internal state
500-
/// without reseting anything. Directly exposes `AllocBytes::as_mut_ptr`. Only works if
512+
/// without resetting anything. Directly exposes `AllocBytes::as_mut_ptr`. Only works if
501513
/// `OFFSET_IS_ADDR` is true.
502514
pub fn get_bytes_unchecked_raw_mut(&mut self) -> *mut u8 {
503515
assert!(Prov::OFFSET_IS_ADDR);
504516
self.bytes.as_mut_ptr()
505517
}
518+
519+
/// This gives direct immutable access to the entire buffer, just exposing their internal state
520+
/// without resetting anything. Directly exposes `AllocBytes::as_ptr`. Only works if
521+
/// `OFFSET_IS_ADDR` is true.
522+
pub fn get_bytes_unchecked_raw(&self) -> *const u8 {
523+
assert!(Prov::OFFSET_IS_ADDR);
524+
self.bytes.as_ptr()
525+
}
506526
}
507527

508528
/// Reading and writing.

‎compiler/rustc_mir_build/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ mir_build_deref_raw_pointer_requires_unsafe_unsafe_op_in_unsafe_fn_allowed =
103103
.note = raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
104104
.label = dereference of raw pointer
105105
106-
mir_build_exceeds_mcdc_condition_limit = Number of conditions in decision ({$num_conditions}) exceeds limit ({$max_conditions}). MC/DC analysis will not count this expression.
106+
mir_build_exceeds_mcdc_condition_limit = number of conditions in decision ({$num_conditions}) exceeds limit ({$max_conditions}), so MC/DC analysis will not count this expression
107107
108108
mir_build_extern_static_requires_unsafe =
109109
use of extern static is unsafe and requires unsafe block
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.