authorbors <bors@rust-lang.org> 2025-07-31 08:54:41 UTC
committerbors <bors@rust-lang.org> 2025-07-31 08:54:41 UTC
log64ca23b6235732fa61c0a2b957c5d7e591e7c972
tree4688ea8f1bef26095df721f0a4344b64e2e66f03
parentcc0a5b73053c62a3df5f84b3ee85079c9b65fa87
parent017586c93abe3b7e6f495a1f2bf34df4f3693411

Auto merge of #144723 - Zalathar:rollup-f9e0rfo, r=Zalathar

Rollup of 3 pull requests Successful merges: - rust-lang/rust#144657 (fix: Only "close the window" when its the last annotated file) - rust-lang/rust#144665 (Re-block SRoA on SIMD types) - rust-lang/rust#144713 (`rustc_middle::ty` cleanups) r? `@ghost` `@rustbot` modify labels: rollup

30 files changed, 244 insertions(+), 152 deletions(-)

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs+2-2
......@@ -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+5-2
......@@ -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+2-1
......@@ -18,6 +18,7 @@ use rustc_span::{DUMMY_SP, Span};
1818use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
1919use tracing::debug;
2020
21use crate::typeck_root_ctxt::InferVarInfo;
2122use 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+20-5
......@@ -17,6 +17,21 @@ enum ClauseFlavor {
1717 Const,
1818}
1919
20#[derive(Copy, Clone, PartialEq, Eq, Debug)]
21enum ParamTerm {
22 Ty(ty::ParamTy),
23 Const(ty::ParamConst),
24}
25
26impl 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
2035impl<'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+14-1
......@@ -17,6 +17,19 @@ use tracing::{debug, instrument};
1717
1818use super::callee::DeferredCallResolution;
1919
20#[derive(Debug, Default, Copy, Clone)]
21pub(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
7790impl<'tcx> Deref for TypeckRootCtxt<'tcx> {
compiler/rustc_infer/src/infer/canonical/canonicalizer.rs+1-1
......@@ -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+26-10
......@@ -19,6 +19,24 @@ use crate::infer::type_variable::TypeVariableValue;
1919use crate::infer::unify_key::ConstVariableValue;
2020use crate::infer::{InferCtxt, RegionVariableOrigin, relate};
2121
22#[derive(Copy, Clone, Eq, PartialEq, Debug)]
23enum TermVid {
24 Ty(ty::TyVid),
25 Const(ty::ConstVid),
26}
27
28impl From<ty::TyVid> for TermVid {
29 fn from(value: ty::TyVid) -> Self {
30 TermVid::Ty(value)
31 }
32}
33
34impl From<ty::ConstVid> for TermVid {
35 fn from(value: ty::ConstVid) -> Self {
36 TermVid::Const(value)
37 }
38}
39
2240impl<'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+2-2
......@@ -29,7 +29,7 @@ use rustc_parse::{
2929 new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal, validate_attr,
3030};
3131use rustc_passes::{abi_test, input_stats, layout_test};
32use rustc_resolve::Resolver;
32use rustc_resolve::{Resolver, ResolverOutputs};
3333use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
3434use rustc_session::cstore::Untracked;
3535use 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-3
......@@ -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]
compiler/rustc_middle/src/ty/mod.rs+3-100
......@@ -49,7 +49,7 @@ use rustc_serialize::{Decodable, Encodable};
4949use rustc_session::lint::LintBuffer;
5050pub use rustc_session::lint::RegisteredTools;
5151use rustc_span::hygiene::MacroKind;
52use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol, kw, sym};
52use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol, sym};
5353pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet};
5454pub use rustc_type_ir::fast_reject::DeepRejectCtxt;
5555#[allow(
......@@ -168,11 +168,6 @@ mod visit;
168168
169169// Data types
170170
171pub struct ResolverOutputs {
172 pub global_ctxt: ResolverGlobalCtxt,
173 pub ast_lowering: ResolverAstLowering,
174}
175
176171#[derive(Debug, HashStable)]
177172pub struct ResolverGlobalCtxt {
178173 pub visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
......@@ -253,18 +248,6 @@ impl MainDefinition {
253248 }
254249}
255250
256/// The "header" of an impl is everything outside the body: a Self type, a trait
257/// ref (in the case of a trait impl), and a set of predicates (from the
258/// bounds / where-clauses).
259#[derive(Clone, Debug, TypeFoldable, TypeVisitable)]
260pub struct ImplHeader<'tcx> {
261 pub impl_def_id: DefId,
262 pub impl_args: ty::GenericArgsRef<'tcx>,
263 pub self_ty: Ty<'tcx>,
264 pub trait_ref: Option<TraitRef<'tcx>>,
265 pub predicates: Vec<Predicate<'tcx>>,
266}
267
268251#[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)]
269252pub struct ImplTraitHeader<'tcx> {
270253 pub trait_ref: ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>,
......@@ -468,14 +451,6 @@ impl<'tcx> rustc_type_ir::Flags for Ty<'tcx> {
468451 }
469452}
470453
471impl EarlyParamRegion {
472 /// Does this early bound region have a name? Early bound regions normally
473 /// always have names except when using anonymous lifetimes (`'_`).
474 pub fn is_named(&self) -> bool {
475 self.name != kw::UnderscoreLifetime
476 }
477}
478
479454/// The crate outlives map is computed during typeck and contains the
480455/// outlives of every item in the local crate. You should not use it
481456/// directly, because to do so will make your pass dependent on the
......@@ -696,39 +671,6 @@ impl<'tcx> TermKind<'tcx> {
696671 }
697672}
698673
699#[derive(Copy, Clone, PartialEq, Eq, Debug)]
700pub enum ParamTerm {
701 Ty(ParamTy),
702 Const(ParamConst),
703}
704
705impl ParamTerm {
706 pub fn index(self) -> usize {
707 match self {
708 ParamTerm::Ty(ty) => ty.index as usize,
709 ParamTerm::Const(ct) => ct.index as usize,
710 }
711 }
712}
713
714#[derive(Copy, Clone, Eq, PartialEq, Debug)]
715pub enum TermVid {
716 Ty(ty::TyVid),
717 Const(ty::ConstVid),
718}
719
720impl From<ty::TyVid> for TermVid {
721 fn from(value: ty::TyVid) -> Self {
722 TermVid::Ty(value)
723 }
724}
725
726impl From<ty::ConstVid> for TermVid {
727 fn from(value: ty::ConstVid) -> Self {
728 TermVid::Const(value)
729 }
730}
731
732674/// Represents the bounds declared on a particular set of type
733675/// parameters. Should eventually be generalized into a flag list of
734676/// where-clauses. You can obtain an `InstantiatedPredicates` list from a
......@@ -1067,12 +1009,6 @@ pub struct ParamEnvAnd<'tcx, T> {
10671009 pub value: T,
10681010}
10691011
1070impl<'tcx, T> ParamEnvAnd<'tcx, T> {
1071 pub fn into_parts(self) -> (ParamEnv<'tcx>, T) {
1072 (self.param_env, self.value)
1073 }
1074}
1075
10761012/// The environment in which to do trait solving.
10771013///
10781014/// Most of the time you only need to care about the `ParamEnv`
......@@ -1768,15 +1704,6 @@ impl<'tcx> TyCtxt<'tcx> {
17681704 }
17691705 }
17701706
1771 // FIXME(@lcnr): Remove this function.
1772 pub fn get_attrs_unchecked(self, did: DefId) -> &'tcx [hir::Attribute] {
1773 if let Some(did) = did.as_local() {
1774 self.hir_attrs(self.local_def_id_to_hir_id(did))
1775 } else {
1776 self.attrs_for_def(did)
1777 }
1778 }
1779
17801707 /// Gets all attributes with the given name.
17811708 pub fn get_attrs(
17821709 self,
......@@ -1788,7 +1715,8 @@ impl<'tcx> TyCtxt<'tcx> {
17881715
17891716 /// Gets all attributes.
17901717 ///
1791 /// To see if an item has a specific attribute, you should use [`rustc_attr_data_structures::find_attr!`] so you can use matching.
1718 /// To see if an item has a specific attribute, you should use
1719 /// [`rustc_attr_data_structures::find_attr!`] so you can use matching.
17921720 pub fn get_all_attrs(self, did: impl Into<DefId>) -> &'tcx [hir::Attribute] {
17931721 let did: DefId = did.into();
17941722 if let Some(did) = did.as_local() {
......@@ -2302,34 +2230,9 @@ impl<'tcx> fmt::Debug for SymbolName<'tcx> {
23022230 }
23032231}
23042232
2305#[derive(Debug, Default, Copy, Clone)]
2306pub struct InferVarInfo {
2307 /// This is true if we identified that this Ty (`?T`) is found in a `?T: Foo`
2308 /// obligation, where:
2309 ///
2310 /// * `Foo` is not `Sized`
2311 /// * `(): Foo` may be satisfied
2312 pub self_in_trait: bool,
2313 /// This is true if we identified that this Ty (`?T`) is found in a `<_ as
2314 /// _>::AssocType = ?T`
2315 pub output: bool,
2316}
2317
23182233/// The constituent parts of a type level constant of kind ADT or array.
23192234#[derive(Copy, Clone, Debug, HashStable)]
23202235pub struct DestructuredConst<'tcx> {
23212236 pub variant: Option<VariantIdx>,
23222237 pub fields: &'tcx [ty::Const<'tcx>],
23232238}
2324
2325// Some types are used a lot. Make sure they don't unintentionally get bigger.
2326#[cfg(target_pointer_width = "64")]
2327mod size_asserts {
2328 use rustc_data_structures::static_assert_size;
2329
2330 use super::*;
2331 // tidy-alphabetical-start
2332 static_assert_size!(PredicateKind<'_>, 32);
2333 static_assert_size!(WithCachedTypeInfo<TyKind<'_>>, 48);
2334 // tidy-alphabetical-end
2335}
compiler/rustc_middle/src/ty/predicate.rs+12
......@@ -704,3 +704,15 @@ impl<'tcx> Predicate<'tcx> {
704704 }
705705 }
706706}
707
708// Some types are used a lot. Make sure they don't unintentionally get bigger.
709#[cfg(target_pointer_width = "64")]
710mod size_asserts {
711 use rustc_data_structures::static_assert_size;
712
713 use super::*;
714 // tidy-alphabetical-start
715 static_assert_size!(PredicateKind<'_>, 32);
716 static_assert_size!(WithCachedTypeInfo<PredicateKind<'_>>, 56);
717 // tidy-alphabetical-end
718}
compiler/rustc_middle/src/ty/region.rs+20
......@@ -324,6 +324,14 @@ pub struct EarlyParamRegion {
324324 pub name: Symbol,
325325}
326326
327impl EarlyParamRegion {
328 /// Does this early bound region have a name? Early bound regions normally
329 /// always have names except when using anonymous lifetimes (`'_`).
330 pub fn is_named(&self) -> bool {
331 self.name != kw::UnderscoreLifetime
332 }
333}
334
327335impl rustc_type_ir::inherent::ParamLike for EarlyParamRegion {
328336 fn index(self) -> u32 {
329337 self.index
......@@ -487,3 +495,15 @@ impl BoundRegionKind {
487495 }
488496 }
489497}
498
499// Some types are used a lot. Make sure they don't unintentionally get bigger.
500#[cfg(target_pointer_width = "64")]
501mod size_asserts {
502 use rustc_data_structures::static_assert_size;
503
504 use super::*;
505 // tidy-alphabetical-start
506 static_assert_size!(RegionKind<'_>, 20);
507 static_assert_size!(ty::WithCachedTypeInfo<RegionKind<'_>>, 48);
508 // tidy-alphabetical-end
509}
compiler/rustc_middle/src/ty/sty.rs+2-2
......@@ -2040,7 +2040,7 @@ mod size_asserts {
20402040
20412041 use super::*;
20422042 // tidy-alphabetical-start
2043 static_assert_size!(ty::RegionKind<'_>, 20);
2044 static_assert_size!(ty::TyKind<'_>, 24);
2043 static_assert_size!(TyKind<'_>, 24);
2044 static_assert_size!(ty::WithCachedTypeInfo<TyKind<'_>>, 48);
20452045 // tidy-alphabetical-end
20462046}
compiler/rustc_mir_transform/src/sroa.rs+5-1
......@@ -72,8 +72,12 @@ fn escaping_locals<'tcx>(
7272 return true;
7373 }
7474 if let ty::Adt(def, _args) = ty.kind()
75 && tcx.is_lang_item(def.did(), LangItem::DynMetadata)
75 && (def.repr().simd() || tcx.is_lang_item(def.did(), LangItem::DynMetadata))
7676 {
77 // Exclude #[repr(simd)] types so that they are not de-optimized into an array
78 // (MCP#838 banned projections into SIMD types, but if the value is unused
79 // this pass sees "all the uses are of the fields" and expands it.)
80
7781 // codegen wants to see the `DynMetadata<T>`,
7882 // not the inner reference-to-opaque-type.
7983 return true;
compiler/rustc_resolve/src/lib.rs+7-2
......@@ -64,8 +64,8 @@ use rustc_middle::middle::privacy::EffectiveVisibilities;
6464use rustc_middle::query::Providers;
6565use rustc_middle::span_bug;
6666use rustc_middle::ty::{
67 self, DelegationFnSig, Feed, MainDefinition, RegisteredTools, ResolverGlobalCtxt,
68 ResolverOutputs, TyCtxt, TyCtxtFeed, Visibility,
67 self, DelegationFnSig, Feed, MainDefinition, RegisteredTools, ResolverAstLowering,
68 ResolverGlobalCtxt, TyCtxt, TyCtxtFeed, Visibility,
6969};
7070use rustc_query_system::ich::StableHashingContext;
7171use rustc_session::lint::builtin::PRIVATE_MACRO_USE;
......@@ -1037,6 +1037,11 @@ impl MacroData {
10371037 }
10381038}
10391039
1040pub struct ResolverOutputs {
1041 pub global_ctxt: ResolverGlobalCtxt,
1042 pub ast_lowering: ResolverAstLowering,
1043}
1044
10401045/// The main resolver class.
10411046///
10421047/// This is the visitor that walks the whole crate.
compiler/rustc_trait_selection/src/traits/coherence.rs+19-6
......@@ -12,6 +12,7 @@ use rustc_hir::def::DefKind;
1212use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
1313use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, TyCtxtInferExt};
1414use rustc_infer::traits::PredicateObligations;
15use rustc_macros::{TypeFoldable, TypeVisitable};
1516use rustc_middle::bug;
1617use rustc_middle::traits::query::NoSolution;
1718use rustc_middle::traits::solve::{CandidateSource, Certainty, Goal};
......@@ -37,8 +38,20 @@ use crate::traits::{
3738 SelectionContext, SkipLeakCheck, util,
3839};
3940
41/// The "header" of an impl is everything outside the body: a Self type, a trait
42/// ref (in the case of a trait impl), and a set of predicates (from the
43/// bounds / where-clauses).
44#[derive(Clone, Debug, TypeFoldable, TypeVisitable)]
45pub struct ImplHeader<'tcx> {
46 pub impl_def_id: DefId,
47 pub impl_args: ty::GenericArgsRef<'tcx>,
48 pub self_ty: Ty<'tcx>,
49 pub trait_ref: Option<ty::TraitRef<'tcx>>,
50 pub predicates: Vec<ty::Predicate<'tcx>>,
51}
52
4053pub struct OverlapResult<'tcx> {
41 pub impl_header: ty::ImplHeader<'tcx>,
54 pub impl_header: ImplHeader<'tcx>,
4255 pub intercrate_ambiguity_causes: FxIndexSet<IntercrateAmbiguityCause<'tcx>>,
4356
4457 /// `true` if the overlap might've been permitted before the shift
......@@ -151,11 +164,11 @@ pub fn overlapping_impls(
151164 }
152165}
153166
154fn fresh_impl_header<'tcx>(infcx: &InferCtxt<'tcx>, impl_def_id: DefId) -> ty::ImplHeader<'tcx> {
167fn fresh_impl_header<'tcx>(infcx: &InferCtxt<'tcx>, impl_def_id: DefId) -> ImplHeader<'tcx> {
155168 let tcx = infcx.tcx;
156169 let impl_args = infcx.fresh_args_for_item(DUMMY_SP, impl_def_id);
157170
158 ty::ImplHeader {
171 ImplHeader {
159172 impl_def_id,
160173 impl_args,
161174 self_ty: tcx.type_of(impl_def_id).instantiate(tcx, impl_args),
......@@ -173,7 +186,7 @@ fn fresh_impl_header_normalized<'tcx>(
173186 infcx: &InferCtxt<'tcx>,
174187 param_env: ty::ParamEnv<'tcx>,
175188 impl_def_id: DefId,
176) -> ty::ImplHeader<'tcx> {
189) -> ImplHeader<'tcx> {
177190 let header = fresh_impl_header(infcx, impl_def_id);
178191
179192 let InferOk { value: mut header, obligations } =
......@@ -287,8 +300,8 @@ fn overlap<'tcx>(
287300fn equate_impl_headers<'tcx>(
288301 infcx: &InferCtxt<'tcx>,
289302 param_env: ty::ParamEnv<'tcx>,
290 impl1: &ty::ImplHeader<'tcx>,
291 impl2: &ty::ImplHeader<'tcx>,
303 impl1: &ImplHeader<'tcx>,
304 impl2: &ImplHeader<'tcx>,
292305) -> Option<PredicateObligations<'tcx>> {
293306 let result =
294307 match (impl1.trait_ref, impl2.trait_ref) {
compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs+1-1
......@@ -44,7 +44,7 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
4444 key: ParamEnvAnd<'tcx, AscribeUserType<'tcx>>,
4545 span: Span,
4646) -> Result<(), NoSolution> {
47 let (param_env, AscribeUserType { mir_ty, user_ty }) = key.into_parts();
47 let ty::ParamEnvAnd { param_env, value: AscribeUserType { mir_ty, user_ty } } = key;
4848 debug!("type_op_ascribe_user_type: mir_ty={:?} user_ty={:?}", mir_ty, user_ty);
4949 match user_ty.kind {
5050 UserTypeKind::Ty(user_ty) => relate_mir_and_user_ty(ocx, param_env, span, mir_ty, user_ty)?,
compiler/rustc_traits/src/implied_outlives_bounds.rs+2-2
......@@ -7,7 +7,7 @@ use rustc_infer::infer::canonical::{self, Canonical};
77use rustc_infer::traits::query::OutlivesBound;
88use rustc_infer::traits::query::type_op::ImpliedOutlivesBounds;
99use rustc_middle::query::Providers;
10use rustc_middle::ty::TyCtxt;
10use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
1111use rustc_span::DUMMY_SP;
1212use rustc_trait_selection::infer::InferCtxtBuilderExt;
1313use rustc_trait_selection::traits::query::type_op::implied_outlives_bounds::compute_implied_outlives_bounds_inner;
......@@ -25,7 +25,7 @@ fn implied_outlives_bounds<'tcx>(
2525 NoSolution,
2626> {
2727 tcx.infer_ctxt().enter_canonical_trait_query(&goal, |ocx, key| {
28 let (param_env, ImpliedOutlivesBounds { ty }) = key.into_parts();
28 let ParamEnvAnd { param_env, value: ImpliedOutlivesBounds { ty } } = key;
2929 compute_implied_outlives_bounds_inner(
3030 ocx,
3131 param_env,
compiler/rustc_traits/src/type_op.rs+2-2
......@@ -43,7 +43,7 @@ fn type_op_normalize<'tcx, T>(
4343where
4444 T: fmt::Debug + TypeFoldable<TyCtxt<'tcx>>,
4545{
46 let (param_env, Normalize { value }) = key.into_parts();
46 let ParamEnvAnd { param_env, value: Normalize { value } } = key;
4747 let Normalized { value, obligations } =
4848 ocx.infcx.at(&ObligationCause::dummy(), param_env).query_normalize(value)?;
4949 ocx.register_obligations(obligations);
......@@ -96,6 +96,6 @@ pub fn type_op_prove_predicate_with_cause<'tcx>(
9696 key: ParamEnvAnd<'tcx, ProvePredicate<'tcx>>,
9797 cause: ObligationCause<'tcx>,
9898) {
99 let (param_env, ProvePredicate { predicate }) = key.into_parts();
99 let ParamEnvAnd { param_env, value: ProvePredicate { predicate } } = key;
100100 ocx.register_obligation(Obligation::new(ocx.infcx.tcx, cause, param_env, predicate));
101101}
src/librustdoc/clean/inline.rs+1-1
......@@ -217,7 +217,7 @@ pub(crate) fn try_inline_glob(
217217}
218218
219219pub(crate) fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> &'hir [hir::Attribute] {
220 cx.tcx.get_attrs_unchecked(did)
220 cx.tcx.get_all_attrs(did)
221221}
222222
223223pub(crate) fn item_relative_path(tcx: TyCtxt<'_>, def_id: DefId) -> Vec<Symbol> {
src/librustdoc/clean/types.rs+2-5
......@@ -404,10 +404,7 @@ impl Item {
404404 }
405405
406406 pub(crate) fn inner_docs(&self, tcx: TyCtxt<'_>) -> bool {
407 self.item_id
408 .as_def_id()
409 .map(|did| inner_docs(tcx.get_attrs_unchecked(did)))
410 .unwrap_or(false)
407 self.item_id.as_def_id().map(|did| inner_docs(tcx.get_all_attrs(did))).unwrap_or(false)
411408 }
412409
413410 pub(crate) fn span(&self, tcx: TyCtxt<'_>) -> Option<Span> {
......@@ -452,7 +449,7 @@ impl Item {
452449 kind: ItemKind,
453450 cx: &mut DocContext<'_>,
454451 ) -> Item {
455 let hir_attrs = cx.tcx.get_attrs_unchecked(def_id);
452 let hir_attrs = cx.tcx.get_all_attrs(def_id);
456453
457454 Self::from_def_id_and_attrs_and_parts(
458455 def_id,
src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs+1-1
......@@ -185,7 +185,7 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
185185 if let Some(adt) = ty.ty_adt_def()
186186 && get_attr(
187187 self.cx.sess(),
188 self.cx.tcx.get_attrs_unchecked(adt.did()),
188 self.cx.tcx.get_all_attrs(adt.did()),
189189 sym::has_significant_drop,
190190 )
191191 .count()
src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs+1-1
......@@ -168,7 +168,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
168168 if let Some(adt) = ty.ty_adt_def() {
169169 let mut iter = get_attr(
170170 self.cx.sess(),
171 self.cx.tcx.get_attrs_unchecked(adt.did()),
171 self.cx.tcx.get_all_attrs(adt.did()),
172172 sym::has_significant_drop,
173173 );
174174 if iter.next().is_some() {
src/tools/clippy/clippy_utils/src/macros.rs+1-1
......@@ -42,7 +42,7 @@ pub fn is_format_macro(cx: &LateContext<'_>, macro_def_id: DefId) -> bool {
4242 } else {
4343 // Allow users to tag any macro as being format!-like
4444 // TODO: consider deleting FORMAT_MACRO_DIAG_ITEMS and using just this method
45 get_unique_attr(cx.sess(), cx.tcx.get_attrs_unchecked(macro_def_id), sym::format_args).is_some()
45 get_unique_attr(cx.sess(), cx.tcx.get_all_attrs(macro_def_id), sym::format_args).is_some()
4646 }
4747}
4848
tests/mir-opt/sroa/simd_sroa.foo.ScalarReplacementOfAggregates.diff created+32
......@@ -0,0 +1,32 @@
1- // MIR for `foo` before ScalarReplacementOfAggregates
2+ // MIR for `foo` after ScalarReplacementOfAggregates
3
4 fn foo(_1: &[Simd<u8, 16>], _2: Simd<u8, 16>) -> () {
5 debug simds => _1;
6 debug _unused => _2;
7 let mut _0: ();
8 let _3: std::simd::Simd<u8, 16>;
9 let _4: usize;
10 let mut _5: usize;
11 let mut _6: bool;
12 scope 1 {
13 debug a => _3;
14 }
15
16 bb0: {
17 StorageLive(_3);
18 StorageLive(_4);
19 _4 = const 0_usize;
20 _5 = PtrMetadata(copy _1);
21 _6 = Lt(copy _4, copy _5);
22 assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, copy _4) -> [success: bb1, unwind continue];
23 }
24
25 bb1: {
26 _3 = copy (*_1)[_4];
27 StorageDead(_4);
28 StorageDead(_3);
29 return;
30 }
31 }
32
tests/mir-opt/sroa/simd_sroa.rs created+18
......@@ -0,0 +1,18 @@
1//@ needs-unwind
2#![feature(portable_simd)]
3
4// SRoA expands things even if they're unused
5// <https://github.com/rust-lang/rust/issues/144621>
6
7use std::simd::Simd;
8
9// EMIT_MIR simd_sroa.foo.ScalarReplacementOfAggregates.diff
10pub(crate) fn foo(simds: &[Simd<u8, 16>], _unused: Simd<u8, 16>) {
11 // CHECK-LABEL: fn foo
12 // CHECK-NOT: [u8; 16]
13 // CHECK: let [[SIMD:_.+]]: std::simd::Simd<u8, 16>;
14 // CHECK-NOT: [u8; 16]
15 // CHECK: [[SIMD]] = copy (*_1)[0 of 1];
16 // CHECK-NOT: [u8; 16]
17 let a = simds[0];
18}
tests/ui/error-emitter/auxiliary/close_window.rs created+4
......@@ -0,0 +1,4 @@
1pub struct S;
2impl S {
3 fn method(&self) {}
4}
tests/ui/error-emitter/close_window.ascii.stderr created+14
......@@ -0,0 +1,14 @@
1error[E0624]: method `method` is private
2 --> $DIR/close_window.rs:9:7
3 |
4LL | s.method();
5 | ^^^^^^ private method
6 |
7 ::: $DIR/auxiliary/close_window.rs:3:5
8 |
9LL | fn method(&self) {}
10 | ---------------- private method defined here
11
12error: aborting due to 1 previous error
13
14For more information about this error, try `rustc --explain E0624`.
tests/ui/error-emitter/close_window.rs created+11
......@@ -0,0 +1,11 @@
1//@ aux-build:close_window.rs
2//@ revisions: ascii unicode
3//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode
4
5extern crate close_window;
6
7fn main() {
8 let s = close_window::S;
9 s.method();
10 //[ascii]~^ ERROR method `method` is private
11}
tests/ui/error-emitter/close_window.unicode.stderr created+14
......@@ -0,0 +1,14 @@
1error[E0624]: method `method` is private
2 ╭▸ $DIR/close_window.rs:9:7
3
4LL │ s.method();
5 │ ━━━━━━ private method
6
7 ⸬ $DIR/auxiliary/close_window.rs:3:5
8
9LL │ fn method(&self) {}
10 ╰╴ ──────────────── private method defined here
11
12error: aborting due to 1 previous error
13
14For more information about this error, try `rustc --explain E0624`.