Skip to content

Commit b45dd71

Browse files
committedApr 30, 2025
Auto merge of #140529 - matthiaskrgr:rollup-jpaa2ky, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #140385 (Subtree update of `rust-analyzer`) - #140458 (Fix for async drop ice with partly dropped tuple) - #140465 (chore: edit and move tests) - #140467 (Don't FCW assoc consts in patterns) - #140468 (Minor tweaks to make some normalization (adjacent) code less confusing) - #140470 (CI: rfl: move job forward to Linux v6.15-rc4) - #140476 (chore: delete unused ui/auxiliary crates) - #140481 (Require sanitizers be enabled for asan_odr_windows.rs) - #140486 (rustfmt: Also allow bool literals as first item of let chain) - #140494 (Parser: Document restrictions) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 251cda5 + a477172 commit b45dd71

File tree

896 files changed

+33319
-39602
lines changed

Some content is hidden

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

896 files changed

+33319
-39602
lines changed
 

‎compiler/rustc_hir_typeck/src/writeback.rs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
// Type resolution: the phase that finds all the types in the AST with
2-
// unresolved type variables and replaces "ty_var" types with their
3-
// generic parameters.
1+
//! During type inference, partially inferred terms are
2+
//! represented using inference variables (ty::Infer). These don't appear in
3+
//! the final [`ty::TypeckResults`] since all of the types should have been
4+
//! inferred once typeck is done.
5+
//!
6+
//! When type inference is running however, having to update the typeck results
7+
//! every time a new type is inferred would be unreasonably slow, so instead all
8+
//! of the replacement happens at the end in [`FnCtxt::resolve_type_vars_in_body`],
9+
//! which creates a new `TypeckResults` which doesn't contain any inference variables.
410
511
use std::mem;
612

@@ -26,15 +32,6 @@ use crate::FnCtxt;
2632
///////////////////////////////////////////////////////////////////////////
2733
// Entry point
2834

29-
// During type inference, partially inferred types are
30-
// represented using Type variables (ty::Infer). These don't appear in
31-
// the final TypeckResults since all of the types should have been
32-
// inferred once typeck is done.
33-
// When type inference is running however, having to update the typeck
34-
// typeck results every time a new type is inferred would be unreasonably slow,
35-
// so instead all of the replacement happens at the end in
36-
// resolve_type_vars_in_body, which creates a new TypeTables which
37-
// doesn't contain any inference types.
3835
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3936
pub(crate) fn resolve_type_vars_in_body(
4037
&self,
@@ -89,14 +86,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8986
}
9087
}
9188

92-
///////////////////////////////////////////////////////////////////////////
93-
// The Writeback context. This visitor walks the HIR, checking the
94-
// fn-specific typeck results to find references to types or regions. It
95-
// resolves those regions to remove inference variables and writes the
96-
// final result back into the master typeck results in the tcx. Here and
97-
// there, it applies a few ad-hoc checks that were not convenient to
98-
// do elsewhere.
99-
89+
/// The Writeback context. This visitor walks the HIR, checking the
90+
/// fn-specific typeck results to find inference variables. It resolves
91+
/// those inference variables and writes the final result into the
92+
/// `TypeckResults`. It also applies a few ad-hoc checks that were not
93+
/// convenient to do elsewhere.
10094
struct WritebackCx<'cx, 'tcx> {
10195
fcx: &'cx FnCtxt<'cx, 'tcx>,
10296

@@ -877,7 +871,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
877871
let cause = ObligationCause::misc(self.span.to_span(tcx), body_id);
878872
let at = self.fcx.at(&cause, self.fcx.param_env);
879873
let universes = vec![None; outer_exclusive_binder(value).as_usize()];
880-
match solve::deeply_normalize_with_skipped_universes_and_ambiguous_goals(
874+
match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals(
881875
at, value, universes,
882876
) {
883877
Ok((value, goals)) => {

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,16 @@ impl<'tcx> TyCtxt<'tcx> {
115115
// @lcnr believes that successfully evaluating even though there are
116116
// used generic parameters is a bug of evaluation, so checking for it
117117
// here does feel somewhat sensible.
118-
if !self.features().generic_const_exprs() && ct.args.has_non_region_param() {
119-
let def_kind = self.def_kind(instance.def_id());
120-
assert!(
121-
matches!(
122-
def_kind,
123-
DefKind::InlineConst | DefKind::AnonConst | DefKind::AssocConst
124-
),
125-
"{cid:?} is {def_kind:?}",
126-
);
118+
if !self.features().generic_const_exprs()
119+
&& ct.args.has_non_region_param()
120+
// We only FCW for anon consts as repeat expr counts with anon consts are the only place
121+
// that we have a back compat hack for. We don't need to check this is a const argument
122+
// as only anon consts as const args should get evaluated "for the type system".
123+
//
124+
// If we don't *only* FCW anon consts we can wind up incorrectly FCW'ing uses of assoc
125+
// consts in pattern positions. #140447
126+
&& self.def_kind(instance.def_id()) == DefKind::AnonConst
127+
{
127128
let mir_body = self.mir_for_ctfe(instance.def_id());
128129
if mir_body.is_polymorphic {
129130
let Some(local_def_id) = ct.def.as_local() else { return };

0 commit comments

Comments
 (0)