Skip to content

Commit 64ca23b

Browse files
committed
Auto merge of #144723 - Zalathar:rollup-f9e0rfo, r=Zalathar
Rollup of 3 pull requests Successful merges: - #144657 (fix: Only "close the window" when its the last annotated file) - #144665 (Re-block SRoA on SIMD types) - #144713 (`rustc_middle::ty` cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2 parents cc0a5b7 + 017586c commit 64ca23b

File tree

30 files changed

+244
-152
lines changed

30 files changed

+244
-152
lines changed

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ where
277277
// `QueryNormalizeExt::query_normalize` used in the query and `normalize` called below:
278278
// the former fails to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs`
279279
// test. Check after #85499 lands to see if its fixes have erased this difference.
280-
let (param_env, value) = key.into_parts();
280+
let ty::ParamEnvAnd { param_env, value } = key;
281281
let _ = ocx.normalize(&cause, param_env, value.value);
282282

283283
let diag = try_extract_error_from_fulfill_cx(
@@ -324,7 +324,7 @@ where
324324
mbcx.infcx.tcx.infer_ctxt().build_with_canonical(cause.span, &self.canonical_query);
325325
let ocx = ObligationCtxt::new(&infcx);
326326

327-
let (param_env, value) = key.into_parts();
327+
let ty::ParamEnvAnd { param_env, value } = key;
328328
let _ = ocx.deeply_normalize(&cause, param_env, value.value);
329329

330330
let diag = try_extract_error_from_fulfill_cx(

compiler/rustc_errors/src/emitter.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,8 +1597,9 @@ impl HumanEmitter {
15971597
annotated_files.swap(0, pos);
15981598
}
15991599

1600+
let annotated_files_len = annotated_files.len();
16001601
// Print out the annotate source lines that correspond with the error
1601-
for annotated_file in annotated_files {
1602+
for (file_idx, annotated_file) in annotated_files.into_iter().enumerate() {
16021603
// we can't annotate anything if the source is unavailable.
16031604
if !should_show_source_code(
16041605
&self.ignored_directories_in_source_blocks,
@@ -1855,7 +1856,9 @@ impl HumanEmitter {
18551856
width_offset,
18561857
code_offset,
18571858
margin,
1858-
!is_cont && line_idx + 1 == annotated_file.lines.len(),
1859+
!is_cont
1860+
&& file_idx + 1 == annotated_files_len
1861+
&& line_idx + 1 == annotated_file.lines.len(),
18591862
);
18601863

18611864
let mut to_add = FxHashMap::default();

compiler/rustc_hir_typeck/src/fallback.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_span::{DUMMY_SP, Span};
1818
use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
1919
use tracing::debug;
2020

21+
use crate::typeck_root_ctxt::InferVarInfo;
2122
use crate::{FnCtxt, errors};
2223

2324
#[derive(Copy, Clone)]
@@ -345,7 +346,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
345346
.map(|(_, info)| *info)
346347
.collect();
347348

348-
let found_infer_var_info = ty::InferVarInfo {
349+
let found_infer_var_info = InferVarInfo {
349350
self_in_trait: infer_var_infos.items().any(|info| info.self_in_trait),
350351
output: infer_var_infos.items().any(|info| info.output),
351352
};

compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ enum ClauseFlavor {
1717
Const,
1818
}
1919

20+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
21+
enum ParamTerm {
22+
Ty(ty::ParamTy),
23+
Const(ty::ParamConst),
24+
}
25+
26+
impl ParamTerm {
27+
fn index(self) -> usize {
28+
match self {
29+
ParamTerm::Ty(ty) => ty.index as usize,
30+
ParamTerm::Const(ct) => ct.index as usize,
31+
}
32+
}
33+
}
34+
2035
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2136
pub(crate) fn adjust_fulfillment_error_for_expr_obligation(
2237
&self,
@@ -77,17 +92,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7792
_ => return false,
7893
};
7994

80-
let find_param_matching = |matches: &dyn Fn(ty::ParamTerm) -> bool| {
95+
let find_param_matching = |matches: &dyn Fn(ParamTerm) -> bool| {
8196
predicate_args.iter().find_map(|arg| {
8297
arg.walk().find_map(|arg| {
8398
if let ty::GenericArgKind::Type(ty) = arg.kind()
8499
&& let ty::Param(param_ty) = *ty.kind()
85-
&& matches(ty::ParamTerm::Ty(param_ty))
100+
&& matches(ParamTerm::Ty(param_ty))
86101
{
87102
Some(arg)
88103
} else if let ty::GenericArgKind::Const(ct) = arg.kind()
89104
&& let ty::ConstKind::Param(param_ct) = ct.kind()
90-
&& matches(ty::ParamTerm::Const(param_ct))
105+
&& matches(ParamTerm::Const(param_ct))
91106
{
92107
Some(arg)
93108
} else {
@@ -106,14 +121,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
106121
// from a trait or impl, for example.
107122
let mut fallback_param_to_point_at = find_param_matching(&|param_term| {
108123
self.tcx.parent(generics.param_at(param_term.index(), self.tcx).def_id) != def_id
109-
&& !matches!(param_term, ty::ParamTerm::Ty(ty) if ty.name == kw::SelfUpper)
124+
&& !matches!(param_term, ParamTerm::Ty(ty) if ty.name == kw::SelfUpper)
110125
});
111126
// Finally, the `Self` parameter is possibly the reason that the predicate
112127
// is unsatisfied. This is less likely to be true for methods, because
113128
// method probe means that we already kinda check that the predicates due
114129
// to the `Self` type are true.
115130
let mut self_param_to_point_at = find_param_matching(
116-
&|param_term| matches!(param_term, ty::ParamTerm::Ty(ty) if ty.name == kw::SelfUpper),
131+
&|param_term| matches!(param_term, ParamTerm::Ty(ty) if ty.name == kw::SelfUpper),
117132
);
118133

119134
// Finally, for ambiguity-related errors, we actually want to look

compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ use tracing::{debug, instrument};
1717

1818
use super::callee::DeferredCallResolution;
1919

20+
#[derive(Debug, Default, Copy, Clone)]
21+
pub(crate) struct InferVarInfo {
22+
/// This is true if we identified that this Ty (`?T`) is found in a `?T: Foo`
23+
/// obligation, where:
24+
///
25+
/// * `Foo` is not `Sized`
26+
/// * `(): Foo` may be satisfied
27+
pub self_in_trait: bool,
28+
/// This is true if we identified that this Ty (`?T`) is found in a `<_ as
29+
/// _>::AssocType = ?T`
30+
pub output: bool,
31+
}
32+
2033
/// Data shared between a "typeck root" and its nested bodies,
2134
/// e.g. closures defined within the function. For example:
2235
/// ```ignore (illustrative)
@@ -71,7 +84,7 @@ pub(crate) struct TypeckRootCtxt<'tcx> {
7184
/// fallback. See the `fallback` module for details.
7285
pub(super) diverging_type_vars: RefCell<UnordSet<Ty<'tcx>>>,
7386

74-
pub(super) infer_var_info: RefCell<UnordMap<ty::TyVid, ty::InferVarInfo>>,
87+
pub(super) infer_var_info: RefCell<UnordMap<ty::TyVid, InferVarInfo>>,
7588
}
7689

7790
impl<'tcx> Deref for TypeckRootCtxt<'tcx> {

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'tcx> InferCtxt<'tcx> {
4444
where
4545
V: TypeFoldable<TyCtxt<'tcx>>,
4646
{
47-
let (param_env, value) = value.into_parts();
47+
let ty::ParamEnvAnd { param_env, value } = value;
4848
let canonical_param_env = self.tcx.canonical_param_env_cache.get_or_insert(
4949
self.tcx,
5050
param_env,

compiler/rustc_infer/src/infer/relate/generalize.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ use crate::infer::type_variable::TypeVariableValue;
1919
use crate::infer::unify_key::ConstVariableValue;
2020
use crate::infer::{InferCtxt, RegionVariableOrigin, relate};
2121

22+
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
23+
enum TermVid {
24+
Ty(ty::TyVid),
25+
Const(ty::ConstVid),
26+
}
27+
28+
impl From<ty::TyVid> for TermVid {
29+
fn from(value: ty::TyVid) -> Self {
30+
TermVid::Ty(value)
31+
}
32+
}
33+
34+
impl From<ty::ConstVid> for TermVid {
35+
fn from(value: ty::ConstVid) -> Self {
36+
TermVid::Const(value)
37+
}
38+
}
39+
2240
impl<'tcx> InferCtxt<'tcx> {
2341
/// The idea is that we should ensure that the type variable `target_vid`
2442
/// is equal to, a subtype of, or a supertype of `source_ty`.
@@ -238,20 +256,18 @@ impl<'tcx> InferCtxt<'tcx> {
238256
&self,
239257
span: Span,
240258
structurally_relate_aliases: StructurallyRelateAliases,
241-
target_vid: impl Into<ty::TermVid>,
259+
target_vid: impl Into<TermVid>,
242260
ambient_variance: ty::Variance,
243261
source_term: T,
244262
) -> RelateResult<'tcx, Generalization<T>> {
245263
assert!(!source_term.has_escaping_bound_vars());
246264
let (for_universe, root_vid) = match target_vid.into() {
247-
ty::TermVid::Ty(ty_vid) => {
248-
(self.probe_ty_var(ty_vid).unwrap_err(), ty::TermVid::Ty(self.root_var(ty_vid)))
265+
TermVid::Ty(ty_vid) => {
266+
(self.probe_ty_var(ty_vid).unwrap_err(), TermVid::Ty(self.root_var(ty_vid)))
249267
}
250-
ty::TermVid::Const(ct_vid) => (
268+
TermVid::Const(ct_vid) => (
251269
self.probe_const_var(ct_vid).unwrap_err(),
252-
ty::TermVid::Const(
253-
self.inner.borrow_mut().const_unification_table().find(ct_vid).vid,
254-
),
270+
TermVid::Const(self.inner.borrow_mut().const_unification_table().find(ct_vid).vid),
255271
),
256272
};
257273

@@ -299,7 +315,7 @@ struct Generalizer<'me, 'tcx> {
299315
/// The vid of the type variable that is in the process of being
300316
/// instantiated. If we find this within the value we are folding,
301317
/// that means we would have created a cyclic value.
302-
root_vid: ty::TermVid,
318+
root_vid: TermVid,
303319

304320
/// The universe of the type variable that is in the process of being
305321
/// instantiated. If we find anything that this universe cannot name,
@@ -469,7 +485,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
469485
ty::Infer(ty::TyVar(vid)) => {
470486
let mut inner = self.infcx.inner.borrow_mut();
471487
let vid = inner.type_variables().root_var(vid);
472-
if ty::TermVid::Ty(vid) == self.root_vid {
488+
if TermVid::Ty(vid) == self.root_vid {
473489
// If sub-roots are equal, then `root_vid` and
474490
// `vid` are related via subtyping.
475491
Err(self.cyclic_term_error())
@@ -621,7 +637,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
621637
// If root const vids are equal, then `root_vid` and
622638
// `vid` are related and we'd be inferring an infinitely
623639
// deep const.
624-
if ty::TermVid::Const(
640+
if TermVid::Const(
625641
self.infcx.inner.borrow_mut().const_unification_table().find(vid).vid,
626642
) == self.root_vid
627643
{

compiler/rustc_interface/src/passes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_parse::{
2929
new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal, validate_attr,
3030
};
3131
use rustc_passes::{abi_test, input_stats, layout_test};
32-
use rustc_resolve::Resolver;
32+
use rustc_resolve::{Resolver, ResolverOutputs};
3333
use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
3434
use rustc_session::cstore::Untracked;
3535
use rustc_session::output::{collect_crate_types, filename_for_input};
@@ -793,7 +793,7 @@ fn resolver_for_lowering_raw<'tcx>(
793793
// Make sure we don't mutate the cstore from here on.
794794
tcx.untracked().cstore.freeze();
795795

796-
let ty::ResolverOutputs {
796+
let ResolverOutputs {
797797
global_ctxt: untracked_resolutions,
798798
ast_lowering: untracked_resolver_for_lowering,
799799
} = resolver.into_outputs();

compiler/rustc_middle/src/ty/codec.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,9 @@ impl_decodable_via_ref! {
510510
&'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
511511
&'tcx traits::ImplSource<'tcx, ()>,
512512
&'tcx mir::Body<'tcx>,
513-
&'tcx mir::ConcreteOpaqueTypes<'tcx>,
514513
&'tcx ty::List<ty::BoundVariableKind>,
515514
&'tcx ty::List<ty::Pattern<'tcx>>,
516515
&'tcx ty::ListWithCachedTypeInfo<ty::Clause<'tcx>>,
517-
&'tcx ty::List<FieldIdx>,
518-
&'tcx ty::List<(VariantIdx, FieldIdx)>,
519516
}
520517

521518
#[macro_export]

0 commit comments

Comments
 (0)