authorbors <bors@rust-lang.org> 2025-05-27 18:59:47 UTC
committerbors <bors@rust-lang.org> 2025-05-27 18:59:47 UTC
log45f256d9d7cffb66185c0bf1b8a864cba79db90c
tree4944e765bd2e520e4de9e977a78e769099e06de4
parentc583fa6d8425dbb38fe5d1dbd007f9ca8e4aa128
parentc7d0a61e2211dd3821933aae7ab83e9e0b043f37

Auto merge of #141662 - matthiaskrgr:rollup-9kt4zj7, r=matthiaskrgr

Rollup of 8 pull requests Successful merges: - rust-lang/rust#141312 (Add From<TryLockError> for io::Error) - rust-lang/rust#141495 (Rename `{GenericArg,Term}::unpack()` to `kind()`) - rust-lang/rust#141602 (triagebot: label LLVM submodule changes with `A-LLVM`) - rust-lang/rust#141632 (remove `visit_mt` from `ast::mut_visit`) - rust-lang/rust#141640 (test: convert version_check ui test to run-make) - rust-lang/rust#141645 (bump fluent-* crates) - rust-lang/rust#141650 (coverage: Revert "unused local file IDs" due to empty function names) - rust-lang/rust#141654 (tests: mark option-niche-eq as fixed on LLVM 21) Failed merges: - rust-lang/rust#141430 (remove `visit_clobber` and move `DummyAstNode` to `rustc_expand`) - rust-lang/rust#141636 (avoid some usages of `&mut P<T>` in AST visitors) r? `@ghost` `@rustbot` modify labels: rollup

112 files changed, 336 insertions(+), 413 deletions(-)

Cargo.lock+10-18
......@@ -1259,16 +1259,16 @@ dependencies = [
12591259
12601260[[package]]
12611261name = "fluent-bundle"
1262version = "0.15.3"
1262version = "0.16.0"
12631263source = "registry+https://github.com/rust-lang/crates.io-index"
1264checksum = "7fe0a21ee80050c678013f82edf4b705fe2f26f1f9877593d13198612503f493"
1264checksum = "01203cb8918f5711e73891b347816d932046f95f54207710bda99beaeb423bf4"
12651265dependencies = [
12661266 "fluent-langneg",
12671267 "fluent-syntax",
12681268 "intl-memoizer",
12691269 "intl_pluralrules",
1270 "rustc-hash 1.1.0",
1271 "self_cell 0.10.3",
1270 "rustc-hash 2.1.1",
1271 "self_cell",
12721272 "smallvec",
12731273 "unic-langid",
12741274]
......@@ -1284,11 +1284,12 @@ dependencies = [
12841284
12851285[[package]]
12861286name = "fluent-syntax"
1287version = "0.11.1"
1287version = "0.12.0"
12881288source = "registry+https://github.com/rust-lang/crates.io-index"
1289checksum = "2a530c4694a6a8d528794ee9bbd8ba0122e779629ac908d15ad5a7ae7763a33d"
1289checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198"
12901290dependencies = [
1291 "thiserror 1.0.69",
1291 "memchr",
1292 "thiserror 2.0.12",
12921293]
12931294
12941295[[package]]
......@@ -1934,9 +1935,9 @@ dependencies = [
19341935
19351936[[package]]
19361937name = "intl-memoizer"
1937version = "0.5.2"
1938version = "0.5.3"
19381939source = "registry+https://github.com/rust-lang/crates.io-index"
1939checksum = "fe22e020fce238ae18a6d5d8c502ee76a52a6e880d99477657e6acc30ec57bda"
1940checksum = "310da2e345f5eb861e7a07ee182262e94975051db9e4223e909ba90f392f163f"
19401941dependencies = [
19411942 "type-map",
19421943 "unic-langid",
......@@ -4832,15 +4833,6 @@ version = "1.2.0"
48324833source = "registry+https://github.com/rust-lang/crates.io-index"
48334834checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
48344835
4835[[package]]
4836name = "self_cell"
4837version = "0.10.3"
4838source = "registry+https://github.com/rust-lang/crates.io-index"
4839checksum = "e14e4d63b804dc0c7ec4a1e52bcb63f02c7ac94476755aa579edac21e01f915d"
4840dependencies = [
4841 "self_cell 1.2.0",
4842]
4843
48444836[[package]]
48454837name = "self_cell"
48464838version = "1.2.0"
compiler/rustc_ast/src/mut_visit.rs+3-11
......@@ -300,10 +300,6 @@ pub trait MutVisitor: Sized {
300300 walk_precise_capturing_arg(self, arg);
301301 }
302302
303 fn visit_mt(&mut self, mt: &mut MutTy) {
304 walk_mt(self, mt);
305 }
306
307303 fn visit_expr_field(&mut self, f: &mut ExprField) {
308304 walk_expr_field(self, f);
309305 }
......@@ -519,10 +515,10 @@ pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) {
519515 TyKind::Infer | TyKind::ImplicitSelf | TyKind::Dummy | TyKind::Never | TyKind::CVarArgs => {
520516 }
521517 TyKind::Slice(ty) => vis.visit_ty(ty),
522 TyKind::Ptr(mt) => vis.visit_mt(mt),
523 TyKind::Ref(lt, mt) | TyKind::PinnedRef(lt, mt) => {
518 TyKind::Ptr(MutTy { ty, mutbl: _ }) => vis.visit_ty(ty),
519 TyKind::Ref(lt, MutTy { ty, mutbl: _ }) | TyKind::PinnedRef(lt, MutTy { ty, mutbl: _ }) => {
524520 visit_opt(lt, |lt| vis.visit_lifetime(lt));
525 vis.visit_mt(mt);
521 vis.visit_ty(ty);
526522 }
527523 TyKind::BareFn(bft) => {
528524 let BareFnTy { safety, ext: _, generic_params, decl, decl_span } = bft.deref_mut();
......@@ -1003,10 +999,6 @@ pub fn walk_flat_map_expr_field<T: MutVisitor>(
1003999 smallvec![f]
10041000}
10051001
1006fn walk_mt<T: MutVisitor>(vis: &mut T, MutTy { ty, mutbl: _ }: &mut MutTy) {
1007 vis.visit_ty(ty);
1008}
1009
10101002pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) {
10111003 let Block { id, stmts, rules: _, span, tokens: _ } = block.deref_mut();
10121004 vis.visit_id(id);
compiler/rustc_borrowck/src/diagnostics/region_name.rs+4-4
......@@ -606,8 +606,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
606606 hir_args: &'hir hir::GenericArgs<'hir>,
607607 search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty<'hir>)>,
608608 ) -> Option<&'hir hir::Lifetime> {
609 for (kind, hir_arg) in iter::zip(args, hir_args.args) {
610 match (kind.unpack(), hir_arg) {
609 for (arg, hir_arg) in iter::zip(args, hir_args.args) {
610 match (arg.kind(), hir_arg) {
611611 (GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => {
612612 if r.as_var() == needle_fr {
613613 return Some(lt);
......@@ -631,7 +631,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
631631 ) => {
632632 self.dcx().span_delayed_bug(
633633 hir_arg.span(),
634 format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
634 format!("unmatched arg and hir arg: found {arg:?} vs {hir_arg:?}"),
635635 );
636636 }
637637 }
......@@ -997,7 +997,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
997997 ) -> bool {
998998 let tcx = self.infcx.tcx;
999999 ty.walk().any(|arg| {
1000 if let ty::GenericArgKind::Type(ty) = arg.unpack()
1000 if let ty::GenericArgKind::Type(ty) = arg.kind()
10011001 && let ty::Param(_) = ty.kind()
10021002 {
10031003 clauses.iter().any(|pred| {
compiler/rustc_borrowck/src/type_check/constraint_conversion.rs+1-1
......@@ -148,7 +148,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
148148
149149 let mut next_outlives_predicates = vec![];
150150 for (ty::OutlivesPredicate(k1, r2), constraint_category) in outlives_predicates {
151 match k1.unpack() {
151 match k1.kind() {
152152 GenericArgKind::Lifetime(r1) => {
153153 let r1_vid = self.to_region_vid(r1);
154154 let r2_vid = self.to_region_vid(r2);
compiler/rustc_borrowck/src/type_check/opaque_types.rs+1-1
......@@ -221,7 +221,7 @@ fn register_member_constraints<'tcx>(
221221 .iter()
222222 .enumerate()
223223 .filter(|(i, _)| variances[*i] == ty::Invariant)
224 .filter_map(|(_, arg)| match arg.unpack() {
224 .filter_map(|(_, arg)| match arg.kind() {
225225 GenericArgKind::Lifetime(r) => Some(typeck.to_region_vid(r)),
226226 GenericArgKind::Type(_) | GenericArgKind::Const(_) => None,
227227 })
compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs+5-21
......@@ -155,20 +155,6 @@ pub(crate) struct Regions {
155155impl Regions {
156156 /// Returns true if none of this structure's tables contain any regions.
157157 pub(crate) fn has_no_regions(&self) -> bool {
158 // Every region has a span, so if there are no spans then there are no regions.
159 self.all_cov_spans().next().is_none()
160 }
161
162 pub(crate) fn all_cov_spans(&self) -> impl Iterator<Item = &CoverageSpan> {
163 macro_rules! iter_cov_spans {
164 ( $( $regions:expr ),* $(,)? ) => {
165 std::iter::empty()
166 $(
167 .chain( $regions.iter().map(|region| &region.cov_span) )
168 )*
169 }
170 }
171
172158 let Self {
173159 code_regions,
174160 expansion_regions,
......@@ -177,13 +163,11 @@ impl Regions {
177163 mcdc_decision_regions,
178164 } = self;
179165
180 iter_cov_spans!(
181 code_regions,
182 expansion_regions,
183 branch_regions,
184 mcdc_branch_regions,
185 mcdc_decision_regions,
186 )
166 code_regions.is_empty()
167 && expansion_regions.is_empty()
168 && branch_regions.is_empty()
169 && mcdc_branch_regions.is_empty()
170 && mcdc_decision_regions.is_empty()
187171 }
188172}
189173
compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs+10-34
......@@ -11,7 +11,6 @@ use rustc_abi::Align;
1111use rustc_codegen_ssa::traits::{
1212 BaseTypeCodegenMethods as _, ConstCodegenMethods, StaticCodegenMethods,
1313};
14use rustc_index::IndexVec;
1514use rustc_middle::mir::coverage::{
1615 BasicCoverageBlock, CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping,
1716 MappingKind, Op,
......@@ -105,16 +104,6 @@ fn fill_region_tables<'tcx>(
105104 ids_info: &'tcx CoverageIdsInfo,
106105 covfun: &mut CovfunRecord<'tcx>,
107106) {
108 // If this function is unused, replace all counters with zero.
109 let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter {
110 let term = if covfun.is_used {
111 ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term")
112 } else {
113 CovTerm::Zero
114 };
115 ffi::Counter::from_term(term)
116 };
117
118107 // Currently a function's mappings must all be in the same file, so use the
119108 // first mapping's span to determine the file.
120109 let source_map = tcx.sess.source_map();
......@@ -126,12 +115,6 @@ fn fill_region_tables<'tcx>(
126115
127116 let local_file_id = covfun.virtual_file_mapping.push_file(&source_file);
128117
129 // If this testing flag is set, add an extra unused entry to the local
130 // file table, to help test the code for detecting unused file IDs.
131 if tcx.sess.coverage_inject_unused_local_file() {
132 covfun.virtual_file_mapping.push_file(&source_file);
133 }
134
135118 // In rare cases, _all_ of a function's spans are discarded, and coverage
136119 // codegen needs to handle that gracefully to avoid #133606.
137120 // It's hard for tests to trigger this organically, so instead we set
......@@ -152,6 +135,16 @@ fn fill_region_tables<'tcx>(
152135 // For each counter/region pair in this function+file, convert it to a
153136 // form suitable for FFI.
154137 for &Mapping { ref kind, span } in &fn_cov_info.mappings {
138 // If this function is unused, replace all counters with zero.
139 let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter {
140 let term = if covfun.is_used {
141 ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term")
142 } else {
143 CovTerm::Zero
144 };
145 ffi::Counter::from_term(term)
146 };
147
155148 let Some(coords) = make_coords(span) else { continue };
156149 let cov_span = coords.make_coverage_span(local_file_id);
157150
......@@ -184,19 +177,6 @@ fn fill_region_tables<'tcx>(
184177 }
185178}
186179
187/// LLVM requires all local file IDs to have at least one mapping region.
188/// If that's not the case, skip this function, to avoid an assertion failure
189/// (or worse) in LLVM.
190fn check_local_file_table(covfun: &CovfunRecord<'_>) -> bool {
191 let mut local_file_id_seen =
192 IndexVec::<u32, _>::from_elem_n(false, covfun.virtual_file_mapping.local_file_table.len());
193 for cov_span in covfun.regions.all_cov_spans() {
194 local_file_id_seen[cov_span.file_id] = true;
195 }
196
197 local_file_id_seen.into_iter().all(|seen| seen)
198}
199
200180/// Generates the contents of the covfun record for this function, which
201181/// contains the function's coverage mapping data. The record is then stored
202182/// as a global variable in the `__llvm_covfun` section.
......@@ -205,10 +185,6 @@ pub(crate) fn generate_covfun_record<'tcx>(
205185 global_file_table: &GlobalFileTable,
206186 covfun: &CovfunRecord<'tcx>,
207187) {
208 if !check_local_file_table(covfun) {
209 return;
210 }
211
212188 let &CovfunRecord {
213189 mangled_function_name,
214190 source_hash,
compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs+24-4
......@@ -39,10 +39,7 @@ impl Coords {
3939/// or other expansions), and if it does happen then skipping a span or function is
4040/// better than an ICE or `llvm-cov` failure that the user might have no way to avoid.
4141pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span) -> Option<Coords> {
42 if span.is_empty() {
43 debug_assert!(false, "can't make coords from empty span: {span:?}");
44 return None;
45 }
42 let span = ensure_non_empty_span(source_map, span)?;
4643
4744 let lo = span.lo();
4845 let hi = span.hi();
......@@ -73,6 +70,29 @@ pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span)
7370 })
7471}
7572
73fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
74 if !span.is_empty() {
75 return Some(span);
76 }
77
78 // The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
79 source_map
80 .span_to_source(span, |src, start, end| try {
81 // Adjusting span endpoints by `BytePos(1)` is normally a bug,
82 // but in this case we have specifically checked that the character
83 // we're skipping over is one of two specific ASCII characters, so
84 // adjusting by exactly 1 byte is correct.
85 if src.as_bytes().get(end).copied() == Some(b'{') {
86 Some(span.with_hi(span.hi() + BytePos(1)))
87 } else if start > 0 && src.as_bytes()[start - 1] == b'}' {
88 Some(span.with_lo(span.lo() - BytePos(1)))
89 } else {
90 None
91 }
92 })
93 .ok()?
94}
95
7696/// If `llvm-cov` sees a source region that is improperly ordered (end < start),
7797/// it will immediately exit with a fatal error. To prevent that from happening,
7898/// discard regions that are improperly ordered, or might be interpreted in a
compiler/rustc_codegen_ssa/src/meth.rs+1-1
......@@ -77,7 +77,7 @@ fn dyn_trait_in_self<'tcx>(
7777 ty: Ty<'tcx>,
7878) -> Option<ty::ExistentialTraitRef<'tcx>> {
7979 for arg in ty.peel_refs().walk() {
80 if let GenericArgKind::Type(ty) = arg.unpack()
80 if let GenericArgKind::Type(ty) = arg.kind()
8181 && let ty::Dynamic(data, _, _) = ty.kind()
8282 {
8383 // FIXME(arbitrary_self_types): This is likely broken for receivers which
compiler/rustc_const_eval/src/check_consts/ops.rs+1-1
......@@ -281,7 +281,7 @@ fn build_error_for_const_call<'tcx>(
281281 let mut sugg = None;
282282
283283 if ccx.tcx.is_lang_item(trait_id, LangItem::PartialEq) {
284 match (args[0].unpack(), args[1].unpack()) {
284 match (args[0].kind(), args[1].kind()) {
285285 (GenericArgKind::Type(self_ty), GenericArgKind::Type(rhs_ty))
286286 if self_ty == rhs_ty
287287 && self_ty.is_ref()
compiler/rustc_const_eval/src/util/type_name.rs+1-1
......@@ -125,7 +125,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
125125 ) -> Result<(), PrintError> {
126126 print_prefix(self)?;
127127 let args =
128 args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
128 args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)));
129129 if args.clone().next().is_some() {
130130 self.generic_delimiters(|cx| cx.comma_sep(args))
131131 } else {
compiler/rustc_error_messages/Cargo.toml+2-2
......@@ -5,8 +5,8 @@ edition = "2024"
55
66[dependencies]
77# tidy-alphabetical-start
8fluent-bundle = "0.15.2"
9fluent-syntax = "0.11"
8fluent-bundle = "0.16"
9fluent-syntax = "0.12"
1010icu_list = "1.2"
1111icu_locid = "1.2"
1212icu_provider_adapters = "1.2"
compiler/rustc_fluent_macro/Cargo.toml+2-2
......@@ -9,8 +9,8 @@ proc-macro = true
99[dependencies]
1010# tidy-alphabetical-start
1111annotate-snippets = "0.11"
12fluent-bundle = "0.15.2"
13fluent-syntax = "0.11"
12fluent-bundle = "0.16"
13fluent-syntax = "0.12"
1414proc-macro2 = "1"
1515quote = "1"
1616syn = { version = "2", features = ["full"] }
compiler/rustc_hir_analysis/src/check/check.rs+2-2
......@@ -1575,7 +1575,7 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
15751575
15761576 let mut params_used = DenseBitSet::new_empty(generics.own_params.len());
15771577 for leaf in ty.walk() {
1578 if let GenericArgKind::Type(leaf_ty) = leaf.unpack()
1578 if let GenericArgKind::Type(leaf_ty) = leaf.kind()
15791579 && let ty::Param(param) = leaf_ty.kind()
15801580 {
15811581 debug!("found use of ty param {:?}", param);
......@@ -1700,7 +1700,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, opaque_def_id: LocalDefId) -> ErrorG
17001700
17011701 let mut label_match = |ty: Ty<'_>, span| {
17021702 for arg in ty.walk() {
1703 if let ty::GenericArgKind::Type(ty) = arg.unpack()
1703 if let ty::GenericArgKind::Type(ty) = arg.kind()
17041704 && let ty::Alias(
17051705 ty::Opaque,
17061706 ty::AliasTy { def_id: captured_def_id, .. },
compiler/rustc_hir_analysis/src/check/compare_impl_item.rs+2-2
......@@ -1231,7 +1231,7 @@ fn check_region_late_boundedness<'tcx>(
12311231 for (id_arg, arg) in
12321232 std::iter::zip(ty::GenericArgs::identity_for_item(tcx, impl_m.def_id), impl_m_args)
12331233 {
1234 if let ty::GenericArgKind::Lifetime(r) = arg.unpack()
1234 if let ty::GenericArgKind::Lifetime(r) = arg.kind()
12351235 && let ty::ReVar(vid) = r.kind()
12361236 && let r = infcx
12371237 .inner
......@@ -1256,7 +1256,7 @@ fn check_region_late_boundedness<'tcx>(
12561256 for (id_arg, arg) in
12571257 std::iter::zip(ty::GenericArgs::identity_for_item(tcx, trait_m.def_id), trait_m_args)
12581258 {
1259 if let ty::GenericArgKind::Lifetime(r) = arg.unpack()
1259 if let ty::GenericArgKind::Lifetime(r) = arg.kind()
12601260 && let ty::ReVar(vid) = r.kind()
12611261 && let r = infcx
12621262 .inner
compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs+1-1
......@@ -427,7 +427,7 @@ fn report_mismatched_rpitit_captures<'tcx>(
427427 };
428428
429429 trait_captured_args
430 .sort_by_cached_key(|arg| !matches!(arg.unpack(), ty::GenericArgKind::Lifetime(_)));
430 .sort_by_cached_key(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_)));
431431 let suggestion = format!("use<{}>", trait_captured_args.iter().join(", "));
432432
433433 tcx.emit_node_span_lint(
compiler/rustc_hir_analysis/src/check/wfcheck.rs+2-2
......@@ -819,7 +819,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GATArgsCollector<'tcx> {
819819 match t.kind() {
820820 ty::Alias(ty::Projection, p) if p.def_id == self.gat => {
821821 for (idx, arg) in p.args.iter().enumerate() {
822 match arg.unpack() {
822 match arg.kind() {
823823 GenericArgKind::Lifetime(lt) if !lt.is_bound() => {
824824 self.regions.insert((lt, idx));
825825 }
......@@ -1517,7 +1517,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
15171517 } else {
15181518 // If we've got a generic const parameter we still want to check its
15191519 // type is correct in case both it and the param type are fully concrete.
1520 let GenericArgKind::Const(ct) = default.unpack() else {
1520 let GenericArgKind::Const(ct) = default.kind() else {
15211521 continue;
15221522 };
15231523
compiler/rustc_hir_analysis/src/collect/item_bounds.rs+1-1
......@@ -151,7 +151,7 @@ fn remap_gat_vars_and_recurse_into_nested_projections<'tcx>(
151151 let mut mapping = FxIndexMap::default();
152152 let generics = tcx.generics_of(assoc_item_def_id);
153153 for (param, var) in std::iter::zip(&generics.own_params, gat_vars) {
154 let existing = match var.unpack() {
154 let existing = match var.kind() {
155155 ty::GenericArgKind::Lifetime(re) => {
156156 if let ty::RegionKind::ReBound(ty::INNERMOST, bv) = re.kind() {
157157 mapping.insert(bv.var, tcx.mk_param_from_def(param))
compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs+1-1
......@@ -215,7 +215,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
215215 let pred = bound_predicate.rebind(pred);
216216 // A `Self` within the original bound will be instantiated with a
217217 // `trait_object_dummy_self`, so check for that.
218 let references_self = match pred.skip_binder().term.unpack() {
218 let references_self = match pred.skip_binder().term.kind() {
219219 ty::TermKind::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()),
220220 // FIXME(associated_const_equality): We should walk the const instead of not doing anything
221221 ty::TermKind::Const(_) => false,
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs+1-1
......@@ -611,7 +611,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
611611 if !infer_args && has_default {
612612 // No type parameter provided, but a default exists.
613613 if let Some(prev) =
614 preceding_args.iter().find_map(|arg| match arg.unpack() {
614 preceding_args.iter().find_map(|arg| match arg.kind() {
615615 GenericArgKind::Type(ty) => ty.error_reported().err(),
616616 _ => None,
617617 })
compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs+2-2
......@@ -119,7 +119,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
119119 explicit_map: &mut ExplicitPredicatesMap<'tcx>,
120120) {
121121 for arg in ty.walk() {
122 let leaf_ty = match arg.unpack() {
122 let leaf_ty = match arg.kind() {
123123 GenericArgKind::Type(ty) => ty,
124124
125125 // No predicates from lifetimes or constants, except potentially
......@@ -299,7 +299,7 @@ fn check_explicit_predicates<'tcx>(
299299 // binding) and thus infer an outlives requirement that `X:
300300 // 'b`.
301301 if let Some(self_ty) = ignored_self_ty
302 && let GenericArgKind::Type(ty) = outlives_predicate.0.unpack()
302 && let GenericArgKind::Type(ty) = outlives_predicate.0.kind()
303303 && ty.walk().any(|arg| arg == self_ty.into())
304304 {
305305 debug!("skipping self ty = {ty:?}");
compiler/rustc_hir_analysis/src/outlives/mod.rs+2-2
......@@ -69,8 +69,8 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
6969 .map(|(&def_id, set)| {
7070 let predicates =
7171 &*tcx.arena.alloc_from_iter(set.as_ref().skip_binder().iter().filter_map(
72 |(ty::OutlivesPredicate(kind1, region2), &span)| {
73 match kind1.unpack() {
72 |(ty::OutlivesPredicate(arg1, region2), &span)| {
73 match arg1.kind() {
7474 GenericArgKind::Type(ty1) => Some((
7575 ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(ty1, *region2))
7676 .upcast(tcx),
compiler/rustc_hir_analysis/src/outlives/utils.rs+3-3
......@@ -14,7 +14,7 @@ pub(crate) type RequiredPredicates<'tcx> =
1414/// outlives_component and add it to `required_predicates`
1515pub(crate) fn insert_outlives_predicate<'tcx>(
1616 tcx: TyCtxt<'tcx>,
17 kind: GenericArg<'tcx>,
17 arg: GenericArg<'tcx>,
1818 outlived_region: Region<'tcx>,
1919 span: Span,
2020 required_predicates: &mut RequiredPredicates<'tcx>,
......@@ -25,7 +25,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>(
2525 return;
2626 }
2727
28 match kind.unpack() {
28 match arg.kind() {
2929 GenericArgKind::Type(ty) => {
3030 // `T: 'outlived_region` for some type `T`
3131 // But T could be a lot of things:
......@@ -135,7 +135,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>(
135135 if !is_free_region(r) {
136136 return;
137137 }
138 required_predicates.entry(ty::OutlivesPredicate(kind, outlived_region)).or_insert(span);
138 required_predicates.entry(ty::OutlivesPredicate(arg, outlived_region)).or_insert(span);
139139 }
140140
141141 GenericArgKind::Const(_) => {
compiler/rustc_hir_analysis/src/variance/constraints.rs+5-5
......@@ -200,8 +200,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
200200 // Trait are always invariant so we can take advantage of that.
201201 let variance_i = self.invariant(variance);
202202
203 for k in args {
204 match k.unpack() {
203 for arg in args {
204 match arg.kind() {
205205 GenericArgKind::Lifetime(lt) => {
206206 self.add_constraints_from_region(current, lt, variance_i)
207207 }
......@@ -294,7 +294,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
294294 }
295295
296296 for projection in data.projection_bounds() {
297 match projection.skip_binder().term.unpack() {
297 match projection.skip_binder().term.kind() {
298298 ty::TermKind::Ty(ty) => {
299299 self.add_constraints_from_ty(current, ty, self.invariant);
300300 }
......@@ -373,7 +373,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
373373 (None, Some(self.tcx().variances_of(def_id)))
374374 };
375375
376 for (i, k) in args.iter().enumerate() {
376 for (i, arg) in args.iter().enumerate() {
377377 let variance_decl = if let Some(InferredIndex(start)) = local {
378378 // Parameter on an item defined within current crate:
379379 // variance not yet inferred, so return a symbolic
......@@ -389,7 +389,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
389389 "add_constraints_from_args: variance_decl={:?} variance_i={:?}",
390390 variance_decl, variance_i
391391 );
392 match k.unpack() {
392 match arg.kind() {
393393 GenericArgKind::Lifetime(lt) => {
394394 self.add_constraints_from_region(current, lt, variance_i)
395395 }
compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs+11-11
......@@ -80,12 +80,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8080 let find_param_matching = |matches: &dyn Fn(ty::ParamTerm) -> bool| {
8181 predicate_args.iter().find_map(|arg| {
8282 arg.walk().find_map(|arg| {
83 if let ty::GenericArgKind::Type(ty) = arg.unpack()
83 if let ty::GenericArgKind::Type(ty) = arg.kind()
8484 && let ty::Param(param_ty) = *ty.kind()
8585 && matches(ty::ParamTerm::Ty(param_ty))
8686 {
8787 Some(arg)
88 } else if let ty::GenericArgKind::Const(ct) = arg.unpack()
88 } else if let ty::GenericArgKind::Const(ct) = arg.kind()
8989 && let ty::ConstKind::Param(param_ct) = ct.kind()
9090 && matches(ty::ParamTerm::Const(param_ct))
9191 {
......@@ -357,7 +357,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
357357 &self,
358358 error: &mut traits::FulfillmentError<'tcx>,
359359 def_id: DefId,
360 param: ty::GenericArg<'tcx>,
360 arg: ty::GenericArg<'tcx>,
361361 qpath: &hir::QPath<'tcx>,
362362 ) -> bool {
363363 match qpath {
......@@ -365,7 +365,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
365365 for segment in path.segments.iter().rev() {
366366 if let Res::Def(kind, def_id) = segment.res
367367 && !matches!(kind, DefKind::Mod | DefKind::ForeignMod)
368 && self.point_at_generic_if_possible(error, def_id, param, segment)
368 && self.point_at_generic_if_possible(error, def_id, arg, segment)
369369 {
370370 return true;
371371 }
......@@ -373,7 +373,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
373373 // Handle `Self` param specifically, since it's separated in
374374 // the path representation
375375 if let Some(self_ty) = self_ty
376 && let ty::GenericArgKind::Type(ty) = param.unpack()
376 && let ty::GenericArgKind::Type(ty) = arg.kind()
377377 && ty == self.tcx.types.self_param
378378 {
379379 error.obligation.cause.span = self_ty
......@@ -384,12 +384,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
384384 }
385385 }
386386 hir::QPath::TypeRelative(self_ty, segment) => {
387 if self.point_at_generic_if_possible(error, def_id, param, segment) {
387 if self.point_at_generic_if_possible(error, def_id, arg, segment) {
388388 return true;
389389 }
390390 // Handle `Self` param specifically, since it's separated in
391391 // the path representation
392 if let ty::GenericArgKind::Type(ty) = param.unpack()
392 if let ty::GenericArgKind::Type(ty) = arg.kind()
393393 && ty == self.tcx.types.self_param
394394 {
395395 error.obligation.cause.span = self_ty
......@@ -424,10 +424,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
424424 // the args list does not, then we should chop off all of the lifetimes,
425425 // since they're all elided.
426426 let segment_args = segment.args().args;
427 if matches!(own_args[0].unpack(), ty::GenericArgKind::Lifetime(_))
427 if matches!(own_args[0].kind(), ty::GenericArgKind::Lifetime(_))
428428 && segment_args.first().is_some_and(|arg| arg.is_ty_or_const())
429429 && let Some(offset) = own_args.iter().position(|arg| {
430 matches!(arg.unpack(), ty::GenericArgKind::Type(_) | ty::GenericArgKind::Const(_))
430 matches!(arg.kind(), ty::GenericArgKind::Type(_) | ty::GenericArgKind::Const(_))
431431 })
432432 && let Some(new_index) = index.checked_sub(offset)
433433 {
......@@ -750,7 +750,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
750750 return Ok(expr);
751751 }
752752
753 let ty::GenericArgKind::Type(in_ty) = in_ty.unpack() else {
753 let ty::GenericArgKind::Type(in_ty) = in_ty.kind() else {
754754 return Err(expr);
755755 };
756756
......@@ -1045,7 +1045,7 @@ fn find_param_in_ty<'tcx>(
10451045 if arg == param_to_point_at {
10461046 return true;
10471047 }
1048 if let ty::GenericArgKind::Type(ty) = arg.unpack()
1048 if let ty::GenericArgKind::Type(ty) = arg.kind()
10491049 && let ty::Alias(ty::Projection | ty::Inherent, ..) = ty.kind()
10501050 {
10511051 // This logic may seem a bit strange, but typically when
compiler/rustc_hir_typeck/src/method/suggest.rs+2-2
......@@ -2226,7 +2226,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22262226 let infer_args = self.tcx.mk_args_from_iter(args.into_iter().map(|arg| {
22272227 if !arg.is_suggestable(self.tcx, true) {
22282228 has_unsuggestable_args = true;
2229 match arg.unpack() {
2229 match arg.kind() {
22302230 GenericArgKind::Lifetime(_) => self
22312231 .next_region_var(RegionVariableOrigin::MiscVariable(DUMMY_SP))
22322232 .into(),
......@@ -2843,7 +2843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28432843 let [first] = ***args else {
28442844 return;
28452845 };
2846 let ty::GenericArgKind::Type(ty) = first.unpack() else {
2846 let ty::GenericArgKind::Type(ty) = first.kind() else {
28472847 return;
28482848 };
28492849 let Ok(pick) = self.lookup_probe_for_diagnostic(
compiler/rustc_infer/src/infer/at.rs+1-1
......@@ -347,7 +347,7 @@ impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> {
347347 fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
348348 TypeTrace {
349349 cause: cause.clone(),
350 values: match (a.unpack(), b.unpack()) {
350 values: match (a.kind(), b.kind()) {
351351 (GenericArgKind::Lifetime(a), GenericArgKind::Lifetime(b)) => {
352352 ValuePairs::Regions(ExpectedFound::new(a, b))
353353 }
compiler/rustc_infer/src/infer/canonical/instantiate.rs+3-3
......@@ -61,15 +61,15 @@ where
6161 value
6262 } else {
6363 let delegate = FnMutDelegate {
64 regions: &mut |br: ty::BoundRegion| match var_values[br.var].unpack() {
64 regions: &mut |br: ty::BoundRegion| match var_values[br.var].kind() {
6565 GenericArgKind::Lifetime(l) => l,
6666 r => bug!("{:?} is a region but value is {:?}", br, r),
6767 },
68 types: &mut |bound_ty: ty::BoundTy| match var_values[bound_ty.var].unpack() {
68 types: &mut |bound_ty: ty::BoundTy| match var_values[bound_ty.var].kind() {
6969 GenericArgKind::Type(ty) => ty,
7070 r => bug!("{:?} is a type but value is {:?}", bound_ty, r),
7171 },
72 consts: &mut |bound_ct: ty::BoundVar| match var_values[bound_ct].unpack() {
72 consts: &mut |bound_ct: ty::BoundVar| match var_values[bound_ct].kind() {
7373 GenericArgKind::Const(ct) => ct,
7474 c => bug!("{:?} is a const but value is {:?}", bound_ct, c),
7575 },
compiler/rustc_infer/src/infer/canonical/query_response.rs+3-3
......@@ -245,7 +245,7 @@ impl<'tcx> InferCtxt<'tcx> {
245245 let result_value = query_response.instantiate_projected(self.tcx, &result_args, |v| {
246246 v.var_values[BoundVar::new(index)]
247247 });
248 match (original_value.unpack(), result_value.unpack()) {
248 match (original_value.kind(), result_value.kind()) {
249249 (GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
250250 if re1.is_erased() && re2.is_erased() =>
251251 {
......@@ -402,7 +402,7 @@ impl<'tcx> InferCtxt<'tcx> {
402402 // [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
403403 for (original_value, result_value) in iter::zip(&original_values.var_values, result_values)
404404 {
405 match result_value.unpack() {
405 match result_value.kind() {
406406 GenericArgKind::Type(result_value) => {
407407 // e.g., here `result_value` might be `?0` in the example above...
408408 if let ty::Bound(debruijn, b) = *result_value.kind() {
......@@ -533,7 +533,7 @@ impl<'tcx> InferCtxt<'tcx> {
533533 for (index, value1) in variables1.var_values.iter().enumerate() {
534534 let value2 = variables2(BoundVar::new(index));
535535
536 match (value1.unpack(), value2.unpack()) {
536 match (value1.kind(), value2.kind()) {
537537 (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
538538 obligations.extend(
539539 self.at(cause, param_env)
compiler/rustc_infer/src/infer/context.rs+1-1
......@@ -90,7 +90,7 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
9090 }
9191
9292 fn is_changed_arg(&self, arg: ty::GenericArg<'tcx>) -> bool {
93 match arg.unpack() {
93 match arg.kind() {
9494 ty::GenericArgKind::Lifetime(_) => {
9595 // Lifetimes should not change affect trait selection.
9696 false
compiler/rustc_infer/src/infer/mod.rs+2-2
......@@ -1372,7 +1372,7 @@ impl<'tcx> TyOrConstInferVar {
13721372 /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
13731373 /// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
13741374 pub fn maybe_from_generic_arg(arg: GenericArg<'tcx>) -> Option<Self> {
1375 match arg.unpack() {
1375 match arg.kind() {
13761376 GenericArgKind::Type(ty) => Self::maybe_from_ty(ty),
13771377 GenericArgKind::Const(ct) => Self::maybe_from_const(ct),
13781378 GenericArgKind::Lifetime(_) => None,
......@@ -1383,7 +1383,7 @@ impl<'tcx> TyOrConstInferVar {
13831383 /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
13841384 /// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
13851385 pub fn maybe_from_term(term: Term<'tcx>) -> Option<Self> {
1386 match term.unpack() {
1386 match term.kind() {
13871387 TermKind::Ty(ty) => Self::maybe_from_ty(ty),
13881388 TermKind::Const(ct) => Self::maybe_from_const(ct),
13891389 }
compiler/rustc_infer/src/infer/outlives/obligations.rs+3-3
......@@ -87,7 +87,7 @@ impl<'tcx> InferCtxt<'tcx> {
8787 ty::OutlivesPredicate(arg, r2): ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>,
8888 cause: &ObligationCause<'tcx>,
8989 ) {
90 match arg.unpack() {
90 match arg.kind() {
9191 ty::GenericArgKind::Lifetime(r1) => {
9292 self.register_region_outlives_constraint(ty::OutlivesPredicate(r1, r2), cause);
9393 }
......@@ -503,8 +503,8 @@ where
503503 opt_variances: Option<&[ty::Variance]>,
504504 ) {
505505 let constraint = origin.to_constraint_category();
506 for (index, k) in args.iter().enumerate() {
507 match k.unpack() {
506 for (index, arg) in args.iter().enumerate() {
507 match arg.kind() {
508508 GenericArgKind::Lifetime(lt) => {
509509 let variance = if let Some(variances) = opt_variances {
510510 variances[index]
compiler/rustc_infer/src/infer/relate/generalize.rs+1-1
......@@ -329,7 +329,7 @@ struct Generalizer<'me, 'tcx> {
329329impl<'tcx> Generalizer<'_, 'tcx> {
330330 /// Create an error that corresponds to the term kind in `root_term`
331331 fn cyclic_term_error(&self) -> TypeError<'tcx> {
332 match self.root_term.unpack() {
332 match self.root_term.kind() {
333333 ty::TermKind::Ty(ty) => TypeError::CyclicTy(ty),
334334 ty::TermKind::Const(ct) => TypeError::CyclicConst(ct),
335335 }
compiler/rustc_interface/src/tests.rs+1-2
......@@ -776,8 +776,7 @@ fn test_unstable_options_tracking_hash() {
776776 CoverageOptions {
777777 level: CoverageLevel::Mcdc,
778778 no_mir_spans: true,
779 discard_all_spans_in_codegen: true,
780 inject_unused_local_file: true,
779 discard_all_spans_in_codegen: true
781780 }
782781 );
783782 tracked!(crate_attr, vec!["abc".to_string()]);
compiler/rustc_lint/src/impl_trait_overcaptures.rs+1-1
......@@ -461,7 +461,7 @@ fn extract_def_id_from_arg<'tcx>(
461461 generics: &'tcx ty::Generics,
462462 arg: ty::GenericArg<'tcx>,
463463) -> DefId {
464 match arg.unpack() {
464 match arg.kind() {
465465 ty::GenericArgKind::Lifetime(re) => match re.kind() {
466466 ty::ReEarlyParam(ebr) => generics.region_param(ebr, tcx).def_id,
467467 ty::ReBound(
compiler/rustc_middle/src/ty/context.rs+2-2
......@@ -2781,7 +2781,7 @@ impl<'tcx> TyCtxt<'tcx> {
27812781 return false;
27822782 }
27832783
2784 if !matches!(args[0].unpack(), ty::GenericArgKind::Type(_)) {
2784 if !matches!(args[0].kind(), ty::GenericArgKind::Type(_)) {
27852785 return false;
27862786 }
27872787
......@@ -2803,7 +2803,7 @@ impl<'tcx> TyCtxt<'tcx> {
28032803 };
28042804
28052805 for (param, arg) in std::iter::zip(&generics.own_params, own_args) {
2806 match (&param.kind, arg.unpack()) {
2806 match (&param.kind, arg.kind()) {
28072807 (ty::GenericParamDefKind::Type { .. }, ty::GenericArgKind::Type(_))
28082808 | (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Lifetime(_))
28092809 | (ty::GenericParamDefKind::Const { .. }, ty::GenericArgKind::Const(_)) => {}
compiler/rustc_middle/src/ty/generic_args.rs+15-15
......@@ -137,7 +137,7 @@ impl<'tcx> rustc_type_ir::inherent::IntoKind for GenericArg<'tcx> {
137137 type Kind = GenericArgKind<'tcx>;
138138
139139 fn kind(self) -> Self::Kind {
140 self.unpack()
140 self.kind()
141141 }
142142}
143143
......@@ -218,7 +218,7 @@ impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> {
218218
219219impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> {
220220 fn from(value: ty::Term<'tcx>) -> Self {
221 match value.unpack() {
221 match value.kind() {
222222 ty::TermKind::Ty(t) => t.into(),
223223 ty::TermKind::Const(c) => c.into(),
224224 }
......@@ -227,7 +227,7 @@ impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> {
227227
228228impl<'tcx> GenericArg<'tcx> {
229229 #[inline]
230 pub fn unpack(self) -> GenericArgKind<'tcx> {
230 pub fn kind(self) -> GenericArgKind<'tcx> {
231231 let ptr =
232232 unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
233233 // SAFETY: use of `Interned::new_unchecked` here is ok because these
......@@ -251,7 +251,7 @@ impl<'tcx> GenericArg<'tcx> {
251251
252252 #[inline]
253253 pub fn as_region(self) -> Option<ty::Region<'tcx>> {
254 match self.unpack() {
254 match self.kind() {
255255 GenericArgKind::Lifetime(re) => Some(re),
256256 _ => None,
257257 }
......@@ -259,7 +259,7 @@ impl<'tcx> GenericArg<'tcx> {
259259
260260 #[inline]
261261 pub fn as_type(self) -> Option<Ty<'tcx>> {
262 match self.unpack() {
262 match self.kind() {
263263 GenericArgKind::Type(ty) => Some(ty),
264264 _ => None,
265265 }
......@@ -267,7 +267,7 @@ impl<'tcx> GenericArg<'tcx> {
267267
268268 #[inline]
269269 pub fn as_const(self) -> Option<ty::Const<'tcx>> {
270 match self.unpack() {
270 match self.kind() {
271271 GenericArgKind::Const(ct) => Some(ct),
272272 _ => None,
273273 }
......@@ -275,7 +275,7 @@ impl<'tcx> GenericArg<'tcx> {
275275
276276 #[inline]
277277 pub fn as_term(self) -> Option<ty::Term<'tcx>> {
278 match self.unpack() {
278 match self.kind() {
279279 GenericArgKind::Lifetime(_) => None,
280280 GenericArgKind::Type(ty) => Some(ty.into()),
281281 GenericArgKind::Const(ct) => Some(ct.into()),
......@@ -300,7 +300,7 @@ impl<'tcx> GenericArg<'tcx> {
300300 }
301301
302302 pub fn is_non_region_infer(self) -> bool {
303 match self.unpack() {
303 match self.kind() {
304304 GenericArgKind::Lifetime(_) => false,
305305 // FIXME: This shouldn't return numerical/float.
306306 GenericArgKind::Type(ty) => ty.is_ty_or_numeric_infer(),
......@@ -327,7 +327,7 @@ impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> {
327327 type Lifted = GenericArg<'tcx>;
328328
329329 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
330 match self.unpack() {
330 match self.kind() {
331331 GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()),
332332 GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()),
333333 GenericArgKind::Const(ct) => tcx.lift(ct).map(|ct| ct.into()),
......@@ -340,7 +340,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
340340 self,
341341 folder: &mut F,
342342 ) -> Result<Self, F::Error> {
343 match self.unpack() {
343 match self.kind() {
344344 GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into),
345345 GenericArgKind::Type(ty) => ty.try_fold_with(folder).map(Into::into),
346346 GenericArgKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
......@@ -348,7 +348,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
348348 }
349349
350350 fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
351 match self.unpack() {
351 match self.kind() {
352352 GenericArgKind::Lifetime(lt) => lt.fold_with(folder).into(),
353353 GenericArgKind::Type(ty) => ty.fold_with(folder).into(),
354354 GenericArgKind::Const(ct) => ct.fold_with(folder).into(),
......@@ -358,7 +358,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
358358
359359impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> {
360360 fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
361 match self.unpack() {
361 match self.kind() {
362362 GenericArgKind::Lifetime(lt) => lt.visit_with(visitor),
363363 GenericArgKind::Type(ty) => ty.visit_with(visitor),
364364 GenericArgKind::Const(ct) => ct.visit_with(visitor),
......@@ -368,7 +368,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> {
368368
369369impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for GenericArg<'tcx> {
370370 fn encode(&self, e: &mut E) {
371 self.unpack().encode(e)
371 self.kind().encode(e)
372372 }
373373}
374374
......@@ -390,7 +390,7 @@ impl<'tcx> GenericArgs<'tcx> {
390390 ///
391391 /// If any of the generic arguments are not types.
392392 pub fn into_type_list(&self, tcx: TyCtxt<'tcx>) -> &'tcx List<Ty<'tcx>> {
393 tcx.mk_type_list_from_iter(self.iter().map(|arg| match arg.unpack() {
393 tcx.mk_type_list_from_iter(self.iter().map(|arg| match arg.kind() {
394394 GenericArgKind::Type(ty) => ty,
395395 _ => bug!("`into_type_list` called on generic arg with non-types"),
396396 }))
......@@ -527,7 +527,7 @@ impl<'tcx> GenericArgs<'tcx> {
527527 /// Returns generic arguments that are not lifetimes.
528528 #[inline]
529529 pub fn non_erasable_generics(&self) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> {
530 self.iter().filter_map(|k| match k.unpack() {
530 self.iter().filter_map(|arg| match arg.kind() {
531531 ty::GenericArgKind::Lifetime(_) => None,
532532 generic => Some(generic),
533533 })
compiler/rustc_middle/src/ty/impls_ty.rs+1-1
......@@ -60,7 +60,7 @@ where
6060
6161impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::GenericArg<'tcx> {
6262 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
63 self.unpack().hash_stable(hcx, hasher);
63 self.kind().hash_stable(hcx, hasher);
6464 }
6565}
6666
compiler/rustc_middle/src/ty/mod.rs+13-13
......@@ -504,7 +504,7 @@ impl<'tcx> rustc_type_ir::inherent::IntoKind for Term<'tcx> {
504504 type Kind = TermKind<'tcx>;
505505
506506 fn kind(self) -> Self::Kind {
507 self.unpack()
507 self.kind()
508508 }
509509}
510510
......@@ -521,7 +521,7 @@ unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync
521521
522522impl Debug for Term<'_> {
523523 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
524 match self.unpack() {
524 match self.kind() {
525525 TermKind::Ty(ty) => write!(f, "Term::Ty({ty:?})"),
526526 TermKind::Const(ct) => write!(f, "Term::Const({ct:?})"),
527527 }
......@@ -542,7 +542,7 @@ impl<'tcx> From<Const<'tcx>> for Term<'tcx> {
542542
543543impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Term<'tcx> {
544544 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
545 self.unpack().hash_stable(hcx, hasher);
545 self.kind().hash_stable(hcx, hasher);
546546 }
547547}
548548
......@@ -551,14 +551,14 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
551551 self,
552552 folder: &mut F,
553553 ) -> Result<Self, F::Error> {
554 match self.unpack() {
554 match self.kind() {
555555 ty::TermKind::Ty(ty) => ty.try_fold_with(folder).map(Into::into),
556556 ty::TermKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
557557 }
558558 }
559559
560560 fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
561 match self.unpack() {
561 match self.kind() {
562562 ty::TermKind::Ty(ty) => ty.fold_with(folder).into(),
563563 ty::TermKind::Const(ct) => ct.fold_with(folder).into(),
564564 }
......@@ -567,7 +567,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
567567
568568impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
569569 fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
570 match self.unpack() {
570 match self.kind() {
571571 ty::TermKind::Ty(ty) => ty.visit_with(visitor),
572572 ty::TermKind::Const(ct) => ct.visit_with(visitor),
573573 }
......@@ -576,7 +576,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
576576
577577impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Term<'tcx> {
578578 fn encode(&self, e: &mut E) {
579 self.unpack().encode(e)
579 self.kind().encode(e)
580580 }
581581}
582582
......@@ -589,7 +589,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Term<'tcx> {
589589
590590impl<'tcx> Term<'tcx> {
591591 #[inline]
592 pub fn unpack(self) -> TermKind<'tcx> {
592 pub fn kind(self) -> TermKind<'tcx> {
593593 let ptr =
594594 unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
595595 // SAFETY: use of `Interned::new_unchecked` here is ok because these
......@@ -609,7 +609,7 @@ impl<'tcx> Term<'tcx> {
609609 }
610610
611611 pub fn as_type(&self) -> Option<Ty<'tcx>> {
612 if let TermKind::Ty(ty) = self.unpack() { Some(ty) } else { None }
612 if let TermKind::Ty(ty) = self.kind() { Some(ty) } else { None }
613613 }
614614
615615 pub fn expect_type(&self) -> Ty<'tcx> {
......@@ -617,7 +617,7 @@ impl<'tcx> Term<'tcx> {
617617 }
618618
619619 pub fn as_const(&self) -> Option<Const<'tcx>> {
620 if let TermKind::Const(c) = self.unpack() { Some(c) } else { None }
620 if let TermKind::Const(c) = self.kind() { Some(c) } else { None }
621621 }
622622
623623 pub fn expect_const(&self) -> Const<'tcx> {
......@@ -625,14 +625,14 @@ impl<'tcx> Term<'tcx> {
625625 }
626626
627627 pub fn into_arg(self) -> GenericArg<'tcx> {
628 match self.unpack() {
628 match self.kind() {
629629 TermKind::Ty(ty) => ty.into(),
630630 TermKind::Const(c) => c.into(),
631631 }
632632 }
633633
634634 pub fn to_alias_term(self) -> Option<AliasTerm<'tcx>> {
635 match self.unpack() {
635 match self.kind() {
636636 TermKind::Ty(ty) => match *ty.kind() {
637637 ty::Alias(_kind, alias_ty) => Some(alias_ty.into()),
638638 _ => None,
......@@ -645,7 +645,7 @@ impl<'tcx> Term<'tcx> {
645645 }
646646
647647 pub fn is_infer(&self) -> bool {
648 match self.unpack() {
648 match self.kind() {
649649 TermKind::Ty(ty) => ty.is_ty_var(),
650650 TermKind::Const(ct) => ct.is_ct_infer(),
651651 }
compiler/rustc_middle/src/ty/opaque_types.rs+3-3
......@@ -120,7 +120,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
120120 }
121121 }
122122
123 match self.map.get(&r.into()).map(|k| k.unpack()) {
123 match self.map.get(&r.into()).map(|arg| arg.kind()) {
124124 Some(GenericArgKind::Lifetime(r1)) => r1,
125125 Some(u) => panic!("region mapped to unexpected kind: {u:?}"),
126126 None if self.do_not_error => self.tcx.lifetimes.re_static,
......@@ -162,7 +162,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
162162
163163 ty::Param(param) => {
164164 // Look it up in the generic parameters list.
165 match self.map.get(&ty.into()).map(|k| k.unpack()) {
165 match self.map.get(&ty.into()).map(|arg| arg.kind()) {
166166 // Found it in the generic parameters list; replace with the parameter from the
167167 // opaque type.
168168 Some(GenericArgKind::Type(t1)) => t1,
......@@ -195,7 +195,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
195195 match ct.kind() {
196196 ty::ConstKind::Param(..) => {
197197 // Look it up in the generic parameters list.
198 match self.map.get(&ct.into()).map(|k| k.unpack()) {
198 match self.map.get(&ct.into()).map(|arg| arg.kind()) {
199199 // Found it in the generic parameters list, replace with the parameter from the
200200 // opaque type.
201201 Some(GenericArgKind::Const(c1)) => c1,
compiler/rustc_middle/src/ty/print/pretty.rs+3-3
......@@ -1239,7 +1239,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
12391239
12401240 p!(write("{} = ", tcx.associated_item(assoc_item_def_id).name()));
12411241
1242 match term.unpack() {
1242 match term.kind() {
12431243 TermKind::Ty(ty) => p!(print(ty)),
12441244 TermKind::Const(c) => p!(print(c)),
12451245 };
......@@ -3386,7 +3386,7 @@ define_print_and_forward_display! {
33863386 }
33873387
33883388 ty::Term<'tcx> {
3389 match self.unpack() {
3389 match self.kind() {
33903390 ty::TermKind::Ty(ty) => p!(print(ty)),
33913391 ty::TermKind::Const(c) => p!(print(c)),
33923392 }
......@@ -3401,7 +3401,7 @@ define_print_and_forward_display! {
34013401 }
34023402
34033403 GenericArg<'tcx> {
3404 match self.unpack() {
3404 match self.kind() {
34053405 GenericArgKind::Lifetime(lt) => p!(print(lt)),
34063406 GenericArgKind::Type(ty) => p!(print(ty)),
34073407 GenericArgKind::Const(ct) => p!(print(ct)),
compiler/rustc_middle/src/ty/relate.rs+2-2
......@@ -169,7 +169,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::GenericArg<'tcx> {
169169 a: ty::GenericArg<'tcx>,
170170 b: ty::GenericArg<'tcx>,
171171 ) -> RelateResult<'tcx, ty::GenericArg<'tcx>> {
172 match (a.unpack(), b.unpack()) {
172 match (a.kind(), b.kind()) {
173173 (ty::GenericArgKind::Lifetime(a_lt), ty::GenericArgKind::Lifetime(b_lt)) => {
174174 Ok(relation.relate(a_lt, b_lt)?.into())
175175 }
......@@ -190,7 +190,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::Term<'tcx> {
190190 a: Self,
191191 b: Self,
192192 ) -> RelateResult<'tcx, Self> {
193 Ok(match (a.unpack(), b.unpack()) {
193 Ok(match (a.kind(), b.kind()) {
194194 (ty::TermKind::Ty(a), ty::TermKind::Ty(b)) => relation.relate(a, b)?.into(),
195195 (ty::TermKind::Const(a), ty::TermKind::Const(b)) => relation.relate(a, b)?.into(),
196196 _ => return Err(TypeError::Mismatch),
compiler/rustc_middle/src/ty/structural_impls.rs+2-2
......@@ -202,7 +202,7 @@ impl<T: fmt::Debug> fmt::Debug for ty::Placeholder<T> {
202202
203203impl<'tcx> fmt::Debug for GenericArg<'tcx> {
204204 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
205 match self.unpack() {
205 match self.kind() {
206206 GenericArgKind::Lifetime(lt) => lt.fmt(f),
207207 GenericArgKind::Type(ty) => ty.fmt(f),
208208 GenericArgKind::Const(ct) => ct.fmt(f),
......@@ -326,7 +326,7 @@ impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
326326impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> {
327327 type Lifted = ty::Term<'tcx>;
328328 fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
329 match self.unpack() {
329 match self.kind() {
330330 TermKind::Ty(ty) => tcx.lift(ty).map(Into::into),
331331 TermKind::Const(c) => tcx.lift(c).map(Into::into),
332332 }
compiler/rustc_middle/src/ty/typeck_results.rs+2-2
......@@ -777,8 +777,8 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
777777 return false;
778778 }
779779
780 iter::zip(user_args.args, BoundVar::ZERO..).all(|(kind, cvar)| {
781 match kind.unpack() {
780 iter::zip(user_args.args, BoundVar::ZERO..).all(|(arg, cvar)| {
781 match arg.kind() {
782782 GenericArgKind::Type(ty) => match ty.kind() {
783783 ty::Bound(debruijn, b) => {
784784 // We only allow a `ty::INNERMOST` index in generic parameters.
compiler/rustc_middle/src/ty/util.rs+3-3
......@@ -516,8 +516,8 @@ impl<'tcx> TyCtxt<'tcx> {
516516 let item_args = ty::GenericArgs::identity_for_item(self, def.did());
517517
518518 let result = iter::zip(item_args, impl_args)
519 .filter(|&(_, k)| {
520 match k.unpack() {
519 .filter(|&(_, arg)| {
520 match arg.kind() {
521521 GenericArgKind::Lifetime(region) => match region.kind() {
522522 ty::ReEarlyParam(ebr) => {
523523 !impl_generics.region_param(ebr, self).pure_wrt_drop
......@@ -554,7 +554,7 @@ impl<'tcx> TyCtxt<'tcx> {
554554 let mut seen = GrowableBitSet::default();
555555 let mut seen_late = FxHashSet::default();
556556 for arg in args {
557 match arg.unpack() {
557 match arg.kind() {
558558 GenericArgKind::Lifetime(lt) => match (ignore_regions, lt.kind()) {
559559 (CheckRegions::FromFunction, ty::ReBound(di, reg)) => {
560560 if !seen_late.insert((di, reg)) {
compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs+1-1
......@@ -131,7 +131,7 @@ impl<'tcx> ConstToPat<'tcx> {
131131 .dcx()
132132 .create_err(ConstPatternDependsOnGenericParameter { span: self.span });
133133 for arg in uv.args {
134 if let ty::GenericArgKind::Type(ty) = arg.unpack()
134 if let ty::GenericArgKind::Type(ty) = arg.kind()
135135 && let ty::Param(param_ty) = ty.kind()
136136 {
137137 let def_id = self.tcx.hir_enclosing_body_owner(self.id);
compiler/rustc_mir_transform/src/coverage/spans.rs+2-36
......@@ -1,8 +1,7 @@
11use rustc_data_structures::fx::FxHashSet;
22use rustc_middle::mir;
33use rustc_middle::ty::TyCtxt;
4use rustc_span::source_map::SourceMap;
5use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span};
4use rustc_span::{DesugaringKind, ExpnKind, MacroKind, Span};
65use tracing::instrument;
76
87use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph};
......@@ -84,18 +83,8 @@ pub(super) fn extract_refined_covspans<'tcx>(
8483 // Discard any span that overlaps with a hole.
8584 discard_spans_overlapping_holes(&mut covspans, &holes);
8685
87 // Discard spans that overlap in unwanted ways.
86 // Perform more refinement steps after holes have been dealt with.
8887 let mut covspans = remove_unwanted_overlapping_spans(covspans);
89
90 // For all empty spans, either enlarge them to be non-empty, or discard them.
91 let source_map = tcx.sess.source_map();
92 covspans.retain_mut(|covspan| {
93 let Some(span) = ensure_non_empty_span(source_map, covspan.span) else { return false };
94 covspan.span = span;
95 true
96 });
97
98 // Merge covspans that can be merged.
9988 covspans.dedup_by(|b, a| a.merge_if_eligible(b));
10089
10190 code_mappings.extend(covspans.into_iter().map(|Covspan { span, bcb }| {
......@@ -241,26 +230,3 @@ fn compare_spans(a: Span, b: Span) -> std::cmp::Ordering {
241230 // - Both have the same start and span A extends further right
242231 .then_with(|| Ord::cmp(&a.hi(), &b.hi()).reverse())
243232}
244
245fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
246 if !span.is_empty() {
247 return Some(span);
248 }
249
250 // The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
251 source_map
252 .span_to_source(span, |src, start, end| try {
253 // Adjusting span endpoints by `BytePos(1)` is normally a bug,
254 // but in this case we have specifically checked that the character
255 // we're skipping over is one of two specific ASCII characters, so
256 // adjusting by exactly 1 byte is correct.
257 if src.as_bytes().get(end).copied() == Some(b'{') {
258 Some(span.with_hi(span.hi() + BytePos(1)))
259 } else if start > 0 && src.as_bytes()[start - 1] == b'}' {
260 Some(span.with_lo(span.lo() - BytePos(1)))
261 } else {
262 None
263 }
264 })
265 .ok()?
266}
compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs+2-2
......@@ -817,8 +817,8 @@ where
817817
818818 /// Returns a ty infer or a const infer depending on whether `kind` is a `Ty` or `Const`.
819819 /// If `kind` is an integer inference variable this will still return a ty infer var.
820 pub(super) fn next_term_infer_of_kind(&mut self, kind: I::Term) -> I::Term {
821 match kind.kind() {
820 pub(super) fn next_term_infer_of_kind(&mut self, term: I::Term) -> I::Term {
821 match term.kind() {
822822 ty::TermKind::Ty(_) => self.next_ty_infer().into(),
823823 ty::TermKind::Const(_) => self.next_const_infer().into(),
824824 }
compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs+2-2
......@@ -79,7 +79,7 @@ fn encode_args<'tcx>(
7979 s.push('I');
8080 let def_generics = tcx.generics_of(for_def);
8181 for (n, arg) in args.iter().enumerate() {
82 match arg.unpack() {
82 match arg.kind() {
8383 GenericArgKind::Lifetime(region) => {
8484 s.push_str(&encode_region(region, dict));
8585 }
......@@ -245,7 +245,7 @@ fn encode_predicate<'tcx>(
245245 let name = encode_ty_name(tcx, projection.def_id);
246246 let _ = write!(s, "u{}{}", name.len(), name);
247247 s.push_str(&encode_args(tcx, projection.args, projection.def_id, true, dict, options));
248 match projection.term.unpack() {
248 match projection.term.kind() {
249249 TermKind::Ty(ty) => s.push_str(&encode_ty(tcx, ty, dict, options)),
250250 TermKind::Const(c) => s.push_str(&encode_const(
251251 tcx,
compiler/rustc_session/src/config.rs-5
......@@ -195,11 +195,6 @@ pub struct CoverageOptions {
195195 /// regression tests for #133606, because we don't have an easy way to
196196 /// reproduce it from actual source code.
197197 pub discard_all_spans_in_codegen: bool,
198
199 /// `-Zcoverage-options=inject-unused-local-file`: During codegen, add an
200 /// extra dummy entry to each function's local file table, to exercise the
201 /// code that checks for local file IDs with no mapping regions.
202 pub inject_unused_local_file: bool,
203198}
204199
205200/// Controls whether branch coverage or MC/DC coverage is enabled.
compiler/rustc_session/src/options.rs-1
......@@ -1413,7 +1413,6 @@ pub mod parse {
14131413 "mcdc" => slot.level = CoverageLevel::Mcdc,
14141414 "no-mir-spans" => slot.no_mir_spans = true,
14151415 "discard-all-spans-in-codegen" => slot.discard_all_spans_in_codegen = true,
1416 "inject-unused-local-file" => slot.inject_unused_local_file = true,
14171416 _ => return false,
14181417 }
14191418 }
compiler/rustc_session/src/session.rs-5
......@@ -371,11 +371,6 @@ impl Session {
371371 self.opts.unstable_opts.coverage_options.discard_all_spans_in_codegen
372372 }
373373
374 /// True if testing flag `-Zcoverage-options=inject-unused-local-file` was passed.
375 pub fn coverage_inject_unused_local_file(&self) -> bool {
376 self.opts.unstable_opts.coverage_options.inject_unused_local_file
377 }
378
379374 pub fn is_sanitizer_cfi_enabled(&self) -> bool {
380375 self.opts.unstable_opts.sanitizer.contains(SanitizerSet::CFI)
381376 }
compiler/rustc_smir/src/rustc_smir/convert/ty.rs+6-6
......@@ -100,7 +100,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> {
100100 stable_mir::ty::ExistentialProjection {
101101 def_id: tables.trait_def(*def_id),
102102 generic_args: args.stable(tables),
103 term: term.unpack().stable(tables),
103 term: term.kind().stable(tables),
104104 }
105105 }
106106}
......@@ -158,7 +158,7 @@ impl<'tcx> Stable<'tcx> for ty::FieldDef {
158158impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
159159 type T = stable_mir::ty::GenericArgs;
160160 fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
161 GenericArgs(self.iter().map(|arg| arg.unpack().stable(tables)).collect())
161 GenericArgs(self.iter().map(|arg| arg.kind().stable(tables)).collect())
162162 }
163163}
164164
......@@ -604,8 +604,8 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> {
604604 PredicateKind::NormalizesTo(_pred) => unimplemented!(),
605605 PredicateKind::AliasRelate(a, b, alias_relation_direction) => {
606606 stable_mir::ty::PredicateKind::AliasRelate(
607 a.unpack().stable(tables),
608 b.unpack().stable(tables),
607 a.kind().stable(tables),
608 b.kind().stable(tables),
609609 alias_relation_direction.stable(tables),
610610 )
611611 }
......@@ -640,7 +640,7 @@ impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> {
640640 ty.stable(tables),
641641 ),
642642 ClauseKind::WellFormed(term) => {
643 stable_mir::ty::ClauseKind::WellFormed(term.unpack().stable(tables))
643 stable_mir::ty::ClauseKind::WellFormed(term.kind().stable(tables))
644644 }
645645 ClauseKind::ConstEvaluatable(const_) => {
646646 stable_mir::ty::ClauseKind::ConstEvaluatable(const_.stable(tables))
......@@ -726,7 +726,7 @@ impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> {
726726 let ty::ProjectionPredicate { projection_term, term } = self;
727727 stable_mir::ty::ProjectionPredicate {
728728 projection_term: projection_term.stable(tables),
729 term: term.unpack().stable(tables),
729 term: term.kind().stable(tables),
730730 }
731731 }
732732}
compiler/rustc_symbol_mangling/src/export.rs+1-1
......@@ -147,7 +147,7 @@ impl<'tcx> AbiHashStable<'tcx> for ty::FnSig<'tcx> {
147147
148148impl<'tcx> AbiHashStable<'tcx> for ty::GenericArg<'tcx> {
149149 fn abi_hash(&self, tcx: TyCtxt<'tcx>, hasher: &mut StableHasher) {
150 self.unpack().abi_hash(tcx, hasher);
150 self.kind().abi_hash(tcx, hasher);
151151 }
152152}
153153
compiler/rustc_symbol_mangling/src/legacy.rs+1-1
......@@ -386,7 +386,7 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> {
386386 print_prefix(self)?;
387387
388388 let args =
389 args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
389 args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)));
390390
391391 if args.clone().next().is_some() {
392392 self.generic_delimiters(|cx| cx.comma_sep(args))
compiler/rustc_symbol_mangling/src/v0.rs+4-4
......@@ -646,7 +646,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
646646 let name = cx.tcx.associated_item(projection.def_id).name();
647647 cx.push("p");
648648 cx.push_ident(name.as_str());
649 match projection.term.unpack() {
649 match projection.term.kind() {
650650 ty::TermKind::Ty(ty) => ty.print(cx),
651651 ty::TermKind::Const(c) => c.print(cx),
652652 }?;
......@@ -912,11 +912,11 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
912912 args: &[GenericArg<'tcx>],
913913 ) -> Result<(), PrintError> {
914914 // Don't print any regions if they're all erased.
915 let print_regions = args.iter().any(|arg| match arg.unpack() {
915 let print_regions = args.iter().any(|arg| match arg.kind() {
916916 GenericArgKind::Lifetime(r) => !r.is_erased(),
917917 _ => false,
918918 });
919 let args = args.iter().cloned().filter(|arg| match arg.unpack() {
919 let args = args.iter().cloned().filter(|arg| match arg.kind() {
920920 GenericArgKind::Lifetime(_) => print_regions,
921921 _ => true,
922922 });
......@@ -928,7 +928,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
928928 self.push("I");
929929 print_prefix(self)?;
930930 for arg in args {
931 match arg.unpack() {
931 match arg.kind() {
932932 GenericArgKind::Lifetime(lt) => {
933933 lt.print(self)?;
934934 }
compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs+4-4
......@@ -738,7 +738,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
738738 value.push_normal(", ");
739739 }
740740
741 match arg.unpack() {
741 match arg.kind() {
742742 ty::GenericArgKind::Lifetime(lt) => {
743743 let s = lt.to_string();
744744 value.push_normal(if s.is_empty() { "'_" } else { &s });
......@@ -1166,7 +1166,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
11661166
11671167 for (i, (arg1, arg2)) in sub1.iter().zip(sub2).enumerate().take(len) {
11681168 self.push_comma(&mut values.0, &mut values.1, i);
1169 match arg1.unpack() {
1169 match arg1.kind() {
11701170 // At one point we'd like to elide all lifetimes here, they are
11711171 // irrelevant for all diagnostics that use this output.
11721172 //
......@@ -1509,7 +1509,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
15091509 }
15101510 let (is_simple_error, exp_found) = match values {
15111511 ValuePairs::Terms(ExpectedFound { expected, found }) => {
1512 match (expected.unpack(), found.unpack()) {
1512 match (expected.kind(), found.kind()) {
15131513 (ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
15141514 let is_simple_err =
15151515 expected.is_simple_text() && found.is_simple_text();
......@@ -2156,7 +2156,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21562156 return None;
21572157 }
21582158
2159 Some(match (exp_found.expected.unpack(), exp_found.found.unpack()) {
2159 Some(match (exp_found.expected.kind(), exp_found.found.kind()) {
21602160 (ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
21612161 let (mut exp, mut fnd) = self.cmp(expected, found);
21622162 // Use the terminal width as the basis to determine when to compress the printed
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs+6-6
......@@ -215,7 +215,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'a, 'tcx> {
215215 // `_` because then we'd end up with `Vec<_, _>`, instead of
216216 // `Vec<_>`.
217217 arg
218 } else if let GenericArgKind::Type(_) = arg.unpack() {
218 } else if let GenericArgKind::Type(_) = arg.kind() {
219219 // We don't replace lifetime or const params, only type params.
220220 self.new_infer().into()
221221 } else {
......@@ -347,7 +347,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
347347 highlight: ty::print::RegionHighlightMode<'tcx>,
348348 ) -> InferenceDiagnosticsData {
349349 let tcx = self.tcx;
350 match term.unpack() {
350 match term.kind() {
351351 TermKind::Ty(ty) => {
352352 if let ty::Infer(ty::TyVar(ty_vid)) = *ty.kind() {
353353 let var_origin = self.infcx.type_var_origin(ty_vid);
......@@ -568,7 +568,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
568568 return arg;
569569 }
570570
571 match arg.unpack() {
571 match arg.kind() {
572572 GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"),
573573 GenericArgKind::Type(_) => self.next_ty_var(DUMMY_SP).into(),
574574 GenericArgKind::Const(_) => self.next_const_var(DUMMY_SP).into(),
......@@ -803,7 +803,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
803803 }
804804 impl<'tcx> CostCtxt<'tcx> {
805805 fn arg_cost(self, arg: GenericArg<'tcx>) -> usize {
806 match arg.unpack() {
806 match arg.kind() {
807807 GenericArgKind::Lifetime(_) => 0, // erased
808808 GenericArgKind::Type(ty) => self.ty_cost(ty),
809809 GenericArgKind::Const(_) => 3, // some non-zero value
......@@ -898,7 +898,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
898898 return true;
899899 }
900900
901 match (arg.unpack(), self.target.unpack()) {
901 match (arg.kind(), self.target.kind()) {
902902 (GenericArgKind::Type(inner_ty), TermKind::Ty(target_ty)) => {
903903 use ty::{Infer, TyVar};
904904 match (inner_ty.kind(), target_ty.kind()) {
......@@ -929,7 +929,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
929929 if self.generic_arg_is_target(inner) {
930930 return true;
931931 }
932 match inner.unpack() {
932 match inner.kind() {
933933 GenericArgKind::Lifetime(_) => {}
934934 GenericArgKind::Type(ty) => {
935935 if matches!(
compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs+2-2
......@@ -664,8 +664,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
664664 let Some(found) = exp_found.found.args.get(1) else {
665665 return;
666666 };
667 let expected = expected.unpack();
668 let found = found.unpack();
667 let expected = expected.kind();
668 let found = found.kind();
669669 // 3. Extract the tuple type from Fn trait and suggest the change.
670670 if let GenericArgKind::Type(expected) = expected
671671 && let GenericArgKind::Type(found) = found
compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs+1-1
......@@ -2446,7 +2446,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
24462446 }
24472447 if let ty::Adt(def, args) = self_ty.kind()
24482448 && let [arg] = &args[..]
2449 && let ty::GenericArgKind::Type(ty) = arg.unpack()
2449 && let ty::GenericArgKind::Type(ty) = arg.kind()
24502450 && let ty::Adt(inner_def, _) = ty.kind()
24512451 && inner_def == def
24522452 {
compiler/rustc_trait_selection/src/opaque_types.rs+1-1
......@@ -81,7 +81,7 @@ pub fn check_opaque_type_parameter_valid<'tcx>(
8181 }
8282
8383 for (i, arg) in opaque_type_key.iter_captured_args(tcx) {
84 let arg_is_param = match arg.unpack() {
84 let arg_is_param = match arg.kind() {
8585 GenericArgKind::Lifetime(lt) => match defining_scope_kind {
8686 DefiningScopeKind::HirTypeck => continue,
8787 DefiningScopeKind::MirBorrowck => {
compiler/rustc_trait_selection/src/solve/delegate.rs+1-1
......@@ -108,7 +108,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
108108 arg: ty::GenericArg<'tcx>,
109109 span: Span,
110110 ) -> ty::GenericArg<'tcx> {
111 match arg.unpack() {
111 match arg.kind() {
112112 ty::GenericArgKind::Lifetime(_) => {
113113 self.next_region_var(RegionVariableOrigin::MiscVariable(span)).into()
114114 }
compiler/rustc_trait_selection/src/solve/inspect/analyse.rs+1-1
......@@ -207,7 +207,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
207207 let infcx = self.goal.infcx;
208208 match goal.predicate.kind().no_bound_vars() {
209209 Some(ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })) => {
210 let unconstrained_term = match term.unpack() {
210 let unconstrained_term = match term.kind() {
211211 ty::TermKind::Ty(_) => infcx.next_ty_var(span).into(),
212212 ty::TermKind::Const(_) => infcx.next_const_var(span).into(),
213213 };
compiler/rustc_trait_selection/src/traits/select/mod.rs+1-1
......@@ -1784,7 +1784,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
17841784 if !generics.is_own_empty()
17851785 && obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
17861786 p.has_non_region_infer()
1787 && match p.unpack() {
1787 && match p.kind() {
17881788 ty::GenericArgKind::Const(ct) => {
17891789 self.infcx.shallow_resolve_const(ct) != ct
17901790 }
compiler/rustc_trait_selection/src/traits/structural_normalize.rs+1-1
......@@ -39,7 +39,7 @@ impl<'tcx> At<'_, 'tcx> {
3939 return Ok(term);
4040 }
4141
42 let new_infer = match term.unpack() {
42 let new_infer = match term.kind() {
4343 ty::TermKind::Ty(_) => self.infcx.next_ty_var(self.cause.span).into(),
4444 ty::TermKind::Const(_) => self.infcx.next_const_var(self.cause.span).into(),
4545 };
compiler/rustc_trait_selection/src/traits/wf.rs+1-1
......@@ -37,7 +37,7 @@ pub fn obligations<'tcx>(
3737 span: Span,
3838) -> Option<PredicateObligations<'tcx>> {
3939 // Handle the "cycle" case (see comment above) by bailing out if necessary.
40 let term = match term.unpack() {
40 let term = match term.kind() {
4141 TermKind::Ty(ty) => {
4242 match ty.kind() {
4343 ty::Infer(ty::TyVar(_)) => {
compiler/rustc_ty_utils/src/representability.rs+2-2
......@@ -74,7 +74,7 @@ fn representability_adt_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Representab
7474 // but the type parameters may cause a cycle with an upstream type
7575 let params_in_repr = tcx.params_in_repr(adt.did());
7676 for (i, arg) in args.iter().enumerate() {
77 if let ty::GenericArgKind::Type(ty) = arg.unpack() {
77 if let ty::GenericArgKind::Type(ty) = arg.kind() {
7878 if params_in_repr.contains(i as u32) {
7979 rtry!(representability_ty(tcx, ty));
8080 }
......@@ -104,7 +104,7 @@ fn params_in_repr_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, params_in_repr: &mut
104104 ty::Adt(adt, args) => {
105105 let inner_params_in_repr = tcx.params_in_repr(adt.did());
106106 for (i, arg) in args.iter().enumerate() {
107 if let ty::GenericArgKind::Type(ty) = arg.unpack() {
107 if let ty::GenericArgKind::Type(ty) = arg.kind() {
108108 if inner_params_in_repr.contains(i as u32) {
109109 params_in_repr_ty(tcx, ty, params_in_repr);
110110 }
compiler/rustc_ty_utils/src/ty.rs+1-1
......@@ -274,7 +274,7 @@ fn unsizing_params_for_adt<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> DenseBitSe
274274 let def = tcx.adt_def(def_id);
275275 let num_params = tcx.generics_of(def_id).count();
276276
277 let maybe_unsizing_param_idx = |arg: ty::GenericArg<'tcx>| match arg.unpack() {
277 let maybe_unsizing_param_idx = |arg: ty::GenericArg<'tcx>| match arg.kind() {
278278 ty::GenericArgKind::Type(ty) => match ty.kind() {
279279 ty::Param(p) => Some(p.index),
280280 _ => None,
compiler/rustc_type_ir/src/binder.rs+3-3
......@@ -676,7 +676,7 @@ impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I> {
676676 // the specialized routine `ty::replace_late_regions()`.
677677 match r.kind() {
678678 ty::ReEarlyParam(data) => {
679 let rk = self.args.get(data.index() as usize).map(|k| k.kind());
679 let rk = self.args.get(data.index() as usize).map(|arg| arg.kind());
680680 match rk {
681681 Some(ty::GenericArgKind::Lifetime(lt)) => self.shift_region_through_binders(lt),
682682 Some(other) => self.region_param_expected(data, r, other),
......@@ -716,7 +716,7 @@ impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I> {
716716impl<'a, I: Interner> ArgFolder<'a, I> {
717717 fn ty_for_param(&self, p: I::ParamTy, source_ty: I::Ty) -> I::Ty {
718718 // Look up the type in the args. It really should be in there.
719 let opt_ty = self.args.get(p.index() as usize).map(|k| k.kind());
719 let opt_ty = self.args.get(p.index() as usize).map(|arg| arg.kind());
720720 let ty = match opt_ty {
721721 Some(ty::GenericArgKind::Type(ty)) => ty,
722722 Some(kind) => self.type_param_expected(p, source_ty, kind),
......@@ -753,7 +753,7 @@ impl<'a, I: Interner> ArgFolder<'a, I> {
753753
754754 fn const_for_param(&self, p: I::ParamConst, source_ct: I::Const) -> I::Const {
755755 // Look up the const in the args. It really should be in there.
756 let opt_ct = self.args.get(p.index() as usize).map(|k| k.kind());
756 let opt_ct = self.args.get(p.index() as usize).map(|arg| arg.kind());
757757 let ct = match opt_ct {
758758 Some(ty::GenericArgKind::Const(ct)) => ct,
759759 Some(kind) => self.const_param_expected(p, source_ct, kind),
compiler/rustc_type_ir/src/flags.rs+2-2
......@@ -479,8 +479,8 @@ impl<I: Interner> FlagComputation<I> {
479479 }
480480
481481 fn add_args(&mut self, args: &[I::GenericArg]) {
482 for kind in args {
483 match kind.kind() {
482 for arg in args {
483 match arg.kind() {
484484 ty::GenericArgKind::Type(ty) => self.add_ty(ty),
485485 ty::GenericArgKind::Lifetime(lt) => self.add_region(lt),
486486 ty::GenericArgKind::Const(ct) => self.add_const(ct),
library/std/src/fs.rs+16
......@@ -391,6 +391,16 @@ impl fmt::Display for TryLockError {
391391 }
392392}
393393
394#[unstable(feature = "file_lock", issue = "130994")]
395impl From<TryLockError> for io::Error {
396 fn from(err: TryLockError) -> io::Error {
397 match err {
398 TryLockError::Error(err) => err,
399 TryLockError::WouldBlock => io::ErrorKind::WouldBlock.into(),
400 }
401 }
402}
403
394404impl File {
395405 /// Attempts to open a file in read-only mode.
396406 ///
......@@ -820,11 +830,14 @@ impl File {
820830 ///
821831 /// fn main() -> std::io::Result<()> {
822832 /// let f = File::create("foo.txt")?;
833 /// // Explicit handling of the WouldBlock error
823834 /// match f.try_lock() {
824835 /// Ok(_) => (),
825836 /// Err(TryLockError::WouldBlock) => (), // Lock not acquired
826837 /// Err(TryLockError::Error(err)) => return Err(err),
827838 /// }
839 /// // Alternately, propagate the error as an io::Error
840 /// f.try_lock()?;
828841 /// Ok(())
829842 /// }
830843 /// ```
......@@ -881,11 +894,14 @@ impl File {
881894 ///
882895 /// fn main() -> std::io::Result<()> {
883896 /// let f = File::open("foo.txt")?;
897 /// // Explicit handling of the WouldBlock error
884898 /// match f.try_lock_shared() {
885899 /// Ok(_) => (),
886900 /// Err(TryLockError::WouldBlock) => (), // Lock not acquired
887901 /// Err(TryLockError::Error(err)) => return Err(err),
888902 /// }
903 /// // Alternately, propagate the error as an io::Error
904 /// f.try_lock_shared()?;
889905 ///
890906 /// Ok(())
891907 /// }
library/std/src/fs/tests.rs+22
......@@ -366,6 +366,28 @@ fn file_lock_blocking_async() {
366366 t.join().unwrap();
367367}
368368
369#[test]
370#[cfg(windows)]
371fn file_try_lock_async() {
372 const FILE_FLAG_OVERLAPPED: u32 = 0x40000000;
373
374 let tmpdir = tmpdir();
375 let filename = &tmpdir.join("file_try_lock_async.txt");
376 let f1 = check!(File::create(filename));
377 let f2 =
378 check!(OpenOptions::new().custom_flags(FILE_FLAG_OVERLAPPED).write(true).open(filename));
379
380 // Check that shared locks block exclusive locks
381 check!(f1.lock_shared());
382 assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
383 check!(f1.unlock());
384
385 // Check that exclusive locks block all locks
386 check!(f1.lock());
387 assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
388 assert_matches!(f2.try_lock_shared(), Err(TryLockError::WouldBlock));
389}
390
369391#[test]
370392fn file_test_io_seek_shakedown() {
371393 // 01234567890123
library/std/src/sys/fs/windows.rs+2-8
......@@ -415,10 +415,7 @@ impl File {
415415
416416 match result {
417417 Ok(_) => Ok(()),
418 Err(err)
419 if err.raw_os_error() == Some(c::ERROR_IO_PENDING as i32)
420 || err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) =>
421 {
418 Err(err) if err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) => {
422419 Err(TryLockError::WouldBlock)
423420 }
424421 Err(err) => Err(TryLockError::Error(err)),
......@@ -440,10 +437,7 @@ impl File {
440437
441438 match result {
442439 Ok(_) => Ok(()),
443 Err(err)
444 if err.raw_os_error() == Some(c::ERROR_IO_PENDING as i32)
445 || err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) =>
446 {
440 Err(err) if err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) => {
447441 Err(TryLockError::WouldBlock)
448442 }
449443 Err(err) => Err(TryLockError::Error(err)),
src/librustdoc/clean/mod.rs+1-1
......@@ -449,7 +449,7 @@ fn clean_middle_term<'tcx>(
449449 term: ty::Binder<'tcx, ty::Term<'tcx>>,
450450 cx: &mut DocContext<'tcx>,
451451) -> Term {
452 match term.skip_binder().unpack() {
452 match term.skip_binder().kind() {
453453 ty::TermKind::Ty(ty) => Term::Type(clean_middle_ty(term.rebind(ty), cx, None, None)),
454454 ty::TermKind::Const(c) => Term::Constant(clean_middle_const(term.rebind(c), cx)),
455455 }
src/librustdoc/clean/utils.rs+2-2
......@@ -124,7 +124,7 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
124124 elision_has_failed_once_before = true;
125125 }
126126
127 match arg.skip_binder().unpack() {
127 match arg.skip_binder().kind() {
128128 GenericArgKind::Lifetime(lt) => {
129129 Some(GenericArg::Lifetime(clean_middle_region(lt).unwrap_or(Lifetime::elided())))
130130 }
......@@ -161,7 +161,7 @@ fn can_elide_generic_arg<'tcx>(
161161 default: ty::Binder<'tcx, ty::GenericArg<'tcx>>,
162162) -> bool {
163163 debug_assert_matches!(
164 (actual.skip_binder().unpack(), default.skip_binder().unpack()),
164 (actual.skip_binder().kind(), default.skip_binder().kind()),
165165 (ty::GenericArgKind::Lifetime(_), ty::GenericArgKind::Lifetime(_))
166166 | (ty::GenericArgKind::Type(_), ty::GenericArgKind::Type(_))
167167 | (ty::GenericArgKind::Const(_), ty::GenericArgKind::Const(_))
src/tools/clippy/clippy_lints/src/arc_with_non_send_sync.rs+1-1
......@@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for ArcWithNonSendSync {
5050 && let arg_ty = cx.typeck_results().expr_ty(arg)
5151 // make sure that the type is not and does not contain any type parameters
5252 && arg_ty.walk().all(|arg| {
53 !matches!(arg.unpack(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_)))
53 !matches!(arg.kind(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_)))
5454 })
5555 && let Some(send) = cx.tcx.get_diagnostic_item(sym::Send)
5656 && let Some(sync) = cx.tcx.lang_items().sync_trait()
src/tools/clippy/clippy_lints/src/derive.rs+1-1
......@@ -345,7 +345,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
345345 if ty_adt.repr().packed()
346346 && ty_subs
347347 .iter()
348 .any(|arg| matches!(arg.unpack(), GenericArgKind::Type(_) | GenericArgKind::Const(_)))
348 .any(|arg| matches!(arg.kind(), GenericArgKind::Type(_) | GenericArgKind::Const(_)))
349349 {
350350 return;
351351 }
src/tools/clippy/clippy_lints/src/eta_reduction.rs+2-2
......@@ -306,7 +306,7 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
306306 return true;
307307 }
308308 for (from_arg, to_arg) in to_subs.iter().zip(from_subs) {
309 match (from_arg.unpack(), to_arg.unpack()) {
309 match (from_arg.kind(), to_arg.kind()) {
310310 (GenericArgKind::Lifetime(from_region), GenericArgKind::Lifetime(to_region)) => {
311311 if check_region(from_region, to_region) {
312312 return true;
......@@ -354,5 +354,5 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
354354
355355fn ty_has_static(ty: Ty<'_>) -> bool {
356356 ty.walk()
357 .any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if re.is_static()))
357 .any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if re.is_static()))
358358}
src/tools/clippy/clippy_lints/src/functions/ref_option.rs+1-1
......@@ -17,7 +17,7 @@ fn check_ty<'a>(cx: &LateContext<'a>, param: &rustc_hir::Ty<'a>, param_ty: Ty<'a
1717 && is_type_diagnostic_item(cx, *opt_ty, sym::Option)
1818 && let ty::Adt(_, opt_gen_args) = opt_ty.kind()
1919 && let [gen_arg] = opt_gen_args.as_slice()
20 && let GenericArgKind::Type(gen_ty) = gen_arg.unpack()
20 && let GenericArgKind::Type(gen_ty) = gen_arg.kind()
2121 && !gen_ty.is_ref()
2222 // Need to gen the original spans, so first parsing mid, and hir parsing afterward
2323 && let hir::TyKind::Ref(lifetime, hir::MutTy { ty, .. }) = param.kind
src/tools/clippy/clippy_lints/src/let_underscore.rs+1-1
......@@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
137137 && !local.span.in_external_macro(cx.tcx.sess.source_map())
138138 {
139139 let init_ty = cx.typeck_results().expr_ty(init);
140 let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() {
140 let contains_sync_guard = init_ty.walk().any(|inner| match inner.kind() {
141141 GenericArgKind::Type(inner_ty) => inner_ty
142142 .ty_adt_def()
143143 .is_some_and(|adt| paths::PARKING_LOT_GUARDS.iter().any(|path| path.matches(cx, adt.did()))),
src/tools/clippy/clippy_lints/src/matches/manual_unwrap_or.rs+1-1
......@@ -109,7 +109,7 @@ fn handle(
109109 && implements_trait(cx, expr_type, default_trait_id, &[])
110110 // We check if the initial condition implements Default.
111111 && let Some(condition_ty) = cx.typeck_results().expr_ty(condition).walk().nth(1)
112 && let GenericArgKind::Type(condition_ty) = condition_ty.unpack()
112 && let GenericArgKind::Type(condition_ty) = condition_ty.kind()
113113 && implements_trait(cx, condition_ty, default_trait_id, &[])
114114 && is_default_equivalent(cx, peel_blocks(body_none))
115115 {
src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs+1-1
......@@ -108,7 +108,7 @@ fn find_match_true<'tcx>(
108108fn try_get_generic_ty(ty: Ty<'_>, index: usize) -> Option<Ty<'_>> {
109109 if let ty::Adt(_, subs) = ty.kind()
110110 && let Some(sub) = subs.get(index)
111 && let GenericArgKind::Type(sub_ty) = sub.unpack()
111 && let GenericArgKind::Type(sub_ty) = sub.kind()
112112 {
113113 Some(sub_ty)
114114 } else {
src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs+2-2
......@@ -208,12 +208,12 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
208208 // (to avoid false positive on `Ref<'a, MutexGuard<Foo>>`)
209209 || (args
210210 .iter()
211 .all(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
211 .all(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)))
212212 // some generic parameter has significant drop
213213 // (to avoid false negative on `Box<MutexGuard<Foo>>`)
214214 && args
215215 .iter()
216 .filter_map(|arg| match arg.unpack() {
216 .filter_map(|arg| match arg.kind() {
217217 GenericArgKind::Type(ty) => Some(ty),
218218 _ => None,
219219 })
src/tools/clippy/clippy_lints/src/methods/needless_collect.rs+1-1
......@@ -508,7 +508,7 @@ fn get_captured_ids(cx: &LateContext<'_>, ty: Ty<'_>) -> HirIdSet {
508508 match ty.kind() {
509509 ty::Adt(_, generics) => {
510510 for generic in *generics {
511 if let GenericArgKind::Type(ty) = generic.unpack() {
511 if let GenericArgKind::Type(ty) = generic.kind() {
512512 get_captured_ids_recursive(cx, ty, set);
513513 }
514514 }
src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs+1-1
......@@ -188,7 +188,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: &Exp
188188
189189fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
190190 let ty = cx.typeck_results().expr_ty(expr);
191 matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
191 matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(_)))
192192}
193193
194194pub(super) fn check<'tcx>(
src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs+2-2
......@@ -608,7 +608,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
608608}
609609
610610fn has_lifetime(ty: Ty<'_>) -> bool {
611 ty.walk().any(|t| matches!(t.unpack(), GenericArgKind::Lifetime(_)))
611 ty.walk().any(|t| matches!(t.kind(), GenericArgKind::Lifetime(_)))
612612}
613613
614614/// Returns true if the named method is `Iterator::cloned` or `Iterator::copied`.
......@@ -643,7 +643,7 @@ fn is_to_string_on_string_like<'a>(
643643
644644 if let Some(args) = cx.typeck_results().node_args_opt(call_expr.hir_id)
645645 && let [generic_arg] = args.as_slice()
646 && let GenericArgKind::Type(ty) = generic_arg.unpack()
646 && let GenericArgKind::Type(ty) = generic_arg.kind()
647647 && let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref)
648648 && let Some(as_ref_trait_id) = cx.tcx.get_diagnostic_item(sym::AsRef)
649649 && (cx.get_associated_type(ty, deref_trait_id, sym::Target) == Some(cx.tcx.types.str_)
src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs+1-1
......@@ -269,7 +269,7 @@ fn needless_borrow_count<'tcx>(
269269 .tcx
270270 .is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id)
271271 && let ty::Param(param_ty) = trait_predicate.self_ty().kind()
272 && let GenericArgKind::Type(ty) = args_with_referent_ty[param_ty.index as usize].unpack()
272 && let GenericArgKind::Type(ty) = args_with_referent_ty[param_ty.index as usize].kind()
273273 && ty.is_array()
274274 && !msrv.meets(cx, msrvs::ARRAY_INTO_ITERATOR)
275275 {
src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs+3-3
......@@ -172,7 +172,7 @@ impl NonSendField<'_> {
172172/// Example: `MyStruct<P, Box<Q, R>>` => `vec![P, Q, R]`
173173fn collect_generic_params(ty: Ty<'_>) -> Vec<Ty<'_>> {
174174 ty.walk()
175 .filter_map(|inner| match inner.unpack() {
175 .filter_map(|inner| match inner.kind() {
176176 GenericArgKind::Type(inner_ty) => Some(inner_ty),
177177 _ => None,
178178 })
......@@ -208,7 +208,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
208208 ty::Adt(_, args) => {
209209 if contains_pointer_like(cx, ty) {
210210 // descends only if ADT contains any raw pointers
211 args.iter().all(|generic_arg| match generic_arg.unpack() {
211 args.iter().all(|generic_arg| match generic_arg.kind() {
212212 GenericArgKind::Type(ty) => ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait),
213213 // Lifetimes and const generics are not solid part of ADT and ignored
214214 GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => true,
......@@ -226,7 +226,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
226226/// Checks if the type contains any pointer-like types in args (including nested ones)
227227fn contains_pointer_like<'tcx>(cx: &LateContext<'tcx>, target_ty: Ty<'tcx>) -> bool {
228228 for ty_node in target_ty.walk() {
229 if let GenericArgKind::Type(inner_ty) = ty_node.unpack() {
229 if let GenericArgKind::Type(inner_ty) = ty_node.kind() {
230230 match inner_ty.kind() {
231231 ty::RawPtr(_, _) => {
232232 return true;
src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs+1-1
......@@ -385,7 +385,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
385385fn has_matching_args(kind: FnKind, args: GenericArgsRef<'_>) -> bool {
386386 match kind {
387387 FnKind::Fn => true,
388 FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.unpack() {
388 FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.kind() {
389389 GenericArgKind::Lifetime(_) => true,
390390 GenericArgKind::Type(ty) => matches!(*ty.kind(), ty::Param(ty) if ty.index as usize == idx),
391391 GenericArgKind::Const(c) => matches!(c.kind(), ConstKind::Param(c) if c.index as usize == idx),
src/tools/clippy/clippy_lints/src/returns.rs+1-1
......@@ -487,7 +487,7 @@ fn last_statement_borrows<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>)
487487 .skip_binder()
488488 .output()
489489 .walk()
490 .any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
490 .any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if !re.is_static()))
491491 {
492492 ControlFlow::Break(())
493493 } else {
src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs+1-1
......@@ -184,7 +184,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
184184 }
185185 }
186186 for generic_arg in *b {
187 if let GenericArgKind::Type(ty) = generic_arg.unpack()
187 if let GenericArgKind::Type(ty) = generic_arg.kind()
188188 && self.has_sig_drop_attr(ty, depth)
189189 {
190190 return true;
src/tools/clippy/clippy_lints/src/use_self.rs+2-2
......@@ -319,7 +319,7 @@ fn same_lifetimes<'tcx>(a: MiddleTy<'tcx>, b: MiddleTy<'tcx>) -> bool {
319319 args_a
320320 .iter()
321321 .zip(args_b.iter())
322 .all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
322 .all(|(arg_a, arg_b)| match (arg_a.kind(), arg_b.kind()) {
323323 // TODO: Handle inferred lifetimes
324324 (GenericArgKind::Lifetime(inner_a), GenericArgKind::Lifetime(inner_b)) => inner_a == inner_b,
325325 (GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => same_lifetimes(type_a, type_b),
......@@ -337,7 +337,7 @@ fn has_no_lifetime(ty: MiddleTy<'_>) -> bool {
337337 &Adt(_, args) => !args
338338 .iter()
339339 // TODO: Handle inferred lifetimes
340 .any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(..))),
340 .any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(..))),
341341 _ => true,
342342 }
343343}
src/tools/clippy/clippy_lints_internal/src/msrv_attr_impl.rs+1-1
......@@ -37,7 +37,7 @@ impl LateLintPass<'_> for MsrvAttrImpl {
3737 .type_of(f.did)
3838 .instantiate_identity()
3939 .walk()
40 .filter(|t| matches!(t.unpack(), GenericArgKind::Type(_)))
40 .filter(|t| matches!(t.kind(), GenericArgKind::Type(_)))
4141 .any(|t| internal_paths::MSRV_STACK.matches_ty(cx, t.expect_ty()))
4242 })
4343 && !items.iter().any(|item| item.ident.name.as_str() == "check_attributes")
src/tools/clippy/clippy_utils/src/lib.rs+1-1
......@@ -3316,7 +3316,7 @@ pub fn leaks_droppable_temporary_with_limited_lifetime<'tcx>(cx: &LateContext<'t
33163316 if temporary_ty.has_significant_drop(cx.tcx, cx.typing_env())
33173317 && temporary_ty
33183318 .walk()
3319 .any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
3319 .any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if !re.is_static()))
33203320 {
33213321 ControlFlow::Break(())
33223322 } else {
src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs+1-1
......@@ -55,7 +55,7 @@ pub fn is_min_const_fn<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, msrv: Ms
5555
5656fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, msrv: Msrv) -> McfResult {
5757 for arg in ty.walk() {
58 let ty = match arg.unpack() {
58 let ty = match arg.kind() {
5959 GenericArgKind::Type(ty) => ty,
6060
6161 // No constraints on lifetimes or constants, except potentially
src/tools/clippy/clippy_utils/src/ty/mod.rs+5-5
......@@ -78,7 +78,7 @@ pub fn can_partially_move_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool
7878/// Walks into `ty` and returns `true` if any inner type is an instance of the given adt
7979/// constructor.
8080pub fn contains_adt_constructor<'tcx>(ty: Ty<'tcx>, adt: AdtDef<'tcx>) -> bool {
81 ty.walk().any(|inner| match inner.unpack() {
81 ty.walk().any(|inner| match inner.kind() {
8282 GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt),
8383 GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
8484 })
......@@ -96,7 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
9696 needle: Ty<'tcx>,
9797 seen: &mut FxHashSet<DefId>,
9898 ) -> bool {
99 ty.walk().any(|inner| match inner.unpack() {
99 ty.walk().any(|inner| match inner.kind() {
100100 GenericArgKind::Type(inner_ty) => {
101101 if inner_ty == needle {
102102 return true;
......@@ -129,7 +129,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
129129 // For `impl Trait<Assoc=U>`, it will register a predicate of `<T as Trait>::Assoc = U`,
130130 // so we check the term for `U`.
131131 ty::ClauseKind::Projection(projection_predicate) => {
132 if let ty::TermKind::Ty(ty) = projection_predicate.term.unpack()
132 if let ty::TermKind::Ty(ty) = projection_predicate.term.kind()
133133 && contains_ty_adt_constructor_opaque_inner(cx, ty, needle, seen)
134134 {
135135 return true;
......@@ -526,7 +526,7 @@ pub fn same_type_and_consts<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
526526 args_a
527527 .iter()
528528 .zip(args_b.iter())
529 .all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
529 .all(|(arg_a, arg_b)| match (arg_a.kind(), arg_b.kind()) {
530530 (GenericArgKind::Const(inner_a), GenericArgKind::Const(inner_b)) => inner_a == inner_b,
531531 (GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => {
532532 same_type_and_consts(type_a, type_b)
......@@ -996,7 +996,7 @@ fn assert_generic_args_match<'tcx>(tcx: TyCtxt<'tcx>, did: DefId, args: &[Generi
996996 if let Some((idx, (param, arg))) =
997997 params
998998 .clone()
999 .zip(args.iter().map(|&x| x.unpack()))
999 .zip(args.iter().map(|&x| x.kind()))
10001000 .enumerate()
10011001 .find(|(_, (param, arg))| match (param, arg) {
10021002 (GenericParamDefKind::Lifetime, GenericArgKind::Lifetime(_))
src/tools/clippy/clippy_utils/src/ty/type_certainty/mod.rs+1-1
......@@ -326,5 +326,5 @@ fn adt_def_id(ty: Ty<'_>) -> Option<DefId> {
326326
327327fn contains_param(ty: Ty<'_>, index: u32) -> bool {
328328 ty.walk()
329 .any(|arg| matches!(arg.unpack(), GenericArgKind::Type(ty) if ty.is_param(index)))
329 .any(|arg| matches!(arg.kind(), GenericArgKind::Type(ty) if ty.is_param(index)))
330330}
src/tools/miri/src/machine.rs+1-1
......@@ -1775,7 +1775,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
17751775 let is_generic = instance
17761776 .args
17771777 .into_iter()
1778 .any(|kind| !matches!(kind.unpack(), ty::GenericArgKind::Lifetime(_)));
1778 .any(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_)));
17791779 let can_be_inlined = matches!(
17801780 ecx.tcx.sess.opts.unstable_opts.cross_crate_inline_threshold,
17811781 InliningThreshold::Always
src/tools/tidy/Cargo.toml+1-1
......@@ -15,7 +15,7 @@ semver = "1.0"
1515serde = { version = "1.0.125", features = ["derive"], optional = true }
1616termcolor = "1.1.3"
1717rustc-hash = "2.0.0"
18fluent-syntax = "0.11.1"
18fluent-syntax = "0.12"
1919similar = "2.5.0"
2020toml = "0.7.8"
2121
tests/codegen/option-niche-eq.rs+11
......@@ -1,5 +1,7 @@
1//@ revisions: REGULAR LLVM21
12//@ min-llvm-version: 20
23//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled
4//@ [LLVM21] min-llvm-version: 21
35#![crate_type = "lib"]
46
57extern crate core;
......@@ -74,3 +76,12 @@ pub fn niche_eq(l: Option<EnumWithNiche>, r: Option<EnumWithNiche>) -> bool {
7476 // CHECK-NEXT: ret i1
7577 l == r
7678}
79
80// LLVM21-LABEL: @bool_eq
81#[no_mangle]
82pub fn bool_eq(l: Option<bool>, r: Option<bool>) -> bool {
83 // LLVM21: start:
84 // LLVM21-NEXT: icmp eq i8
85 // LLVM21-NEXT: ret i1
86 l == r
87}
tests/codegen/option-niche-unfixed/option-bool-eq.rs deleted-15
......@@ -1,15 +0,0 @@
1//@ should-fail
2//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled
3//! FIXME(#49892)
4//! Tests that LLVM does not fully optimize comparisons of `Option<bool>`.
5//! If this starts passing, it can be moved to `tests/codegen/option-niche-eq.rs`
6#![crate_type = "lib"]
7
8// CHECK-LABEL: @bool_eq
9#[no_mangle]
10pub fn bool_eq(l: Option<bool>, r: Option<bool>) -> bool {
11 // CHECK: start:
12 // CHECK-NEXT: icmp eq i8
13 // CHECK-NEXT: ret i1
14 l == r
15}
tests/coverage/async_closure.cov-map+12-9
......@@ -37,29 +37,32 @@ Number of file 0 mappings: 8
3737Highest counter ID seen: c0
3838
3939Function name: async_closure::main::{closure#0}
40Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24]
40Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24]
4141Number of files: 1
4242- file 0 => $DIR/async_closure.rs
4343Number of expressions: 0
44Number of file 0 mappings: 1
45- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36)
44Number of file 0 mappings: 2
45- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35)
46- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36)
4647Highest counter ID seen: c0
4748
4849Function name: async_closure::main::{closure#0}
49Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24]
50Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24]
5051Number of files: 1
5152- file 0 => $DIR/async_closure.rs
5253Number of expressions: 0
53Number of file 0 mappings: 1
54- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36)
54Number of file 0 mappings: 2
55- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35)
56- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36)
5557Highest counter ID seen: c0
5658
5759Function name: async_closure::main::{closure#0}::{closure#0}::<i16>
58Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24]
60Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24]
5961Number of files: 1
6062- file 0 => $DIR/async_closure.rs
6163Number of expressions: 0
62Number of file 0 mappings: 1
63- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36)
64Number of file 0 mappings: 2
65- Code(Counter(0)) at (prev + 11, 34) to (start + 0, 35)
66- Code(Counter(0)) at (prev + 0, 35) to (start + 0, 36)
6467Highest counter ID seen: c0
6568
tests/coverage/unused-local-file.coverage deleted-7
......@@ -1,7 +0,0 @@
1 LL| |//@ edition: 2021
2 LL| |
3 LL| |// Force this function to be generated in its home crate, so that it ends up
4 LL| |// with normal coverage metadata.
5 LL| |#[inline(never)]
6 LL| 1|pub fn external_function() {}
7
tests/coverage/unused-local-file.rs deleted-22
......@@ -1,22 +0,0 @@
1//! If we give LLVM a local file table for a function, but some of the entries
2//! in that table have no associated mapping regions, then an assertion failure
3//! will occur in LLVM. We therefore need to detect and skip any function that
4//! would trigger that assertion.
5//!
6//! To test that this case is handled, even before adding code that could allow
7//! it to happen organically (for expansion region support), we use a special
8//! testing-only flag to force it to occur.
9
10//@ edition: 2024
11//@ compile-flags: -Zcoverage-options=inject-unused-local-file
12
13// The `llvm-cov` tool will complain if the test binary ends up having no
14// coverage metadata at all. To prevent that, we also link to instrumented
15// code in an auxiliary crate that doesn't have the special flag set.
16
17//@ aux-build: discard_all_helper.rs
18extern crate discard_all_helper;
19
20fn main() {
21 discard_all_helper::external_function();
22}
tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff+1-1
......@@ -40,7 +40,7 @@
4040+ coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:17: 19:18 (#0);
4141+ coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:23: 19:30 (#0);
4242+ coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:31: 19:32 (#0);
43+ coverage Code { bcb: bcb2 } => $DIR/branch_match_arms.rs:21:1: 21:2 (#0);
43+ coverage Code { bcb: bcb2 } => $DIR/branch_match_arms.rs:21:2: 21:2 (#0);
4444+
4545 bb0: {
4646+ Coverage::VirtualCounter(bcb0);
tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff+1-1
......@@ -6,7 +6,7 @@
66
77+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:27:1: 27:17 (#0);
88+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:28:5: 28:9 (#0);
9+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:1: 29:2 (#0);
9+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:2: 29:2 (#0);
1010+
1111 bb0: {
1212+ Coverage::VirtualCounter(bcb0);
tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff+2-2
......@@ -10,8 +10,8 @@
1010+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:13:1: 13:10 (#0);
1111+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:15:12: 15:15 (#0);
1212+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:16:13: 16:18 (#0);
13+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:17:9: 17:10 (#0);
14+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:19:1: 19:2 (#0);
13+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:17:10: 17:10 (#0);
14+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:19:2: 19:2 (#0);
1515+
1616 bb0: {
1717+ Coverage::VirtualCounter(bcb0);
tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff+2-2
......@@ -10,8 +10,8 @@
1010 coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 13:10 (#0);
1111 coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0);
1212 coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0);
13 coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:38: 14:39 (#0);
14 coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:1: 15:2 (#0);
13 coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0);
14 coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0);
1515 coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0);
1616
1717 bb0: {
tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff+2-2
......@@ -10,8 +10,8 @@
1010+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 13:10 (#0);
1111+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0);
1212+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0);
13+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:38: 14:39 (#0);
14+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:1: 15:2 (#0);
13+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0);
14+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0);
1515+ coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0);
1616+
1717 bb0: {
tests/run-make/version-check/rmake.rs created+13
......@@ -0,0 +1,13 @@
1use run_make_support::bare_rustc;
2
3fn main() {
4 let signalled_version = "Ceci n'est pas une rustc";
5 let rustc_out = bare_rustc()
6 .env("RUSTC_OVERRIDE_VERSION_STRING", signalled_version)
7 .arg("--version")
8 .run()
9 .stdout_utf8();
10
11 let version = rustc_out.strip_prefix("rustc ").unwrap().trim_end();
12 assert_eq!(version, signalled_version);
13}
tests/ui/feature-gates/version_check.rs deleted-17
......@@ -1,17 +0,0 @@
1//@ run-pass
2//@ only-linux
3//@ only-x86
4// FIXME: this should be more like //@ needs-subprocesses
5use std::process::Command;
6
7fn main() {
8 let signalled_version = "Ceci n'est pas une rustc";
9 let version = Command::new(std::env::var_os("RUSTC").unwrap())
10 .env("RUSTC_OVERRIDE_VERSION_STRING", signalled_version)
11 .arg("--version")
12 .output()
13 .unwrap()
14 .stdout;
15 let version = std::str::from_utf8(&version).unwrap().strip_prefix("rustc ").unwrap().trim_end();
16 assert_eq!(version, signalled_version);
17}
triagebot.toml+7
......@@ -593,6 +593,13 @@ trigger_files = [
593593 "src/doc/rustc-dev-guide",
594594]
595595
596[autolabel."A-LLVM"]
597trigger_files = [
598 "src/llvm-project",
599 "compiler/rustc_llvm",
600 "compiler/rustc_codegen_llvm",
601]
602
596603[notify-zulip."I-prioritize"]
597604zulip_stream = 245100 # #t-compiler/prioritization/alerts
598605topic = "#{number} {title}"