Skip to content

Commit 8068e2f

Browse files
committed
Auto merge of #156324 - JonathanBrouwer:rollup-HKA8242, r=JonathanBrouwer
Rollup of 4 pull requests Successful merges: - #156246 (Introduce a `RerunNonErased` error type mirroring `NoSolution`, to better track when we're bailing) - #156038 (turn `compute_goal_fast_path` into a single match) - #156291 (Treat MSVC "performing full link" message as informational) - #156301 (Avoid ICE when suggesting as_ref for ill-typed closure receivers)
2 parents f2b291d + 01cccf9 commit 8068e2f

28 files changed

Lines changed: 879 additions & 518 deletions

File tree

compiler/rustc_ast_ir/src/visit.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ impl<T> VisitorResult for ControlFlow<T> {
4141
}
4242
}
4343

44+
impl<E> VisitorResult for Result<(), E> {
45+
type Residual = E;
46+
47+
fn output() -> Self {
48+
Ok(())
49+
}
50+
fn from_residual(residual: Self::Residual) -> Self {
51+
Err(residual)
52+
}
53+
fn from_branch(b: ControlFlow<Self::Residual>) -> Self {
54+
match b {
55+
ControlFlow::Continue(()) => Ok(()),
56+
ControlFlow::Break(e) => Err(e),
57+
}
58+
}
59+
fn branch(self) -> ControlFlow<Self::Residual> {
60+
match self {
61+
Ok(()) => ControlFlow::Continue(()),
62+
Err(e) => ControlFlow::Break(e),
63+
}
64+
}
65+
}
66+
4467
#[macro_export]
4568
macro_rules! try_visit {
4669
($e:expr) => {

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,15 @@ fn report_linker_output(sess: &Session, levels: CodegenLintLevels, stdout: &[u8]
754754
escaped_stdout = for_each(&stdout, |line, output| {
755755
// Hide some progress messages from link.exe that we don't care about.
756756
// See https://github.com/chromium/chromium/blob/bfa41e41145ffc85f041384280caf2949bb7bd72/build/toolchain/win/tool_wrapper.py#L144-L146
757+
// When incremental linking is enabled and an .ilk exists, but its associated .exe is
758+
// missing, link.exe prints the path of the missing .exe followed by:
759+
let ilk_but_no_exe =
760+
"not found or not built by the last incremental link; performing full link";
757761
let trimmed = line.trim_start();
758762
if trimmed.starts_with("Creating library")
759763
|| trimmed.starts_with("Generating code")
760764
|| trimmed.starts_with("Finished generating code")
765+
|| trimmed.ends_with(ilk_but_no_exe)
761766
{
762767
linker_info += line;
763768
linker_info += "\r\n";

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27872787
return None;
27882788
};
27892789

2790-
let self_ty = self.typeck_results.borrow().expr_ty(receiver);
2790+
let self_ty = self.typeck_results.borrow().expr_ty_opt(receiver)?;
27912791
let name = method_path.ident.name;
27922792
let is_as_ref_able = match self_ty.peel_refs().kind() {
27932793
ty::Adt(def, _) => {

compiler/rustc_middle/src/ty/context/impl_interner.rs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Implementation of [`rustc_type_ir::Interner`] for [`TyCtxt`].
22
3+
use std::ops::ControlFlow;
34
use std::{debug_assert_matches, fmt};
45

56
use rustc_errors::ErrorGuaranteed;
@@ -9,7 +10,9 @@ use rustc_hir::def_id::{DefId, LocalDefId};
910
use rustc_hir::lang_items::LangItem;
1011
use rustc_span::{DUMMY_SP, Span, Symbol};
1112
use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverProjectionLangItem, SolverTraitLangItem};
12-
use rustc_type_ir::{CollectAndApply, Interner, TypeFoldable, Unnormalized, search_graph};
13+
use rustc_type_ir::{
14+
CollectAndApply, Interner, TypeFoldable, Unnormalized, VisitorResult, search_graph,
15+
};
1316

1417
use crate::dep_graph::{DepKind, DepNodeIndex};
1518
use crate::infer::canonical::CanonicalVarKinds;
@@ -522,20 +525,31 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
522525
// This implementation is a bit different from `TyCtxt::for_each_relevant_impl`,
523526
// since we want to skip over blanket impls for non-rigid aliases, and also we
524527
// only want to consider types that *actually* unify with float/int vars.
525-
fn for_each_relevant_impl(
528+
fn for_each_relevant_impl<R: VisitorResult>(
526529
self,
527530
trait_def_id: DefId,
528531
self_ty: Ty<'tcx>,
529-
mut f: impl FnMut(DefId),
530-
) {
532+
mut f: impl FnMut(DefId) -> R,
533+
) -> R {
534+
macro_rules! ret {
535+
($e: expr) => {
536+
match $e.branch() {
537+
ControlFlow::Break(b) => return R::from_residual(b),
538+
ControlFlow::Continue(()) => {}
539+
}
540+
};
541+
}
542+
531543
let tcx = self;
532544
let trait_impls = tcx.trait_impls_of(trait_def_id);
533545
let mut consider_impls_for_simplified_type = |simp| {
534546
if let Some(impls_for_type) = trait_impls.non_blanket_impls().get(&simp) {
535547
for &impl_def_id in impls_for_type {
536-
f(impl_def_id);
548+
ret!(f(impl_def_id))
537549
}
538550
}
551+
552+
R::output()
539553
};
540554

541555
match self_ty.kind() {
@@ -566,7 +580,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
566580
self_ty,
567581
ty::fast_reject::TreatParams::AsRigid,
568582
) {
569-
consider_impls_for_simplified_type(simp);
583+
ret!(consider_impls_for_simplified_type(simp));
570584
}
571585
}
572586

@@ -595,7 +609,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
595609
ty::SimplifiedType::Uint(Usize),
596610
];
597611
for simp in possible_integers {
598-
consider_impls_for_simplified_type(simp);
612+
ret!(consider_impls_for_simplified_type(simp));
599613
}
600614
}
601615

@@ -610,7 +624,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
610624
];
611625

612626
for simp in possible_floats {
613-
consider_impls_for_simplified_type(simp);
627+
ret!(consider_impls_for_simplified_type(simp));
614628
}
615629
}
616630

@@ -634,11 +648,20 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
634648
#[allow(rustc::usage_of_type_ir_traits)]
635649
self.for_each_blanket_impl(trait_def_id, f)
636650
}
637-
fn for_each_blanket_impl(self, trait_def_id: DefId, mut f: impl FnMut(DefId)) {
651+
fn for_each_blanket_impl<R: VisitorResult>(
652+
self,
653+
trait_def_id: DefId,
654+
mut f: impl FnMut(DefId) -> R,
655+
) -> R {
638656
let trait_impls = self.trait_impls_of(trait_def_id);
639657
for &impl_def_id in trait_impls.blanket_impls() {
640-
f(impl_def_id);
658+
match f(impl_def_id).branch() {
659+
ControlFlow::Break(b) => return R::from_residual(b),
660+
ControlFlow::Continue(()) => {}
661+
}
641662
}
663+
664+
R::output()
642665
}
643666

644667
fn has_item_definition(self, def_id: DefId) -> bool {

compiler/rustc_next_trait_solver/src/solve/alias_relate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
//! relate them structurally.
1717
1818
use rustc_type_ir::inherent::*;
19-
use rustc_type_ir::solve::GoalSource;
19+
use rustc_type_ir::solve::{GoalSource, QueryResultOrRerunNonErased};
2020
use rustc_type_ir::{self as ty, Interner};
2121
use tracing::{instrument, trace};
2222

2323
use crate::delegate::SolverDelegate;
24-
use crate::solve::{Certainty, EvalCtxt, Goal, QueryResult};
24+
use crate::solve::{Certainty, EvalCtxt, Goal};
2525

2626
impl<D, I> EvalCtxt<'_, D>
2727
where
@@ -32,7 +32,7 @@ where
3232
pub(super) fn compute_alias_relate_goal(
3333
&mut self,
3434
goal: Goal<I, (I::Term, I::Term, ty::AliasRelationDirection)>,
35-
) -> QueryResult<I> {
35+
) -> QueryResultOrRerunNonErased<I> {
3636
let cx = self.cx();
3737
let Goal { param_env, predicate: (lhs, rhs, direction) } = goal;
3838

0 commit comments

Comments
 (0)