Skip to content

Rollup of 15 pull requests #143853

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

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4c94798
random: Add comment on `RandomSource::fill_bytes` about multiple calls
joshtriplett Jul 9, 2025
8d0e0c6
interpret/allocation: expose init + write_wildcards on a range
nia-e Jul 8, 2025
e681d1a
constify `From` and `Into`
oli-obk Jul 11, 2025
0748462
std: move NuttX to use arc4random for random number generation
no1wudi Jul 11, 2025
7ad30cc
Some const_trait_impl test cleanups
oli-obk Jul 11, 2025
120c9fc
Disambiguate between rustc vs std having debug assertions
jieyouxu Jul 11, 2025
33e6962
Fix std debug assertions gate in `fmt-write-boat`
jieyouxu Jul 11, 2025
1a28fb8
Update sysinfo version to `0.36.0`
GuillaumeGomez Jul 11, 2025
2f05fa6
Fix ICE for parsed attributes with longer path not handled by CheckAt…
JonathanBrouwer Jul 11, 2025
cdbe44d
Use short command method directly from fingerprint
Shourya742 Jul 11, 2025
0c81bf8
fix PartialEq const feature name and const_cmp tracking issue
RalfJung Jul 11, 2025
b94083e
fix const_ops tracking issue
RalfJung Jul 11, 2025
d004abb
remove format short command and push format short command method insi…
Shourya742 Jul 11, 2025
5e20385
random: Provide a `Distribution<T>` trait
joshtriplett Jul 9, 2025
900aa00
Update miri for change to random API
joshtriplett Jul 11, 2025
3751e13
slice: Mark `rotate_left`, `rotate_right` unstably const
okaneco Jul 6, 2025
507fd38
htmldocck: better error messages for negative raw directives
lolbinarycat Jul 11, 2025
0528cc9
Access `wasi_sdk_path` instead of reading environment variable in boo…
Kobzol Jul 11, 2025
b0e4c35
./x test miri: fix cleaning the miri_ui directory
RalfJung Jul 12, 2025
33668c1
Remove outdated debugger version warning
jieyouxu Jul 5, 2025
832b627
Move `string_enum` to `util` module
jieyouxu Jul 12, 2025
b4dfd51
Do not allow defaults for `Mode` and `Config`
jieyouxu Jul 12, 2025
4aad9ab
Rename `Mode` to `TestMode`
jieyouxu Jul 12, 2025
b9ae117
Do not glob-reexport `TestMode` variants
jieyouxu Jul 12, 2025
6f8a7f0
Make rustdoc-gui-test dummy compiletest config purpose explicit
jieyouxu Jul 12, 2025
d0259aa
Rollup merge of #143554 - okaneco:const_slice_rotate, r=Amanieu,tgross35
jhpratt Jul 12, 2025
bf22a09
Rollup merge of #143634 - nia-e:init-and-wildcards, r=RalfJung
jhpratt Jul 12, 2025
4c36374
Rollup merge of #143710 - joshtriplett:random-updates, r=Amanieu
jhpratt Jul 12, 2025
c374b03
Rollup merge of #143774 - oli-obk:const_from, r=fee1-dead
jhpratt Jul 12, 2025
3a7afe4
Rollup merge of #143776 - no1wudi:fix, r=tgross35
jhpratt Jul 12, 2025
47f1ddc
Rollup merge of #143778 - oli-obk:const-cleanup, r=fee1-dead
jhpratt Jul 12, 2025
e138a07
Rollup merge of #143782 - jieyouxu:debug-assertions, r=ChrisDenton
jhpratt Jul 12, 2025
2e8c97c
Rollup merge of #143791 - GuillaumeGomez:update-sysinfo, r=jieyouxu
jhpratt Jul 12, 2025
265df11
Rollup merge of #143796 - JonathanBrouwer:fix-builtin-attribute-prefi…
jhpratt Jul 12, 2025
d06b79f
Rollup merge of #143798 - Shourya742:2025-07-11-remove-format-short-c…
jhpratt Jul 12, 2025
d1aa1e8
Rollup merge of #143803 - RalfJung:const-trait-tracking, r=compiler-e…
jhpratt Jul 12, 2025
424dad0
Rollup merge of #143814 - lolbinarycat:htmldocck-negative-err, r=fmease
jhpratt Jul 12, 2025
f5faf81
Rollup merge of #143817 - Kobzol:wasi-sdk-path, r=jieyouxu
jhpratt Jul 12, 2025
3aad16b
Rollup merge of #143822 - RalfJung:miri-ui-clean, r=jieyouxu
jhpratt Jul 12, 2025
f223ade
Rollup merge of #143823 - jieyouxu:compiletest-maintenance-5, r=Kobzol
jhpratt Jul 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4349,6 +4349,7 @@ dependencies = [
"rustc_ast_lowering",
"rustc_ast_pretty",
"rustc_attr_data_structures",
"rustc_attr_parsing",
"rustc_data_structures",
"rustc_errors",
"rustc_expand",
Expand Down Expand Up @@ -5230,9 +5231,9 @@ dependencies = [

[[package]]
name = "sysinfo"
version = "0.35.2"
version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3ffa3e4ff2b324a57f7aeb3c349656c7b127c3c189520251a648102a92496e"
checksum = "aab138f5c1bb35231de19049060a87977ad23e04f2303e953bc5c2947ac7dec4"
dependencies = [
"libc",
"objc2-core-foundation",
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,11 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
attributes
}

/// Returns whether there is a parser for an attribute with this name
pub fn is_parsed_attribute(path: &[Symbol]) -> bool {
Late::parsers().0.contains_key(path)
}

fn lower_attr_args(&self, args: &ast::AttrArgs, lower_span: impl Fn(Span) -> Span) -> AttrArgs {
match args {
ast::AttrArgs::Empty => AttrArgs::Empty,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
dest_alloc
.write_uninit(&tcx, dest_range)
.map_err(|e| e.to_interp_error(dest_alloc_id))?;
// We can forget about the provenance, this is all not initialized anyway.
// `write_uninit` also resets the provenance, so we are done.
return interp_ok(());
}

Expand Down
33 changes: 15 additions & 18 deletions compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ pub struct Allocation<Prov: Provenance = CtfeProvenance, Extra = (), Bytes = Box
/// at the given offset.
provenance: ProvenanceMap<Prov>,
/// Denotes which part of this allocation is initialized.
///
/// Invariant: the uninitialized parts have no provenance.
init_mask: InitMask,
/// The alignment of the allocation to detect unaligned reads.
/// (`Align` guarantees that this is a power of two.)
Expand Down Expand Up @@ -796,24 +798,19 @@ impl<Prov: Provenance, Extra, Bytes: AllocBytes> Allocation<Prov, Extra, Bytes>
Ok(())
}

/// Initialize all previously uninitialized bytes in the entire allocation, and set
/// provenance of everything to `Wildcard`. Before calling this, make sure all
/// provenance in this allocation is exposed!
pub fn prepare_for_native_access(&mut self) {
let full_range = AllocRange { start: Size::ZERO, size: Size::from_bytes(self.len()) };
// Overwrite uninitialized bytes with 0, to ensure we don't leak whatever their value happens to be.
for chunk in self.init_mask.range_as_init_chunks(full_range) {
if !chunk.is_init() {
let uninit_bytes = &mut self.bytes
[chunk.range().start.bytes_usize()..chunk.range().end.bytes_usize()];
uninit_bytes.fill(0);
}
}
// Mark everything as initialized now.
self.mark_init(full_range, true);

// Set provenance of all bytes to wildcard.
self.provenance.write_wildcards(self.len());
/// Mark all bytes in the given range as initialised and reset the provenance
/// to wildcards. This entirely breaks the normal mechanisms for tracking
/// initialisation and is only provided for Miri operating in native-lib
/// mode. UB will be missed if the underlying bytes were not actually written to.
///
/// If `range` is `None`, defaults to performing this on the whole allocation.
pub fn process_native_write(&mut self, cx: &impl HasDataLayout, range: Option<AllocRange>) {
let range = range.unwrap_or_else(|| AllocRange {
start: Size::ZERO,
size: Size::from_bytes(self.len()),
});
self.mark_init(range, true);
self.provenance.write_wildcards(cx, range);
}

/// Remove all provenance in the given memory range.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,37 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
Ok(())
}

/// Overwrites all provenance in the allocation with wildcard provenance.
/// Overwrites all provenance in the given range with wildcard provenance.
/// Pointers partially overwritten will have their provenances preserved
/// bytewise on their remaining bytes.
///
/// Provided for usage in Miri and panics otherwise.
pub fn write_wildcards(&mut self, alloc_size: usize) {
pub fn write_wildcards(&mut self, cx: &impl HasDataLayout, range: AllocRange) {
assert!(
Prov::OFFSET_IS_ADDR,
"writing wildcard provenance is not supported when `OFFSET_IS_ADDR` is false"
);
let wildcard = Prov::WILDCARD.unwrap();

// Remove all pointer provenances, then write wildcards into the whole byte range.
self.ptrs.clear();
let last = Size::from_bytes(alloc_size);
let bytes = self.bytes.get_or_insert_with(Box::default);
for offset in Size::ZERO..last {

// Remove pointer provenances that overlap with the range, then readd the edge ones bytewise.
let ptr_range = Self::adjusted_range_ptrs(range, cx);
let ptrs = self.ptrs.range(ptr_range.clone());
if let Some((offset, prov)) = ptrs.first() {
for byte_ofs in *offset..range.start {
bytes.insert(byte_ofs, *prov);
}
}
if let Some((offset, prov)) = ptrs.last() {
for byte_ofs in range.end()..*offset + cx.data_layout().pointer_size() {
bytes.insert(byte_ofs, *prov);
}
}
self.ptrs.remove_range(ptr_range);

// Overwrite bytewise provenance.
for offset in range.start..range.end() {
bytes.insert(offset, wildcard);
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_passes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rustc_ast = { path = "../rustc_ast" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" }
Expand Down
11 changes: 10 additions & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

use std::cell::Cell;
use std::collections::hash_map::Entry;
use std::slice;

use rustc_abi::{Align, ExternAbi, Size};
use rustc_ast::{AttrStyle, LitKind, MetaItemInner, MetaItemKind, ast};
use rustc_attr_data_structures::{AttributeKind, InlineAttr, ReprAttr, find_attr};
use rustc_attr_parsing::{AttributeParser, Late};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{Applicability, DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey};
use rustc_feature::{AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute};
Expand Down Expand Up @@ -384,11 +386,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| sym::custom_mir,
..
] => {}
[name, ..] => {
[name, rest@..] => {
match BUILTIN_ATTRIBUTE_MAP.get(name) {
// checked below
Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {}
Some(_) => {
if rest.len() > 0 && AttributeParser::<Late>::is_parsed_attribute(slice::from_ref(name)) {
// Check if we tried to use a builtin attribute as an attribute namespace, like `#[must_use::skip]`.
// This check is here to solve https://github.com/rust-lang/rust/issues/137590
// An error is already produced for this case elsewhere
continue
}

// FIXME: differentiate between unstable and internal attributes just
// like we do with features instead of just accepting `rustc_`
// attributes by name. That should allow trimming the above list, too.
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ use crate::ops::ControlFlow;
)]
#[rustc_diagnostic_item = "PartialEq"]
#[const_trait]
#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
/// Tests for `self` and `other` values to be equal, and is used by `==`.
#[must_use]
Expand Down Expand Up @@ -1809,7 +1809,7 @@ mod impls {
macro_rules! partial_eq_impl {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const PartialEq for $t {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
Expand Down Expand Up @@ -2017,7 +2017,7 @@ mod impls {
// & pointers

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &A
where
A: ~const PartialEq<B>,
Expand Down Expand Up @@ -2089,7 +2089,7 @@ mod impls {
// &mut pointers

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&mut B> for &mut A
where
A: ~const PartialEq<B>,
Expand Down Expand Up @@ -2159,7 +2159,7 @@ mod impls {
impl<A: PointeeSized> Eq for &mut A where A: Eq {}

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&mut B> for &A
where
A: ~const PartialEq<B>,
Expand All @@ -2175,7 +2175,7 @@ mod impls {
}

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "92391")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &mut A
where
A: ~const PartialEq<B>,
Expand Down
29 changes: 21 additions & 8 deletions library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ pub trait AsMut<T: PointeeSized>: PointeeSized {
#[rustc_diagnostic_item = "Into"]
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(search_unbox)]
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
#[const_trait]
pub trait Into<T>: Sized {
/// Converts this type into the (usually inferred) input type.
#[must_use]
Expand Down Expand Up @@ -580,6 +582,8 @@ pub trait Into<T>: Sized {
note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix",
))]
#[doc(search_unbox)]
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
#[const_trait]
pub trait From<T>: Sized {
/// Converts to this type from the input type.
#[rustc_diagnostic_item = "from_fn"]
Expand Down Expand Up @@ -607,6 +611,8 @@ pub trait From<T>: Sized {
/// [`Into`], see there for details.
#[rustc_diagnostic_item = "TryInto"]
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
#[const_trait]
pub trait TryInto<T>: Sized {
/// The type returned in the event of a conversion error.
#[stable(feature = "try_from", since = "1.34.0")]
Expand Down Expand Up @@ -685,6 +691,8 @@ pub trait TryInto<T>: Sized {
/// [`try_from`]: TryFrom::try_from
#[rustc_diagnostic_item = "TryFrom"]
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
#[const_trait]
pub trait TryFrom<T>: Sized {
/// The type returned in the event of a conversion error.
#[stable(feature = "try_from", since = "1.34.0")]
Expand Down Expand Up @@ -754,9 +762,10 @@ where

// From implies Into
#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U> Into<U> for T
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
impl<T, U> const Into<U> for T
where
U: From<T>,
U: ~const From<T>,
{
/// Calls `U::from(self)`.
///
Expand All @@ -771,7 +780,8 @@ where

// From (and thus Into) is reflexive
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> From<T> for T {
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
impl<T> const From<T> for T {
/// Returns the argument unchanged.
#[inline(always)]
fn from(t: T) -> T {
Expand All @@ -787,17 +797,19 @@ impl<T> From<T> for T {
#[stable(feature = "convert_infallible", since = "1.34.0")]
#[rustc_reservation_impl = "permitting this impl would forbid us from adding \
`impl<T> From<!> for T` later; see rust-lang/rust#64715 for details"]
impl<T> From<!> for T {
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
impl<T> const From<!> for T {
fn from(t: !) -> T {
t
}
}

// TryFrom implies TryInto
#[stable(feature = "try_from", since = "1.34.0")]
impl<T, U> TryInto<U> for T
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
impl<T, U> const TryInto<U> for T
where
U: TryFrom<T>,
U: ~const TryFrom<T>,
{
type Error = U::Error;

Expand All @@ -810,9 +822,10 @@ where
// Infallible conversions are semantically equivalent to fallible conversions
// with an uninhabited error type.
#[stable(feature = "try_from", since = "1.34.0")]
impl<T, U> TryFrom<U> for T
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
impl<T, U> const TryFrom<U> for T
where
U: Into<T>,
U: ~const Into<T>,
{
type Error = Infallible;

Expand Down
Loading
Loading