| author | bors <bors@rust-lang.org> 2025-05-27 18:59:47 UTC |
| committer | bors <bors@rust-lang.org> 2025-05-27 18:59:47 UTC |
| log | 45f256d9d7cffb66185c0bf1b8a864cba79db90c |
| tree | 4944e765bd2e520e4de9e977a78e769099e06de4 |
| parent | c583fa6d8425dbb38fe5d1dbd007f9ca8e4aa128 |
| parent | c7d0a61e2211dd3821933aae7ab83e9e0b043f37 |
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: rollup112 files changed, 336 insertions(+), 413 deletions(-)
Cargo.lock+10-18| ... | ... | @@ -1259,16 +1259,16 @@ dependencies = [ |
| 1259 | 1259 | |
| 1260 | 1260 | [[package]] |
| 1261 | 1261 | name = "fluent-bundle" |
| 1262 | version = "0.15.3" | |
| 1262 | version = "0.16.0" | |
| 1263 | 1263 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1264 | checksum = "7fe0a21ee80050c678013f82edf4b705fe2f26f1f9877593d13198612503f493" | |
| 1264 | checksum = "01203cb8918f5711e73891b347816d932046f95f54207710bda99beaeb423bf4" | |
| 1265 | 1265 | dependencies = [ |
| 1266 | 1266 | "fluent-langneg", |
| 1267 | 1267 | "fluent-syntax", |
| 1268 | 1268 | "intl-memoizer", |
| 1269 | 1269 | "intl_pluralrules", |
| 1270 | "rustc-hash 1.1.0", | |
| 1271 | "self_cell 0.10.3", | |
| 1270 | "rustc-hash 2.1.1", | |
| 1271 | "self_cell", | |
| 1272 | 1272 | "smallvec", |
| 1273 | 1273 | "unic-langid", |
| 1274 | 1274 | ] |
| ... | ... | @@ -1284,11 +1284,12 @@ dependencies = [ |
| 1284 | 1284 | |
| 1285 | 1285 | [[package]] |
| 1286 | 1286 | name = "fluent-syntax" |
| 1287 | version = "0.11.1" | |
| 1287 | version = "0.12.0" | |
| 1288 | 1288 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1289 | checksum = "2a530c4694a6a8d528794ee9bbd8ba0122e779629ac908d15ad5a7ae7763a33d" | |
| 1289 | checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198" | |
| 1290 | 1290 | dependencies = [ |
| 1291 | "thiserror 1.0.69", | |
| 1291 | "memchr", | |
| 1292 | "thiserror 2.0.12", | |
| 1292 | 1293 | ] |
| 1293 | 1294 | |
| 1294 | 1295 | [[package]] |
| ... | ... | @@ -1934,9 +1935,9 @@ dependencies = [ |
| 1934 | 1935 | |
| 1935 | 1936 | [[package]] |
| 1936 | 1937 | name = "intl-memoizer" |
| 1937 | version = "0.5.2" | |
| 1938 | version = "0.5.3" | |
| 1938 | 1939 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 1939 | checksum = "fe22e020fce238ae18a6d5d8c502ee76a52a6e880d99477657e6acc30ec57bda" | |
| 1940 | checksum = "310da2e345f5eb861e7a07ee182262e94975051db9e4223e909ba90f392f163f" | |
| 1940 | 1941 | dependencies = [ |
| 1941 | 1942 | "type-map", |
| 1942 | 1943 | "unic-langid", |
| ... | ... | @@ -4832,15 +4833,6 @@ version = "1.2.0" |
| 4832 | 4833 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 4833 | 4834 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" |
| 4834 | 4835 | |
| 4835 | [[package]] | |
| 4836 | name = "self_cell" | |
| 4837 | version = "0.10.3" | |
| 4838 | source = "registry+https://github.com/rust-lang/crates.io-index" | |
| 4839 | checksum = "e14e4d63b804dc0c7ec4a1e52bcb63f02c7ac94476755aa579edac21e01f915d" | |
| 4840 | dependencies = [ | |
| 4841 | "self_cell 1.2.0", | |
| 4842 | ] | |
| 4843 | ||
| 4844 | 4836 | [[package]] |
| 4845 | 4837 | name = "self_cell" |
| 4846 | 4838 | version = "1.2.0" |
compiler/rustc_ast/src/mut_visit.rs+3-11| ... | ... | @@ -300,10 +300,6 @@ pub trait MutVisitor: Sized { |
| 300 | 300 | walk_precise_capturing_arg(self, arg); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | fn visit_mt(&mut self, mt: &mut MutTy) { | |
| 304 | walk_mt(self, mt); | |
| 305 | } | |
| 306 | ||
| 307 | 303 | fn visit_expr_field(&mut self, f: &mut ExprField) { |
| 308 | 304 | walk_expr_field(self, f); |
| 309 | 305 | } |
| ... | ... | @@ -519,10 +515,10 @@ pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) { |
| 519 | 515 | TyKind::Infer | TyKind::ImplicitSelf | TyKind::Dummy | TyKind::Never | TyKind::CVarArgs => { |
| 520 | 516 | } |
| 521 | 517 | 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: _ }) => { | |
| 524 | 520 | visit_opt(lt, |lt| vis.visit_lifetime(lt)); |
| 525 | vis.visit_mt(mt); | |
| 521 | vis.visit_ty(ty); | |
| 526 | 522 | } |
| 527 | 523 | TyKind::BareFn(bft) => { |
| 528 | 524 | 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>( |
| 1003 | 999 | smallvec![f] |
| 1004 | 1000 | } |
| 1005 | 1001 | |
| 1006 | fn walk_mt<T: MutVisitor>(vis: &mut T, MutTy { ty, mutbl: _ }: &mut MutTy) { | |
| 1007 | vis.visit_ty(ty); | |
| 1008 | } | |
| 1009 | ||
| 1010 | 1002 | pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) { |
| 1011 | 1003 | let Block { id, stmts, rules: _, span, tokens: _ } = block.deref_mut(); |
| 1012 | 1004 | vis.visit_id(id); |
compiler/rustc_borrowck/src/diagnostics/region_name.rs+4-4| ... | ... | @@ -606,8 +606,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { |
| 606 | 606 | hir_args: &'hir hir::GenericArgs<'hir>, |
| 607 | 607 | search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty<'hir>)>, |
| 608 | 608 | ) -> 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) { | |
| 611 | 611 | (GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => { |
| 612 | 612 | if r.as_var() == needle_fr { |
| 613 | 613 | return Some(lt); |
| ... | ... | @@ -631,7 +631,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { |
| 631 | 631 | ) => { |
| 632 | 632 | self.dcx().span_delayed_bug( |
| 633 | 633 | 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:?}"), | |
| 635 | 635 | ); |
| 636 | 636 | } |
| 637 | 637 | } |
| ... | ... | @@ -997,7 +997,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { |
| 997 | 997 | ) -> bool { |
| 998 | 998 | let tcx = self.infcx.tcx; |
| 999 | 999 | ty.walk().any(|arg| { |
| 1000 | if let ty::GenericArgKind::Type(ty) = arg.unpack() | |
| 1000 | if let ty::GenericArgKind::Type(ty) = arg.kind() | |
| 1001 | 1001 | && let ty::Param(_) = ty.kind() |
| 1002 | 1002 | { |
| 1003 | 1003 | 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> { |
| 148 | 148 | |
| 149 | 149 | let mut next_outlives_predicates = vec![]; |
| 150 | 150 | for (ty::OutlivesPredicate(k1, r2), constraint_category) in outlives_predicates { |
| 151 | match k1.unpack() { | |
| 151 | match k1.kind() { | |
| 152 | 152 | GenericArgKind::Lifetime(r1) => { |
| 153 | 153 | let r1_vid = self.to_region_vid(r1); |
| 154 | 154 | 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>( |
| 221 | 221 | .iter() |
| 222 | 222 | .enumerate() |
| 223 | 223 | .filter(|(i, _)| variances[*i] == ty::Invariant) |
| 224 | .filter_map(|(_, arg)| match arg.unpack() { | |
| 224 | .filter_map(|(_, arg)| match arg.kind() { | |
| 225 | 225 | GenericArgKind::Lifetime(r) => Some(typeck.to_region_vid(r)), |
| 226 | 226 | GenericArgKind::Type(_) | GenericArgKind::Const(_) => None, |
| 227 | 227 | }) |
compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs+5-21| ... | ... | @@ -155,20 +155,6 @@ pub(crate) struct Regions { |
| 155 | 155 | impl Regions { |
| 156 | 156 | /// Returns true if none of this structure's tables contain any regions. |
| 157 | 157 | 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 | ||
| 172 | 158 | let Self { |
| 173 | 159 | code_regions, |
| 174 | 160 | expansion_regions, |
| ... | ... | @@ -177,13 +163,11 @@ impl Regions { |
| 177 | 163 | mcdc_decision_regions, |
| 178 | 164 | } = self; |
| 179 | 165 | |
| 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() | |
| 187 | 171 | } |
| 188 | 172 | } |
| 189 | 173 |
compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs+10-34| ... | ... | @@ -11,7 +11,6 @@ use rustc_abi::Align; |
| 11 | 11 | use rustc_codegen_ssa::traits::{ |
| 12 | 12 | BaseTypeCodegenMethods as _, ConstCodegenMethods, StaticCodegenMethods, |
| 13 | 13 | }; |
| 14 | use rustc_index::IndexVec; | |
| 15 | 14 | use rustc_middle::mir::coverage::{ |
| 16 | 15 | BasicCoverageBlock, CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping, |
| 17 | 16 | MappingKind, Op, |
| ... | ... | @@ -105,16 +104,6 @@ fn fill_region_tables<'tcx>( |
| 105 | 104 | ids_info: &'tcx CoverageIdsInfo, |
| 106 | 105 | covfun: &mut CovfunRecord<'tcx>, |
| 107 | 106 | ) { |
| 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 | ||
| 118 | 107 | // Currently a function's mappings must all be in the same file, so use the |
| 119 | 108 | // first mapping's span to determine the file. |
| 120 | 109 | let source_map = tcx.sess.source_map(); |
| ... | ... | @@ -126,12 +115,6 @@ fn fill_region_tables<'tcx>( |
| 126 | 115 | |
| 127 | 116 | let local_file_id = covfun.virtual_file_mapping.push_file(&source_file); |
| 128 | 117 | |
| 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 | ||
| 135 | 118 | // In rare cases, _all_ of a function's spans are discarded, and coverage |
| 136 | 119 | // codegen needs to handle that gracefully to avoid #133606. |
| 137 | 120 | // It's hard for tests to trigger this organically, so instead we set |
| ... | ... | @@ -152,6 +135,16 @@ fn fill_region_tables<'tcx>( |
| 152 | 135 | // For each counter/region pair in this function+file, convert it to a |
| 153 | 136 | // form suitable for FFI. |
| 154 | 137 | 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 | ||
| 155 | 148 | let Some(coords) = make_coords(span) else { continue }; |
| 156 | 149 | let cov_span = coords.make_coverage_span(local_file_id); |
| 157 | 150 | |
| ... | ... | @@ -184,19 +177,6 @@ fn fill_region_tables<'tcx>( |
| 184 | 177 | } |
| 185 | 178 | } |
| 186 | 179 | |
| 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. | |
| 190 | fn 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 | ||
| 200 | 180 | /// Generates the contents of the covfun record for this function, which |
| 201 | 181 | /// contains the function's coverage mapping data. The record is then stored |
| 202 | 182 | /// as a global variable in the `__llvm_covfun` section. |
| ... | ... | @@ -205,10 +185,6 @@ pub(crate) fn generate_covfun_record<'tcx>( |
| 205 | 185 | global_file_table: &GlobalFileTable, |
| 206 | 186 | covfun: &CovfunRecord<'tcx>, |
| 207 | 187 | ) { |
| 208 | if !check_local_file_table(covfun) { | |
| 209 | return; | |
| 210 | } | |
| 211 | ||
| 212 | 188 | let &CovfunRecord { |
| 213 | 189 | mangled_function_name, |
| 214 | 190 | source_hash, |
compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/spans.rs+24-4| ... | ... | @@ -39,10 +39,7 @@ impl Coords { |
| 39 | 39 | /// or other expansions), and if it does happen then skipping a span or function is |
| 40 | 40 | /// better than an ICE or `llvm-cov` failure that the user might have no way to avoid. |
| 41 | 41 | pub(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)?; | |
| 46 | 43 | |
| 47 | 44 | let lo = span.lo(); |
| 48 | 45 | let hi = span.hi(); |
| ... | ... | @@ -73,6 +70,29 @@ pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span) |
| 73 | 70 | }) |
| 74 | 71 | } |
| 75 | 72 | |
| 73 | fn 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 | ||
| 76 | 96 | /// If `llvm-cov` sees a source region that is improperly ordered (end < start), |
| 77 | 97 | /// it will immediately exit with a fatal error. To prevent that from happening, |
| 78 | 98 | /// 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>( |
| 77 | 77 | ty: Ty<'tcx>, |
| 78 | 78 | ) -> Option<ty::ExistentialTraitRef<'tcx>> { |
| 79 | 79 | for arg in ty.peel_refs().walk() { |
| 80 | if let GenericArgKind::Type(ty) = arg.unpack() | |
| 80 | if let GenericArgKind::Type(ty) = arg.kind() | |
| 81 | 81 | && let ty::Dynamic(data, _, _) = ty.kind() |
| 82 | 82 | { |
| 83 | 83 | // 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>( |
| 281 | 281 | let mut sugg = None; |
| 282 | 282 | |
| 283 | 283 | 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()) { | |
| 285 | 285 | (GenericArgKind::Type(self_ty), GenericArgKind::Type(rhs_ty)) |
| 286 | 286 | if self_ty == rhs_ty |
| 287 | 287 | && 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> { |
| 125 | 125 | ) -> Result<(), PrintError> { |
| 126 | 126 | print_prefix(self)?; |
| 127 | 127 | let args = |
| 128 | args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_))); | |
| 128 | args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_))); | |
| 129 | 129 | if args.clone().next().is_some() { |
| 130 | 130 | self.generic_delimiters(|cx| cx.comma_sep(args)) |
| 131 | 131 | } else { |
compiler/rustc_error_messages/Cargo.toml+2-2| ... | ... | @@ -5,8 +5,8 @@ edition = "2024" |
| 5 | 5 | |
| 6 | 6 | [dependencies] |
| 7 | 7 | # tidy-alphabetical-start |
| 8 | fluent-bundle = "0.15.2" | |
| 9 | fluent-syntax = "0.11" | |
| 8 | fluent-bundle = "0.16" | |
| 9 | fluent-syntax = "0.12" | |
| 10 | 10 | icu_list = "1.2" |
| 11 | 11 | icu_locid = "1.2" |
| 12 | 12 | icu_provider_adapters = "1.2" |
compiler/rustc_fluent_macro/Cargo.toml+2-2| ... | ... | @@ -9,8 +9,8 @@ proc-macro = true |
| 9 | 9 | [dependencies] |
| 10 | 10 | # tidy-alphabetical-start |
| 11 | 11 | annotate-snippets = "0.11" |
| 12 | fluent-bundle = "0.15.2" | |
| 13 | fluent-syntax = "0.11" | |
| 12 | fluent-bundle = "0.16" | |
| 13 | fluent-syntax = "0.12" | |
| 14 | 14 | proc-macro2 = "1" |
| 15 | 15 | quote = "1" |
| 16 | 16 | syn = { 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 |
| 1575 | 1575 | |
| 1576 | 1576 | let mut params_used = DenseBitSet::new_empty(generics.own_params.len()); |
| 1577 | 1577 | for leaf in ty.walk() { |
| 1578 | if let GenericArgKind::Type(leaf_ty) = leaf.unpack() | |
| 1578 | if let GenericArgKind::Type(leaf_ty) = leaf.kind() | |
| 1579 | 1579 | && let ty::Param(param) = leaf_ty.kind() |
| 1580 | 1580 | { |
| 1581 | 1581 | debug!("found use of ty param {:?}", param); |
| ... | ... | @@ -1700,7 +1700,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, opaque_def_id: LocalDefId) -> ErrorG |
| 1700 | 1700 | |
| 1701 | 1701 | let mut label_match = |ty: Ty<'_>, span| { |
| 1702 | 1702 | for arg in ty.walk() { |
| 1703 | if let ty::GenericArgKind::Type(ty) = arg.unpack() | |
| 1703 | if let ty::GenericArgKind::Type(ty) = arg.kind() | |
| 1704 | 1704 | && let ty::Alias( |
| 1705 | 1705 | ty::Opaque, |
| 1706 | 1706 | 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>( |
| 1231 | 1231 | for (id_arg, arg) in |
| 1232 | 1232 | std::iter::zip(ty::GenericArgs::identity_for_item(tcx, impl_m.def_id), impl_m_args) |
| 1233 | 1233 | { |
| 1234 | if let ty::GenericArgKind::Lifetime(r) = arg.unpack() | |
| 1234 | if let ty::GenericArgKind::Lifetime(r) = arg.kind() | |
| 1235 | 1235 | && let ty::ReVar(vid) = r.kind() |
| 1236 | 1236 | && let r = infcx |
| 1237 | 1237 | .inner |
| ... | ... | @@ -1256,7 +1256,7 @@ fn check_region_late_boundedness<'tcx>( |
| 1256 | 1256 | for (id_arg, arg) in |
| 1257 | 1257 | std::iter::zip(ty::GenericArgs::identity_for_item(tcx, trait_m.def_id), trait_m_args) |
| 1258 | 1258 | { |
| 1259 | if let ty::GenericArgKind::Lifetime(r) = arg.unpack() | |
| 1259 | if let ty::GenericArgKind::Lifetime(r) = arg.kind() | |
| 1260 | 1260 | && let ty::ReVar(vid) = r.kind() |
| 1261 | 1261 | && let r = infcx |
| 1262 | 1262 | .inner |
compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs+1-1| ... | ... | @@ -427,7 +427,7 @@ fn report_mismatched_rpitit_captures<'tcx>( |
| 427 | 427 | }; |
| 428 | 428 | |
| 429 | 429 | 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(_))); | |
| 431 | 431 | let suggestion = format!("use<{}>", trait_captured_args.iter().join(", ")); |
| 432 | 432 | |
| 433 | 433 | 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> { |
| 819 | 819 | match t.kind() { |
| 820 | 820 | ty::Alias(ty::Projection, p) if p.def_id == self.gat => { |
| 821 | 821 | for (idx, arg) in p.args.iter().enumerate() { |
| 822 | match arg.unpack() { | |
| 822 | match arg.kind() { | |
| 823 | 823 | GenericArgKind::Lifetime(lt) if !lt.is_bound() => { |
| 824 | 824 | self.regions.insert((lt, idx)); |
| 825 | 825 | } |
| ... | ... | @@ -1517,7 +1517,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id |
| 1517 | 1517 | } else { |
| 1518 | 1518 | // If we've got a generic const parameter we still want to check its |
| 1519 | 1519 | // 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 { | |
| 1521 | 1521 | continue; |
| 1522 | 1522 | }; |
| 1523 | 1523 |
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>( |
| 151 | 151 | let mut mapping = FxIndexMap::default(); |
| 152 | 152 | let generics = tcx.generics_of(assoc_item_def_id); |
| 153 | 153 | for (param, var) in std::iter::zip(&generics.own_params, gat_vars) { |
| 154 | let existing = match var.unpack() { | |
| 154 | let existing = match var.kind() { | |
| 155 | 155 | ty::GenericArgKind::Lifetime(re) => { |
| 156 | 156 | if let ty::RegionKind::ReBound(ty::INNERMOST, bv) = re.kind() { |
| 157 | 157 | 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> + '_ { |
| 215 | 215 | let pred = bound_predicate.rebind(pred); |
| 216 | 216 | // A `Self` within the original bound will be instantiated with a |
| 217 | 217 | // `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() { | |
| 219 | 219 | ty::TermKind::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()), |
| 220 | 220 | // FIXME(associated_const_equality): We should walk the const instead of not doing anything |
| 221 | 221 | 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> + '_ { |
| 611 | 611 | if !infer_args && has_default { |
| 612 | 612 | // No type parameter provided, but a default exists. |
| 613 | 613 | if let Some(prev) = |
| 614 | preceding_args.iter().find_map(|arg| match arg.unpack() { | |
| 614 | preceding_args.iter().find_map(|arg| match arg.kind() { | |
| 615 | 615 | GenericArgKind::Type(ty) => ty.error_reported().err(), |
| 616 | 616 | _ => None, |
| 617 | 617 | }) |
compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs+2-2| ... | ... | @@ -119,7 +119,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( |
| 119 | 119 | explicit_map: &mut ExplicitPredicatesMap<'tcx>, |
| 120 | 120 | ) { |
| 121 | 121 | for arg in ty.walk() { |
| 122 | let leaf_ty = match arg.unpack() { | |
| 122 | let leaf_ty = match arg.kind() { | |
| 123 | 123 | GenericArgKind::Type(ty) => ty, |
| 124 | 124 | |
| 125 | 125 | // No predicates from lifetimes or constants, except potentially |
| ... | ... | @@ -299,7 +299,7 @@ fn check_explicit_predicates<'tcx>( |
| 299 | 299 | // binding) and thus infer an outlives requirement that `X: |
| 300 | 300 | // 'b`. |
| 301 | 301 | 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() | |
| 303 | 303 | && ty.walk().any(|arg| arg == self_ty.into()) |
| 304 | 304 | { |
| 305 | 305 | 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<'_> { |
| 69 | 69 | .map(|(&def_id, set)| { |
| 70 | 70 | let predicates = |
| 71 | 71 | &*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() { | |
| 74 | 74 | GenericArgKind::Type(ty1) => Some(( |
| 75 | 75 | ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(ty1, *region2)) |
| 76 | 76 | .upcast(tcx), |
compiler/rustc_hir_analysis/src/outlives/utils.rs+3-3| ... | ... | @@ -14,7 +14,7 @@ pub(crate) type RequiredPredicates<'tcx> = |
| 14 | 14 | /// outlives_component and add it to `required_predicates` |
| 15 | 15 | pub(crate) fn insert_outlives_predicate<'tcx>( |
| 16 | 16 | tcx: TyCtxt<'tcx>, |
| 17 | kind: GenericArg<'tcx>, | |
| 17 | arg: GenericArg<'tcx>, | |
| 18 | 18 | outlived_region: Region<'tcx>, |
| 19 | 19 | span: Span, |
| 20 | 20 | required_predicates: &mut RequiredPredicates<'tcx>, |
| ... | ... | @@ -25,7 +25,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>( |
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | match kind.unpack() { | |
| 28 | match arg.kind() { | |
| 29 | 29 | GenericArgKind::Type(ty) => { |
| 30 | 30 | // `T: 'outlived_region` for some type `T` |
| 31 | 31 | // But T could be a lot of things: |
| ... | ... | @@ -135,7 +135,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>( |
| 135 | 135 | if !is_free_region(r) { |
| 136 | 136 | return; |
| 137 | 137 | } |
| 138 | required_predicates.entry(ty::OutlivesPredicate(kind, outlived_region)).or_insert(span); | |
| 138 | required_predicates.entry(ty::OutlivesPredicate(arg, outlived_region)).or_insert(span); | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | GenericArgKind::Const(_) => { |
compiler/rustc_hir_analysis/src/variance/constraints.rs+5-5| ... | ... | @@ -200,8 +200,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { |
| 200 | 200 | // Trait are always invariant so we can take advantage of that. |
| 201 | 201 | let variance_i = self.invariant(variance); |
| 202 | 202 | |
| 203 | for k in args { | |
| 204 | match k.unpack() { | |
| 203 | for arg in args { | |
| 204 | match arg.kind() { | |
| 205 | 205 | GenericArgKind::Lifetime(lt) => { |
| 206 | 206 | self.add_constraints_from_region(current, lt, variance_i) |
| 207 | 207 | } |
| ... | ... | @@ -294,7 +294,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | for projection in data.projection_bounds() { |
| 297 | match projection.skip_binder().term.unpack() { | |
| 297 | match projection.skip_binder().term.kind() { | |
| 298 | 298 | ty::TermKind::Ty(ty) => { |
| 299 | 299 | self.add_constraints_from_ty(current, ty, self.invariant); |
| 300 | 300 | } |
| ... | ... | @@ -373,7 +373,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { |
| 373 | 373 | (None, Some(self.tcx().variances_of(def_id))) |
| 374 | 374 | }; |
| 375 | 375 | |
| 376 | for (i, k) in args.iter().enumerate() { | |
| 376 | for (i, arg) in args.iter().enumerate() { | |
| 377 | 377 | let variance_decl = if let Some(InferredIndex(start)) = local { |
| 378 | 378 | // Parameter on an item defined within current crate: |
| 379 | 379 | // variance not yet inferred, so return a symbolic |
| ... | ... | @@ -389,7 +389,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { |
| 389 | 389 | "add_constraints_from_args: variance_decl={:?} variance_i={:?}", |
| 390 | 390 | variance_decl, variance_i |
| 391 | 391 | ); |
| 392 | match k.unpack() { | |
| 392 | match arg.kind() { | |
| 393 | 393 | GenericArgKind::Lifetime(lt) => { |
| 394 | 394 | self.add_constraints_from_region(current, lt, variance_i) |
| 395 | 395 | } |
compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs+11-11| ... | ... | @@ -80,12 +80,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 80 | 80 | let find_param_matching = |matches: &dyn Fn(ty::ParamTerm) -> bool| { |
| 81 | 81 | predicate_args.iter().find_map(|arg| { |
| 82 | 82 | arg.walk().find_map(|arg| { |
| 83 | if let ty::GenericArgKind::Type(ty) = arg.unpack() | |
| 83 | if let ty::GenericArgKind::Type(ty) = arg.kind() | |
| 84 | 84 | && let ty::Param(param_ty) = *ty.kind() |
| 85 | 85 | && matches(ty::ParamTerm::Ty(param_ty)) |
| 86 | 86 | { |
| 87 | 87 | Some(arg) |
| 88 | } else if let ty::GenericArgKind::Const(ct) = arg.unpack() | |
| 88 | } else if let ty::GenericArgKind::Const(ct) = arg.kind() | |
| 89 | 89 | && let ty::ConstKind::Param(param_ct) = ct.kind() |
| 90 | 90 | && matches(ty::ParamTerm::Const(param_ct)) |
| 91 | 91 | { |
| ... | ... | @@ -357,7 +357,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 357 | 357 | &self, |
| 358 | 358 | error: &mut traits::FulfillmentError<'tcx>, |
| 359 | 359 | def_id: DefId, |
| 360 | param: ty::GenericArg<'tcx>, | |
| 360 | arg: ty::GenericArg<'tcx>, | |
| 361 | 361 | qpath: &hir::QPath<'tcx>, |
| 362 | 362 | ) -> bool { |
| 363 | 363 | match qpath { |
| ... | ... | @@ -365,7 +365,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 365 | 365 | for segment in path.segments.iter().rev() { |
| 366 | 366 | if let Res::Def(kind, def_id) = segment.res |
| 367 | 367 | && !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) | |
| 369 | 369 | { |
| 370 | 370 | return true; |
| 371 | 371 | } |
| ... | ... | @@ -373,7 +373,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 373 | 373 | // Handle `Self` param specifically, since it's separated in |
| 374 | 374 | // the path representation |
| 375 | 375 | if let Some(self_ty) = self_ty |
| 376 | && let ty::GenericArgKind::Type(ty) = param.unpack() | |
| 376 | && let ty::GenericArgKind::Type(ty) = arg.kind() | |
| 377 | 377 | && ty == self.tcx.types.self_param |
| 378 | 378 | { |
| 379 | 379 | error.obligation.cause.span = self_ty |
| ... | ... | @@ -384,12 +384,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | 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) { | |
| 388 | 388 | return true; |
| 389 | 389 | } |
| 390 | 390 | // Handle `Self` param specifically, since it's separated in |
| 391 | 391 | // the path representation |
| 392 | if let ty::GenericArgKind::Type(ty) = param.unpack() | |
| 392 | if let ty::GenericArgKind::Type(ty) = arg.kind() | |
| 393 | 393 | && ty == self.tcx.types.self_param |
| 394 | 394 | { |
| 395 | 395 | error.obligation.cause.span = self_ty |
| ... | ... | @@ -424,10 +424,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 424 | 424 | // the args list does not, then we should chop off all of the lifetimes, |
| 425 | 425 | // since they're all elided. |
| 426 | 426 | 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(_)) | |
| 428 | 428 | && segment_args.first().is_some_and(|arg| arg.is_ty_or_const()) |
| 429 | 429 | && 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(_)) | |
| 431 | 431 | }) |
| 432 | 432 | && let Some(new_index) = index.checked_sub(offset) |
| 433 | 433 | { |
| ... | ... | @@ -750,7 +750,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 750 | 750 | return Ok(expr); |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | let ty::GenericArgKind::Type(in_ty) = in_ty.unpack() else { | |
| 753 | let ty::GenericArgKind::Type(in_ty) = in_ty.kind() else { | |
| 754 | 754 | return Err(expr); |
| 755 | 755 | }; |
| 756 | 756 | |
| ... | ... | @@ -1045,7 +1045,7 @@ fn find_param_in_ty<'tcx>( |
| 1045 | 1045 | if arg == param_to_point_at { |
| 1046 | 1046 | return true; |
| 1047 | 1047 | } |
| 1048 | if let ty::GenericArgKind::Type(ty) = arg.unpack() | |
| 1048 | if let ty::GenericArgKind::Type(ty) = arg.kind() | |
| 1049 | 1049 | && let ty::Alias(ty::Projection | ty::Inherent, ..) = ty.kind() |
| 1050 | 1050 | { |
| 1051 | 1051 | // 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> { |
| 2226 | 2226 | let infer_args = self.tcx.mk_args_from_iter(args.into_iter().map(|arg| { |
| 2227 | 2227 | if !arg.is_suggestable(self.tcx, true) { |
| 2228 | 2228 | has_unsuggestable_args = true; |
| 2229 | match arg.unpack() { | |
| 2229 | match arg.kind() { | |
| 2230 | 2230 | GenericArgKind::Lifetime(_) => self |
| 2231 | 2231 | .next_region_var(RegionVariableOrigin::MiscVariable(DUMMY_SP)) |
| 2232 | 2232 | .into(), |
| ... | ... | @@ -2843,7 +2843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2843 | 2843 | let [first] = ***args else { |
| 2844 | 2844 | return; |
| 2845 | 2845 | }; |
| 2846 | let ty::GenericArgKind::Type(ty) = first.unpack() else { | |
| 2846 | let ty::GenericArgKind::Type(ty) = first.kind() else { | |
| 2847 | 2847 | return; |
| 2848 | 2848 | }; |
| 2849 | 2849 | 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> { |
| 347 | 347 | fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> { |
| 348 | 348 | TypeTrace { |
| 349 | 349 | cause: cause.clone(), |
| 350 | values: match (a.unpack(), b.unpack()) { | |
| 350 | values: match (a.kind(), b.kind()) { | |
| 351 | 351 | (GenericArgKind::Lifetime(a), GenericArgKind::Lifetime(b)) => { |
| 352 | 352 | ValuePairs::Regions(ExpectedFound::new(a, b)) |
| 353 | 353 | } |
compiler/rustc_infer/src/infer/canonical/instantiate.rs+3-3| ... | ... | @@ -61,15 +61,15 @@ where |
| 61 | 61 | value |
| 62 | 62 | } else { |
| 63 | 63 | 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() { | |
| 65 | 65 | GenericArgKind::Lifetime(l) => l, |
| 66 | 66 | r => bug!("{:?} is a region but value is {:?}", br, r), |
| 67 | 67 | }, |
| 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() { | |
| 69 | 69 | GenericArgKind::Type(ty) => ty, |
| 70 | 70 | r => bug!("{:?} is a type but value is {:?}", bound_ty, r), |
| 71 | 71 | }, |
| 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() { | |
| 73 | 73 | GenericArgKind::Const(ct) => ct, |
| 74 | 74 | c => bug!("{:?} is a const but value is {:?}", bound_ct, c), |
| 75 | 75 | }, |
compiler/rustc_infer/src/infer/canonical/query_response.rs+3-3| ... | ... | @@ -245,7 +245,7 @@ impl<'tcx> InferCtxt<'tcx> { |
| 245 | 245 | let result_value = query_response.instantiate_projected(self.tcx, &result_args, |v| { |
| 246 | 246 | v.var_values[BoundVar::new(index)] |
| 247 | 247 | }); |
| 248 | match (original_value.unpack(), result_value.unpack()) { | |
| 248 | match (original_value.kind(), result_value.kind()) { | |
| 249 | 249 | (GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2)) |
| 250 | 250 | if re1.is_erased() && re2.is_erased() => |
| 251 | 251 | { |
| ... | ... | @@ -402,7 +402,7 @@ impl<'tcx> InferCtxt<'tcx> { |
| 402 | 402 | // [(?A, Vec<?0>), ('static, '?1), (?B, ?0)] |
| 403 | 403 | for (original_value, result_value) in iter::zip(&original_values.var_values, result_values) |
| 404 | 404 | { |
| 405 | match result_value.unpack() { | |
| 405 | match result_value.kind() { | |
| 406 | 406 | GenericArgKind::Type(result_value) => { |
| 407 | 407 | // e.g., here `result_value` might be `?0` in the example above... |
| 408 | 408 | if let ty::Bound(debruijn, b) = *result_value.kind() { |
| ... | ... | @@ -533,7 +533,7 @@ impl<'tcx> InferCtxt<'tcx> { |
| 533 | 533 | for (index, value1) in variables1.var_values.iter().enumerate() { |
| 534 | 534 | let value2 = variables2(BoundVar::new(index)); |
| 535 | 535 | |
| 536 | match (value1.unpack(), value2.unpack()) { | |
| 536 | match (value1.kind(), value2.kind()) { | |
| 537 | 537 | (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => { |
| 538 | 538 | obligations.extend( |
| 539 | 539 | 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> { |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | fn is_changed_arg(&self, arg: ty::GenericArg<'tcx>) -> bool { |
| 93 | match arg.unpack() { | |
| 93 | match arg.kind() { | |
| 94 | 94 | ty::GenericArgKind::Lifetime(_) => { |
| 95 | 95 | // Lifetimes should not change affect trait selection. |
| 96 | 96 | false |
compiler/rustc_infer/src/infer/mod.rs+2-2| ... | ... | @@ -1372,7 +1372,7 @@ impl<'tcx> TyOrConstInferVar { |
| 1372 | 1372 | /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and |
| 1373 | 1373 | /// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`). |
| 1374 | 1374 | pub fn maybe_from_generic_arg(arg: GenericArg<'tcx>) -> Option<Self> { |
| 1375 | match arg.unpack() { | |
| 1375 | match arg.kind() { | |
| 1376 | 1376 | GenericArgKind::Type(ty) => Self::maybe_from_ty(ty), |
| 1377 | 1377 | GenericArgKind::Const(ct) => Self::maybe_from_const(ct), |
| 1378 | 1378 | GenericArgKind::Lifetime(_) => None, |
| ... | ... | @@ -1383,7 +1383,7 @@ impl<'tcx> TyOrConstInferVar { |
| 1383 | 1383 | /// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and |
| 1384 | 1384 | /// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`). |
| 1385 | 1385 | pub fn maybe_from_term(term: Term<'tcx>) -> Option<Self> { |
| 1386 | match term.unpack() { | |
| 1386 | match term.kind() { | |
| 1387 | 1387 | TermKind::Ty(ty) => Self::maybe_from_ty(ty), |
| 1388 | 1388 | TermKind::Const(ct) => Self::maybe_from_const(ct), |
| 1389 | 1389 | } |
compiler/rustc_infer/src/infer/outlives/obligations.rs+3-3| ... | ... | @@ -87,7 +87,7 @@ impl<'tcx> InferCtxt<'tcx> { |
| 87 | 87 | ty::OutlivesPredicate(arg, r2): ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>, |
| 88 | 88 | cause: &ObligationCause<'tcx>, |
| 89 | 89 | ) { |
| 90 | match arg.unpack() { | |
| 90 | match arg.kind() { | |
| 91 | 91 | ty::GenericArgKind::Lifetime(r1) => { |
| 92 | 92 | self.register_region_outlives_constraint(ty::OutlivesPredicate(r1, r2), cause); |
| 93 | 93 | } |
| ... | ... | @@ -503,8 +503,8 @@ where |
| 503 | 503 | opt_variances: Option<&[ty::Variance]>, |
| 504 | 504 | ) { |
| 505 | 505 | 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() { | |
| 508 | 508 | GenericArgKind::Lifetime(lt) => { |
| 509 | 509 | let variance = if let Some(variances) = opt_variances { |
| 510 | 510 | variances[index] |
compiler/rustc_infer/src/infer/relate/generalize.rs+1-1| ... | ... | @@ -329,7 +329,7 @@ struct Generalizer<'me, 'tcx> { |
| 329 | 329 | impl<'tcx> Generalizer<'_, 'tcx> { |
| 330 | 330 | /// Create an error that corresponds to the term kind in `root_term` |
| 331 | 331 | fn cyclic_term_error(&self) -> TypeError<'tcx> { |
| 332 | match self.root_term.unpack() { | |
| 332 | match self.root_term.kind() { | |
| 333 | 333 | ty::TermKind::Ty(ty) => TypeError::CyclicTy(ty), |
| 334 | 334 | ty::TermKind::Const(ct) => TypeError::CyclicConst(ct), |
| 335 | 335 | } |
compiler/rustc_interface/src/tests.rs+1-2| ... | ... | @@ -776,8 +776,7 @@ fn test_unstable_options_tracking_hash() { |
| 776 | 776 | CoverageOptions { |
| 777 | 777 | level: CoverageLevel::Mcdc, |
| 778 | 778 | no_mir_spans: true, |
| 779 | discard_all_spans_in_codegen: true, | |
| 780 | inject_unused_local_file: true, | |
| 779 | discard_all_spans_in_codegen: true | |
| 781 | 780 | } |
| 782 | 781 | ); |
| 783 | 782 | 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>( |
| 461 | 461 | generics: &'tcx ty::Generics, |
| 462 | 462 | arg: ty::GenericArg<'tcx>, |
| 463 | 463 | ) -> DefId { |
| 464 | match arg.unpack() { | |
| 464 | match arg.kind() { | |
| 465 | 465 | ty::GenericArgKind::Lifetime(re) => match re.kind() { |
| 466 | 466 | ty::ReEarlyParam(ebr) => generics.region_param(ebr, tcx).def_id, |
| 467 | 467 | ty::ReBound( |
compiler/rustc_middle/src/ty/context.rs+2-2| ... | ... | @@ -2781,7 +2781,7 @@ impl<'tcx> TyCtxt<'tcx> { |
| 2781 | 2781 | return false; |
| 2782 | 2782 | } |
| 2783 | 2783 | |
| 2784 | if !matches!(args[0].unpack(), ty::GenericArgKind::Type(_)) { | |
| 2784 | if !matches!(args[0].kind(), ty::GenericArgKind::Type(_)) { | |
| 2785 | 2785 | return false; |
| 2786 | 2786 | } |
| 2787 | 2787 | |
| ... | ... | @@ -2803,7 +2803,7 @@ impl<'tcx> TyCtxt<'tcx> { |
| 2803 | 2803 | }; |
| 2804 | 2804 | |
| 2805 | 2805 | for (param, arg) in std::iter::zip(&generics.own_params, own_args) { |
| 2806 | match (&param.kind, arg.unpack()) { | |
| 2806 | match (&param.kind, arg.kind()) { | |
| 2807 | 2807 | (ty::GenericParamDefKind::Type { .. }, ty::GenericArgKind::Type(_)) |
| 2808 | 2808 | | (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Lifetime(_)) |
| 2809 | 2809 | | (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> { |
| 137 | 137 | type Kind = GenericArgKind<'tcx>; |
| 138 | 138 | |
| 139 | 139 | fn kind(self) -> Self::Kind { |
| 140 | self.unpack() | |
| 140 | self.kind() | |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| ... | ... | @@ -218,7 +218,7 @@ impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> { |
| 218 | 218 | |
| 219 | 219 | impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> { |
| 220 | 220 | fn from(value: ty::Term<'tcx>) -> Self { |
| 221 | match value.unpack() { | |
| 221 | match value.kind() { | |
| 222 | 222 | ty::TermKind::Ty(t) => t.into(), |
| 223 | 223 | ty::TermKind::Const(c) => c.into(), |
| 224 | 224 | } |
| ... | ... | @@ -227,7 +227,7 @@ impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> { |
| 227 | 227 | |
| 228 | 228 | impl<'tcx> GenericArg<'tcx> { |
| 229 | 229 | #[inline] |
| 230 | pub fn unpack(self) -> GenericArgKind<'tcx> { | |
| 230 | pub fn kind(self) -> GenericArgKind<'tcx> { | |
| 231 | 231 | let ptr = |
| 232 | 232 | unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) }; |
| 233 | 233 | // SAFETY: use of `Interned::new_unchecked` here is ok because these |
| ... | ... | @@ -251,7 +251,7 @@ impl<'tcx> GenericArg<'tcx> { |
| 251 | 251 | |
| 252 | 252 | #[inline] |
| 253 | 253 | pub fn as_region(self) -> Option<ty::Region<'tcx>> { |
| 254 | match self.unpack() { | |
| 254 | match self.kind() { | |
| 255 | 255 | GenericArgKind::Lifetime(re) => Some(re), |
| 256 | 256 | _ => None, |
| 257 | 257 | } |
| ... | ... | @@ -259,7 +259,7 @@ impl<'tcx> GenericArg<'tcx> { |
| 259 | 259 | |
| 260 | 260 | #[inline] |
| 261 | 261 | pub fn as_type(self) -> Option<Ty<'tcx>> { |
| 262 | match self.unpack() { | |
| 262 | match self.kind() { | |
| 263 | 263 | GenericArgKind::Type(ty) => Some(ty), |
| 264 | 264 | _ => None, |
| 265 | 265 | } |
| ... | ... | @@ -267,7 +267,7 @@ impl<'tcx> GenericArg<'tcx> { |
| 267 | 267 | |
| 268 | 268 | #[inline] |
| 269 | 269 | pub fn as_const(self) -> Option<ty::Const<'tcx>> { |
| 270 | match self.unpack() { | |
| 270 | match self.kind() { | |
| 271 | 271 | GenericArgKind::Const(ct) => Some(ct), |
| 272 | 272 | _ => None, |
| 273 | 273 | } |
| ... | ... | @@ -275,7 +275,7 @@ impl<'tcx> GenericArg<'tcx> { |
| 275 | 275 | |
| 276 | 276 | #[inline] |
| 277 | 277 | pub fn as_term(self) -> Option<ty::Term<'tcx>> { |
| 278 | match self.unpack() { | |
| 278 | match self.kind() { | |
| 279 | 279 | GenericArgKind::Lifetime(_) => None, |
| 280 | 280 | GenericArgKind::Type(ty) => Some(ty.into()), |
| 281 | 281 | GenericArgKind::Const(ct) => Some(ct.into()), |
| ... | ... | @@ -300,7 +300,7 @@ impl<'tcx> GenericArg<'tcx> { |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | pub fn is_non_region_infer(self) -> bool { |
| 303 | match self.unpack() { | |
| 303 | match self.kind() { | |
| 304 | 304 | GenericArgKind::Lifetime(_) => false, |
| 305 | 305 | // FIXME: This shouldn't return numerical/float. |
| 306 | 306 | GenericArgKind::Type(ty) => ty.is_ty_or_numeric_infer(), |
| ... | ... | @@ -327,7 +327,7 @@ impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> { |
| 327 | 327 | type Lifted = GenericArg<'tcx>; |
| 328 | 328 | |
| 329 | 329 | fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> { |
| 330 | match self.unpack() { | |
| 330 | match self.kind() { | |
| 331 | 331 | GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()), |
| 332 | 332 | GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()), |
| 333 | 333 | GenericArgKind::Const(ct) => tcx.lift(ct).map(|ct| ct.into()), |
| ... | ... | @@ -340,7 +340,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> { |
| 340 | 340 | self, |
| 341 | 341 | folder: &mut F, |
| 342 | 342 | ) -> Result<Self, F::Error> { |
| 343 | match self.unpack() { | |
| 343 | match self.kind() { | |
| 344 | 344 | GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into), |
| 345 | 345 | GenericArgKind::Type(ty) => ty.try_fold_with(folder).map(Into::into), |
| 346 | 346 | GenericArgKind::Const(ct) => ct.try_fold_with(folder).map(Into::into), |
| ... | ... | @@ -348,7 +348,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> { |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self { |
| 351 | match self.unpack() { | |
| 351 | match self.kind() { | |
| 352 | 352 | GenericArgKind::Lifetime(lt) => lt.fold_with(folder).into(), |
| 353 | 353 | GenericArgKind::Type(ty) => ty.fold_with(folder).into(), |
| 354 | 354 | GenericArgKind::Const(ct) => ct.fold_with(folder).into(), |
| ... | ... | @@ -358,7 +358,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> { |
| 358 | 358 | |
| 359 | 359 | impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> { |
| 360 | 360 | fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result { |
| 361 | match self.unpack() { | |
| 361 | match self.kind() { | |
| 362 | 362 | GenericArgKind::Lifetime(lt) => lt.visit_with(visitor), |
| 363 | 363 | GenericArgKind::Type(ty) => ty.visit_with(visitor), |
| 364 | 364 | GenericArgKind::Const(ct) => ct.visit_with(visitor), |
| ... | ... | @@ -368,7 +368,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> { |
| 368 | 368 | |
| 369 | 369 | impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for GenericArg<'tcx> { |
| 370 | 370 | fn encode(&self, e: &mut E) { |
| 371 | self.unpack().encode(e) | |
| 371 | self.kind().encode(e) | |
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | |
| ... | ... | @@ -390,7 +390,7 @@ impl<'tcx> GenericArgs<'tcx> { |
| 390 | 390 | /// |
| 391 | 391 | /// If any of the generic arguments are not types. |
| 392 | 392 | 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() { | |
| 394 | 394 | GenericArgKind::Type(ty) => ty, |
| 395 | 395 | _ => bug!("`into_type_list` called on generic arg with non-types"), |
| 396 | 396 | })) |
| ... | ... | @@ -527,7 +527,7 @@ impl<'tcx> GenericArgs<'tcx> { |
| 527 | 527 | /// Returns generic arguments that are not lifetimes. |
| 528 | 528 | #[inline] |
| 529 | 529 | 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() { | |
| 531 | 531 | ty::GenericArgKind::Lifetime(_) => None, |
| 532 | 532 | generic => Some(generic), |
| 533 | 533 | }) |
compiler/rustc_middle/src/ty/impls_ty.rs+1-1| ... | ... | @@ -60,7 +60,7 @@ where |
| 60 | 60 | |
| 61 | 61 | impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::GenericArg<'tcx> { |
| 62 | 62 | 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); | |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 |
compiler/rustc_middle/src/ty/mod.rs+13-13| ... | ... | @@ -504,7 +504,7 @@ impl<'tcx> rustc_type_ir::inherent::IntoKind for Term<'tcx> { |
| 504 | 504 | type Kind = TermKind<'tcx>; |
| 505 | 505 | |
| 506 | 506 | fn kind(self) -> Self::Kind { |
| 507 | self.unpack() | |
| 507 | self.kind() | |
| 508 | 508 | } |
| 509 | 509 | } |
| 510 | 510 | |
| ... | ... | @@ -521,7 +521,7 @@ unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync |
| 521 | 521 | |
| 522 | 522 | impl Debug for Term<'_> { |
| 523 | 523 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 524 | match self.unpack() { | |
| 524 | match self.kind() { | |
| 525 | 525 | TermKind::Ty(ty) => write!(f, "Term::Ty({ty:?})"), |
| 526 | 526 | TermKind::Const(ct) => write!(f, "Term::Const({ct:?})"), |
| 527 | 527 | } |
| ... | ... | @@ -542,7 +542,7 @@ impl<'tcx> From<Const<'tcx>> for Term<'tcx> { |
| 542 | 542 | |
| 543 | 543 | impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Term<'tcx> { |
| 544 | 544 | 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); | |
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
| ... | ... | @@ -551,14 +551,14 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> { |
| 551 | 551 | self, |
| 552 | 552 | folder: &mut F, |
| 553 | 553 | ) -> Result<Self, F::Error> { |
| 554 | match self.unpack() { | |
| 554 | match self.kind() { | |
| 555 | 555 | ty::TermKind::Ty(ty) => ty.try_fold_with(folder).map(Into::into), |
| 556 | 556 | ty::TermKind::Const(ct) => ct.try_fold_with(folder).map(Into::into), |
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self { |
| 561 | match self.unpack() { | |
| 561 | match self.kind() { | |
| 562 | 562 | ty::TermKind::Ty(ty) => ty.fold_with(folder).into(), |
| 563 | 563 | ty::TermKind::Const(ct) => ct.fold_with(folder).into(), |
| 564 | 564 | } |
| ... | ... | @@ -567,7 +567,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> { |
| 567 | 567 | |
| 568 | 568 | impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> { |
| 569 | 569 | fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result { |
| 570 | match self.unpack() { | |
| 570 | match self.kind() { | |
| 571 | 571 | ty::TermKind::Ty(ty) => ty.visit_with(visitor), |
| 572 | 572 | ty::TermKind::Const(ct) => ct.visit_with(visitor), |
| 573 | 573 | } |
| ... | ... | @@ -576,7 +576,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> { |
| 576 | 576 | |
| 577 | 577 | impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Term<'tcx> { |
| 578 | 578 | fn encode(&self, e: &mut E) { |
| 579 | self.unpack().encode(e) | |
| 579 | self.kind().encode(e) | |
| 580 | 580 | } |
| 581 | 581 | } |
| 582 | 582 | |
| ... | ... | @@ -589,7 +589,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Term<'tcx> { |
| 589 | 589 | |
| 590 | 590 | impl<'tcx> Term<'tcx> { |
| 591 | 591 | #[inline] |
| 592 | pub fn unpack(self) -> TermKind<'tcx> { | |
| 592 | pub fn kind(self) -> TermKind<'tcx> { | |
| 593 | 593 | let ptr = |
| 594 | 594 | unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) }; |
| 595 | 595 | // SAFETY: use of `Interned::new_unchecked` here is ok because these |
| ... | ... | @@ -609,7 +609,7 @@ impl<'tcx> Term<'tcx> { |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | 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 } | |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | pub fn expect_type(&self) -> Ty<'tcx> { |
| ... | ... | @@ -617,7 +617,7 @@ impl<'tcx> Term<'tcx> { |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | 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 } | |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | pub fn expect_const(&self) -> Const<'tcx> { |
| ... | ... | @@ -625,14 +625,14 @@ impl<'tcx> Term<'tcx> { |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | pub fn into_arg(self) -> GenericArg<'tcx> { |
| 628 | match self.unpack() { | |
| 628 | match self.kind() { | |
| 629 | 629 | TermKind::Ty(ty) => ty.into(), |
| 630 | 630 | TermKind::Const(c) => c.into(), |
| 631 | 631 | } |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | pub fn to_alias_term(self) -> Option<AliasTerm<'tcx>> { |
| 635 | match self.unpack() { | |
| 635 | match self.kind() { | |
| 636 | 636 | TermKind::Ty(ty) => match *ty.kind() { |
| 637 | 637 | ty::Alias(_kind, alias_ty) => Some(alias_ty.into()), |
| 638 | 638 | _ => None, |
| ... | ... | @@ -645,7 +645,7 @@ impl<'tcx> Term<'tcx> { |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | pub fn is_infer(&self) -> bool { |
| 648 | match self.unpack() { | |
| 648 | match self.kind() { | |
| 649 | 649 | TermKind::Ty(ty) => ty.is_ty_var(), |
| 650 | 650 | TermKind::Const(ct) => ct.is_ct_infer(), |
| 651 | 651 | } |
compiler/rustc_middle/src/ty/opaque_types.rs+3-3| ... | ... | @@ -120,7 +120,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> { |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | match self.map.get(&r.into()).map(|k| k.unpack()) { | |
| 123 | match self.map.get(&r.into()).map(|arg| arg.kind()) { | |
| 124 | 124 | Some(GenericArgKind::Lifetime(r1)) => r1, |
| 125 | 125 | Some(u) => panic!("region mapped to unexpected kind: {u:?}"), |
| 126 | 126 | None if self.do_not_error => self.tcx.lifetimes.re_static, |
| ... | ... | @@ -162,7 +162,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> { |
| 162 | 162 | |
| 163 | 163 | ty::Param(param) => { |
| 164 | 164 | // 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()) { | |
| 166 | 166 | // Found it in the generic parameters list; replace with the parameter from the |
| 167 | 167 | // opaque type. |
| 168 | 168 | Some(GenericArgKind::Type(t1)) => t1, |
| ... | ... | @@ -195,7 +195,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> { |
| 195 | 195 | match ct.kind() { |
| 196 | 196 | ty::ConstKind::Param(..) => { |
| 197 | 197 | // 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()) { | |
| 199 | 199 | // Found it in the generic parameters list, replace with the parameter from the |
| 200 | 200 | // opaque type. |
| 201 | 201 | 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 { |
| 1239 | 1239 | |
| 1240 | 1240 | p!(write("{} = ", tcx.associated_item(assoc_item_def_id).name())); |
| 1241 | 1241 | |
| 1242 | match term.unpack() { | |
| 1242 | match term.kind() { | |
| 1243 | 1243 | TermKind::Ty(ty) => p!(print(ty)), |
| 1244 | 1244 | TermKind::Const(c) => p!(print(c)), |
| 1245 | 1245 | }; |
| ... | ... | @@ -3386,7 +3386,7 @@ define_print_and_forward_display! { |
| 3386 | 3386 | } |
| 3387 | 3387 | |
| 3388 | 3388 | ty::Term<'tcx> { |
| 3389 | match self.unpack() { | |
| 3389 | match self.kind() { | |
| 3390 | 3390 | ty::TermKind::Ty(ty) => p!(print(ty)), |
| 3391 | 3391 | ty::TermKind::Const(c) => p!(print(c)), |
| 3392 | 3392 | } |
| ... | ... | @@ -3401,7 +3401,7 @@ define_print_and_forward_display! { |
| 3401 | 3401 | } |
| 3402 | 3402 | |
| 3403 | 3403 | GenericArg<'tcx> { |
| 3404 | match self.unpack() { | |
| 3404 | match self.kind() { | |
| 3405 | 3405 | GenericArgKind::Lifetime(lt) => p!(print(lt)), |
| 3406 | 3406 | GenericArgKind::Type(ty) => p!(print(ty)), |
| 3407 | 3407 | 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> { |
| 169 | 169 | a: ty::GenericArg<'tcx>, |
| 170 | 170 | b: ty::GenericArg<'tcx>, |
| 171 | 171 | ) -> RelateResult<'tcx, ty::GenericArg<'tcx>> { |
| 172 | match (a.unpack(), b.unpack()) { | |
| 172 | match (a.kind(), b.kind()) { | |
| 173 | 173 | (ty::GenericArgKind::Lifetime(a_lt), ty::GenericArgKind::Lifetime(b_lt)) => { |
| 174 | 174 | Ok(relation.relate(a_lt, b_lt)?.into()) |
| 175 | 175 | } |
| ... | ... | @@ -190,7 +190,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::Term<'tcx> { |
| 190 | 190 | a: Self, |
| 191 | 191 | b: Self, |
| 192 | 192 | ) -> RelateResult<'tcx, Self> { |
| 193 | Ok(match (a.unpack(), b.unpack()) { | |
| 193 | Ok(match (a.kind(), b.kind()) { | |
| 194 | 194 | (ty::TermKind::Ty(a), ty::TermKind::Ty(b)) => relation.relate(a, b)?.into(), |
| 195 | 195 | (ty::TermKind::Const(a), ty::TermKind::Const(b)) => relation.relate(a, b)?.into(), |
| 196 | 196 | _ => 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> { |
| 202 | 202 | |
| 203 | 203 | impl<'tcx> fmt::Debug for GenericArg<'tcx> { |
| 204 | 204 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 205 | match self.unpack() { | |
| 205 | match self.kind() { | |
| 206 | 206 | GenericArgKind::Lifetime(lt) => lt.fmt(f), |
| 207 | 207 | GenericArgKind::Type(ty) => ty.fmt(f), |
| 208 | 208 | GenericArgKind::Const(ct) => ct.fmt(f), |
| ... | ... | @@ -326,7 +326,7 @@ impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> { |
| 326 | 326 | impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> { |
| 327 | 327 | type Lifted = ty::Term<'tcx>; |
| 328 | 328 | fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> { |
| 329 | match self.unpack() { | |
| 329 | match self.kind() { | |
| 330 | 330 | TermKind::Ty(ty) => tcx.lift(ty).map(Into::into), |
| 331 | 331 | TermKind::Const(c) => tcx.lift(c).map(Into::into), |
| 332 | 332 | } |
compiler/rustc_middle/src/ty/typeck_results.rs+2-2| ... | ... | @@ -777,8 +777,8 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> { |
| 777 | 777 | return false; |
| 778 | 778 | } |
| 779 | 779 | |
| 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() { | |
| 782 | 782 | GenericArgKind::Type(ty) => match ty.kind() { |
| 783 | 783 | ty::Bound(debruijn, b) => { |
| 784 | 784 | // 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> { |
| 516 | 516 | let item_args = ty::GenericArgs::identity_for_item(self, def.did()); |
| 517 | 517 | |
| 518 | 518 | let result = iter::zip(item_args, impl_args) |
| 519 | .filter(|&(_, k)| { | |
| 520 | match k.unpack() { | |
| 519 | .filter(|&(_, arg)| { | |
| 520 | match arg.kind() { | |
| 521 | 521 | GenericArgKind::Lifetime(region) => match region.kind() { |
| 522 | 522 | ty::ReEarlyParam(ebr) => { |
| 523 | 523 | !impl_generics.region_param(ebr, self).pure_wrt_drop |
| ... | ... | @@ -554,7 +554,7 @@ impl<'tcx> TyCtxt<'tcx> { |
| 554 | 554 | let mut seen = GrowableBitSet::default(); |
| 555 | 555 | let mut seen_late = FxHashSet::default(); |
| 556 | 556 | for arg in args { |
| 557 | match arg.unpack() { | |
| 557 | match arg.kind() { | |
| 558 | 558 | GenericArgKind::Lifetime(lt) => match (ignore_regions, lt.kind()) { |
| 559 | 559 | (CheckRegions::FromFunction, ty::ReBound(di, reg)) => { |
| 560 | 560 | 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> { |
| 131 | 131 | .dcx() |
| 132 | 132 | .create_err(ConstPatternDependsOnGenericParameter { span: self.span }); |
| 133 | 133 | for arg in uv.args { |
| 134 | if let ty::GenericArgKind::Type(ty) = arg.unpack() | |
| 134 | if let ty::GenericArgKind::Type(ty) = arg.kind() | |
| 135 | 135 | && let ty::Param(param_ty) = ty.kind() |
| 136 | 136 | { |
| 137 | 137 | 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 @@ |
| 1 | 1 | use rustc_data_structures::fx::FxHashSet; |
| 2 | 2 | use rustc_middle::mir; |
| 3 | 3 | use rustc_middle::ty::TyCtxt; |
| 4 | use rustc_span::source_map::SourceMap; | |
| 5 | use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span}; | |
| 4 | use rustc_span::{DesugaringKind, ExpnKind, MacroKind, Span}; | |
| 6 | 5 | use tracing::instrument; |
| 7 | 6 | |
| 8 | 7 | use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph}; |
| ... | ... | @@ -84,18 +83,8 @@ pub(super) fn extract_refined_covspans<'tcx>( |
| 84 | 83 | // Discard any span that overlaps with a hole. |
| 85 | 84 | discard_spans_overlapping_holes(&mut covspans, &holes); |
| 86 | 85 | |
| 87 | // Discard spans that overlap in unwanted ways. | |
| 86 | // Perform more refinement steps after holes have been dealt with. | |
| 88 | 87 | 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. | |
| 99 | 88 | covspans.dedup_by(|b, a| a.merge_if_eligible(b)); |
| 100 | 89 | |
| 101 | 90 | code_mappings.extend(covspans.into_iter().map(|Covspan { span, bcb }| { |
| ... | ... | @@ -241,26 +230,3 @@ fn compare_spans(a: Span, b: Span) -> std::cmp::Ordering { |
| 241 | 230 | // - Both have the same start and span A extends further right |
| 242 | 231 | .then_with(|| Ord::cmp(&a.hi(), &b.hi()).reverse()) |
| 243 | 232 | } |
| 244 | ||
| 245 | fn 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 |
| 817 | 817 | |
| 818 | 818 | /// Returns a ty infer or a const infer depending on whether `kind` is a `Ty` or `Const`. |
| 819 | 819 | /// 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() { | |
| 822 | 822 | ty::TermKind::Ty(_) => self.next_ty_infer().into(), |
| 823 | 823 | ty::TermKind::Const(_) => self.next_const_infer().into(), |
| 824 | 824 | } |
compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs+2-2| ... | ... | @@ -79,7 +79,7 @@ fn encode_args<'tcx>( |
| 79 | 79 | s.push('I'); |
| 80 | 80 | let def_generics = tcx.generics_of(for_def); |
| 81 | 81 | for (n, arg) in args.iter().enumerate() { |
| 82 | match arg.unpack() { | |
| 82 | match arg.kind() { | |
| 83 | 83 | GenericArgKind::Lifetime(region) => { |
| 84 | 84 | s.push_str(&encode_region(region, dict)); |
| 85 | 85 | } |
| ... | ... | @@ -245,7 +245,7 @@ fn encode_predicate<'tcx>( |
| 245 | 245 | let name = encode_ty_name(tcx, projection.def_id); |
| 246 | 246 | let _ = write!(s, "u{}{}", name.len(), name); |
| 247 | 247 | s.push_str(&encode_args(tcx, projection.args, projection.def_id, true, dict, options)); |
| 248 | match projection.term.unpack() { | |
| 248 | match projection.term.kind() { | |
| 249 | 249 | TermKind::Ty(ty) => s.push_str(&encode_ty(tcx, ty, dict, options)), |
| 250 | 250 | TermKind::Const(c) => s.push_str(&encode_const( |
| 251 | 251 | tcx, |
compiler/rustc_session/src/config.rs-5| ... | ... | @@ -195,11 +195,6 @@ pub struct CoverageOptions { |
| 195 | 195 | /// regression tests for #133606, because we don't have an easy way to |
| 196 | 196 | /// reproduce it from actual source code. |
| 197 | 197 | 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, | |
| 203 | 198 | } |
| 204 | 199 | |
| 205 | 200 | /// Controls whether branch coverage or MC/DC coverage is enabled. |
compiler/rustc_session/src/options.rs-1| ... | ... | @@ -1413,7 +1413,6 @@ pub mod parse { |
| 1413 | 1413 | "mcdc" => slot.level = CoverageLevel::Mcdc, |
| 1414 | 1414 | "no-mir-spans" => slot.no_mir_spans = true, |
| 1415 | 1415 | "discard-all-spans-in-codegen" => slot.discard_all_spans_in_codegen = true, |
| 1416 | "inject-unused-local-file" => slot.inject_unused_local_file = true, | |
| 1417 | 1416 | _ => return false, |
| 1418 | 1417 | } |
| 1419 | 1418 | } |
compiler/rustc_session/src/session.rs-5| ... | ... | @@ -371,11 +371,6 @@ impl Session { |
| 371 | 371 | self.opts.unstable_opts.coverage_options.discard_all_spans_in_codegen |
| 372 | 372 | } |
| 373 | 373 | |
| 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 | ||
| 379 | 374 | pub fn is_sanitizer_cfi_enabled(&self) -> bool { |
| 380 | 375 | self.opts.unstable_opts.sanitizer.contains(SanitizerSet::CFI) |
| 381 | 376 | } |
compiler/rustc_smir/src/rustc_smir/convert/ty.rs+6-6| ... | ... | @@ -100,7 +100,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> { |
| 100 | 100 | stable_mir::ty::ExistentialProjection { |
| 101 | 101 | def_id: tables.trait_def(*def_id), |
| 102 | 102 | generic_args: args.stable(tables), |
| 103 | term: term.unpack().stable(tables), | |
| 103 | term: term.kind().stable(tables), | |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } |
| ... | ... | @@ -158,7 +158,7 @@ impl<'tcx> Stable<'tcx> for ty::FieldDef { |
| 158 | 158 | impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> { |
| 159 | 159 | type T = stable_mir::ty::GenericArgs; |
| 160 | 160 | 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()) | |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| ... | ... | @@ -604,8 +604,8 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> { |
| 604 | 604 | PredicateKind::NormalizesTo(_pred) => unimplemented!(), |
| 605 | 605 | PredicateKind::AliasRelate(a, b, alias_relation_direction) => { |
| 606 | 606 | 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), | |
| 609 | 609 | alias_relation_direction.stable(tables), |
| 610 | 610 | ) |
| 611 | 611 | } |
| ... | ... | @@ -640,7 +640,7 @@ impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> { |
| 640 | 640 | ty.stable(tables), |
| 641 | 641 | ), |
| 642 | 642 | ClauseKind::WellFormed(term) => { |
| 643 | stable_mir::ty::ClauseKind::WellFormed(term.unpack().stable(tables)) | |
| 643 | stable_mir::ty::ClauseKind::WellFormed(term.kind().stable(tables)) | |
| 644 | 644 | } |
| 645 | 645 | ClauseKind::ConstEvaluatable(const_) => { |
| 646 | 646 | stable_mir::ty::ClauseKind::ConstEvaluatable(const_.stable(tables)) |
| ... | ... | @@ -726,7 +726,7 @@ impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> { |
| 726 | 726 | let ty::ProjectionPredicate { projection_term, term } = self; |
| 727 | 727 | stable_mir::ty::ProjectionPredicate { |
| 728 | 728 | projection_term: projection_term.stable(tables), |
| 729 | term: term.unpack().stable(tables), | |
| 729 | term: term.kind().stable(tables), | |
| 730 | 730 | } |
| 731 | 731 | } |
| 732 | 732 | } |
compiler/rustc_symbol_mangling/src/export.rs+1-1| ... | ... | @@ -147,7 +147,7 @@ impl<'tcx> AbiHashStable<'tcx> for ty::FnSig<'tcx> { |
| 147 | 147 | |
| 148 | 148 | impl<'tcx> AbiHashStable<'tcx> for ty::GenericArg<'tcx> { |
| 149 | 149 | fn abi_hash(&self, tcx: TyCtxt<'tcx>, hasher: &mut StableHasher) { |
| 150 | self.unpack().abi_hash(tcx, hasher); | |
| 150 | self.kind().abi_hash(tcx, hasher); | |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 |
compiler/rustc_symbol_mangling/src/legacy.rs+1-1| ... | ... | @@ -386,7 +386,7 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> { |
| 386 | 386 | print_prefix(self)?; |
| 387 | 387 | |
| 388 | 388 | let args = |
| 389 | args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_))); | |
| 389 | args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_))); | |
| 390 | 390 | |
| 391 | 391 | if args.clone().next().is_some() { |
| 392 | 392 | 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> { |
| 646 | 646 | let name = cx.tcx.associated_item(projection.def_id).name(); |
| 647 | 647 | cx.push("p"); |
| 648 | 648 | cx.push_ident(name.as_str()); |
| 649 | match projection.term.unpack() { | |
| 649 | match projection.term.kind() { | |
| 650 | 650 | ty::TermKind::Ty(ty) => ty.print(cx), |
| 651 | 651 | ty::TermKind::Const(c) => c.print(cx), |
| 652 | 652 | }?; |
| ... | ... | @@ -912,11 +912,11 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { |
| 912 | 912 | args: &[GenericArg<'tcx>], |
| 913 | 913 | ) -> Result<(), PrintError> { |
| 914 | 914 | // 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() { | |
| 916 | 916 | GenericArgKind::Lifetime(r) => !r.is_erased(), |
| 917 | 917 | _ => false, |
| 918 | 918 | }); |
| 919 | let args = args.iter().cloned().filter(|arg| match arg.unpack() { | |
| 919 | let args = args.iter().cloned().filter(|arg| match arg.kind() { | |
| 920 | 920 | GenericArgKind::Lifetime(_) => print_regions, |
| 921 | 921 | _ => true, |
| 922 | 922 | }); |
| ... | ... | @@ -928,7 +928,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { |
| 928 | 928 | self.push("I"); |
| 929 | 929 | print_prefix(self)?; |
| 930 | 930 | for arg in args { |
| 931 | match arg.unpack() { | |
| 931 | match arg.kind() { | |
| 932 | 932 | GenericArgKind::Lifetime(lt) => { |
| 933 | 933 | lt.print(self)?; |
| 934 | 934 | } |
compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs+4-4| ... | ... | @@ -738,7 +738,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 738 | 738 | value.push_normal(", "); |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | match arg.unpack() { | |
| 741 | match arg.kind() { | |
| 742 | 742 | ty::GenericArgKind::Lifetime(lt) => { |
| 743 | 743 | let s = lt.to_string(); |
| 744 | 744 | value.push_normal(if s.is_empty() { "'_" } else { &s }); |
| ... | ... | @@ -1166,7 +1166,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 1166 | 1166 | |
| 1167 | 1167 | for (i, (arg1, arg2)) in sub1.iter().zip(sub2).enumerate().take(len) { |
| 1168 | 1168 | self.push_comma(&mut values.0, &mut values.1, i); |
| 1169 | match arg1.unpack() { | |
| 1169 | match arg1.kind() { | |
| 1170 | 1170 | // At one point we'd like to elide all lifetimes here, they are |
| 1171 | 1171 | // irrelevant for all diagnostics that use this output. |
| 1172 | 1172 | // |
| ... | ... | @@ -1509,7 +1509,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 1509 | 1509 | } |
| 1510 | 1510 | let (is_simple_error, exp_found) = match values { |
| 1511 | 1511 | ValuePairs::Terms(ExpectedFound { expected, found }) => { |
| 1512 | match (expected.unpack(), found.unpack()) { | |
| 1512 | match (expected.kind(), found.kind()) { | |
| 1513 | 1513 | (ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => { |
| 1514 | 1514 | let is_simple_err = |
| 1515 | 1515 | expected.is_simple_text() && found.is_simple_text(); |
| ... | ... | @@ -2156,7 +2156,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 2156 | 2156 | return None; |
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | Some(match (exp_found.expected.unpack(), exp_found.found.unpack()) { | |
| 2159 | Some(match (exp_found.expected.kind(), exp_found.found.kind()) { | |
| 2160 | 2160 | (ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => { |
| 2161 | 2161 | let (mut exp, mut fnd) = self.cmp(expected, found); |
| 2162 | 2162 | // 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> { |
| 215 | 215 | // `_` because then we'd end up with `Vec<_, _>`, instead of |
| 216 | 216 | // `Vec<_>`. |
| 217 | 217 | arg |
| 218 | } else if let GenericArgKind::Type(_) = arg.unpack() { | |
| 218 | } else if let GenericArgKind::Type(_) = arg.kind() { | |
| 219 | 219 | // We don't replace lifetime or const params, only type params. |
| 220 | 220 | self.new_infer().into() |
| 221 | 221 | } else { |
| ... | ... | @@ -347,7 +347,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 347 | 347 | highlight: ty::print::RegionHighlightMode<'tcx>, |
| 348 | 348 | ) -> InferenceDiagnosticsData { |
| 349 | 349 | let tcx = self.tcx; |
| 350 | match term.unpack() { | |
| 350 | match term.kind() { | |
| 351 | 351 | TermKind::Ty(ty) => { |
| 352 | 352 | if let ty::Infer(ty::TyVar(ty_vid)) = *ty.kind() { |
| 353 | 353 | let var_origin = self.infcx.type_var_origin(ty_vid); |
| ... | ... | @@ -568,7 +568,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 568 | 568 | return arg; |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | match arg.unpack() { | |
| 571 | match arg.kind() { | |
| 572 | 572 | GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"), |
| 573 | 573 | GenericArgKind::Type(_) => self.next_ty_var(DUMMY_SP).into(), |
| 574 | 574 | GenericArgKind::Const(_) => self.next_const_var(DUMMY_SP).into(), |
| ... | ... | @@ -803,7 +803,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { |
| 803 | 803 | } |
| 804 | 804 | impl<'tcx> CostCtxt<'tcx> { |
| 805 | 805 | fn arg_cost(self, arg: GenericArg<'tcx>) -> usize { |
| 806 | match arg.unpack() { | |
| 806 | match arg.kind() { | |
| 807 | 807 | GenericArgKind::Lifetime(_) => 0, // erased |
| 808 | 808 | GenericArgKind::Type(ty) => self.ty_cost(ty), |
| 809 | 809 | GenericArgKind::Const(_) => 3, // some non-zero value |
| ... | ... | @@ -898,7 +898,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { |
| 898 | 898 | return true; |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | match (arg.unpack(), self.target.unpack()) { | |
| 901 | match (arg.kind(), self.target.kind()) { | |
| 902 | 902 | (GenericArgKind::Type(inner_ty), TermKind::Ty(target_ty)) => { |
| 903 | 903 | use ty::{Infer, TyVar}; |
| 904 | 904 | match (inner_ty.kind(), target_ty.kind()) { |
| ... | ... | @@ -929,7 +929,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { |
| 929 | 929 | if self.generic_arg_is_target(inner) { |
| 930 | 930 | return true; |
| 931 | 931 | } |
| 932 | match inner.unpack() { | |
| 932 | match inner.kind() { | |
| 933 | 933 | GenericArgKind::Lifetime(_) => {} |
| 934 | 934 | GenericArgKind::Type(ty) => { |
| 935 | 935 | if matches!( |
compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs+2-2| ... | ... | @@ -664,8 +664,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { |
| 664 | 664 | let Some(found) = exp_found.found.args.get(1) else { |
| 665 | 665 | return; |
| 666 | 666 | }; |
| 667 | let expected = expected.unpack(); | |
| 668 | let found = found.unpack(); | |
| 667 | let expected = expected.kind(); | |
| 668 | let found = found.kind(); | |
| 669 | 669 | // 3. Extract the tuple type from Fn trait and suggest the change. |
| 670 | 670 | if let GenericArgKind::Type(expected) = expected |
| 671 | 671 | && 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> { |
| 2446 | 2446 | } |
| 2447 | 2447 | if let ty::Adt(def, args) = self_ty.kind() |
| 2448 | 2448 | && let [arg] = &args[..] |
| 2449 | && let ty::GenericArgKind::Type(ty) = arg.unpack() | |
| 2449 | && let ty::GenericArgKind::Type(ty) = arg.kind() | |
| 2450 | 2450 | && let ty::Adt(inner_def, _) = ty.kind() |
| 2451 | 2451 | && inner_def == def |
| 2452 | 2452 | { |
compiler/rustc_trait_selection/src/opaque_types.rs+1-1| ... | ... | @@ -81,7 +81,7 @@ pub fn check_opaque_type_parameter_valid<'tcx>( |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | 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() { | |
| 85 | 85 | GenericArgKind::Lifetime(lt) => match defining_scope_kind { |
| 86 | 86 | DefiningScopeKind::HirTypeck => continue, |
| 87 | 87 | 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< |
| 108 | 108 | arg: ty::GenericArg<'tcx>, |
| 109 | 109 | span: Span, |
| 110 | 110 | ) -> ty::GenericArg<'tcx> { |
| 111 | match arg.unpack() { | |
| 111 | match arg.kind() { | |
| 112 | 112 | ty::GenericArgKind::Lifetime(_) => { |
| 113 | 113 | self.next_region_var(RegionVariableOrigin::MiscVariable(span)).into() |
| 114 | 114 | } |
compiler/rustc_trait_selection/src/solve/inspect/analyse.rs+1-1| ... | ... | @@ -207,7 +207,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> { |
| 207 | 207 | let infcx = self.goal.infcx; |
| 208 | 208 | match goal.predicate.kind().no_bound_vars() { |
| 209 | 209 | Some(ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })) => { |
| 210 | let unconstrained_term = match term.unpack() { | |
| 210 | let unconstrained_term = match term.kind() { | |
| 211 | 211 | ty::TermKind::Ty(_) => infcx.next_ty_var(span).into(), |
| 212 | 212 | ty::TermKind::Const(_) => infcx.next_const_var(span).into(), |
| 213 | 213 | }; |
compiler/rustc_trait_selection/src/traits/select/mod.rs+1-1| ... | ... | @@ -1784,7 +1784,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 1784 | 1784 | if !generics.is_own_empty() |
| 1785 | 1785 | && obligation.predicate.args[generics.parent_count..].iter().any(|&p| { |
| 1786 | 1786 | p.has_non_region_infer() |
| 1787 | && match p.unpack() { | |
| 1787 | && match p.kind() { | |
| 1788 | 1788 | ty::GenericArgKind::Const(ct) => { |
| 1789 | 1789 | self.infcx.shallow_resolve_const(ct) != ct |
| 1790 | 1790 | } |
compiler/rustc_trait_selection/src/traits/structural_normalize.rs+1-1| ... | ... | @@ -39,7 +39,7 @@ impl<'tcx> At<'_, 'tcx> { |
| 39 | 39 | return Ok(term); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | let new_infer = match term.unpack() { | |
| 42 | let new_infer = match term.kind() { | |
| 43 | 43 | ty::TermKind::Ty(_) => self.infcx.next_ty_var(self.cause.span).into(), |
| 44 | 44 | ty::TermKind::Const(_) => self.infcx.next_const_var(self.cause.span).into(), |
| 45 | 45 | }; |
compiler/rustc_trait_selection/src/traits/wf.rs+1-1| ... | ... | @@ -37,7 +37,7 @@ pub fn obligations<'tcx>( |
| 37 | 37 | span: Span, |
| 38 | 38 | ) -> Option<PredicateObligations<'tcx>> { |
| 39 | 39 | // Handle the "cycle" case (see comment above) by bailing out if necessary. |
| 40 | let term = match term.unpack() { | |
| 40 | let term = match term.kind() { | |
| 41 | 41 | TermKind::Ty(ty) => { |
| 42 | 42 | match ty.kind() { |
| 43 | 43 | 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 |
| 74 | 74 | // but the type parameters may cause a cycle with an upstream type |
| 75 | 75 | let params_in_repr = tcx.params_in_repr(adt.did()); |
| 76 | 76 | 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() { | |
| 78 | 78 | if params_in_repr.contains(i as u32) { |
| 79 | 79 | rtry!(representability_ty(tcx, ty)); |
| 80 | 80 | } |
| ... | ... | @@ -104,7 +104,7 @@ fn params_in_repr_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, params_in_repr: &mut |
| 104 | 104 | ty::Adt(adt, args) => { |
| 105 | 105 | let inner_params_in_repr = tcx.params_in_repr(adt.did()); |
| 106 | 106 | 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() { | |
| 108 | 108 | if inner_params_in_repr.contains(i as u32) { |
| 109 | 109 | params_in_repr_ty(tcx, ty, params_in_repr); |
| 110 | 110 | } |
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 |
| 274 | 274 | let def = tcx.adt_def(def_id); |
| 275 | 275 | let num_params = tcx.generics_of(def_id).count(); |
| 276 | 276 | |
| 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() { | |
| 278 | 278 | ty::GenericArgKind::Type(ty) => match ty.kind() { |
| 279 | 279 | ty::Param(p) => Some(p.index), |
| 280 | 280 | _ => None, |
compiler/rustc_type_ir/src/binder.rs+3-3| ... | ... | @@ -676,7 +676,7 @@ impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I> { |
| 676 | 676 | // the specialized routine `ty::replace_late_regions()`. |
| 677 | 677 | match r.kind() { |
| 678 | 678 | 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()); | |
| 680 | 680 | match rk { |
| 681 | 681 | Some(ty::GenericArgKind::Lifetime(lt)) => self.shift_region_through_binders(lt), |
| 682 | 682 | Some(other) => self.region_param_expected(data, r, other), |
| ... | ... | @@ -716,7 +716,7 @@ impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I> { |
| 716 | 716 | impl<'a, I: Interner> ArgFolder<'a, I> { |
| 717 | 717 | fn ty_for_param(&self, p: I::ParamTy, source_ty: I::Ty) -> I::Ty { |
| 718 | 718 | // 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()); | |
| 720 | 720 | let ty = match opt_ty { |
| 721 | 721 | Some(ty::GenericArgKind::Type(ty)) => ty, |
| 722 | 722 | Some(kind) => self.type_param_expected(p, source_ty, kind), |
| ... | ... | @@ -753,7 +753,7 @@ impl<'a, I: Interner> ArgFolder<'a, I> { |
| 753 | 753 | |
| 754 | 754 | fn const_for_param(&self, p: I::ParamConst, source_ct: I::Const) -> I::Const { |
| 755 | 755 | // 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()); | |
| 757 | 757 | let ct = match opt_ct { |
| 758 | 758 | Some(ty::GenericArgKind::Const(ct)) => ct, |
| 759 | 759 | 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> { |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | 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() { | |
| 484 | 484 | ty::GenericArgKind::Type(ty) => self.add_ty(ty), |
| 485 | 485 | ty::GenericArgKind::Lifetime(lt) => self.add_region(lt), |
| 486 | 486 | ty::GenericArgKind::Const(ct) => self.add_const(ct), |
library/std/src/fs.rs+16| ... | ... | @@ -391,6 +391,16 @@ impl fmt::Display for TryLockError { |
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | #[unstable(feature = "file_lock", issue = "130994")] | |
| 395 | impl 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 | ||
| 394 | 404 | impl File { |
| 395 | 405 | /// Attempts to open a file in read-only mode. |
| 396 | 406 | /// |
| ... | ... | @@ -820,11 +830,14 @@ impl File { |
| 820 | 830 | /// |
| 821 | 831 | /// fn main() -> std::io::Result<()> { |
| 822 | 832 | /// let f = File::create("foo.txt")?; |
| 833 | /// // Explicit handling of the WouldBlock error | |
| 823 | 834 | /// match f.try_lock() { |
| 824 | 835 | /// Ok(_) => (), |
| 825 | 836 | /// Err(TryLockError::WouldBlock) => (), // Lock not acquired |
| 826 | 837 | /// Err(TryLockError::Error(err)) => return Err(err), |
| 827 | 838 | /// } |
| 839 | /// // Alternately, propagate the error as an io::Error | |
| 840 | /// f.try_lock()?; | |
| 828 | 841 | /// Ok(()) |
| 829 | 842 | /// } |
| 830 | 843 | /// ``` |
| ... | ... | @@ -881,11 +894,14 @@ impl File { |
| 881 | 894 | /// |
| 882 | 895 | /// fn main() -> std::io::Result<()> { |
| 883 | 896 | /// let f = File::open("foo.txt")?; |
| 897 | /// // Explicit handling of the WouldBlock error | |
| 884 | 898 | /// match f.try_lock_shared() { |
| 885 | 899 | /// Ok(_) => (), |
| 886 | 900 | /// Err(TryLockError::WouldBlock) => (), // Lock not acquired |
| 887 | 901 | /// Err(TryLockError::Error(err)) => return Err(err), |
| 888 | 902 | /// } |
| 903 | /// // Alternately, propagate the error as an io::Error | |
| 904 | /// f.try_lock_shared()?; | |
| 889 | 905 | /// |
| 890 | 906 | /// Ok(()) |
| 891 | 907 | /// } |
library/std/src/fs/tests.rs+22| ... | ... | @@ -366,6 +366,28 @@ fn file_lock_blocking_async() { |
| 366 | 366 | t.join().unwrap(); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | #[test] | |
| 370 | #[cfg(windows)] | |
| 371 | fn 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 | ||
| 369 | 391 | #[test] |
| 370 | 392 | fn file_test_io_seek_shakedown() { |
| 371 | 393 | // 01234567890123 |
library/std/src/sys/fs/windows.rs+2-8| ... | ... | @@ -415,10 +415,7 @@ impl File { |
| 415 | 415 | |
| 416 | 416 | match result { |
| 417 | 417 | 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) => { | |
| 422 | 419 | Err(TryLockError::WouldBlock) |
| 423 | 420 | } |
| 424 | 421 | Err(err) => Err(TryLockError::Error(err)), |
| ... | ... | @@ -440,10 +437,7 @@ impl File { |
| 440 | 437 | |
| 441 | 438 | match result { |
| 442 | 439 | 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) => { | |
| 447 | 441 | Err(TryLockError::WouldBlock) |
| 448 | 442 | } |
| 449 | 443 | Err(err) => Err(TryLockError::Error(err)), |
src/librustdoc/clean/mod.rs+1-1| ... | ... | @@ -449,7 +449,7 @@ fn clean_middle_term<'tcx>( |
| 449 | 449 | term: ty::Binder<'tcx, ty::Term<'tcx>>, |
| 450 | 450 | cx: &mut DocContext<'tcx>, |
| 451 | 451 | ) -> Term { |
| 452 | match term.skip_binder().unpack() { | |
| 452 | match term.skip_binder().kind() { | |
| 453 | 453 | ty::TermKind::Ty(ty) => Term::Type(clean_middle_ty(term.rebind(ty), cx, None, None)), |
| 454 | 454 | ty::TermKind::Const(c) => Term::Constant(clean_middle_const(term.rebind(c), cx)), |
| 455 | 455 | } |
src/librustdoc/clean/utils.rs+2-2| ... | ... | @@ -124,7 +124,7 @@ pub(crate) fn clean_middle_generic_args<'tcx>( |
| 124 | 124 | elision_has_failed_once_before = true; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | match arg.skip_binder().unpack() { | |
| 127 | match arg.skip_binder().kind() { | |
| 128 | 128 | GenericArgKind::Lifetime(lt) => { |
| 129 | 129 | Some(GenericArg::Lifetime(clean_middle_region(lt).unwrap_or(Lifetime::elided()))) |
| 130 | 130 | } |
| ... | ... | @@ -161,7 +161,7 @@ fn can_elide_generic_arg<'tcx>( |
| 161 | 161 | default: ty::Binder<'tcx, ty::GenericArg<'tcx>>, |
| 162 | 162 | ) -> bool { |
| 163 | 163 | debug_assert_matches!( |
| 164 | (actual.skip_binder().unpack(), default.skip_binder().unpack()), | |
| 164 | (actual.skip_binder().kind(), default.skip_binder().kind()), | |
| 165 | 165 | (ty::GenericArgKind::Lifetime(_), ty::GenericArgKind::Lifetime(_)) |
| 166 | 166 | | (ty::GenericArgKind::Type(_), ty::GenericArgKind::Type(_)) |
| 167 | 167 | | (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 { |
| 50 | 50 | && let arg_ty = cx.typeck_results().expr_ty(arg) |
| 51 | 51 | // make sure that the type is not and does not contain any type parameters |
| 52 | 52 | && 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(_))) | |
| 54 | 54 | }) |
| 55 | 55 | && let Some(send) = cx.tcx.get_diagnostic_item(sym::Send) |
| 56 | 56 | && 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 |
| 345 | 345 | if ty_adt.repr().packed() |
| 346 | 346 | && ty_subs |
| 347 | 347 | .iter() |
| 348 | .any(|arg| matches!(arg.unpack(), GenericArgKind::Type(_) | GenericArgKind::Const(_))) | |
| 348 | .any(|arg| matches!(arg.kind(), GenericArgKind::Type(_) | GenericArgKind::Const(_))) | |
| 349 | 349 | { |
| 350 | 350 | return; |
| 351 | 351 | } |
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<' |
| 306 | 306 | return true; |
| 307 | 307 | } |
| 308 | 308 | 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()) { | |
| 310 | 310 | (GenericArgKind::Lifetime(from_region), GenericArgKind::Lifetime(to_region)) => { |
| 311 | 311 | if check_region(from_region, to_region) { |
| 312 | 312 | return true; |
| ... | ... | @@ -354,5 +354,5 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<' |
| 354 | 354 | |
| 355 | 355 | fn ty_has_static(ty: Ty<'_>) -> bool { |
| 356 | 356 | 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())) | |
| 358 | 358 | } |
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 |
| 17 | 17 | && is_type_diagnostic_item(cx, *opt_ty, sym::Option) |
| 18 | 18 | && let ty::Adt(_, opt_gen_args) = opt_ty.kind() |
| 19 | 19 | && 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() | |
| 21 | 21 | && !gen_ty.is_ref() |
| 22 | 22 | // Need to gen the original spans, so first parsing mid, and hir parsing afterward |
| 23 | 23 | && 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 { |
| 137 | 137 | && !local.span.in_external_macro(cx.tcx.sess.source_map()) |
| 138 | 138 | { |
| 139 | 139 | 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() { | |
| 141 | 141 | GenericArgKind::Type(inner_ty) => inner_ty |
| 142 | 142 | .ty_adt_def() |
| 143 | 143 | .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( |
| 109 | 109 | && implements_trait(cx, expr_type, default_trait_id, &[]) |
| 110 | 110 | // We check if the initial condition implements Default. |
| 111 | 111 | && 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() | |
| 113 | 113 | && implements_trait(cx, condition_ty, default_trait_id, &[]) |
| 114 | 114 | && is_default_equivalent(cx, peel_blocks(body_none)) |
| 115 | 115 | { |
src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs+1-1| ... | ... | @@ -108,7 +108,7 @@ fn find_match_true<'tcx>( |
| 108 | 108 | fn try_get_generic_ty(ty: Ty<'_>, index: usize) -> Option<Ty<'_>> { |
| 109 | 109 | if let ty::Adt(_, subs) = ty.kind() |
| 110 | 110 | && let Some(sub) = subs.get(index) |
| 111 | && let GenericArgKind::Type(sub_ty) = sub.unpack() | |
| 111 | && let GenericArgKind::Type(sub_ty) = sub.kind() | |
| 112 | 112 | { |
| 113 | 113 | Some(sub_ty) |
| 114 | 114 | } 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> { |
| 208 | 208 | // (to avoid false positive on `Ref<'a, MutexGuard<Foo>>`) |
| 209 | 209 | || (args |
| 210 | 210 | .iter() |
| 211 | .all(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_))) | |
| 211 | .all(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_))) | |
| 212 | 212 | // some generic parameter has significant drop |
| 213 | 213 | // (to avoid false negative on `Box<MutexGuard<Foo>>`) |
| 214 | 214 | && args |
| 215 | 215 | .iter() |
| 216 | .filter_map(|arg| match arg.unpack() { | |
| 216 | .filter_map(|arg| match arg.kind() { | |
| 217 | 217 | GenericArgKind::Type(ty) => Some(ty), |
| 218 | 218 | _ => None, |
| 219 | 219 | }) |
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 { |
| 508 | 508 | match ty.kind() { |
| 509 | 509 | ty::Adt(_, generics) => { |
| 510 | 510 | for generic in *generics { |
| 511 | if let GenericArgKind::Type(ty) = generic.unpack() { | |
| 511 | if let GenericArgKind::Type(ty) = generic.kind() { | |
| 512 | 512 | get_captured_ids_recursive(cx, ty, set); |
| 513 | 513 | } |
| 514 | 514 | } |
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 |
| 188 | 188 | |
| 189 | 189 | fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { |
| 190 | 190 | 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(_))) | |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | pub(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< |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | fn 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(_))) | |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /// Returns true if the named method is `Iterator::cloned` or `Iterator::copied`. |
| ... | ... | @@ -643,7 +643,7 @@ fn is_to_string_on_string_like<'a>( |
| 643 | 643 | |
| 644 | 644 | if let Some(args) = cx.typeck_results().node_args_opt(call_expr.hir_id) |
| 645 | 645 | && let [generic_arg] = args.as_slice() |
| 646 | && let GenericArgKind::Type(ty) = generic_arg.unpack() | |
| 646 | && let GenericArgKind::Type(ty) = generic_arg.kind() | |
| 647 | 647 | && let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref) |
| 648 | 648 | && let Some(as_ref_trait_id) = cx.tcx.get_diagnostic_item(sym::AsRef) |
| 649 | 649 | && (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>( |
| 269 | 269 | .tcx |
| 270 | 270 | .is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id) |
| 271 | 271 | && 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() | |
| 273 | 273 | && ty.is_array() |
| 274 | 274 | && !msrv.meets(cx, msrvs::ARRAY_INTO_ITERATOR) |
| 275 | 275 | { |
src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs+3-3| ... | ... | @@ -172,7 +172,7 @@ impl NonSendField<'_> { |
| 172 | 172 | /// Example: `MyStruct<P, Box<Q, R>>` => `vec![P, Q, R]` |
| 173 | 173 | fn collect_generic_params(ty: Ty<'_>) -> Vec<Ty<'_>> { |
| 174 | 174 | ty.walk() |
| 175 | .filter_map(|inner| match inner.unpack() { | |
| 175 | .filter_map(|inner| match inner.kind() { | |
| 176 | 176 | GenericArgKind::Type(inner_ty) => Some(inner_ty), |
| 177 | 177 | _ => None, |
| 178 | 178 | }) |
| ... | ... | @@ -208,7 +208,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t |
| 208 | 208 | ty::Adt(_, args) => { |
| 209 | 209 | if contains_pointer_like(cx, ty) { |
| 210 | 210 | // 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() { | |
| 212 | 212 | GenericArgKind::Type(ty) => ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait), |
| 213 | 213 | // Lifetimes and const generics are not solid part of ADT and ignored |
| 214 | 214 | GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => true, |
| ... | ... | @@ -226,7 +226,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t |
| 226 | 226 | /// Checks if the type contains any pointer-like types in args (including nested ones) |
| 227 | 227 | fn contains_pointer_like<'tcx>(cx: &LateContext<'tcx>, target_ty: Ty<'tcx>) -> bool { |
| 228 | 228 | 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() { | |
| 230 | 230 | match inner_ty.kind() { |
| 231 | 231 | ty::RawPtr(_, _) => { |
| 232 | 232 | 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 { |
| 385 | 385 | fn has_matching_args(kind: FnKind, args: GenericArgsRef<'_>) -> bool { |
| 386 | 386 | match kind { |
| 387 | 387 | 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() { | |
| 389 | 389 | GenericArgKind::Lifetime(_) => true, |
| 390 | 390 | GenericArgKind::Type(ty) => matches!(*ty.kind(), ty::Param(ty) if ty.index as usize == idx), |
| 391 | 391 | 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>) |
| 487 | 487 | .skip_binder() |
| 488 | 488 | .output() |
| 489 | 489 | .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())) | |
| 491 | 491 | { |
| 492 | 492 | ControlFlow::Break(()) |
| 493 | 493 | } 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> { |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | for generic_arg in *b { |
| 187 | if let GenericArgKind::Type(ty) = generic_arg.unpack() | |
| 187 | if let GenericArgKind::Type(ty) = generic_arg.kind() | |
| 188 | 188 | && self.has_sig_drop_attr(ty, depth) |
| 189 | 189 | { |
| 190 | 190 | 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 { |
| 319 | 319 | args_a |
| 320 | 320 | .iter() |
| 321 | 321 | .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()) { | |
| 323 | 323 | // TODO: Handle inferred lifetimes |
| 324 | 324 | (GenericArgKind::Lifetime(inner_a), GenericArgKind::Lifetime(inner_b)) => inner_a == inner_b, |
| 325 | 325 | (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 { |
| 337 | 337 | &Adt(_, args) => !args |
| 338 | 338 | .iter() |
| 339 | 339 | // TODO: Handle inferred lifetimes |
| 340 | .any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(..))), | |
| 340 | .any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(..))), | |
| 341 | 341 | _ => true, |
| 342 | 342 | } |
| 343 | 343 | } |
src/tools/clippy/clippy_lints_internal/src/msrv_attr_impl.rs+1-1| ... | ... | @@ -37,7 +37,7 @@ impl LateLintPass<'_> for MsrvAttrImpl { |
| 37 | 37 | .type_of(f.did) |
| 38 | 38 | .instantiate_identity() |
| 39 | 39 | .walk() |
| 40 | .filter(|t| matches!(t.unpack(), GenericArgKind::Type(_))) | |
| 40 | .filter(|t| matches!(t.kind(), GenericArgKind::Type(_))) | |
| 41 | 41 | .any(|t| internal_paths::MSRV_STACK.matches_ty(cx, t.expect_ty())) |
| 42 | 42 | }) |
| 43 | 43 | && !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 |
| 3316 | 3316 | if temporary_ty.has_significant_drop(cx.tcx, cx.typing_env()) |
| 3317 | 3317 | && temporary_ty |
| 3318 | 3318 | .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())) | |
| 3320 | 3320 | { |
| 3321 | 3321 | ControlFlow::Break(()) |
| 3322 | 3322 | } 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 |
| 55 | 55 | |
| 56 | 56 | fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, msrv: Msrv) -> McfResult { |
| 57 | 57 | for arg in ty.walk() { |
| 58 | let ty = match arg.unpack() { | |
| 58 | let ty = match arg.kind() { | |
| 59 | 59 | GenericArgKind::Type(ty) => ty, |
| 60 | 60 | |
| 61 | 61 | // 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 |
| 78 | 78 | /// Walks into `ty` and returns `true` if any inner type is an instance of the given adt |
| 79 | 79 | /// constructor. |
| 80 | 80 | pub 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() { | |
| 82 | 82 | GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt), |
| 83 | 83 | GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false, |
| 84 | 84 | }) |
| ... | ... | @@ -96,7 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<' |
| 96 | 96 | needle: Ty<'tcx>, |
| 97 | 97 | seen: &mut FxHashSet<DefId>, |
| 98 | 98 | ) -> bool { |
| 99 | ty.walk().any(|inner| match inner.unpack() { | |
| 99 | ty.walk().any(|inner| match inner.kind() { | |
| 100 | 100 | GenericArgKind::Type(inner_ty) => { |
| 101 | 101 | if inner_ty == needle { |
| 102 | 102 | return true; |
| ... | ... | @@ -129,7 +129,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<' |
| 129 | 129 | // For `impl Trait<Assoc=U>`, it will register a predicate of `<T as Trait>::Assoc = U`, |
| 130 | 130 | // so we check the term for `U`. |
| 131 | 131 | 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() | |
| 133 | 133 | && contains_ty_adt_constructor_opaque_inner(cx, ty, needle, seen) |
| 134 | 134 | { |
| 135 | 135 | return true; |
| ... | ... | @@ -526,7 +526,7 @@ pub fn same_type_and_consts<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool { |
| 526 | 526 | args_a |
| 527 | 527 | .iter() |
| 528 | 528 | .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()) { | |
| 530 | 530 | (GenericArgKind::Const(inner_a), GenericArgKind::Const(inner_b)) => inner_a == inner_b, |
| 531 | 531 | (GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => { |
| 532 | 532 | 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 |
| 996 | 996 | if let Some((idx, (param, arg))) = |
| 997 | 997 | params |
| 998 | 998 | .clone() |
| 999 | .zip(args.iter().map(|&x| x.unpack())) | |
| 999 | .zip(args.iter().map(|&x| x.kind())) | |
| 1000 | 1000 | .enumerate() |
| 1001 | 1001 | .find(|(_, (param, arg))| match (param, arg) { |
| 1002 | 1002 | (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> { |
| 326 | 326 | |
| 327 | 327 | fn contains_param(ty: Ty<'_>, index: u32) -> bool { |
| 328 | 328 | 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))) | |
| 330 | 330 | } |
src/tools/miri/src/machine.rs+1-1| ... | ... | @@ -1775,7 +1775,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> { |
| 1775 | 1775 | let is_generic = instance |
| 1776 | 1776 | .args |
| 1777 | 1777 | .into_iter() |
| 1778 | .any(|kind| !matches!(kind.unpack(), ty::GenericArgKind::Lifetime(_))); | |
| 1778 | .any(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_))); | |
| 1779 | 1779 | let can_be_inlined = matches!( |
| 1780 | 1780 | ecx.tcx.sess.opts.unstable_opts.cross_crate_inline_threshold, |
| 1781 | 1781 | InliningThreshold::Always |
src/tools/tidy/Cargo.toml+1-1| ... | ... | @@ -15,7 +15,7 @@ semver = "1.0" |
| 15 | 15 | serde = { version = "1.0.125", features = ["derive"], optional = true } |
| 16 | 16 | termcolor = "1.1.3" |
| 17 | 17 | rustc-hash = "2.0.0" |
| 18 | fluent-syntax = "0.11.1" | |
| 18 | fluent-syntax = "0.12" | |
| 19 | 19 | similar = "2.5.0" |
| 20 | 20 | toml = "0.7.8" |
| 21 | 21 |
tests/codegen/option-niche-eq.rs+11| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | //@ revisions: REGULAR LLVM21 | |
| 1 | 2 | //@ min-llvm-version: 20 |
| 2 | 3 | //@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled |
| 4 | //@ [LLVM21] min-llvm-version: 21 | |
| 3 | 5 | #![crate_type = "lib"] |
| 4 | 6 | |
| 5 | 7 | extern crate core; |
| ... | ... | @@ -74,3 +76,12 @@ pub fn niche_eq(l: Option<EnumWithNiche>, r: Option<EnumWithNiche>) -> bool { |
| 74 | 76 | // CHECK-NEXT: ret i1 |
| 75 | 77 | l == r |
| 76 | 78 | } |
| 79 | ||
| 80 | // LLVM21-LABEL: @bool_eq | |
| 81 | #[no_mangle] | |
| 82 | pub 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] | |
| 10 | pub 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 |
| 37 | 37 | Highest counter ID seen: c0 |
| 38 | 38 | |
| 39 | 39 | Function name: async_closure::main::{closure#0} |
| 40 | Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] | |
| 40 | Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] | |
| 41 | 41 | Number of files: 1 |
| 42 | 42 | - file 0 => $DIR/async_closure.rs |
| 43 | 43 | Number of expressions: 0 |
| 44 | Number of file 0 mappings: 1 | |
| 45 | - Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) | |
| 44 | Number 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) | |
| 46 | 47 | Highest counter ID seen: c0 |
| 47 | 48 | |
| 48 | 49 | Function name: async_closure::main::{closure#0} |
| 49 | Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] | |
| 50 | Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] | |
| 50 | 51 | Number of files: 1 |
| 51 | 52 | - file 0 => $DIR/async_closure.rs |
| 52 | 53 | Number of expressions: 0 |
| 53 | Number of file 0 mappings: 1 | |
| 54 | - Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) | |
| 54 | Number 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) | |
| 55 | 57 | Highest counter ID seen: c0 |
| 56 | 58 | |
| 57 | 59 | Function name: async_closure::main::{closure#0}::{closure#0}::<i16> |
| 58 | Raw bytes (9): 0x[01, 01, 00, 01, 01, 0b, 22, 00, 24] | |
| 60 | Raw bytes (14): 0x[01, 01, 00, 02, 01, 0b, 22, 00, 23, 01, 00, 23, 00, 24] | |
| 59 | 61 | Number of files: 1 |
| 60 | 62 | - file 0 => $DIR/async_closure.rs |
| 61 | 63 | Number of expressions: 0 |
| 62 | Number of file 0 mappings: 1 | |
| 63 | - Code(Counter(0)) at (prev + 11, 34) to (start + 0, 36) | |
| 64 | Number 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) | |
| 64 | 67 | Highest counter ID seen: c0 |
| 65 | 68 |
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 | |
| 18 | extern crate discard_all_helper; | |
| 19 | ||
| 20 | fn main() { | |
| 21 | discard_all_helper::external_function(); | |
| 22 | } |
tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff+1-1| ... | ... | @@ -40,7 +40,7 @@ |
| 40 | 40 | + coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:17: 19:18 (#0); |
| 41 | 41 | + coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:23: 19:30 (#0); |
| 42 | 42 | + 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); | |
| 44 | 44 | + |
| 45 | 45 | bb0: { |
| 46 | 46 | + Coverage::VirtualCounter(bcb0); |
tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | |
| 7 | 7 | + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:27:1: 27:17 (#0); |
| 8 | 8 | + 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); | |
| 10 | 10 | + |
| 11 | 11 | bb0: { |
| 12 | 12 | + Coverage::VirtualCounter(bcb0); |
tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff+2-2| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:13:1: 13:10 (#0); |
| 11 | 11 | + coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:15:12: 15:15 (#0); |
| 12 | 12 | + 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); | |
| 15 | 15 | + |
| 16 | 16 | bb0: { |
| 17 | 17 | + Coverage::VirtualCounter(bcb0); |
tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff+2-2| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 13:10 (#0); |
| 11 | 11 | coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); |
| 12 | 12 | 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); | |
| 15 | 15 | coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); |
| 16 | 16 | |
| 17 | 17 | bb0: { |
tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff+2-2| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 13:10 (#0); |
| 11 | 11 | + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); |
| 12 | 12 | + 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); | |
| 15 | 15 | + coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); |
| 16 | 16 | + |
| 17 | 17 | bb0: { |
tests/run-make/version-check/rmake.rs created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | use run_make_support::bare_rustc; | |
| 2 | ||
| 3 | fn 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 | |
| 5 | use std::process::Command; | |
| 6 | ||
| 7 | fn 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 = [ |
| 593 | 593 | "src/doc/rustc-dev-guide", |
| 594 | 594 | ] |
| 595 | 595 | |
| 596 | [autolabel."A-LLVM"] | |
| 597 | trigger_files = [ | |
| 598 | "src/llvm-project", | |
| 599 | "compiler/rustc_llvm", | |
| 600 | "compiler/rustc_codegen_llvm", | |
| 601 | ] | |
| 602 | ||
| 596 | 603 | [notify-zulip."I-prioritize"] |
| 597 | 604 | zulip_stream = 245100 # #t-compiler/prioritization/alerts |
| 598 | 605 | topic = "#{number} {title}" |