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

Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#141312 (Add From<TryLockError> for io::Error)
 - rust-lang/rust#141495 (Rename `{GenericArg,Term}::unpack()` to `kind()`)
 - rust-lang/rust#141602 (triagebot: label LLVM submodule changes with `A-LLVM`)
 - rust-lang/rust#141632 (remove `visit_mt` from `ast::mut_visit`)
 - rust-lang/rust#141640 (test: convert version_check ui test to run-make)
 - rust-lang/rust#141645 (bump fluent-* crates)
 - rust-lang/rust#141650 (coverage: Revert "unused local file IDs" due to empty function names)
 - rust-lang/rust#141654 (tests: mark option-niche-eq as fixed on LLVM 21)

Failed merges:

 - rust-lang/rust#141430 (remove `visit_clobber` and move `DummyAstNode` to `rustc_expand`)
 - rust-lang/rust#141636 (avoid some usages of `&mut P<T>` in AST visitors)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-05-27 18:59:47 +00:00
commit 45f256d9d7
112 changed files with 336 additions and 413 deletions

View file

@ -1259,16 +1259,16 @@ dependencies = [
[[package]]
name = "fluent-bundle"
version = "0.15.3"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe0a21ee80050c678013f82edf4b705fe2f26f1f9877593d13198612503f493"
checksum = "01203cb8918f5711e73891b347816d932046f95f54207710bda99beaeb423bf4"
dependencies = [
"fluent-langneg",
"fluent-syntax",
"intl-memoizer",
"intl_pluralrules",
"rustc-hash 1.1.0",
"self_cell 0.10.3",
"rustc-hash 2.1.1",
"self_cell",
"smallvec",
"unic-langid",
]
@ -1284,11 +1284,12 @@ dependencies = [
[[package]]
name = "fluent-syntax"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a530c4694a6a8d528794ee9bbd8ba0122e779629ac908d15ad5a7ae7763a33d"
checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198"
dependencies = [
"thiserror 1.0.69",
"memchr",
"thiserror 2.0.12",
]
[[package]]
@ -1934,9 +1935,9 @@ dependencies = [
[[package]]
name = "intl-memoizer"
version = "0.5.2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe22e020fce238ae18a6d5d8c502ee76a52a6e880d99477657e6acc30ec57bda"
checksum = "310da2e345f5eb861e7a07ee182262e94975051db9e4223e909ba90f392f163f"
dependencies = [
"type-map",
"unic-langid",
@ -4832,15 +4833,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "self_cell"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e14e4d63b804dc0c7ec4a1e52bcb63f02c7ac94476755aa579edac21e01f915d"
dependencies = [
"self_cell 1.2.0",
]
[[package]]
name = "self_cell"
version = "1.2.0"

View file

@ -300,10 +300,6 @@ pub trait MutVisitor: Sized {
walk_precise_capturing_arg(self, arg);
}
fn visit_mt(&mut self, mt: &mut MutTy) {
walk_mt(self, mt);
}
fn visit_expr_field(&mut self, f: &mut ExprField) {
walk_expr_field(self, f);
}
@ -519,10 +515,10 @@ pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) {
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Dummy | TyKind::Never | TyKind::CVarArgs => {
}
TyKind::Slice(ty) => vis.visit_ty(ty),
TyKind::Ptr(mt) => vis.visit_mt(mt),
TyKind::Ref(lt, mt) | TyKind::PinnedRef(lt, mt) => {
TyKind::Ptr(MutTy { ty, mutbl: _ }) => vis.visit_ty(ty),
TyKind::Ref(lt, MutTy { ty, mutbl: _ }) | TyKind::PinnedRef(lt, MutTy { ty, mutbl: _ }) => {
visit_opt(lt, |lt| vis.visit_lifetime(lt));
vis.visit_mt(mt);
vis.visit_ty(ty);
}
TyKind::BareFn(bft) => {
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>(
smallvec![f]
}
fn walk_mt<T: MutVisitor>(vis: &mut T, MutTy { ty, mutbl: _ }: &mut MutTy) {
vis.visit_ty(ty);
}
pub fn walk_block<T: MutVisitor>(vis: &mut T, block: &mut P<Block>) {
let Block { id, stmts, rules: _, span, tokens: _ } = block.deref_mut();
vis.visit_id(id);

View file

@ -606,8 +606,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
hir_args: &'hir hir::GenericArgs<'hir>,
search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty<'hir>)>,
) -> Option<&'hir hir::Lifetime> {
for (kind, hir_arg) in iter::zip(args, hir_args.args) {
match (kind.unpack(), hir_arg) {
for (arg, hir_arg) in iter::zip(args, hir_args.args) {
match (arg.kind(), hir_arg) {
(GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => {
if r.as_var() == needle_fr {
return Some(lt);
@ -631,7 +631,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
) => {
self.dcx().span_delayed_bug(
hir_arg.span(),
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
format!("unmatched arg and hir arg: found {arg:?} vs {hir_arg:?}"),
);
}
}
@ -997,7 +997,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
) -> bool {
let tcx = self.infcx.tcx;
ty.walk().any(|arg| {
if let ty::GenericArgKind::Type(ty) = arg.unpack()
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Param(_) = ty.kind()
{
clauses.iter().any(|pred| {

View file

@ -148,7 +148,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
let mut next_outlives_predicates = vec![];
for (ty::OutlivesPredicate(k1, r2), constraint_category) in outlives_predicates {
match k1.unpack() {
match k1.kind() {
GenericArgKind::Lifetime(r1) => {
let r1_vid = self.to_region_vid(r1);
let r2_vid = self.to_region_vid(r2);

View file

@ -221,7 +221,7 @@ fn register_member_constraints<'tcx>(
.iter()
.enumerate()
.filter(|(i, _)| variances[*i] == ty::Invariant)
.filter_map(|(_, arg)| match arg.unpack() {
.filter_map(|(_, arg)| match arg.kind() {
GenericArgKind::Lifetime(r) => Some(typeck.to_region_vid(r)),
GenericArgKind::Type(_) | GenericArgKind::Const(_) => None,
})

View file

@ -155,20 +155,6 @@ pub(crate) struct Regions {
impl Regions {
/// Returns true if none of this structure's tables contain any regions.
pub(crate) fn has_no_regions(&self) -> bool {
// Every region has a span, so if there are no spans then there are no regions.
self.all_cov_spans().next().is_none()
}
pub(crate) fn all_cov_spans(&self) -> impl Iterator<Item = &CoverageSpan> {
macro_rules! iter_cov_spans {
( $( $regions:expr ),* $(,)? ) => {
std::iter::empty()
$(
.chain( $regions.iter().map(|region| &region.cov_span) )
)*
}
}
let Self {
code_regions,
expansion_regions,
@ -177,13 +163,11 @@ impl Regions {
mcdc_decision_regions,
} = self;
iter_cov_spans!(
code_regions,
expansion_regions,
branch_regions,
mcdc_branch_regions,
mcdc_decision_regions,
)
code_regions.is_empty()
&& expansion_regions.is_empty()
&& branch_regions.is_empty()
&& mcdc_branch_regions.is_empty()
&& mcdc_decision_regions.is_empty()
}
}

View file

@ -11,7 +11,6 @@ use rustc_abi::Align;
use rustc_codegen_ssa::traits::{
BaseTypeCodegenMethods as _, ConstCodegenMethods, StaticCodegenMethods,
};
use rustc_index::IndexVec;
use rustc_middle::mir::coverage::{
BasicCoverageBlock, CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping,
MappingKind, Op,
@ -105,16 +104,6 @@ fn fill_region_tables<'tcx>(
ids_info: &'tcx CoverageIdsInfo,
covfun: &mut CovfunRecord<'tcx>,
) {
// If this function is unused, replace all counters with zero.
let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter {
let term = if covfun.is_used {
ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term")
} else {
CovTerm::Zero
};
ffi::Counter::from_term(term)
};
// Currently a function's mappings must all be in the same file, so use the
// first mapping's span to determine the file.
let source_map = tcx.sess.source_map();
@ -126,12 +115,6 @@ fn fill_region_tables<'tcx>(
let local_file_id = covfun.virtual_file_mapping.push_file(&source_file);
// If this testing flag is set, add an extra unused entry to the local
// file table, to help test the code for detecting unused file IDs.
if tcx.sess.coverage_inject_unused_local_file() {
covfun.virtual_file_mapping.push_file(&source_file);
}
// In rare cases, _all_ of a function's spans are discarded, and coverage
// codegen needs to handle that gracefully to avoid #133606.
// It's hard for tests to trigger this organically, so instead we set
@ -152,6 +135,16 @@ fn fill_region_tables<'tcx>(
// For each counter/region pair in this function+file, convert it to a
// form suitable for FFI.
for &Mapping { ref kind, span } in &fn_cov_info.mappings {
// If this function is unused, replace all counters with zero.
let counter_for_bcb = |bcb: BasicCoverageBlock| -> ffi::Counter {
let term = if covfun.is_used {
ids_info.term_for_bcb[bcb].expect("every BCB in a mapping was given a term")
} else {
CovTerm::Zero
};
ffi::Counter::from_term(term)
};
let Some(coords) = make_coords(span) else { continue };
let cov_span = coords.make_coverage_span(local_file_id);
@ -184,19 +177,6 @@ fn fill_region_tables<'tcx>(
}
}
/// LLVM requires all local file IDs to have at least one mapping region.
/// If that's not the case, skip this function, to avoid an assertion failure
/// (or worse) in LLVM.
fn check_local_file_table(covfun: &CovfunRecord<'_>) -> bool {
let mut local_file_id_seen =
IndexVec::<u32, _>::from_elem_n(false, covfun.virtual_file_mapping.local_file_table.len());
for cov_span in covfun.regions.all_cov_spans() {
local_file_id_seen[cov_span.file_id] = true;
}
local_file_id_seen.into_iter().all(|seen| seen)
}
/// Generates the contents of the covfun record for this function, which
/// contains the function's coverage mapping data. The record is then stored
/// as a global variable in the `__llvm_covfun` section.
@ -205,10 +185,6 @@ pub(crate) fn generate_covfun_record<'tcx>(
global_file_table: &GlobalFileTable,
covfun: &CovfunRecord<'tcx>,
) {
if !check_local_file_table(covfun) {
return;
}
let &CovfunRecord {
mangled_function_name,
source_hash,

View file

@ -39,10 +39,7 @@ impl Coords {
/// or other expansions), and if it does happen then skipping a span or function is
/// better than an ICE or `llvm-cov` failure that the user might have no way to avoid.
pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span) -> Option<Coords> {
if span.is_empty() {
debug_assert!(false, "can't make coords from empty span: {span:?}");
return None;
}
let span = ensure_non_empty_span(source_map, span)?;
let lo = span.lo();
let hi = span.hi();
@ -73,6 +70,29 @@ pub(crate) fn make_coords(source_map: &SourceMap, file: &SourceFile, span: Span)
})
}
fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
if !span.is_empty() {
return Some(span);
}
// The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
source_map
.span_to_source(span, |src, start, end| try {
// Adjusting span endpoints by `BytePos(1)` is normally a bug,
// but in this case we have specifically checked that the character
// we're skipping over is one of two specific ASCII characters, so
// adjusting by exactly 1 byte is correct.
if src.as_bytes().get(end).copied() == Some(b'{') {
Some(span.with_hi(span.hi() + BytePos(1)))
} else if start > 0 && src.as_bytes()[start - 1] == b'}' {
Some(span.with_lo(span.lo() - BytePos(1)))
} else {
None
}
})
.ok()?
}
/// If `llvm-cov` sees a source region that is improperly ordered (end < start),
/// it will immediately exit with a fatal error. To prevent that from happening,
/// discard regions that are improperly ordered, or might be interpreted in a

View file

@ -77,7 +77,7 @@ fn dyn_trait_in_self<'tcx>(
ty: Ty<'tcx>,
) -> Option<ty::ExistentialTraitRef<'tcx>> {
for arg in ty.peel_refs().walk() {
if let GenericArgKind::Type(ty) = arg.unpack()
if let GenericArgKind::Type(ty) = arg.kind()
&& let ty::Dynamic(data, _, _) = ty.kind()
{
// FIXME(arbitrary_self_types): This is likely broken for receivers which

View file

@ -281,7 +281,7 @@ fn build_error_for_const_call<'tcx>(
let mut sugg = None;
if ccx.tcx.is_lang_item(trait_id, LangItem::PartialEq) {
match (args[0].unpack(), args[1].unpack()) {
match (args[0].kind(), args[1].kind()) {
(GenericArgKind::Type(self_ty), GenericArgKind::Type(rhs_ty))
if self_ty == rhs_ty
&& self_ty.is_ref()

View file

@ -125,7 +125,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
) -> Result<(), PrintError> {
print_prefix(self)?;
let args =
args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)));
if args.clone().next().is_some() {
self.generic_delimiters(|cx| cx.comma_sep(args))
} else {

View file

@ -5,8 +5,8 @@ edition = "2024"
[dependencies]
# tidy-alphabetical-start
fluent-bundle = "0.15.2"
fluent-syntax = "0.11"
fluent-bundle = "0.16"
fluent-syntax = "0.12"
icu_list = "1.2"
icu_locid = "1.2"
icu_provider_adapters = "1.2"

View file

@ -9,8 +9,8 @@ proc-macro = true
[dependencies]
# tidy-alphabetical-start
annotate-snippets = "0.11"
fluent-bundle = "0.15.2"
fluent-syntax = "0.11"
fluent-bundle = "0.16"
fluent-syntax = "0.12"
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }

View file

@ -1575,7 +1575,7 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
let mut params_used = DenseBitSet::new_empty(generics.own_params.len());
for leaf in ty.walk() {
if let GenericArgKind::Type(leaf_ty) = leaf.unpack()
if let GenericArgKind::Type(leaf_ty) = leaf.kind()
&& let ty::Param(param) = leaf_ty.kind()
{
debug!("found use of ty param {:?}", param);
@ -1700,7 +1700,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, opaque_def_id: LocalDefId) -> ErrorG
let mut label_match = |ty: Ty<'_>, span| {
for arg in ty.walk() {
if let ty::GenericArgKind::Type(ty) = arg.unpack()
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Alias(
ty::Opaque,
ty::AliasTy { def_id: captured_def_id, .. },

View file

@ -1231,7 +1231,7 @@ fn check_region_late_boundedness<'tcx>(
for (id_arg, arg) in
std::iter::zip(ty::GenericArgs::identity_for_item(tcx, impl_m.def_id), impl_m_args)
{
if let ty::GenericArgKind::Lifetime(r) = arg.unpack()
if let ty::GenericArgKind::Lifetime(r) = arg.kind()
&& let ty::ReVar(vid) = r.kind()
&& let r = infcx
.inner
@ -1256,7 +1256,7 @@ fn check_region_late_boundedness<'tcx>(
for (id_arg, arg) in
std::iter::zip(ty::GenericArgs::identity_for_item(tcx, trait_m.def_id), trait_m_args)
{
if let ty::GenericArgKind::Lifetime(r) = arg.unpack()
if let ty::GenericArgKind::Lifetime(r) = arg.kind()
&& let ty::ReVar(vid) = r.kind()
&& let r = infcx
.inner

View file

@ -427,7 +427,7 @@ fn report_mismatched_rpitit_captures<'tcx>(
};
trait_captured_args
.sort_by_cached_key(|arg| !matches!(arg.unpack(), ty::GenericArgKind::Lifetime(_)));
.sort_by_cached_key(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_)));
let suggestion = format!("use<{}>", trait_captured_args.iter().join(", "));
tcx.emit_node_span_lint(

View file

@ -819,7 +819,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GATArgsCollector<'tcx> {
match t.kind() {
ty::Alias(ty::Projection, p) if p.def_id == self.gat => {
for (idx, arg) in p.args.iter().enumerate() {
match arg.unpack() {
match arg.kind() {
GenericArgKind::Lifetime(lt) if !lt.is_bound() => {
self.regions.insert((lt, idx));
}
@ -1517,7 +1517,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
} else {
// If we've got a generic const parameter we still want to check its
// type is correct in case both it and the param type are fully concrete.
let GenericArgKind::Const(ct) = default.unpack() else {
let GenericArgKind::Const(ct) = default.kind() else {
continue;
};

View file

@ -151,7 +151,7 @@ fn remap_gat_vars_and_recurse_into_nested_projections<'tcx>(
let mut mapping = FxIndexMap::default();
let generics = tcx.generics_of(assoc_item_def_id);
for (param, var) in std::iter::zip(&generics.own_params, gat_vars) {
let existing = match var.unpack() {
let existing = match var.kind() {
ty::GenericArgKind::Lifetime(re) => {
if let ty::RegionKind::ReBound(ty::INNERMOST, bv) = re.kind() {
mapping.insert(bv.var, tcx.mk_param_from_def(param))

View file

@ -215,7 +215,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let pred = bound_predicate.rebind(pred);
// A `Self` within the original bound will be instantiated with a
// `trait_object_dummy_self`, so check for that.
let references_self = match pred.skip_binder().term.unpack() {
let references_self = match pred.skip_binder().term.kind() {
ty::TermKind::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()),
// FIXME(associated_const_equality): We should walk the const instead of not doing anything
ty::TermKind::Const(_) => false,

View file

@ -611,7 +611,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
if !infer_args && has_default {
// No type parameter provided, but a default exists.
if let Some(prev) =
preceding_args.iter().find_map(|arg| match arg.unpack() {
preceding_args.iter().find_map(|arg| match arg.kind() {
GenericArgKind::Type(ty) => ty.error_reported().err(),
_ => None,
})

View file

@ -119,7 +119,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
explicit_map: &mut ExplicitPredicatesMap<'tcx>,
) {
for arg in ty.walk() {
let leaf_ty = match arg.unpack() {
let leaf_ty = match arg.kind() {
GenericArgKind::Type(ty) => ty,
// No predicates from lifetimes or constants, except potentially
@ -299,7 +299,7 @@ fn check_explicit_predicates<'tcx>(
// binding) and thus infer an outlives requirement that `X:
// 'b`.
if let Some(self_ty) = ignored_self_ty
&& let GenericArgKind::Type(ty) = outlives_predicate.0.unpack()
&& let GenericArgKind::Type(ty) = outlives_predicate.0.kind()
&& ty.walk().any(|arg| arg == self_ty.into())
{
debug!("skipping self ty = {ty:?}");

View file

@ -69,8 +69,8 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
.map(|(&def_id, set)| {
let predicates =
&*tcx.arena.alloc_from_iter(set.as_ref().skip_binder().iter().filter_map(
|(ty::OutlivesPredicate(kind1, region2), &span)| {
match kind1.unpack() {
|(ty::OutlivesPredicate(arg1, region2), &span)| {
match arg1.kind() {
GenericArgKind::Type(ty1) => Some((
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(ty1, *region2))
.upcast(tcx),

View file

@ -14,7 +14,7 @@ pub(crate) type RequiredPredicates<'tcx> =
/// outlives_component and add it to `required_predicates`
pub(crate) fn insert_outlives_predicate<'tcx>(
tcx: TyCtxt<'tcx>,
kind: GenericArg<'tcx>,
arg: GenericArg<'tcx>,
outlived_region: Region<'tcx>,
span: Span,
required_predicates: &mut RequiredPredicates<'tcx>,
@ -25,7 +25,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>(
return;
}
match kind.unpack() {
match arg.kind() {
GenericArgKind::Type(ty) => {
// `T: 'outlived_region` for some type `T`
// But T could be a lot of things:
@ -135,7 +135,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>(
if !is_free_region(r) {
return;
}
required_predicates.entry(ty::OutlivesPredicate(kind, outlived_region)).or_insert(span);
required_predicates.entry(ty::OutlivesPredicate(arg, outlived_region)).or_insert(span);
}
GenericArgKind::Const(_) => {

View file

@ -200,8 +200,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
// Trait are always invariant so we can take advantage of that.
let variance_i = self.invariant(variance);
for k in args {
match k.unpack() {
for arg in args {
match arg.kind() {
GenericArgKind::Lifetime(lt) => {
self.add_constraints_from_region(current, lt, variance_i)
}
@ -294,7 +294,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
}
for projection in data.projection_bounds() {
match projection.skip_binder().term.unpack() {
match projection.skip_binder().term.kind() {
ty::TermKind::Ty(ty) => {
self.add_constraints_from_ty(current, ty, self.invariant);
}
@ -373,7 +373,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
(None, Some(self.tcx().variances_of(def_id)))
};
for (i, k) in args.iter().enumerate() {
for (i, arg) in args.iter().enumerate() {
let variance_decl = if let Some(InferredIndex(start)) = local {
// Parameter on an item defined within current crate:
// variance not yet inferred, so return a symbolic
@ -389,7 +389,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
"add_constraints_from_args: variance_decl={:?} variance_i={:?}",
variance_decl, variance_i
);
match k.unpack() {
match arg.kind() {
GenericArgKind::Lifetime(lt) => {
self.add_constraints_from_region(current, lt, variance_i)
}

View file

@ -80,12 +80,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let find_param_matching = |matches: &dyn Fn(ty::ParamTerm) -> bool| {
predicate_args.iter().find_map(|arg| {
arg.walk().find_map(|arg| {
if let ty::GenericArgKind::Type(ty) = arg.unpack()
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Param(param_ty) = *ty.kind()
&& matches(ty::ParamTerm::Ty(param_ty))
{
Some(arg)
} else if let ty::GenericArgKind::Const(ct) = arg.unpack()
} else if let ty::GenericArgKind::Const(ct) = arg.kind()
&& let ty::ConstKind::Param(param_ct) = ct.kind()
&& matches(ty::ParamTerm::Const(param_ct))
{
@ -357,7 +357,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self,
error: &mut traits::FulfillmentError<'tcx>,
def_id: DefId,
param: ty::GenericArg<'tcx>,
arg: ty::GenericArg<'tcx>,
qpath: &hir::QPath<'tcx>,
) -> bool {
match qpath {
@ -365,7 +365,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for segment in path.segments.iter().rev() {
if let Res::Def(kind, def_id) = segment.res
&& !matches!(kind, DefKind::Mod | DefKind::ForeignMod)
&& self.point_at_generic_if_possible(error, def_id, param, segment)
&& self.point_at_generic_if_possible(error, def_id, arg, segment)
{
return true;
}
@ -373,7 +373,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Handle `Self` param specifically, since it's separated in
// the path representation
if let Some(self_ty) = self_ty
&& let ty::GenericArgKind::Type(ty) = param.unpack()
&& let ty::GenericArgKind::Type(ty) = arg.kind()
&& ty == self.tcx.types.self_param
{
error.obligation.cause.span = self_ty
@ -384,12 +384,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
hir::QPath::TypeRelative(self_ty, segment) => {
if self.point_at_generic_if_possible(error, def_id, param, segment) {
if self.point_at_generic_if_possible(error, def_id, arg, segment) {
return true;
}
// Handle `Self` param specifically, since it's separated in
// the path representation
if let ty::GenericArgKind::Type(ty) = param.unpack()
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& ty == self.tcx.types.self_param
{
error.obligation.cause.span = self_ty
@ -424,10 +424,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// the args list does not, then we should chop off all of the lifetimes,
// since they're all elided.
let segment_args = segment.args().args;
if matches!(own_args[0].unpack(), ty::GenericArgKind::Lifetime(_))
if matches!(own_args[0].kind(), ty::GenericArgKind::Lifetime(_))
&& segment_args.first().is_some_and(|arg| arg.is_ty_or_const())
&& let Some(offset) = own_args.iter().position(|arg| {
matches!(arg.unpack(), ty::GenericArgKind::Type(_) | ty::GenericArgKind::Const(_))
matches!(arg.kind(), ty::GenericArgKind::Type(_) | ty::GenericArgKind::Const(_))
})
&& let Some(new_index) = index.checked_sub(offset)
{
@ -750,7 +750,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return Ok(expr);
}
let ty::GenericArgKind::Type(in_ty) = in_ty.unpack() else {
let ty::GenericArgKind::Type(in_ty) = in_ty.kind() else {
return Err(expr);
};
@ -1045,7 +1045,7 @@ fn find_param_in_ty<'tcx>(
if arg == param_to_point_at {
return true;
}
if let ty::GenericArgKind::Type(ty) = arg.unpack()
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Alias(ty::Projection | ty::Inherent, ..) = ty.kind()
{
// This logic may seem a bit strange, but typically when

View file

@ -2226,7 +2226,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let infer_args = self.tcx.mk_args_from_iter(args.into_iter().map(|arg| {
if !arg.is_suggestable(self.tcx, true) {
has_unsuggestable_args = true;
match arg.unpack() {
match arg.kind() {
GenericArgKind::Lifetime(_) => self
.next_region_var(RegionVariableOrigin::MiscVariable(DUMMY_SP))
.into(),
@ -2843,7 +2843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let [first] = ***args else {
return;
};
let ty::GenericArgKind::Type(ty) = first.unpack() else {
let ty::GenericArgKind::Type(ty) = first.kind() else {
return;
};
let Ok(pick) = self.lookup_probe_for_diagnostic(

View file

@ -347,7 +347,7 @@ impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> {
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
TypeTrace {
cause: cause.clone(),
values: match (a.unpack(), b.unpack()) {
values: match (a.kind(), b.kind()) {
(GenericArgKind::Lifetime(a), GenericArgKind::Lifetime(b)) => {
ValuePairs::Regions(ExpectedFound::new(a, b))
}

View file

@ -61,15 +61,15 @@ where
value
} else {
let delegate = FnMutDelegate {
regions: &mut |br: ty::BoundRegion| match var_values[br.var].unpack() {
regions: &mut |br: ty::BoundRegion| match var_values[br.var].kind() {
GenericArgKind::Lifetime(l) => l,
r => bug!("{:?} is a region but value is {:?}", br, r),
},
types: &mut |bound_ty: ty::BoundTy| match var_values[bound_ty.var].unpack() {
types: &mut |bound_ty: ty::BoundTy| match var_values[bound_ty.var].kind() {
GenericArgKind::Type(ty) => ty,
r => bug!("{:?} is a type but value is {:?}", bound_ty, r),
},
consts: &mut |bound_ct: ty::BoundVar| match var_values[bound_ct].unpack() {
consts: &mut |bound_ct: ty::BoundVar| match var_values[bound_ct].kind() {
GenericArgKind::Const(ct) => ct,
c => bug!("{:?} is a const but value is {:?}", bound_ct, c),
},

View file

@ -245,7 +245,7 @@ impl<'tcx> InferCtxt<'tcx> {
let result_value = query_response.instantiate_projected(self.tcx, &result_args, |v| {
v.var_values[BoundVar::new(index)]
});
match (original_value.unpack(), result_value.unpack()) {
match (original_value.kind(), result_value.kind()) {
(GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
if re1.is_erased() && re2.is_erased() =>
{
@ -402,7 +402,7 @@ impl<'tcx> InferCtxt<'tcx> {
// [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
for (original_value, result_value) in iter::zip(&original_values.var_values, result_values)
{
match result_value.unpack() {
match result_value.kind() {
GenericArgKind::Type(result_value) => {
// e.g., here `result_value` might be `?0` in the example above...
if let ty::Bound(debruijn, b) = *result_value.kind() {
@ -533,7 +533,7 @@ impl<'tcx> InferCtxt<'tcx> {
for (index, value1) in variables1.var_values.iter().enumerate() {
let value2 = variables2(BoundVar::new(index));
match (value1.unpack(), value2.unpack()) {
match (value1.kind(), value2.kind()) {
(GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
obligations.extend(
self.at(cause, param_env)

View file

@ -90,7 +90,7 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
}
fn is_changed_arg(&self, arg: ty::GenericArg<'tcx>) -> bool {
match arg.unpack() {
match arg.kind() {
ty::GenericArgKind::Lifetime(_) => {
// Lifetimes should not change affect trait selection.
false

View file

@ -1372,7 +1372,7 @@ impl<'tcx> TyOrConstInferVar {
/// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
/// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
pub fn maybe_from_generic_arg(arg: GenericArg<'tcx>) -> Option<Self> {
match arg.unpack() {
match arg.kind() {
GenericArgKind::Type(ty) => Self::maybe_from_ty(ty),
GenericArgKind::Const(ct) => Self::maybe_from_const(ct),
GenericArgKind::Lifetime(_) => None,
@ -1383,7 +1383,7 @@ impl<'tcx> TyOrConstInferVar {
/// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
/// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
pub fn maybe_from_term(term: Term<'tcx>) -> Option<Self> {
match term.unpack() {
match term.kind() {
TermKind::Ty(ty) => Self::maybe_from_ty(ty),
TermKind::Const(ct) => Self::maybe_from_const(ct),
}

View file

@ -87,7 +87,7 @@ impl<'tcx> InferCtxt<'tcx> {
ty::OutlivesPredicate(arg, r2): ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>,
cause: &ObligationCause<'tcx>,
) {
match arg.unpack() {
match arg.kind() {
ty::GenericArgKind::Lifetime(r1) => {
self.register_region_outlives_constraint(ty::OutlivesPredicate(r1, r2), cause);
}
@ -503,8 +503,8 @@ where
opt_variances: Option<&[ty::Variance]>,
) {
let constraint = origin.to_constraint_category();
for (index, k) in args.iter().enumerate() {
match k.unpack() {
for (index, arg) in args.iter().enumerate() {
match arg.kind() {
GenericArgKind::Lifetime(lt) => {
let variance = if let Some(variances) = opt_variances {
variances[index]

View file

@ -329,7 +329,7 @@ struct Generalizer<'me, 'tcx> {
impl<'tcx> Generalizer<'_, 'tcx> {
/// Create an error that corresponds to the term kind in `root_term`
fn cyclic_term_error(&self) -> TypeError<'tcx> {
match self.root_term.unpack() {
match self.root_term.kind() {
ty::TermKind::Ty(ty) => TypeError::CyclicTy(ty),
ty::TermKind::Const(ct) => TypeError::CyclicConst(ct),
}

View file

@ -776,8 +776,7 @@ fn test_unstable_options_tracking_hash() {
CoverageOptions {
level: CoverageLevel::Mcdc,
no_mir_spans: true,
discard_all_spans_in_codegen: true,
inject_unused_local_file: true,
discard_all_spans_in_codegen: true
}
);
tracked!(crate_attr, vec!["abc".to_string()]);

View file

@ -461,7 +461,7 @@ fn extract_def_id_from_arg<'tcx>(
generics: &'tcx ty::Generics,
arg: ty::GenericArg<'tcx>,
) -> DefId {
match arg.unpack() {
match arg.kind() {
ty::GenericArgKind::Lifetime(re) => match re.kind() {
ty::ReEarlyParam(ebr) => generics.region_param(ebr, tcx).def_id,
ty::ReBound(

View file

@ -2781,7 +2781,7 @@ impl<'tcx> TyCtxt<'tcx> {
return false;
}
if !matches!(args[0].unpack(), ty::GenericArgKind::Type(_)) {
if !matches!(args[0].kind(), ty::GenericArgKind::Type(_)) {
return false;
}
@ -2803,7 +2803,7 @@ impl<'tcx> TyCtxt<'tcx> {
};
for (param, arg) in std::iter::zip(&generics.own_params, own_args) {
match (&param.kind, arg.unpack()) {
match (&param.kind, arg.kind()) {
(ty::GenericParamDefKind::Type { .. }, ty::GenericArgKind::Type(_))
| (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Lifetime(_))
| (ty::GenericParamDefKind::Const { .. }, ty::GenericArgKind::Const(_)) => {}

View file

@ -137,7 +137,7 @@ impl<'tcx> rustc_type_ir::inherent::IntoKind for GenericArg<'tcx> {
type Kind = GenericArgKind<'tcx>;
fn kind(self) -> Self::Kind {
self.unpack()
self.kind()
}
}
@ -218,7 +218,7 @@ impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> {
impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> {
fn from(value: ty::Term<'tcx>) -> Self {
match value.unpack() {
match value.kind() {
ty::TermKind::Ty(t) => t.into(),
ty::TermKind::Const(c) => c.into(),
}
@ -227,7 +227,7 @@ impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> {
impl<'tcx> GenericArg<'tcx> {
#[inline]
pub fn unpack(self) -> GenericArgKind<'tcx> {
pub fn kind(self) -> GenericArgKind<'tcx> {
let ptr =
unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
// SAFETY: use of `Interned::new_unchecked` here is ok because these
@ -251,7 +251,7 @@ impl<'tcx> GenericArg<'tcx> {
#[inline]
pub fn as_region(self) -> Option<ty::Region<'tcx>> {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(re) => Some(re),
_ => None,
}
@ -259,7 +259,7 @@ impl<'tcx> GenericArg<'tcx> {
#[inline]
pub fn as_type(self) -> Option<Ty<'tcx>> {
match self.unpack() {
match self.kind() {
GenericArgKind::Type(ty) => Some(ty),
_ => None,
}
@ -267,7 +267,7 @@ impl<'tcx> GenericArg<'tcx> {
#[inline]
pub fn as_const(self) -> Option<ty::Const<'tcx>> {
match self.unpack() {
match self.kind() {
GenericArgKind::Const(ct) => Some(ct),
_ => None,
}
@ -275,7 +275,7 @@ impl<'tcx> GenericArg<'tcx> {
#[inline]
pub fn as_term(self) -> Option<ty::Term<'tcx>> {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(_) => None,
GenericArgKind::Type(ty) => Some(ty.into()),
GenericArgKind::Const(ct) => Some(ct.into()),
@ -300,7 +300,7 @@ impl<'tcx> GenericArg<'tcx> {
}
pub fn is_non_region_infer(self) -> bool {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(_) => false,
// FIXME: This shouldn't return numerical/float.
GenericArgKind::Type(ty) => ty.is_ty_or_numeric_infer(),
@ -327,7 +327,7 @@ impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> {
type Lifted = GenericArg<'tcx>;
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()),
GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()),
GenericArgKind::Const(ct) => tcx.lift(ct).map(|ct| ct.into()),
@ -340,7 +340,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
self,
folder: &mut F,
) -> Result<Self, F::Error> {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into),
GenericArgKind::Type(ty) => ty.try_fold_with(folder).map(Into::into),
GenericArgKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
@ -348,7 +348,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
}
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(lt) => lt.fold_with(folder).into(),
GenericArgKind::Type(ty) => ty.fold_with(folder).into(),
GenericArgKind::Const(ct) => ct.fold_with(folder).into(),
@ -358,7 +358,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> {
fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(lt) => lt.visit_with(visitor),
GenericArgKind::Type(ty) => ty.visit_with(visitor),
GenericArgKind::Const(ct) => ct.visit_with(visitor),
@ -368,7 +368,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> {
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for GenericArg<'tcx> {
fn encode(&self, e: &mut E) {
self.unpack().encode(e)
self.kind().encode(e)
}
}
@ -390,7 +390,7 @@ impl<'tcx> GenericArgs<'tcx> {
///
/// If any of the generic arguments are not types.
pub fn into_type_list(&self, tcx: TyCtxt<'tcx>) -> &'tcx List<Ty<'tcx>> {
tcx.mk_type_list_from_iter(self.iter().map(|arg| match arg.unpack() {
tcx.mk_type_list_from_iter(self.iter().map(|arg| match arg.kind() {
GenericArgKind::Type(ty) => ty,
_ => bug!("`into_type_list` called on generic arg with non-types"),
}))
@ -527,7 +527,7 @@ impl<'tcx> GenericArgs<'tcx> {
/// Returns generic arguments that are not lifetimes.
#[inline]
pub fn non_erasable_generics(&self) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> {
self.iter().filter_map(|k| match k.unpack() {
self.iter().filter_map(|arg| match arg.kind() {
ty::GenericArgKind::Lifetime(_) => None,
generic => Some(generic),
})

View file

@ -60,7 +60,7 @@ where
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::GenericArg<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
self.unpack().hash_stable(hcx, hasher);
self.kind().hash_stable(hcx, hasher);
}
}

View file

@ -504,7 +504,7 @@ impl<'tcx> rustc_type_ir::inherent::IntoKind for Term<'tcx> {
type Kind = TermKind<'tcx>;
fn kind(self) -> Self::Kind {
self.unpack()
self.kind()
}
}
@ -521,7 +521,7 @@ unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync
impl Debug for Term<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.unpack() {
match self.kind() {
TermKind::Ty(ty) => write!(f, "Term::Ty({ty:?})"),
TermKind::Const(ct) => write!(f, "Term::Const({ct:?})"),
}
@ -542,7 +542,7 @@ impl<'tcx> From<Const<'tcx>> for Term<'tcx> {
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Term<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
self.unpack().hash_stable(hcx, hasher);
self.kind().hash_stable(hcx, hasher);
}
}
@ -551,14 +551,14 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
self,
folder: &mut F,
) -> Result<Self, F::Error> {
match self.unpack() {
match self.kind() {
ty::TermKind::Ty(ty) => ty.try_fold_with(folder).map(Into::into),
ty::TermKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
}
}
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
match self.unpack() {
match self.kind() {
ty::TermKind::Ty(ty) => ty.fold_with(folder).into(),
ty::TermKind::Const(ct) => ct.fold_with(folder).into(),
}
@ -567,7 +567,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
match self.unpack() {
match self.kind() {
ty::TermKind::Ty(ty) => ty.visit_with(visitor),
ty::TermKind::Const(ct) => ct.visit_with(visitor),
}
@ -576,7 +576,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Term<'tcx> {
fn encode(&self, e: &mut E) {
self.unpack().encode(e)
self.kind().encode(e)
}
}
@ -589,7 +589,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Term<'tcx> {
impl<'tcx> Term<'tcx> {
#[inline]
pub fn unpack(self) -> TermKind<'tcx> {
pub fn kind(self) -> TermKind<'tcx> {
let ptr =
unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
// SAFETY: use of `Interned::new_unchecked` here is ok because these
@ -609,7 +609,7 @@ impl<'tcx> Term<'tcx> {
}
pub fn as_type(&self) -> Option<Ty<'tcx>> {
if let TermKind::Ty(ty) = self.unpack() { Some(ty) } else { None }
if let TermKind::Ty(ty) = self.kind() { Some(ty) } else { None }
}
pub fn expect_type(&self) -> Ty<'tcx> {
@ -617,7 +617,7 @@ impl<'tcx> Term<'tcx> {
}
pub fn as_const(&self) -> Option<Const<'tcx>> {
if let TermKind::Const(c) = self.unpack() { Some(c) } else { None }
if let TermKind::Const(c) = self.kind() { Some(c) } else { None }
}
pub fn expect_const(&self) -> Const<'tcx> {
@ -625,14 +625,14 @@ impl<'tcx> Term<'tcx> {
}
pub fn into_arg(self) -> GenericArg<'tcx> {
match self.unpack() {
match self.kind() {
TermKind::Ty(ty) => ty.into(),
TermKind::Const(c) => c.into(),
}
}
pub fn to_alias_term(self) -> Option<AliasTerm<'tcx>> {
match self.unpack() {
match self.kind() {
TermKind::Ty(ty) => match *ty.kind() {
ty::Alias(_kind, alias_ty) => Some(alias_ty.into()),
_ => None,
@ -645,7 +645,7 @@ impl<'tcx> Term<'tcx> {
}
pub fn is_infer(&self) -> bool {
match self.unpack() {
match self.kind() {
TermKind::Ty(ty) => ty.is_ty_var(),
TermKind::Const(ct) => ct.is_ct_infer(),
}

View file

@ -120,7 +120,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
}
}
match self.map.get(&r.into()).map(|k| k.unpack()) {
match self.map.get(&r.into()).map(|arg| arg.kind()) {
Some(GenericArgKind::Lifetime(r1)) => r1,
Some(u) => panic!("region mapped to unexpected kind: {u:?}"),
None if self.do_not_error => self.tcx.lifetimes.re_static,
@ -162,7 +162,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
ty::Param(param) => {
// Look it up in the generic parameters list.
match self.map.get(&ty.into()).map(|k| k.unpack()) {
match self.map.get(&ty.into()).map(|arg| arg.kind()) {
// Found it in the generic parameters list; replace with the parameter from the
// opaque type.
Some(GenericArgKind::Type(t1)) => t1,
@ -195,7 +195,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
match ct.kind() {
ty::ConstKind::Param(..) => {
// Look it up in the generic parameters list.
match self.map.get(&ct.into()).map(|k| k.unpack()) {
match self.map.get(&ct.into()).map(|arg| arg.kind()) {
// Found it in the generic parameters list, replace with the parameter from the
// opaque type.
Some(GenericArgKind::Const(c1)) => c1,

View file

@ -1239,7 +1239,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
p!(write("{} = ", tcx.associated_item(assoc_item_def_id).name()));
match term.unpack() {
match term.kind() {
TermKind::Ty(ty) => p!(print(ty)),
TermKind::Const(c) => p!(print(c)),
};
@ -3386,7 +3386,7 @@ define_print_and_forward_display! {
}
ty::Term<'tcx> {
match self.unpack() {
match self.kind() {
ty::TermKind::Ty(ty) => p!(print(ty)),
ty::TermKind::Const(c) => p!(print(c)),
}
@ -3401,7 +3401,7 @@ define_print_and_forward_display! {
}
GenericArg<'tcx> {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(lt) => p!(print(lt)),
GenericArgKind::Type(ty) => p!(print(ty)),
GenericArgKind::Const(ct) => p!(print(ct)),

View file

@ -169,7 +169,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::GenericArg<'tcx> {
a: ty::GenericArg<'tcx>,
b: ty::GenericArg<'tcx>,
) -> RelateResult<'tcx, ty::GenericArg<'tcx>> {
match (a.unpack(), b.unpack()) {
match (a.kind(), b.kind()) {
(ty::GenericArgKind::Lifetime(a_lt), ty::GenericArgKind::Lifetime(b_lt)) => {
Ok(relation.relate(a_lt, b_lt)?.into())
}
@ -190,7 +190,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::Term<'tcx> {
a: Self,
b: Self,
) -> RelateResult<'tcx, Self> {
Ok(match (a.unpack(), b.unpack()) {
Ok(match (a.kind(), b.kind()) {
(ty::TermKind::Ty(a), ty::TermKind::Ty(b)) => relation.relate(a, b)?.into(),
(ty::TermKind::Const(a), ty::TermKind::Const(b)) => relation.relate(a, b)?.into(),
_ => return Err(TypeError::Mismatch),

View file

@ -202,7 +202,7 @@ impl<T: fmt::Debug> fmt::Debug for ty::Placeholder<T> {
impl<'tcx> fmt::Debug for GenericArg<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.unpack() {
match self.kind() {
GenericArgKind::Lifetime(lt) => lt.fmt(f),
GenericArgKind::Type(ty) => ty.fmt(f),
GenericArgKind::Const(ct) => ct.fmt(f),
@ -326,7 +326,7 @@ impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> {
type Lifted = ty::Term<'tcx>;
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
match self.unpack() {
match self.kind() {
TermKind::Ty(ty) => tcx.lift(ty).map(Into::into),
TermKind::Const(c) => tcx.lift(c).map(Into::into),
}

View file

@ -777,8 +777,8 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
return false;
}
iter::zip(user_args.args, BoundVar::ZERO..).all(|(kind, cvar)| {
match kind.unpack() {
iter::zip(user_args.args, BoundVar::ZERO..).all(|(arg, cvar)| {
match arg.kind() {
GenericArgKind::Type(ty) => match ty.kind() {
ty::Bound(debruijn, b) => {
// We only allow a `ty::INNERMOST` index in generic parameters.

View file

@ -516,8 +516,8 @@ impl<'tcx> TyCtxt<'tcx> {
let item_args = ty::GenericArgs::identity_for_item(self, def.did());
let result = iter::zip(item_args, impl_args)
.filter(|&(_, k)| {
match k.unpack() {
.filter(|&(_, arg)| {
match arg.kind() {
GenericArgKind::Lifetime(region) => match region.kind() {
ty::ReEarlyParam(ebr) => {
!impl_generics.region_param(ebr, self).pure_wrt_drop
@ -554,7 +554,7 @@ impl<'tcx> TyCtxt<'tcx> {
let mut seen = GrowableBitSet::default();
let mut seen_late = FxHashSet::default();
for arg in args {
match arg.unpack() {
match arg.kind() {
GenericArgKind::Lifetime(lt) => match (ignore_regions, lt.kind()) {
(CheckRegions::FromFunction, ty::ReBound(di, reg)) => {
if !seen_late.insert((di, reg)) {

View file

@ -131,7 +131,7 @@ impl<'tcx> ConstToPat<'tcx> {
.dcx()
.create_err(ConstPatternDependsOnGenericParameter { span: self.span });
for arg in uv.args {
if let ty::GenericArgKind::Type(ty) = arg.unpack()
if let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Param(param_ty) = ty.kind()
{
let def_id = self.tcx.hir_enclosing_body_owner(self.id);

View file

@ -1,8 +1,7 @@
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir;
use rustc_middle::ty::TyCtxt;
use rustc_span::source_map::SourceMap;
use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span};
use rustc_span::{DesugaringKind, ExpnKind, MacroKind, Span};
use tracing::instrument;
use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph};
@ -84,18 +83,8 @@ pub(super) fn extract_refined_covspans<'tcx>(
// Discard any span that overlaps with a hole.
discard_spans_overlapping_holes(&mut covspans, &holes);
// Discard spans that overlap in unwanted ways.
// Perform more refinement steps after holes have been dealt with.
let mut covspans = remove_unwanted_overlapping_spans(covspans);
// For all empty spans, either enlarge them to be non-empty, or discard them.
let source_map = tcx.sess.source_map();
covspans.retain_mut(|covspan| {
let Some(span) = ensure_non_empty_span(source_map, covspan.span) else { return false };
covspan.span = span;
true
});
// Merge covspans that can be merged.
covspans.dedup_by(|b, a| a.merge_if_eligible(b));
code_mappings.extend(covspans.into_iter().map(|Covspan { span, bcb }| {
@ -241,26 +230,3 @@ fn compare_spans(a: Span, b: Span) -> std::cmp::Ordering {
// - Both have the same start and span A extends further right
.then_with(|| Ord::cmp(&a.hi(), &b.hi()).reverse())
}
fn ensure_non_empty_span(source_map: &SourceMap, span: Span) -> Option<Span> {
if !span.is_empty() {
return Some(span);
}
// The span is empty, so try to enlarge it to cover an adjacent '{' or '}'.
source_map
.span_to_source(span, |src, start, end| try {
// Adjusting span endpoints by `BytePos(1)` is normally a bug,
// but in this case we have specifically checked that the character
// we're skipping over is one of two specific ASCII characters, so
// adjusting by exactly 1 byte is correct.
if src.as_bytes().get(end).copied() == Some(b'{') {
Some(span.with_hi(span.hi() + BytePos(1)))
} else if start > 0 && src.as_bytes()[start - 1] == b'}' {
Some(span.with_lo(span.lo() - BytePos(1)))
} else {
None
}
})
.ok()?
}

View file

@ -817,8 +817,8 @@ where
/// Returns a ty infer or a const infer depending on whether `kind` is a `Ty` or `Const`.
/// If `kind` is an integer inference variable this will still return a ty infer var.
pub(super) fn next_term_infer_of_kind(&mut self, kind: I::Term) -> I::Term {
match kind.kind() {
pub(super) fn next_term_infer_of_kind(&mut self, term: I::Term) -> I::Term {
match term.kind() {
ty::TermKind::Ty(_) => self.next_ty_infer().into(),
ty::TermKind::Const(_) => self.next_const_infer().into(),
}

View file

@ -79,7 +79,7 @@ fn encode_args<'tcx>(
s.push('I');
let def_generics = tcx.generics_of(for_def);
for (n, arg) in args.iter().enumerate() {
match arg.unpack() {
match arg.kind() {
GenericArgKind::Lifetime(region) => {
s.push_str(&encode_region(region, dict));
}
@ -245,7 +245,7 @@ fn encode_predicate<'tcx>(
let name = encode_ty_name(tcx, projection.def_id);
let _ = write!(s, "u{}{}", name.len(), name);
s.push_str(&encode_args(tcx, projection.args, projection.def_id, true, dict, options));
match projection.term.unpack() {
match projection.term.kind() {
TermKind::Ty(ty) => s.push_str(&encode_ty(tcx, ty, dict, options)),
TermKind::Const(c) => s.push_str(&encode_const(
tcx,

View file

@ -195,11 +195,6 @@ pub struct CoverageOptions {
/// regression tests for #133606, because we don't have an easy way to
/// reproduce it from actual source code.
pub discard_all_spans_in_codegen: bool,
/// `-Zcoverage-options=inject-unused-local-file`: During codegen, add an
/// extra dummy entry to each function's local file table, to exercise the
/// code that checks for local file IDs with no mapping regions.
pub inject_unused_local_file: bool,
}
/// Controls whether branch coverage or MC/DC coverage is enabled.

View file

@ -1413,7 +1413,6 @@ pub mod parse {
"mcdc" => slot.level = CoverageLevel::Mcdc,
"no-mir-spans" => slot.no_mir_spans = true,
"discard-all-spans-in-codegen" => slot.discard_all_spans_in_codegen = true,
"inject-unused-local-file" => slot.inject_unused_local_file = true,
_ => return false,
}
}

View file

@ -371,11 +371,6 @@ impl Session {
self.opts.unstable_opts.coverage_options.discard_all_spans_in_codegen
}
/// True if testing flag `-Zcoverage-options=inject-unused-local-file` was passed.
pub fn coverage_inject_unused_local_file(&self) -> bool {
self.opts.unstable_opts.coverage_options.inject_unused_local_file
}
pub fn is_sanitizer_cfi_enabled(&self) -> bool {
self.opts.unstable_opts.sanitizer.contains(SanitizerSet::CFI)
}

View file

@ -100,7 +100,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> {
stable_mir::ty::ExistentialProjection {
def_id: tables.trait_def(*def_id),
generic_args: args.stable(tables),
term: term.unpack().stable(tables),
term: term.kind().stable(tables),
}
}
}
@ -158,7 +158,7 @@ impl<'tcx> Stable<'tcx> for ty::FieldDef {
impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
type T = stable_mir::ty::GenericArgs;
fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
GenericArgs(self.iter().map(|arg| arg.unpack().stable(tables)).collect())
GenericArgs(self.iter().map(|arg| arg.kind().stable(tables)).collect())
}
}
@ -604,8 +604,8 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> {
PredicateKind::NormalizesTo(_pred) => unimplemented!(),
PredicateKind::AliasRelate(a, b, alias_relation_direction) => {
stable_mir::ty::PredicateKind::AliasRelate(
a.unpack().stable(tables),
b.unpack().stable(tables),
a.kind().stable(tables),
b.kind().stable(tables),
alias_relation_direction.stable(tables),
)
}
@ -640,7 +640,7 @@ impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> {
ty.stable(tables),
),
ClauseKind::WellFormed(term) => {
stable_mir::ty::ClauseKind::WellFormed(term.unpack().stable(tables))
stable_mir::ty::ClauseKind::WellFormed(term.kind().stable(tables))
}
ClauseKind::ConstEvaluatable(const_) => {
stable_mir::ty::ClauseKind::ConstEvaluatable(const_.stable(tables))
@ -726,7 +726,7 @@ impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> {
let ty::ProjectionPredicate { projection_term, term } = self;
stable_mir::ty::ProjectionPredicate {
projection_term: projection_term.stable(tables),
term: term.unpack().stable(tables),
term: term.kind().stable(tables),
}
}
}

View file

@ -147,7 +147,7 @@ impl<'tcx> AbiHashStable<'tcx> for ty::FnSig<'tcx> {
impl<'tcx> AbiHashStable<'tcx> for ty::GenericArg<'tcx> {
fn abi_hash(&self, tcx: TyCtxt<'tcx>, hasher: &mut StableHasher) {
self.unpack().abi_hash(tcx, hasher);
self.kind().abi_hash(tcx, hasher);
}
}

View file

@ -386,7 +386,7 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> {
print_prefix(self)?;
let args =
args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)));
if args.clone().next().is_some() {
self.generic_delimiters(|cx| cx.comma_sep(args))

View file

@ -646,7 +646,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
let name = cx.tcx.associated_item(projection.def_id).name();
cx.push("p");
cx.push_ident(name.as_str());
match projection.term.unpack() {
match projection.term.kind() {
ty::TermKind::Ty(ty) => ty.print(cx),
ty::TermKind::Const(c) => c.print(cx),
}?;
@ -912,11 +912,11 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
args: &[GenericArg<'tcx>],
) -> Result<(), PrintError> {
// Don't print any regions if they're all erased.
let print_regions = args.iter().any(|arg| match arg.unpack() {
let print_regions = args.iter().any(|arg| match arg.kind() {
GenericArgKind::Lifetime(r) => !r.is_erased(),
_ => false,
});
let args = args.iter().cloned().filter(|arg| match arg.unpack() {
let args = args.iter().cloned().filter(|arg| match arg.kind() {
GenericArgKind::Lifetime(_) => print_regions,
_ => true,
});
@ -928,7 +928,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
self.push("I");
print_prefix(self)?;
for arg in args {
match arg.unpack() {
match arg.kind() {
GenericArgKind::Lifetime(lt) => {
lt.print(self)?;
}

View file

@ -738,7 +738,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
value.push_normal(", ");
}
match arg.unpack() {
match arg.kind() {
ty::GenericArgKind::Lifetime(lt) => {
let s = lt.to_string();
value.push_normal(if s.is_empty() { "'_" } else { &s });
@ -1166,7 +1166,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
for (i, (arg1, arg2)) in sub1.iter().zip(sub2).enumerate().take(len) {
self.push_comma(&mut values.0, &mut values.1, i);
match arg1.unpack() {
match arg1.kind() {
// At one point we'd like to elide all lifetimes here, they are
// irrelevant for all diagnostics that use this output.
//
@ -1509,7 +1509,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}
let (is_simple_error, exp_found) = match values {
ValuePairs::Terms(ExpectedFound { expected, found }) => {
match (expected.unpack(), found.unpack()) {
match (expected.kind(), found.kind()) {
(ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
let is_simple_err =
expected.is_simple_text() && found.is_simple_text();
@ -2156,7 +2156,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
return None;
}
Some(match (exp_found.expected.unpack(), exp_found.found.unpack()) {
Some(match (exp_found.expected.kind(), exp_found.found.kind()) {
(ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
let (mut exp, mut fnd) = self.cmp(expected, found);
// Use the terminal width as the basis to determine when to compress the printed

View file

@ -215,7 +215,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'a, 'tcx> {
// `_` because then we'd end up with `Vec<_, _>`, instead of
// `Vec<_>`.
arg
} else if let GenericArgKind::Type(_) = arg.unpack() {
} else if let GenericArgKind::Type(_) = arg.kind() {
// We don't replace lifetime or const params, only type params.
self.new_infer().into()
} else {
@ -347,7 +347,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
highlight: ty::print::RegionHighlightMode<'tcx>,
) -> InferenceDiagnosticsData {
let tcx = self.tcx;
match term.unpack() {
match term.kind() {
TermKind::Ty(ty) => {
if let ty::Infer(ty::TyVar(ty_vid)) = *ty.kind() {
let var_origin = self.infcx.type_var_origin(ty_vid);
@ -568,7 +568,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
return arg;
}
match arg.unpack() {
match arg.kind() {
GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"),
GenericArgKind::Type(_) => self.next_ty_var(DUMMY_SP).into(),
GenericArgKind::Const(_) => self.next_const_var(DUMMY_SP).into(),
@ -803,7 +803,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
}
impl<'tcx> CostCtxt<'tcx> {
fn arg_cost(self, arg: GenericArg<'tcx>) -> usize {
match arg.unpack() {
match arg.kind() {
GenericArgKind::Lifetime(_) => 0, // erased
GenericArgKind::Type(ty) => self.ty_cost(ty),
GenericArgKind::Const(_) => 3, // some non-zero value
@ -898,7 +898,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
return true;
}
match (arg.unpack(), self.target.unpack()) {
match (arg.kind(), self.target.kind()) {
(GenericArgKind::Type(inner_ty), TermKind::Ty(target_ty)) => {
use ty::{Infer, TyVar};
match (inner_ty.kind(), target_ty.kind()) {
@ -929,7 +929,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
if self.generic_arg_is_target(inner) {
return true;
}
match inner.unpack() {
match inner.kind() {
GenericArgKind::Lifetime(_) => {}
GenericArgKind::Type(ty) => {
if matches!(

View file

@ -664,8 +664,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let Some(found) = exp_found.found.args.get(1) else {
return;
};
let expected = expected.unpack();
let found = found.unpack();
let expected = expected.kind();
let found = found.kind();
// 3. Extract the tuple type from Fn trait and suggest the change.
if let GenericArgKind::Type(expected) = expected
&& let GenericArgKind::Type(found) = found

View file

@ -2446,7 +2446,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}
if let ty::Adt(def, args) = self_ty.kind()
&& let [arg] = &args[..]
&& let ty::GenericArgKind::Type(ty) = arg.unpack()
&& let ty::GenericArgKind::Type(ty) = arg.kind()
&& let ty::Adt(inner_def, _) = ty.kind()
&& inner_def == def
{

View file

@ -81,7 +81,7 @@ pub fn check_opaque_type_parameter_valid<'tcx>(
}
for (i, arg) in opaque_type_key.iter_captured_args(tcx) {
let arg_is_param = match arg.unpack() {
let arg_is_param = match arg.kind() {
GenericArgKind::Lifetime(lt) => match defining_scope_kind {
DefiningScopeKind::HirTypeck => continue,
DefiningScopeKind::MirBorrowck => {

View file

@ -108,7 +108,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
arg: ty::GenericArg<'tcx>,
span: Span,
) -> ty::GenericArg<'tcx> {
match arg.unpack() {
match arg.kind() {
ty::GenericArgKind::Lifetime(_) => {
self.next_region_var(RegionVariableOrigin::MiscVariable(span)).into()
}

View file

@ -207,7 +207,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
let infcx = self.goal.infcx;
match goal.predicate.kind().no_bound_vars() {
Some(ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })) => {
let unconstrained_term = match term.unpack() {
let unconstrained_term = match term.kind() {
ty::TermKind::Ty(_) => infcx.next_ty_var(span).into(),
ty::TermKind::Const(_) => infcx.next_const_var(span).into(),
};

View file

@ -1784,7 +1784,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
if !generics.is_own_empty()
&& obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
p.has_non_region_infer()
&& match p.unpack() {
&& match p.kind() {
ty::GenericArgKind::Const(ct) => {
self.infcx.shallow_resolve_const(ct) != ct
}

View file

@ -39,7 +39,7 @@ impl<'tcx> At<'_, 'tcx> {
return Ok(term);
}
let new_infer = match term.unpack() {
let new_infer = match term.kind() {
ty::TermKind::Ty(_) => self.infcx.next_ty_var(self.cause.span).into(),
ty::TermKind::Const(_) => self.infcx.next_const_var(self.cause.span).into(),
};

View file

@ -37,7 +37,7 @@ pub fn obligations<'tcx>(
span: Span,
) -> Option<PredicateObligations<'tcx>> {
// Handle the "cycle" case (see comment above) by bailing out if necessary.
let term = match term.unpack() {
let term = match term.kind() {
TermKind::Ty(ty) => {
match ty.kind() {
ty::Infer(ty::TyVar(_)) => {

View file

@ -74,7 +74,7 @@ fn representability_adt_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Representab
// but the type parameters may cause a cycle with an upstream type
let params_in_repr = tcx.params_in_repr(adt.did());
for (i, arg) in args.iter().enumerate() {
if let ty::GenericArgKind::Type(ty) = arg.unpack() {
if let ty::GenericArgKind::Type(ty) = arg.kind() {
if params_in_repr.contains(i as u32) {
rtry!(representability_ty(tcx, ty));
}
@ -104,7 +104,7 @@ fn params_in_repr_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, params_in_repr: &mut
ty::Adt(adt, args) => {
let inner_params_in_repr = tcx.params_in_repr(adt.did());
for (i, arg) in args.iter().enumerate() {
if let ty::GenericArgKind::Type(ty) = arg.unpack() {
if let ty::GenericArgKind::Type(ty) = arg.kind() {
if inner_params_in_repr.contains(i as u32) {
params_in_repr_ty(tcx, ty, params_in_repr);
}

View file

@ -274,7 +274,7 @@ fn unsizing_params_for_adt<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> DenseBitSe
let def = tcx.adt_def(def_id);
let num_params = tcx.generics_of(def_id).count();
let maybe_unsizing_param_idx = |arg: ty::GenericArg<'tcx>| match arg.unpack() {
let maybe_unsizing_param_idx = |arg: ty::GenericArg<'tcx>| match arg.kind() {
ty::GenericArgKind::Type(ty) => match ty.kind() {
ty::Param(p) => Some(p.index),
_ => None,

View file

@ -676,7 +676,7 @@ impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I> {
// the specialized routine `ty::replace_late_regions()`.
match r.kind() {
ty::ReEarlyParam(data) => {
let rk = self.args.get(data.index() as usize).map(|k| k.kind());
let rk = self.args.get(data.index() as usize).map(|arg| arg.kind());
match rk {
Some(ty::GenericArgKind::Lifetime(lt)) => self.shift_region_through_binders(lt),
Some(other) => self.region_param_expected(data, r, other),
@ -716,7 +716,7 @@ impl<'a, I: Interner> TypeFolder<I> for ArgFolder<'a, I> {
impl<'a, I: Interner> ArgFolder<'a, I> {
fn ty_for_param(&self, p: I::ParamTy, source_ty: I::Ty) -> I::Ty {
// Look up the type in the args. It really should be in there.
let opt_ty = self.args.get(p.index() as usize).map(|k| k.kind());
let opt_ty = self.args.get(p.index() as usize).map(|arg| arg.kind());
let ty = match opt_ty {
Some(ty::GenericArgKind::Type(ty)) => ty,
Some(kind) => self.type_param_expected(p, source_ty, kind),
@ -753,7 +753,7 @@ impl<'a, I: Interner> ArgFolder<'a, I> {
fn const_for_param(&self, p: I::ParamConst, source_ct: I::Const) -> I::Const {
// Look up the const in the args. It really should be in there.
let opt_ct = self.args.get(p.index() as usize).map(|k| k.kind());
let opt_ct = self.args.get(p.index() as usize).map(|arg| arg.kind());
let ct = match opt_ct {
Some(ty::GenericArgKind::Const(ct)) => ct,
Some(kind) => self.const_param_expected(p, source_ct, kind),

View file

@ -479,8 +479,8 @@ impl<I: Interner> FlagComputation<I> {
}
fn add_args(&mut self, args: &[I::GenericArg]) {
for kind in args {
match kind.kind() {
for arg in args {
match arg.kind() {
ty::GenericArgKind::Type(ty) => self.add_ty(ty),
ty::GenericArgKind::Lifetime(lt) => self.add_region(lt),
ty::GenericArgKind::Const(ct) => self.add_const(ct),

View file

@ -391,6 +391,16 @@ impl fmt::Display for TryLockError {
}
}
#[unstable(feature = "file_lock", issue = "130994")]
impl From<TryLockError> for io::Error {
fn from(err: TryLockError) -> io::Error {
match err {
TryLockError::Error(err) => err,
TryLockError::WouldBlock => io::ErrorKind::WouldBlock.into(),
}
}
}
impl File {
/// Attempts to open a file in read-only mode.
///
@ -820,11 +830,14 @@ impl File {
///
/// fn main() -> std::io::Result<()> {
/// let f = File::create("foo.txt")?;
/// // Explicit handling of the WouldBlock error
/// match f.try_lock() {
/// Ok(_) => (),
/// Err(TryLockError::WouldBlock) => (), // Lock not acquired
/// Err(TryLockError::Error(err)) => return Err(err),
/// }
/// // Alternately, propagate the error as an io::Error
/// f.try_lock()?;
/// Ok(())
/// }
/// ```
@ -881,11 +894,14 @@ impl File {
///
/// fn main() -> std::io::Result<()> {
/// let f = File::open("foo.txt")?;
/// // Explicit handling of the WouldBlock error
/// match f.try_lock_shared() {
/// Ok(_) => (),
/// Err(TryLockError::WouldBlock) => (), // Lock not acquired
/// Err(TryLockError::Error(err)) => return Err(err),
/// }
/// // Alternately, propagate the error as an io::Error
/// f.try_lock_shared()?;
///
/// Ok(())
/// }

View file

@ -366,6 +366,28 @@ fn file_lock_blocking_async() {
t.join().unwrap();
}
#[test]
#[cfg(windows)]
fn file_try_lock_async() {
const FILE_FLAG_OVERLAPPED: u32 = 0x40000000;
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_try_lock_async.txt");
let f1 = check!(File::create(filename));
let f2 =
check!(OpenOptions::new().custom_flags(FILE_FLAG_OVERLAPPED).write(true).open(filename));
// Check that shared locks block exclusive locks
check!(f1.lock_shared());
assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
check!(f1.unlock());
// Check that exclusive locks block all locks
check!(f1.lock());
assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
assert_matches!(f2.try_lock_shared(), Err(TryLockError::WouldBlock));
}
#[test]
fn file_test_io_seek_shakedown() {
// 01234567890123

View file

@ -415,10 +415,7 @@ impl File {
match result {
Ok(_) => Ok(()),
Err(err)
if err.raw_os_error() == Some(c::ERROR_IO_PENDING as i32)
|| err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) =>
{
Err(err) if err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) => {
Err(TryLockError::WouldBlock)
}
Err(err) => Err(TryLockError::Error(err)),
@ -440,10 +437,7 @@ impl File {
match result {
Ok(_) => Ok(()),
Err(err)
if err.raw_os_error() == Some(c::ERROR_IO_PENDING as i32)
|| err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) =>
{
Err(err) if err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) => {
Err(TryLockError::WouldBlock)
}
Err(err) => Err(TryLockError::Error(err)),

View file

@ -449,7 +449,7 @@ fn clean_middle_term<'tcx>(
term: ty::Binder<'tcx, ty::Term<'tcx>>,
cx: &mut DocContext<'tcx>,
) -> Term {
match term.skip_binder().unpack() {
match term.skip_binder().kind() {
ty::TermKind::Ty(ty) => Term::Type(clean_middle_ty(term.rebind(ty), cx, None, None)),
ty::TermKind::Const(c) => Term::Constant(clean_middle_const(term.rebind(c), cx)),
}

View file

@ -124,7 +124,7 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
elision_has_failed_once_before = true;
}
match arg.skip_binder().unpack() {
match arg.skip_binder().kind() {
GenericArgKind::Lifetime(lt) => {
Some(GenericArg::Lifetime(clean_middle_region(lt).unwrap_or(Lifetime::elided())))
}
@ -161,7 +161,7 @@ fn can_elide_generic_arg<'tcx>(
default: ty::Binder<'tcx, ty::GenericArg<'tcx>>,
) -> bool {
debug_assert_matches!(
(actual.skip_binder().unpack(), default.skip_binder().unpack()),
(actual.skip_binder().kind(), default.skip_binder().kind()),
(ty::GenericArgKind::Lifetime(_), ty::GenericArgKind::Lifetime(_))
| (ty::GenericArgKind::Type(_), ty::GenericArgKind::Type(_))
| (ty::GenericArgKind::Const(_), ty::GenericArgKind::Const(_))

View file

@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for ArcWithNonSendSync {
&& let arg_ty = cx.typeck_results().expr_ty(arg)
// make sure that the type is not and does not contain any type parameters
&& arg_ty.walk().all(|arg| {
!matches!(arg.unpack(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_)))
!matches!(arg.kind(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_)))
})
&& let Some(send) = cx.tcx.get_diagnostic_item(sym::Send)
&& let Some(sync) = cx.tcx.lang_items().sync_trait()

View file

@ -345,7 +345,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
if ty_adt.repr().packed()
&& ty_subs
.iter()
.any(|arg| matches!(arg.unpack(), GenericArgKind::Type(_) | GenericArgKind::Const(_)))
.any(|arg| matches!(arg.kind(), GenericArgKind::Type(_) | GenericArgKind::Const(_)))
{
return;
}

View file

@ -306,7 +306,7 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
return true;
}
for (from_arg, to_arg) in to_subs.iter().zip(from_subs) {
match (from_arg.unpack(), to_arg.unpack()) {
match (from_arg.kind(), to_arg.kind()) {
(GenericArgKind::Lifetime(from_region), GenericArgKind::Lifetime(to_region)) => {
if check_region(from_region, to_region) {
return true;
@ -354,5 +354,5 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
fn ty_has_static(ty: Ty<'_>) -> bool {
ty.walk()
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if re.is_static()))
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if re.is_static()))
}

View file

@ -17,7 +17,7 @@ fn check_ty<'a>(cx: &LateContext<'a>, param: &rustc_hir::Ty<'a>, param_ty: Ty<'a
&& is_type_diagnostic_item(cx, *opt_ty, sym::Option)
&& let ty::Adt(_, opt_gen_args) = opt_ty.kind()
&& let [gen_arg] = opt_gen_args.as_slice()
&& let GenericArgKind::Type(gen_ty) = gen_arg.unpack()
&& let GenericArgKind::Type(gen_ty) = gen_arg.kind()
&& !gen_ty.is_ref()
// Need to gen the original spans, so first parsing mid, and hir parsing afterward
&& let hir::TyKind::Ref(lifetime, hir::MutTy { ty, .. }) = param.kind

View file

@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
&& !local.span.in_external_macro(cx.tcx.sess.source_map())
{
let init_ty = cx.typeck_results().expr_ty(init);
let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() {
let contains_sync_guard = init_ty.walk().any(|inner| match inner.kind() {
GenericArgKind::Type(inner_ty) => inner_ty
.ty_adt_def()
.is_some_and(|adt| paths::PARKING_LOT_GUARDS.iter().any(|path| path.matches(cx, adt.did()))),

View file

@ -109,7 +109,7 @@ fn handle(
&& implements_trait(cx, expr_type, default_trait_id, &[])
// We check if the initial condition implements Default.
&& let Some(condition_ty) = cx.typeck_results().expr_ty(condition).walk().nth(1)
&& let GenericArgKind::Type(condition_ty) = condition_ty.unpack()
&& let GenericArgKind::Type(condition_ty) = condition_ty.kind()
&& implements_trait(cx, condition_ty, default_trait_id, &[])
&& is_default_equivalent(cx, peel_blocks(body_none))
{

View file

@ -108,7 +108,7 @@ fn find_match_true<'tcx>(
fn try_get_generic_ty(ty: Ty<'_>, index: usize) -> Option<Ty<'_>> {
if let ty::Adt(_, subs) = ty.kind()
&& let Some(sub) = subs.get(index)
&& let GenericArgKind::Type(sub_ty) = sub.unpack()
&& let GenericArgKind::Type(sub_ty) = sub.kind()
{
Some(sub_ty)
} else {

View file

@ -208,12 +208,12 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
// (to avoid false positive on `Ref<'a, MutexGuard<Foo>>`)
|| (args
.iter()
.all(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
.all(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)))
// some generic parameter has significant drop
// (to avoid false negative on `Box<MutexGuard<Foo>>`)
&& args
.iter()
.filter_map(|arg| match arg.unpack() {
.filter_map(|arg| match arg.kind() {
GenericArgKind::Type(ty) => Some(ty),
_ => None,
})

View file

@ -508,7 +508,7 @@ fn get_captured_ids(cx: &LateContext<'_>, ty: Ty<'_>) -> HirIdSet {
match ty.kind() {
ty::Adt(_, generics) => {
for generic in *generics {
if let GenericArgKind::Type(ty) = generic.unpack() {
if let GenericArgKind::Type(ty) = generic.kind() {
get_captured_ids_recursive(cx, ty, set);
}
}

View file

@ -188,7 +188,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: &Exp
fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
let ty = cx.typeck_results().expr_ty(expr);
matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(_)))
}
pub(super) fn check<'tcx>(

View file

@ -608,7 +608,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
}
fn has_lifetime(ty: Ty<'_>) -> bool {
ty.walk().any(|t| matches!(t.unpack(), GenericArgKind::Lifetime(_)))
ty.walk().any(|t| matches!(t.kind(), GenericArgKind::Lifetime(_)))
}
/// Returns true if the named method is `Iterator::cloned` or `Iterator::copied`.
@ -643,7 +643,7 @@ fn is_to_string_on_string_like<'a>(
if let Some(args) = cx.typeck_results().node_args_opt(call_expr.hir_id)
&& let [generic_arg] = args.as_slice()
&& let GenericArgKind::Type(ty) = generic_arg.unpack()
&& let GenericArgKind::Type(ty) = generic_arg.kind()
&& let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref)
&& let Some(as_ref_trait_id) = cx.tcx.get_diagnostic_item(sym::AsRef)
&& (cx.get_associated_type(ty, deref_trait_id, sym::Target) == Some(cx.tcx.types.str_)

View file

@ -269,7 +269,7 @@ fn needless_borrow_count<'tcx>(
.tcx
.is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id)
&& let ty::Param(param_ty) = trait_predicate.self_ty().kind()
&& let GenericArgKind::Type(ty) = args_with_referent_ty[param_ty.index as usize].unpack()
&& let GenericArgKind::Type(ty) = args_with_referent_ty[param_ty.index as usize].kind()
&& ty.is_array()
&& !msrv.meets(cx, msrvs::ARRAY_INTO_ITERATOR)
{

View file

@ -172,7 +172,7 @@ impl NonSendField<'_> {
/// Example: `MyStruct<P, Box<Q, R>>` => `vec![P, Q, R]`
fn collect_generic_params(ty: Ty<'_>) -> Vec<Ty<'_>> {
ty.walk()
.filter_map(|inner| match inner.unpack() {
.filter_map(|inner| match inner.kind() {
GenericArgKind::Type(inner_ty) => Some(inner_ty),
_ => None,
})
@ -208,7 +208,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
ty::Adt(_, args) => {
if contains_pointer_like(cx, ty) {
// descends only if ADT contains any raw pointers
args.iter().all(|generic_arg| match generic_arg.unpack() {
args.iter().all(|generic_arg| match generic_arg.kind() {
GenericArgKind::Type(ty) => ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait),
// Lifetimes and const generics are not solid part of ADT and ignored
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => true,
@ -226,7 +226,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
/// Checks if the type contains any pointer-like types in args (including nested ones)
fn contains_pointer_like<'tcx>(cx: &LateContext<'tcx>, target_ty: Ty<'tcx>) -> bool {
for ty_node in target_ty.walk() {
if let GenericArgKind::Type(inner_ty) = ty_node.unpack() {
if let GenericArgKind::Type(inner_ty) = ty_node.kind() {
match inner_ty.kind() {
ty::RawPtr(_, _) => {
return true;

View file

@ -385,7 +385,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
fn has_matching_args(kind: FnKind, args: GenericArgsRef<'_>) -> bool {
match kind {
FnKind::Fn => true,
FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.unpack() {
FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.kind() {
GenericArgKind::Lifetime(_) => true,
GenericArgKind::Type(ty) => matches!(*ty.kind(), ty::Param(ty) if ty.index as usize == idx),
GenericArgKind::Const(c) => matches!(c.kind(), ConstKind::Param(c) if c.index as usize == idx),

View file

@ -487,7 +487,7 @@ fn last_statement_borrows<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>)
.skip_binder()
.output()
.walk()
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if !re.is_static()))
{
ControlFlow::Break(())
} else {

View file

@ -184,7 +184,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
}
}
for generic_arg in *b {
if let GenericArgKind::Type(ty) = generic_arg.unpack()
if let GenericArgKind::Type(ty) = generic_arg.kind()
&& self.has_sig_drop_attr(ty, depth)
{
return true;

View file

@ -319,7 +319,7 @@ fn same_lifetimes<'tcx>(a: MiddleTy<'tcx>, b: MiddleTy<'tcx>) -> bool {
args_a
.iter()
.zip(args_b.iter())
.all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
.all(|(arg_a, arg_b)| match (arg_a.kind(), arg_b.kind()) {
// TODO: Handle inferred lifetimes
(GenericArgKind::Lifetime(inner_a), GenericArgKind::Lifetime(inner_b)) => inner_a == inner_b,
(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 {
&Adt(_, args) => !args
.iter()
// TODO: Handle inferred lifetimes
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(..))),
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(..))),
_ => true,
}
}

View file

@ -37,7 +37,7 @@ impl LateLintPass<'_> for MsrvAttrImpl {
.type_of(f.did)
.instantiate_identity()
.walk()
.filter(|t| matches!(t.unpack(), GenericArgKind::Type(_)))
.filter(|t| matches!(t.kind(), GenericArgKind::Type(_)))
.any(|t| internal_paths::MSRV_STACK.matches_ty(cx, t.expect_ty()))
})
&& !items.iter().any(|item| item.ident.name.as_str() == "check_attributes")

View file

@ -3316,7 +3316,7 @@ pub fn leaks_droppable_temporary_with_limited_lifetime<'tcx>(cx: &LateContext<'t
if temporary_ty.has_significant_drop(cx.tcx, cx.typing_env())
&& temporary_ty
.walk()
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if !re.is_static()))
{
ControlFlow::Break(())
} else {

View file

@ -55,7 +55,7 @@ pub fn is_min_const_fn<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, msrv: Ms
fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, msrv: Msrv) -> McfResult {
for arg in ty.walk() {
let ty = match arg.unpack() {
let ty = match arg.kind() {
GenericArgKind::Type(ty) => ty,
// No constraints on lifetimes or constants, except potentially

View file

@ -78,7 +78,7 @@ pub fn can_partially_move_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool
/// Walks into `ty` and returns `true` if any inner type is an instance of the given adt
/// constructor.
pub fn contains_adt_constructor<'tcx>(ty: Ty<'tcx>, adt: AdtDef<'tcx>) -> bool {
ty.walk().any(|inner| match inner.unpack() {
ty.walk().any(|inner| match inner.kind() {
GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt),
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
})
@ -96,7 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
needle: Ty<'tcx>,
seen: &mut FxHashSet<DefId>,
) -> bool {
ty.walk().any(|inner| match inner.unpack() {
ty.walk().any(|inner| match inner.kind() {
GenericArgKind::Type(inner_ty) => {
if inner_ty == needle {
return true;
@ -129,7 +129,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
// For `impl Trait<Assoc=U>`, it will register a predicate of `<T as Trait>::Assoc = U`,
// so we check the term for `U`.
ty::ClauseKind::Projection(projection_predicate) => {
if let ty::TermKind::Ty(ty) = projection_predicate.term.unpack()
if let ty::TermKind::Ty(ty) = projection_predicate.term.kind()
&& contains_ty_adt_constructor_opaque_inner(cx, ty, needle, seen)
{
return true;
@ -526,7 +526,7 @@ pub fn same_type_and_consts<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
args_a
.iter()
.zip(args_b.iter())
.all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
.all(|(arg_a, arg_b)| match (arg_a.kind(), arg_b.kind()) {
(GenericArgKind::Const(inner_a), GenericArgKind::Const(inner_b)) => inner_a == inner_b,
(GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => {
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
if let Some((idx, (param, arg))) =
params
.clone()
.zip(args.iter().map(|&x| x.unpack()))
.zip(args.iter().map(|&x| x.kind()))
.enumerate()
.find(|(_, (param, arg))| match (param, arg) {
(GenericParamDefKind::Lifetime, GenericArgKind::Lifetime(_))

View file

@ -326,5 +326,5 @@ fn adt_def_id(ty: Ty<'_>) -> Option<DefId> {
fn contains_param(ty: Ty<'_>, index: u32) -> bool {
ty.walk()
.any(|arg| matches!(arg.unpack(), GenericArgKind::Type(ty) if ty.is_param(index)))
.any(|arg| matches!(arg.kind(), GenericArgKind::Type(ty) if ty.is_param(index)))
}

View file

@ -1775,7 +1775,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
let is_generic = instance
.args
.into_iter()
.any(|kind| !matches!(kind.unpack(), ty::GenericArgKind::Lifetime(_)));
.any(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_)));
let can_be_inlined = matches!(
ecx.tcx.sess.opts.unstable_opts.cross_crate_inline_threshold,
InliningThreshold::Always

View file

@ -15,7 +15,7 @@ semver = "1.0"
serde = { version = "1.0.125", features = ["derive"], optional = true }
termcolor = "1.1.3"
rustc-hash = "2.0.0"
fluent-syntax = "0.11.1"
fluent-syntax = "0.12"
similar = "2.5.0"
toml = "0.7.8"

View file

@ -1,5 +1,7 @@
//@ revisions: REGULAR LLVM21
//@ min-llvm-version: 20
//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled
//@ [LLVM21] min-llvm-version: 21
#![crate_type = "lib"]
extern crate core;
@ -74,3 +76,12 @@ pub fn niche_eq(l: Option<EnumWithNiche>, r: Option<EnumWithNiche>) -> bool {
// CHECK-NEXT: ret i1
l == r
}
// LLVM21-LABEL: @bool_eq
#[no_mangle]
pub fn bool_eq(l: Option<bool>, r: Option<bool>) -> bool {
// LLVM21: start:
// LLVM21-NEXT: icmp eq i8
// LLVM21-NEXT: ret i1
l == r
}

Some files were not shown because too many files have changed in this diff Show more