Skip to content

Commit 0c0c58b

Browse files
committed
Auto merge of rust-lang#146727 - matthiaskrgr:rollup-98812uj, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#146434 (c-variadic: allow c-variadic inherent and trait methods) - rust-lang#146487 (Improve `core::num` coverage) - rust-lang#146597 (Add span for struct tail recursion limit error) - rust-lang#146622 (Add regression test for issue rust-lang#91831) - rust-lang#146717 (Clean up universe evaluation during type test evaluation) - rust-lang#146723 (Include patch in release notes) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4cd91ef + 24d6259 commit 0c0c58b

Some content is hidden

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

42 files changed

+892
-128
lines changed

RELEASES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Version 1.90 (2025-09-18)
2-
==========================
1+
Version 1.90.0 (2025-09-18)
2+
===========================
33

44
<a id="1.90-Language"></a>
55

compiler/rustc_ast_passes/messages.ftl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block
6464
6565
ast_passes_bound_in_context = bounds on `type`s in {$ctx} have no effect
6666
67-
ast_passes_c_variadic_associated_function = associated functions cannot have a C variable argument list
68-
6967
ast_passes_c_variadic_bad_extern = `...` is not supported for `extern "{$abi}"` functions
7068
.label = `extern "{$abi}"` because of this
7169
.help = only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl<'a> AstValidator<'a> {
696696

697697
match fn_ctxt {
698698
FnCtxt::Foreign => return,
699-
FnCtxt::Free => match sig.header.ext {
699+
FnCtxt::Free | FnCtxt::Assoc(_) => match sig.header.ext {
700700
Extern::Implicit(_) => {
701701
if !matches!(sig.header.safety, Safety::Unsafe(_)) {
702702
self.dcx().emit_err(errors::CVariadicMustBeUnsafe {
@@ -726,11 +726,6 @@ impl<'a> AstValidator<'a> {
726726
self.dcx().emit_err(err);
727727
}
728728
},
729-
FnCtxt::Assoc(_) => {
730-
// For now, C variable argument lists are unsupported in associated functions.
731-
let err = errors::CVariadicAssociatedFunction { span: variadic_param.span };
732-
self.dcx().emit_err(err);
733-
}
734729
}
735730
}
736731

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,6 @@ pub(crate) struct ExternItemAscii {
318318
pub block: Span,
319319
}
320320

321-
#[derive(Diagnostic)]
322-
#[diag(ast_passes_c_variadic_associated_function)]
323-
pub(crate) struct CVariadicAssociatedFunction {
324-
#[primary_span]
325-
pub span: Span,
326-
}
327-
328321
#[derive(Diagnostic)]
329322
#[diag(ast_passes_c_variadic_no_extern)]
330323
#[help]

compiler/rustc_borrowck/src/handle_placeholders.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,9 @@ impl RegionTracker {
166166
}
167167
}
168168

169-
/// Determine if the tracked universes of the two SCCs are compatible.
170-
pub(crate) fn universe_compatible_with(&self, other: Self) -> bool {
171-
// HACK: We first check whether we can name the highest existential universe
172-
// of `other`. This only exists to avoid errors in case that scc already
173-
// depends on a placeholder it cannot name itself.
174-
self.max_nameable_universe().can_name(other.max_nameable_universe())
175-
|| other.reachable_placeholders.can_be_named_by(self.max_nameable_universe())
169+
/// Determine if we can name all the placeholders in `other`.
170+
pub(crate) fn can_name_all_placeholders(&self, other: Self) -> bool {
171+
other.reachable_placeholders.can_be_named_by(self.max_nameable_universe.0)
176172
}
177173

178174
/// If this SCC reaches a placeholder it can't name, return it.

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
571571
}
572572
}
573573

574-
/// Returns `true` if all the elements in the value of `scc_b` are nameable
574+
/// Returns `true` if all the placeholders in the value of `scc_b` are nameable
575575
/// in `scc_a`. Used during constraint propagation, and only once
576576
/// the value of `scc_b` has been computed.
577-
fn universe_compatible(&self, scc_b: ConstraintSccIndex, scc_a: ConstraintSccIndex) -> bool {
578-
self.scc_annotations[scc_a].universe_compatible_with(self.scc_annotations[scc_b])
577+
fn can_name_all_placeholders(
578+
&self,
579+
scc_a: ConstraintSccIndex,
580+
scc_b: ConstraintSccIndex,
581+
) -> bool {
582+
self.scc_annotations[scc_a].can_name_all_placeholders(self.scc_annotations[scc_b])
579583
}
580584

581585
/// Once regions have been propagated, this method is used to see
@@ -964,16 +968,22 @@ impl<'tcx> RegionInferenceContext<'tcx> {
964968
return true;
965969
}
966970

971+
let fr_static = self.universal_regions().fr_static;
972+
967973
// If we are checking that `'sup: 'sub`, and `'sub` contains
968974
// some placeholder that `'sup` cannot name, then this is only
969975
// true if `'sup` outlives static.
970-
if !self.universe_compatible(sub_region_scc, sup_region_scc) {
976+
//
977+
// Avoid infinite recursion if `sub_region` is already `'static`
978+
if sub_region != fr_static
979+
&& !self.can_name_all_placeholders(sup_region_scc, sub_region_scc)
980+
{
971981
debug!(
972982
"sub universe `{sub_region_scc:?}` is not nameable \
973983
by super `{sup_region_scc:?}`, promoting to static",
974984
);
975985

976-
return self.eval_outlives(sup_region, self.universal_regions().fr_static);
986+
return self.eval_outlives(sup_region, fr_static);
977987
}
978988

979989
// Both the `sub_region` and `sup_region` consist of the union

compiler/rustc_borrowck/src/type_check/canonical.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,14 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
230230
location: impl NormalizeLocation,
231231
) -> Ty<'tcx> {
232232
let tcx = self.tcx();
233+
let body = self.body;
234+
235+
let cause = ObligationCause::misc(
236+
location.to_locations().span(body),
237+
body.source.def_id().expect_local(),
238+
);
239+
233240
if self.infcx.next_trait_solver() {
234-
let body = self.body;
235241
let param_env = self.infcx.param_env;
236242
// FIXME: Make this into a real type op?
237243
self.fully_perform_op(
@@ -241,10 +247,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
241247
|ocx| {
242248
let structurally_normalize = |ty| {
243249
ocx.structurally_normalize_ty(
244-
&ObligationCause::misc(
245-
location.to_locations().span(body),
246-
body.source.def_id().expect_local(),
247-
),
250+
&cause,
248251
param_env,
249252
ty,
250253
)
@@ -253,6 +256,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
253256

254257
let tail = tcx.struct_tail_raw(
255258
ty,
259+
&cause,
256260
structurally_normalize,
257261
|| {},
258262
);
@@ -265,7 +269,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
265269
.unwrap_or_else(|guar| Ty::new_error(tcx, guar))
266270
} else {
267271
let mut normalize = |ty| self.normalize(ty, location);
268-
let tail = tcx.struct_tail_raw(ty, &mut normalize, || {});
272+
let tail = tcx.struct_tail_raw(ty, &cause, &mut normalize, || {});
269273
normalize(tail)
270274
}
271275
}

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc_abi::{BackendRepr, FieldIdx, VariantIdx};
22
use rustc_data_structures::stack::ensure_sufficient_stack;
33
use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId, ValTreeCreationError};
4+
use rustc_middle::traits::ObligationCause;
45
use rustc_middle::ty::layout::{LayoutCx, TyAndLayout};
56
use rustc_middle::ty::{self, Ty, TyCtxt};
67
use rustc_middle::{bug, mir};
@@ -196,6 +197,7 @@ fn reconstruct_place_meta<'tcx>(
196197
// Traverse the type, and update `last_valtree` as we go.
197198
let tail = tcx.struct_tail_raw(
198199
layout.ty,
200+
&ObligationCause::dummy(),
199201
|ty| ty,
200202
|| {
201203
let branches = last_valtree.unwrap_branch();

compiler/rustc_hir_typeck/src/expectation.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_middle::traits::ObligationCause;
12
use rustc_middle::ty::{self, Ty};
23
use rustc_span::Span;
34

@@ -74,8 +75,14 @@ impl<'a, 'tcx> Expectation<'tcx> {
7475
/// See the test case `test/ui/coerce-expect-unsized.rs` and #20169
7576
/// for examples of where this comes up,.
7677
pub(super) fn rvalue_hint(fcx: &FnCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
78+
let span = match ty.kind() {
79+
ty::Adt(adt_def, _) => fcx.tcx.def_span(adt_def.did()),
80+
_ => fcx.tcx.def_span(fcx.body_id),
81+
};
82+
let cause = ObligationCause::misc(span, fcx.body_id);
83+
7784
// FIXME: This is not right, even in the old solver...
78-
match fcx.tcx.struct_tail_raw(ty, |ty| ty, || {}).kind() {
85+
match fcx.tcx.struct_tail_raw(ty, &cause, |ty| ty, || {}).kind() {
7986
ty::Slice(_) | ty::Str | ty::Dynamic(..) => ExpectRvalueLikeUnsized(ty),
8087
_ => ExpectHasType(ty),
8188
}

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
424424
if !ty.references_error() {
425425
let tail = self.tcx.struct_tail_raw(
426426
ty,
427+
&self.misc(span),
427428
|ty| {
428429
if self.next_trait_solver() {
429430
self.try_structurally_resolve_type(span, ty)

0 commit comments

Comments
 (0)