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

Rollup of 8 pull requests #138768

Merged
merged 18 commits into from
Mar 21, 2025
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a0c3dd4
Optimize io::Write::write_fmt for constant strings
thaliaarchi Mar 1, 2025
027423d
Fix: add ohos target notes
LuuuXXX Mar 19, 2025
b5069da
Check attrs: Don't try to retrieve the name of list stems
fmease Mar 19, 2025
0199d04
Document results of non-positive logarithms
syvb Mar 19, 2025
8f27449
make it possible to override CI/non-CI environment behaviour
onur-ozkan Mar 20, 2025
b126655
add test for `Config::is_running_on_ci`
onur-ozkan Mar 20, 2025
b5eaeaf
update completion files
onur-ozkan Mar 20, 2025
b9f59f6
interpret memory access hooks: also pass through the Pointer used for…
RalfJung Mar 19, 2025
660509d
Fix the "used_with_archive" test on Fuchsia
Jeff-A-Martin Mar 20, 2025
ff46ea8
Handle spans of `~const`, `const` and `async` trait bounds in macro …
oli-obk Mar 20, 2025
1530b03
Rollup merge of #137357 - syvb:sv/log-docs, r=tgross35
matthiaskrgr Mar 21, 2025
809378b
Rollup merge of #138650 - thaliaarchi:io-write-fmt-known, r=ibraheemdev
matthiaskrgr Mar 21, 2025
ff8738a
Rollup merge of #138694 - LuuuXXX:fix-platform-support-book, r=jieyouxu
matthiaskrgr Mar 21, 2025
7c1b128
Rollup merge of #138713 - RalfJung:memory-hook-pointers, r=oli-obk
matthiaskrgr Mar 21, 2025
1135a63
Rollup merge of #138724 - fmease:list-stems-bear-no-name, r=nnethercote
matthiaskrgr Mar 21, 2025
828f33c
Rollup merge of #138743 - onur-ozkan:override-is-ci-behaviour, r=Kobzol
matthiaskrgr Mar 21, 2025
4447953
Rollup merge of #138751 - Jeff-A-Martin:used-with-archive-test-fuchsi…
matthiaskrgr Mar 21, 2025
5ba395a
Rollup merge of #138754 - oli-obk:push-vtqtnwluyxop, r=compiler-errors
matthiaskrgr Mar 21, 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
23 changes: 22 additions & 1 deletion compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
@@ -238,6 +238,10 @@ pub trait MutVisitor: Sized {
walk_ident(self, i);
}

fn visit_modifiers(&mut self, m: &mut TraitBoundModifiers) {
walk_modifiers(self, m);
}

fn visit_path(&mut self, p: &mut Path) {
walk_path(self, p);
}
@@ -1156,12 +1160,29 @@ fn walk_trait_ref<T: MutVisitor>(vis: &mut T, TraitRef { path, ref_id }: &mut Tr
}

fn walk_poly_trait_ref<T: MutVisitor>(vis: &mut T, p: &mut PolyTraitRef) {
let PolyTraitRef { bound_generic_params, modifiers: _, trait_ref, span } = p;
let PolyTraitRef { bound_generic_params, modifiers, trait_ref, span } = p;
vis.visit_modifiers(modifiers);
bound_generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
vis.visit_trait_ref(trait_ref);
vis.visit_span(span);
}

fn walk_modifiers<V: MutVisitor>(vis: &mut V, m: &mut TraitBoundModifiers) {
let TraitBoundModifiers { constness, asyncness, polarity } = m;
match constness {
BoundConstness::Never => {}
BoundConstness::Always(span) | BoundConstness::Maybe(span) => vis.visit_span(span),
}
match asyncness {
BoundAsyncness::Normal => {}
BoundAsyncness::Async(span) => vis.visit_span(span),
}
match polarity {
BoundPolarity::Positive => {}
BoundPolarity::Negative(span) | BoundPolarity::Maybe(span) => vis.visit_span(span),
}
}

pub fn walk_field_def<T: MutVisitor>(visitor: &mut T, fd: &mut FieldDef) {
let FieldDef { span, ident, vis, id, ty, attrs, is_placeholder: _, safety, default } = fd;
visitor.visit_id(id);
3 changes: 2 additions & 1 deletion compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ use crate::errors::{LongRunning, LongRunningWarn};
use crate::fluent_generated as fluent;
use crate::interpret::{
self, AllocId, AllocInit, AllocRange, ConstAllocation, CtfeProvenance, FnArg, Frame,
GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, RangeSet, Scalar,
GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, RangeSet, Scalar,
compile_time_machine, interp_ok, throw_exhaust, throw_inval, throw_ub, throw_ub_custom,
throw_unsup, throw_unsup_format,
};
@@ -688,6 +688,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
_tcx: TyCtxtAt<'tcx>,
_machine: &mut Self,
_alloc_extra: &mut Self::AllocExtra,
_ptr: Pointer<Option<Self::Provenance>>,
(_alloc_id, immutable): (AllocId, bool),
range: AllocRange,
) -> InterpResult<'tcx> {
9 changes: 9 additions & 0 deletions compiler/rustc_const_eval/src/interpret/machine.rs
Original file line number Diff line number Diff line change
@@ -400,6 +400,8 @@ pub trait Machine<'tcx>: Sized {
) -> InterpResult<'tcx, Self::AllocExtra>;

/// Hook for performing extra checks on a memory read access.
/// `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of
/// `range`.
///
/// This will *not* be called during validation!
///
@@ -413,6 +415,7 @@ pub trait Machine<'tcx>: Sized {
_tcx: TyCtxtAt<'tcx>,
_machine: &Self,
_alloc_extra: &Self::AllocExtra,
_ptr: Pointer<Option<Self::Provenance>>,
_prov: (AllocId, Self::ProvenanceExtra),
_range: AllocRange,
) -> InterpResult<'tcx> {
@@ -432,23 +435,29 @@ pub trait Machine<'tcx>: Sized {

/// Hook for performing extra checks on a memory write access.
/// This is not invoked for ZST accesses, as no write actually happens.
/// `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of
/// `range`.
#[inline(always)]
fn before_memory_write(
_tcx: TyCtxtAt<'tcx>,
_machine: &mut Self,
_alloc_extra: &mut Self::AllocExtra,
_ptr: Pointer<Option<Self::Provenance>>,
_prov: (AllocId, Self::ProvenanceExtra),
_range: AllocRange,
) -> InterpResult<'tcx> {
interp_ok(())
}

/// Hook for performing extra operations on a memory deallocation.
/// `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of
/// the allocation.
#[inline(always)]
fn before_memory_deallocation(
_tcx: TyCtxtAt<'tcx>,
_machine: &mut Self,
_alloc_extra: &mut Self::AllocExtra,
_ptr: Pointer<Option<Self::Provenance>>,
_prov: (AllocId, Self::ProvenanceExtra),
_size: Size,
_align: Align,
13 changes: 12 additions & 1 deletion compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
@@ -385,6 +385,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
self.tcx,
&mut self.machine,
&mut alloc.extra,
ptr,
(alloc_id, prov),
size,
alloc.align,
@@ -727,6 +728,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
self.tcx,
&self.machine,
&alloc.extra,
ptr,
(alloc_id, prov),
range,
)?;
@@ -816,7 +818,14 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
if let Some((alloc_id, offset, prov, alloc, machine)) = ptr_and_alloc {
let range = alloc_range(offset, size);
if !validation_in_progress {
M::before_memory_write(tcx, machine, &mut alloc.extra, (alloc_id, prov), range)?;
M::before_memory_write(
tcx,
machine,
&mut alloc.extra,
ptr,
(alloc_id, prov),
range,
)?;
}
interp_ok(Some(AllocRefMut { alloc, range, tcx: *tcx, alloc_id }))
} else {
@@ -1373,6 +1382,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
tcx,
&self.machine,
&src_alloc.extra,
src,
(src_alloc_id, src_prov),
src_range,
)?;
@@ -1403,6 +1413,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
tcx,
extra,
&mut dest_alloc.extra,
dest,
(dest_alloc_id, dest_prov),
dest_range,
)?;
3 changes: 1 addition & 2 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
@@ -954,8 +954,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
tcx.dcx().emit_err(errors::DocAliasBadLocation { span, attr_str, location });
return;
}
let item_name = self.tcx.hir_name(hir_id);
if item_name == doc_alias {
if self.tcx.hir_opt_name(hir_id) == Some(doc_alias) {
tcx.dcx().emit_err(errors::DocAliasNotAnAlias { span, attr_str });
return;
}
3 changes: 2 additions & 1 deletion library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
@@ -710,9 +710,10 @@ impl<'a> Arguments<'a> {
}

/// Same as [`Arguments::as_str`], but will only return `Some(s)` if it can be determined at compile time.
#[unstable(feature = "fmt_internals", reason = "internal to standard library", issue = "none")]
#[must_use]
#[inline]
fn as_statically_known_str(&self) -> Option<&'static str> {
pub fn as_statically_known_str(&self) -> Option<&'static str> {
let s = self.as_str();
if core::intrinsics::is_val_statically_known(s.is_some()) { s } else { None }
}
60 changes: 60 additions & 0 deletions library/std/src/f128.rs
Original file line number Diff line number Diff line change
@@ -468,6 +468,8 @@ impl f128 {

/// Returns the natural logarithm of the number.
///
/// This returns NaN when the number is negative, and negative infinity when number is zero.
///
/// # Unspecified precision
///
/// The precision of this function is non-deterministic. This means it varies by platform,
@@ -489,6 +491,16 @@ impl f128 {
/// assert!(abs_difference <= f128::EPSILON);
/// # }
/// ```
///
/// Non-positive values:
/// ```
/// #![feature(f128)]
/// # #[cfg(reliable_f128_math)] {
///
/// assert_eq!(0_f128.ln(), f128::NEG_INFINITY);
/// assert!((-42_f128).ln().is_nan());
/// # }
/// ```
#[inline]
#[rustc_allow_incoherent_impl]
#[unstable(feature = "f128", issue = "116909")]
@@ -499,6 +511,8 @@ impl f128 {

/// Returns the logarithm of the number with respect to an arbitrary base.
///
/// This returns NaN when the number is negative, and negative infinity when number is zero.
///
/// The result might not be correctly rounded owing to implementation details;
/// `self.log2()` can produce more accurate results for base 2, and
/// `self.log10()` can produce more accurate results for base 10.
@@ -522,6 +536,16 @@ impl f128 {
/// assert!(abs_difference <= f128::EPSILON);
/// # }
/// ```
///
/// Non-positive values:
/// ```
/// #![feature(f128)]
/// # #[cfg(reliable_f128_math)] {
///
/// assert_eq!(0_f128.log(10.0), f128::NEG_INFINITY);
/// assert!((-42_f128).log(10.0).is_nan());
/// # }
/// ```
#[inline]
#[rustc_allow_incoherent_impl]
#[unstable(feature = "f128", issue = "116909")]
@@ -532,6 +556,8 @@ impl f128 {

/// Returns the base 2 logarithm of the number.
///
/// This returns NaN when the number is negative, and negative infinity when number is zero.
///
/// # Unspecified precision
///
/// The precision of this function is non-deterministic. This means it varies by platform,
@@ -551,6 +577,16 @@ impl f128 {
/// assert!(abs_difference <= f128::EPSILON);
/// # }
/// ```
///
/// Non-positive values:
/// ```
/// #![feature(f128)]
/// # #[cfg(reliable_f128_math)] {
///
/// assert_eq!(0_f128.log2(), f128::NEG_INFINITY);
/// assert!((-42_f128).log2().is_nan());
/// # }
/// ```
#[inline]
#[rustc_allow_incoherent_impl]
#[unstable(feature = "f128", issue = "116909")]
@@ -561,6 +597,8 @@ impl f128 {

/// Returns the base 10 logarithm of the number.
///
/// This returns NaN when the number is negative, and negative infinity when number is zero.
///
/// # Unspecified precision
///
/// The precision of this function is non-deterministic. This means it varies by platform,
@@ -580,6 +618,16 @@ impl f128 {
/// assert!(abs_difference <= f128::EPSILON);
/// # }
/// ```
///
/// Non-positive values:
/// ```
/// #![feature(f128)]
/// # #[cfg(reliable_f128_math)] {
///
/// assert_eq!(0_f128.log10(), f128::NEG_INFINITY);
/// assert!((-42_f128).log10().is_nan());
/// # }
/// ```
#[inline]
#[rustc_allow_incoherent_impl]
#[unstable(feature = "f128", issue = "116909")]
@@ -966,6 +1014,8 @@ impl f128 {
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
/// the operations were performed separately.
///
/// This returns NaN when `n < -1.0`, and negative infinity when `n == -1.0`.
///
/// # Unspecified precision
///
/// The precision of this function is non-deterministic. This means it varies by platform,
@@ -989,6 +1039,16 @@ impl f128 {
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
///
/// Out-of-range values:
/// ```
/// #![feature(f128)]
/// # #[cfg(reliable_f128_math)] {
///
/// assert_eq!((-1.0_f128).ln_1p(), f128::NEG_INFINITY);
/// assert!((-2.0_f128).ln_1p().is_nan());
/// # }
/// ```
#[inline]
#[doc(alias = "log1p")]
#[must_use = "method returns a new number and does not mutate the original value"]
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.