Skip to content

Commit 9e48dfe

Browse files
committed
Auto merge of rust-lang#136371 - matthiaskrgr:rollup-0b880v3, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#135840 (omit unused args warnings for intrinsics without body) - rust-lang#135900 (Manually walk into WF obligations in `BestObligation` proof tree visitor) - rust-lang#136163 (Fix off-by-one error causing slice::sort to abort the program) - rust-lang#136266 (fix broken release notes id) - rust-lang#136314 (Use proper type when applying deref adjustment in const) - rust-lang#136348 (miri: make float min/max non-deterministic) - rust-lang#136351 (Add documentation for derive(CoercePointee)) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9709af7 + 70894fe commit 9e48dfe

37 files changed

+997
-620
lines changed

RELEASES.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ Version 1.84.1 (2025-01-30)
1616
Version 1.84.0 (2025-01-09)
1717
==========================
1818

19-
<a id="
20-
Language"></a>
19+
<a id="1.84.0-Language"></a>
2120

2221
Language
2322
--------

compiler/rustc_const_eval/src/interpret/intrinsics.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
747747
{
748748
let a: F = self.read_scalar(&args[0])?.to_float()?;
749749
let b: F = self.read_scalar(&args[1])?.to_float()?;
750-
let res = self.adjust_nan(a.min(b), &[a, b]);
750+
let res = if a == b {
751+
// They are definitely not NaN (those are never equal), but they could be `+0` and `-0`.
752+
// Let the machine decide which one to return.
753+
M::equal_float_min_max(self, a, b)
754+
} else {
755+
self.adjust_nan(a.min(b), &[a, b])
756+
};
751757
self.write_scalar(res, dest)?;
752758
interp_ok(())
753759
}
@@ -762,7 +768,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
762768
{
763769
let a: F = self.read_scalar(&args[0])?.to_float()?;
764770
let b: F = self.read_scalar(&args[1])?.to_float()?;
765-
let res = self.adjust_nan(a.max(b), &[a, b]);
771+
let res = if a == b {
772+
// They are definitely not NaN (those are never equal), but they could be `+0` and `-0`.
773+
// Let the machine decide which one to return.
774+
M::equal_float_min_max(self, a, b)
775+
} else {
776+
self.adjust_nan(a.max(b), &[a, b])
777+
};
766778
self.write_scalar(res, dest)?;
767779
interp_ok(())
768780
}

compiler/rustc_const_eval/src/interpret/machine.rs

+6
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ pub trait Machine<'tcx>: Sized {
278278
F2::NAN
279279
}
280280

281+
/// Determines the result of `min`/`max` on floats when the arguments are equal.
282+
fn equal_float_min_max<F: Float>(_ecx: &InterpCx<'tcx, Self>, a: F, _b: F) -> F {
283+
// By default, we pick the left argument.
284+
a
285+
}
286+
281287
/// Called before a basic block terminator is executed.
282288
#[inline]
283289
fn before_terminator(_ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<'tcx> {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
253253
return;
254254
}
255255

256+
let mut expr_ty = self.typeck_results.borrow().expr_ty_adjusted(expr);
257+
256258
for a in &adj {
257259
match a.kind {
258260
Adjust::NeverToAny => {
@@ -266,7 +268,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
266268
None,
267269
expr.span,
268270
overloaded_deref.method_call(self.tcx),
269-
self.tcx.mk_args(&[a.target.into()]),
271+
self.tcx.mk_args(&[expr_ty.into()]),
270272
);
271273
}
272274
Adjust::Deref(None) => {
@@ -283,6 +285,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
283285
// No effects to enforce here.
284286
}
285287
}
288+
289+
expr_ty = a.target;
286290
}
287291

288292
let autoborrow_mut = adj.iter().any(|adj| {

compiler/rustc_passes/src/liveness.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,14 @@ impl<'tcx> Liveness<'_, 'tcx> {
15221522
}
15231523

15241524
fn warn_about_unused_args(&self, body: &hir::Body<'_>, entry_ln: LiveNode) {
1525+
if let Some(intrinsic) =
1526+
self.ir.tcx.intrinsic(self.ir.tcx.hir().body_owner_def_id(body.id()))
1527+
{
1528+
if intrinsic.must_be_overridden {
1529+
return;
1530+
}
1531+
}
1532+
15251533
for p in body.params {
15261534
self.check_unused_vars_in_pat(
15271535
p.pat,

compiler/rustc_trait_selection/src/solve/delegate.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::ops::Deref;
22

33
use rustc_data_structures::fx::FxHashSet;
4-
use rustc_hir::def_id::DefId;
4+
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
55
use rustc_infer::infer::canonical::query_response::make_query_region_constraints;
66
use rustc_infer::infer::canonical::{
77
Canonical, CanonicalExt as _, CanonicalQueryInput, CanonicalVarInfo, CanonicalVarValues,
@@ -98,9 +98,10 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
9898
param_env: ty::ParamEnv<'tcx>,
9999
arg: ty::GenericArg<'tcx>,
100100
) -> Option<Vec<Goal<'tcx, ty::Predicate<'tcx>>>> {
101-
crate::traits::wf::unnormalized_obligations(&self.0, param_env, arg).map(|obligations| {
102-
obligations.into_iter().map(|obligation| obligation.into()).collect()
103-
})
101+
crate::traits::wf::unnormalized_obligations(&self.0, param_env, arg, DUMMY_SP, CRATE_DEF_ID)
102+
.map(|obligations| {
103+
obligations.into_iter().map(|obligation| obligation.into()).collect()
104+
})
104105
}
105106

106107
fn clone_opaque_types_for_query_response(&self) -> Vec<(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)> {

0 commit comments

Comments
 (0)