summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_mir_build/src/thir
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_mir_build/src/thir')
-rw-r--r--compiler/rustc_mir_build/src/thir/cx/expr.rs106
-rw-r--r--compiler/rustc_mir_build/src/thir/cx/mod.rs16
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/check_match.rs41
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs17
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs64
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/mod.rs40
-rw-r--r--compiler/rustc_mir_build/src/thir/pattern/usefulness.rs4
-rw-r--r--compiler/rustc_mir_build/src/thir/print.rs20
-rw-r--r--compiler/rustc_mir_build/src/thir/util.rs2
9 files changed, 143 insertions, 167 deletions
diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs
index 37537683f..6c1f7d7a6 100644
--- a/compiler/rustc_mir_build/src/thir/cx/expr.rs
+++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs
@@ -15,9 +15,9 @@ use rustc_middle::thir::*;
use rustc_middle::ty::adjustment::{
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCoercion,
};
-use rustc_middle::ty::subst::InternalSubsts;
+use rustc_middle::ty::GenericArgs;
use rustc_middle::ty::{
- self, AdtKind, InlineConstSubsts, InlineConstSubstsParts, ScalarInt, Ty, UpvarSubsts, UserType,
+ self, AdtKind, InlineConstArgs, InlineConstArgsParts, ScalarInt, Ty, UpvarArgs, UserType,
};
use rustc_span::{sym, Span};
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
@@ -41,11 +41,6 @@ impl<'tcx> Cx<'tcx> {
let mut expr = self.make_mirror_unadjusted(hir_expr);
- let adjustment_span = match self.adjustment_span {
- Some((hir_id, span)) if hir_id == hir_expr.hir_id => Some(span),
- _ => None,
- };
-
trace!(?expr.ty);
// Now apply adjustments, if any.
@@ -53,12 +48,7 @@ impl<'tcx> Cx<'tcx> {
for adjustment in self.typeck_results.expr_adjustments(hir_expr) {
trace!(?expr, ?adjustment);
let span = expr.span;
- expr = self.apply_adjustment(
- hir_expr,
- expr,
- adjustment,
- adjustment_span.unwrap_or(span),
- );
+ expr = self.apply_adjustment(hir_expr, expr, adjustment, span);
}
}
@@ -220,7 +210,7 @@ impl<'tcx> Cx<'tcx> {
let res = self.typeck_results().qpath_res(qpath, source.hir_id);
let ty = self.typeck_results().node_type(source.hir_id);
- let ty::Adt(adt_def, substs) = ty.kind() else {
+ let ty::Adt(adt_def, args) = ty.kind() else {
return ExprKind::Cast { source: self.mirror_expr(source) };
};
@@ -239,9 +229,7 @@ impl<'tcx> Cx<'tcx> {
let param_env_ty = self.param_env.and(discr_ty);
let size = tcx
.layout_of(param_env_ty)
- .unwrap_or_else(|e| {
- panic!("could not compute layout for {:?}: {:?}", param_env_ty, e)
- })
+ .unwrap_or_else(|e| panic!("could not compute layout for {param_env_ty:?}: {e:?}"))
.size;
let lit = ScalarInt::try_from_uint(discr_offset as u128, size).unwrap();
@@ -252,7 +240,7 @@ impl<'tcx> Cx<'tcx> {
// in case we are offsetting from a computed discriminant
// and not the beginning of discriminants (which is always `0`)
Some(did) => {
- let kind = ExprKind::NamedConst { def_id: did, substs, user_ty: None };
+ let kind = ExprKind::NamedConst { def_id: did, args, user_ty: None };
let lhs =
self.thir.exprs.push(Expr { temp_lifetime, ty: discr_ty, span, kind });
let bin = ExprKind::Binary { op: BinOp::Add, lhs, rhs: offset };
@@ -274,7 +262,6 @@ impl<'tcx> Cx<'tcx> {
fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> {
let tcx = self.tcx;
let expr_ty = self.typeck_results().expr_ty(expr);
- let expr_span = expr.span;
let temp_lifetime =
self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id);
@@ -283,17 +270,11 @@ impl<'tcx> Cx<'tcx> {
hir::ExprKind::MethodCall(segment, receiver, ref args, fn_span) => {
// Rewrite a.b(c) into UFCS form like Trait::b(a, c)
let expr = self.method_callee(expr, segment.ident.span, None);
- // When we apply adjustments to the receiver, use the span of
- // the overall method call for better diagnostics. args[0]
- // is guaranteed to exist, since a method call always has a receiver.
- let old_adjustment_span =
- self.adjustment_span.replace((receiver.hir_id, expr_span));
info!("Using method span: {:?}", expr.span);
let args = std::iter::once(receiver)
.chain(args.iter())
.map(|expr| self.mirror_expr(expr))
.collect();
- self.adjustment_span = old_adjustment_span;
ExprKind::Call {
ty: expr.ty,
fun: self.thir.exprs.push(expr),
@@ -389,7 +370,7 @@ impl<'tcx> Cx<'tcx> {
None
};
if let Some((adt_def, index)) = adt_data {
- let substs = self.typeck_results().node_substs(fun.hir_id);
+ let node_args = self.typeck_results().node_args(fun.hir_id);
let user_provided_types = self.typeck_results().user_provided_types();
let user_ty =
user_provided_types.get(fun.hir_id).copied().map(|mut u_ty| {
@@ -410,7 +391,7 @@ impl<'tcx> Cx<'tcx> {
.collect();
ExprKind::Adt(Box::new(AdtExpr {
adt_def,
- substs,
+ args: node_args,
variant_index: index,
fields: field_refs,
user_ty,
@@ -464,7 +445,6 @@ impl<'tcx> Cx<'tcx> {
let rhs = self.mirror_expr(rhs);
self.overloaded_operator(expr, Box::new([lhs, rhs]))
} else {
- // FIXME overflow
match op.node {
hir::BinOpKind::And => ExprKind::LogicalOp {
op: LogicalOp::And,
@@ -488,11 +468,17 @@ impl<'tcx> Cx<'tcx> {
}
}
- hir::ExprKind::Index(ref lhs, ref index) => {
+ hir::ExprKind::Index(ref lhs, ref index, brackets_span) => {
if self.typeck_results().is_method_call(expr) {
let lhs = self.mirror_expr(lhs);
let index = self.mirror_expr(index);
- self.overloaded_place(expr, expr_ty, None, Box::new([lhs, index]), expr.span)
+ self.overloaded_place(
+ expr,
+ expr_ty,
+ None,
+ Box::new([lhs, index]),
+ brackets_span,
+ )
} else {
ExprKind::Index { lhs: self.mirror_expr(lhs), index: self.mirror_expr(index) }
}
@@ -528,7 +514,7 @@ impl<'tcx> Cx<'tcx> {
}
hir::ExprKind::Struct(ref qpath, ref fields, ref base) => match expr_ty.kind() {
- ty::Adt(adt, substs) => match adt.adt_kind() {
+ ty::Adt(adt, args) => match adt.adt_kind() {
AdtKind::Struct | AdtKind::Union => {
let user_provided_types = self.typeck_results().user_provided_types();
let user_ty = user_provided_types.get(expr.hir_id).copied().map(Box::new);
@@ -536,7 +522,7 @@ impl<'tcx> Cx<'tcx> {
ExprKind::Adt(Box::new(AdtExpr {
adt_def: *adt,
variant_index: FIRST_VARIANT,
- substs,
+ args,
user_ty,
fields: self.field_refs(fields),
base: base.map(|base| FruInfo {
@@ -563,7 +549,7 @@ impl<'tcx> Cx<'tcx> {
ExprKind::Adt(Box::new(AdtExpr {
adt_def: *adt,
variant_index: index,
- substs,
+ args,
user_ty,
fields: self.field_refs(fields),
base: None,
@@ -582,10 +568,10 @@ impl<'tcx> Cx<'tcx> {
hir::ExprKind::Closure { .. } => {
let closure_ty = self.typeck_results().expr_ty(expr);
- let (def_id, substs, movability) = match *closure_ty.kind() {
- ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None),
- ty::Generator(def_id, substs, movability) => {
- (def_id, UpvarSubsts::Generator(substs), Some(movability))
+ let (def_id, args, movability) = match *closure_ty.kind() {
+ ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args), None),
+ ty::Generator(def_id, args, movability) => {
+ (def_id, UpvarArgs::Generator(args), Some(movability))
}
_ => {
span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty);
@@ -597,7 +583,7 @@ impl<'tcx> Cx<'tcx> {
.tcx
.closure_captures(def_id)
.iter()
- .zip(substs.upvar_tys())
+ .zip(args.upvar_tys())
.map(|(captured_place, ty)| {
let upvars = self.capture_upvar(expr, captured_place, ty);
self.thir.exprs.push(upvars)
@@ -618,7 +604,7 @@ impl<'tcx> Cx<'tcx> {
ExprKind::Closure(Box::new(ClosureExpr {
closure_id: def_id,
- substs,
+ args,
upvars,
movability,
fake_reads,
@@ -701,13 +687,11 @@ impl<'tcx> Cx<'tcx> {
let ty = self.typeck_results().node_type(anon_const.hir_id);
let did = anon_const.def_id.to_def_id();
let typeck_root_def_id = tcx.typeck_root_def_id(did);
- let parent_substs =
- tcx.erase_regions(InternalSubsts::identity_for_item(tcx, typeck_root_def_id));
- let substs =
- InlineConstSubsts::new(tcx, InlineConstSubstsParts { parent_substs, ty })
- .substs;
+ let parent_args =
+ tcx.erase_regions(GenericArgs::identity_for_item(tcx, typeck_root_def_id));
+ let args = InlineConstArgs::new(tcx, InlineConstArgsParts { parent_args, ty }).args;
- ExprKind::ConstBlock { did, substs }
+ ExprKind::ConstBlock { did, args }
}
// Now comes the rote stuff:
hir::ExprKind::Repeat(ref v, _) => {
@@ -748,6 +732,7 @@ impl<'tcx> Cx<'tcx> {
},
hir::ExprKind::Match(ref discr, ref arms, _) => ExprKind::Match {
scrutinee: self.mirror_expr(discr),
+ scrutinee_hir_id: discr.hir_id,
arms: arms.iter().map(|a| self.convert_arm(a)).collect(),
},
hir::ExprKind::Loop(ref body, ..) => {
@@ -826,12 +811,12 @@ impl<'tcx> Cx<'tcx> {
Expr { temp_lifetime, ty: expr_ty, span: expr.span, kind }
}
- fn user_substs_applied_to_res(
+ fn user_args_applied_to_res(
&mut self,
hir_id: hir::HirId,
res: Res,
) -> Option<Box<ty::CanonicalUserType<'tcx>>> {
- debug!("user_substs_applied_to_res: res={:?}", res);
+ debug!("user_args_applied_to_res: res={:?}", res);
let user_provided_type = match res {
// A reference to something callable -- e.g., a fn, method, or
// a tuple-struct or tuple-variant. This has the type of a
@@ -849,15 +834,15 @@ impl<'tcx> Cx<'tcx> {
// this variant -- but with the substitutions given by the
// user.
Res::Def(DefKind::Ctor(_, CtorKind::Const), _) => {
- self.user_substs_applied_to_ty_of_hir_id(hir_id).map(Box::new)
+ self.user_args_applied_to_ty_of_hir_id(hir_id).map(Box::new)
}
// `Self` is used in expression as a tuple struct constructor or a unit struct constructor
- Res::SelfCtor(_) => self.user_substs_applied_to_ty_of_hir_id(hir_id).map(Box::new),
+ Res::SelfCtor(_) => self.user_args_applied_to_ty_of_hir_id(hir_id).map(Box::new),
- _ => bug!("user_substs_applied_to_res: unexpected res {:?} at {:?}", res, hir_id),
+ _ => bug!("user_args_applied_to_res: unexpected res {:?} at {:?}", res, hir_id),
};
- debug!("user_substs_applied_to_res: user_provided_type={:?}", user_provided_type);
+ debug!("user_args_applied_to_res: user_provided_type={:?}", user_provided_type);
user_provided_type
}
@@ -876,13 +861,13 @@ impl<'tcx> Cx<'tcx> {
self.typeck_results().type_dependent_def(expr.hir_id).unwrap_or_else(|| {
span_bug!(expr.span, "no type-dependent def for method callee")
});
- let user_ty = self.user_substs_applied_to_res(expr.hir_id, Res::Def(kind, def_id));
+ let user_ty = self.user_args_applied_to_res(expr.hir_id, Res::Def(kind, def_id));
debug!("method_callee: user_ty={:?}", user_ty);
(
Ty::new_fn_def(
self.tcx(),
def_id,
- self.typeck_results().node_substs(expr.hir_id),
+ self.typeck_results().node_args(expr.hir_id),
),
user_ty,
)
@@ -909,14 +894,14 @@ impl<'tcx> Cx<'tcx> {
}
fn convert_path_expr(&mut self, expr: &'tcx hir::Expr<'tcx>, res: Res) -> ExprKind<'tcx> {
- let substs = self.typeck_results().node_substs(expr.hir_id);
+ let args = self.typeck_results().node_args(expr.hir_id);
match res {
// A regular function, constructor function or a constant.
Res::Def(DefKind::Fn, _)
| Res::Def(DefKind::AssocFn, _)
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
| Res::SelfCtor(_) => {
- let user_ty = self.user_substs_applied_to_res(expr.hir_id, res);
+ let user_ty = self.user_args_applied_to_res(expr.hir_id, res);
ExprKind::ZstLiteral { user_ty }
}
@@ -931,8 +916,8 @@ impl<'tcx> Cx<'tcx> {
}
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
- let user_ty = self.user_substs_applied_to_res(expr.hir_id, res);
- ExprKind::NamedConst { def_id, substs, user_ty }
+ let user_ty = self.user_args_applied_to_res(expr.hir_id, res);
+ ExprKind::NamedConst { def_id, args, user_ty }
}
Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id) => {
@@ -943,10 +928,10 @@ impl<'tcx> Cx<'tcx> {
match ty.kind() {
// A unit struct/variant which is used as a value.
// We return a completely different ExprKind here to account for this special case.
- ty::Adt(adt_def, substs) => ExprKind::Adt(Box::new(AdtExpr {
+ ty::Adt(adt_def, args) => ExprKind::Adt(Box::new(AdtExpr {
adt_def: *adt_def,
variant_index: adt_def.variant_index_with_ctor_id(def_id),
- substs,
+ args,
user_ty,
fields: Box::new([]),
base: None,
@@ -1093,6 +1078,9 @@ impl<'tcx> Cx<'tcx> {
variant_index,
name: field,
},
+ HirProjectionKind::OpaqueCast => {
+ ExprKind::Use { source: self.thir.exprs.push(captured_place_expr) }
+ }
HirProjectionKind::Index | HirProjectionKind::Subslice => {
// We don't capture these projections, so we can ignore them here
continue;
diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs
index e6a98d1aa..d98cc76ad 100644
--- a/compiler/rustc_mir_build/src/thir/cx/mod.rs
+++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs
@@ -16,7 +16,6 @@ use rustc_hir::Node;
use rustc_middle::middle::region;
use rustc_middle::thir::*;
use rustc_middle::ty::{self, RvalueScopes, Ty, TyCtxt};
-use rustc_span::Span;
pub(crate) fn thir_body(
tcx: TyCtxt<'_>,
@@ -62,14 +61,6 @@ struct Cx<'tcx> {
typeck_results: &'tcx ty::TypeckResults<'tcx>,
rvalue_scopes: &'tcx RvalueScopes,
- /// When applying adjustments to the expression
- /// with the given `HirId`, use the given `Span`,
- /// instead of the usual span. This is used to
- /// assign the span of an overall method call
- /// (e.g. `my_val.foo()`) to the adjustment expressions
- /// for the receiver.
- adjustment_span: Option<(HirId, Span)>,
-
/// False to indicate that adjustments should not be applied. Only used for `custom_mir`
apply_adjustments: bool,
@@ -110,7 +101,6 @@ impl<'tcx> Cx<'tcx> {
typeck_results,
rvalue_scopes: &typeck_results.rvalue_scopes,
body_owner: def.to_def_id(),
- adjustment_span: None,
apply_adjustments: hir
.attrs(hir_id)
.iter()
@@ -132,7 +122,7 @@ impl<'tcx> Cx<'tcx> {
DefKind::Closure => {
let closure_ty = self.typeck_results.node_type(owner_id);
- let ty::Closure(closure_def_id, closure_substs) = *closure_ty.kind() else {
+ let ty::Closure(closure_def_id, closure_args) = *closure_ty.kind() else {
bug!("closure expr does not have closure type: {:?}", closure_ty);
};
@@ -144,7 +134,7 @@ impl<'tcx> Cx<'tcx> {
};
let env_region = ty::Region::new_late_bound(self.tcx, ty::INNERMOST, br);
let closure_env_ty =
- self.tcx.closure_env_ty(closure_def_id, closure_substs, env_region).unwrap();
+ self.tcx.closure_env_ty(closure_def_id, closure_args, env_region).unwrap();
let liberated_closure_env_ty = self.tcx.erase_late_bound_regions(
ty::Binder::bind_with_vars(closure_env_ty, bound_vars),
);
@@ -196,7 +186,7 @@ impl<'tcx> Cx<'tcx> {
self.tcx
.type_of(va_list_did)
- .subst(self.tcx, &[self.tcx.lifetimes.re_erased.into()])
+ .instantiate(self.tcx, &[self.tcx.lifetimes.re_erased.into()])
} else {
fn_sig.inputs()[index]
};
diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
index ef60f08bf..383e80851 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
@@ -135,10 +135,12 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for MatchVisitor<'a, '_, 'tcx> {
});
return;
}
- ExprKind::Match { scrutinee, box ref arms } => {
+ ExprKind::Match { scrutinee, scrutinee_hir_id, box ref arms } => {
let source = match ex.span.desugaring_kind() {
Some(DesugaringKind::ForLoop) => hir::MatchSource::ForLoopDesugar,
- Some(DesugaringKind::QuestionMark) => hir::MatchSource::TryDesugar,
+ Some(DesugaringKind::QuestionMark) => {
+ hir::MatchSource::TryDesugar(scrutinee_hir_id)
+ }
Some(DesugaringKind::Await) => hir::MatchSource::AwaitDesugar,
_ => hir::MatchSource::Normal,
};
@@ -277,7 +279,7 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
| hir::MatchSource::FormatArgs => report_arm_reachability(&cx, &report),
// Unreachable patterns in try and await expressions occur when one of
// the arms are an uninhabited type. Which is OK.
- hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar => {}
+ hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar(_) => {}
}
// Check if the match is exhaustive.
@@ -501,12 +503,12 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
let witness_1_is_privately_uninhabited =
if cx.tcx.features().exhaustive_patterns
&& let Some(witness_1) = witnesses.get(0)
- && let ty::Adt(adt, substs) = witness_1.ty().kind()
+ && let ty::Adt(adt, args) = witness_1.ty().kind()
&& adt.is_enum()
&& let Constructor::Variant(variant_index) = witness_1.ctor()
{
let variant = adt.variant(*variant_index);
- let inhabited = variant.inhabited_predicate(cx.tcx, *adt).subst(cx.tcx, substs);
+ let inhabited = variant.inhabited_predicate(cx.tcx, *adt).instantiate(cx.tcx, args);
assert!(inhabited.apply(cx.tcx, cx.param_env, cx.module));
!inhabited.apply_ignore_module(cx.tcx, cx.param_env)
} else {
@@ -691,7 +693,7 @@ fn non_exhaustive_match<'p, 'tcx>(
err = create_e0004(
cx.tcx.sess,
sp,
- format!("non-exhaustive patterns: {} not covered", joined_patterns),
+ format!("non-exhaustive patterns: {joined_patterns} not covered"),
);
err.span_label(sp, pattern_not_covered_label(&witnesses, &joined_patterns));
patterns_len = witnesses.len();
@@ -721,15 +723,13 @@ fn non_exhaustive_match<'p, 'tcx>(
&& matches!(witnesses[0].ctor(), Constructor::NonExhaustive)
{
err.note(format!(
- "`{}` does not have a fixed maximum value, so a wildcard `_` is necessary to match \
+ "`{scrut_ty}` does not have a fixed maximum value, so a wildcard `_` is necessary to match \
exhaustively",
- scrut_ty,
));
if cx.tcx.sess.is_nightly_build() {
err.help(format!(
"add `#![feature(precise_pointer_size_matching)]` to the crate attributes to \
- enable precise `{}` matching",
- scrut_ty,
+ enable precise `{scrut_ty}` matching",
));
}
}
@@ -745,18 +745,13 @@ fn non_exhaustive_match<'p, 'tcx>(
[] if sp.eq_ctxt(expr_span) => {
// Get the span for the empty match body `{}`.
let (indentation, more) = if let Some(snippet) = sm.indentation_before(sp) {
- (format!("\n{}", snippet), " ")
+ (format!("\n{snippet}"), " ")
} else {
(" ".to_string(), "")
};
suggestion = Some((
sp.shrink_to_hi().with_hi(expr_span.hi()),
- format!(
- " {{{indentation}{more}{pattern} => todo!(),{indentation}}}",
- indentation = indentation,
- more = more,
- pattern = pattern,
- ),
+ format!(" {{{indentation}{more}{pattern} => todo!(),{indentation}}}",),
));
}
[only] => {
@@ -765,7 +760,7 @@ fn non_exhaustive_match<'p, 'tcx>(
&& let Ok(with_trailing) = sm.span_extend_while(only.span, |c| c.is_whitespace() || c == ',')
&& sm.is_multiline(with_trailing)
{
- (format!("\n{}", snippet), true)
+ (format!("\n{snippet}"), true)
} else {
(" ".to_string(), false)
};
@@ -780,7 +775,7 @@ fn non_exhaustive_match<'p, 'tcx>(
};
suggestion = Some((
only.span.shrink_to_hi(),
- format!("{}{}{} => todo!()", comma, pre_indentation, pattern),
+ format!("{comma}{pre_indentation}{pattern} => todo!()"),
));
}
[.., prev, last] => {
@@ -803,7 +798,7 @@ fn non_exhaustive_match<'p, 'tcx>(
if let Some(spacing) = spacing {
suggestion = Some((
last.span.shrink_to_hi(),
- format!("{}{}{} => todo!()", comma, spacing, pattern),
+ format!("{comma}{spacing}{pattern} => todo!()"),
));
}
}
@@ -900,7 +895,7 @@ fn adt_defined_here<'p, 'tcx>(
for pat in spans {
span.push_span_label(pat, "not covered");
}
- err.span_note(span, format!("`{}` defined here", ty));
+ err.span_note(span, format!("`{ty}` defined here"));
}
}
@@ -942,7 +937,9 @@ fn maybe_point_at_variant<'a, 'p: 'a, 'tcx: 'a>(
/// This analysis is *not* subsumed by NLL.
fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, '_, 'tcx>, pat: &Pat<'tcx>) {
// Extract `sub` in `binding @ sub`.
- let PatKind::Binding { name, mode, ty, subpattern: Some(box ref sub), .. } = pat.kind else { return };
+ let PatKind::Binding { name, mode, ty, subpattern: Some(box ref sub), .. } = pat.kind else {
+ return;
+ };
let is_binding_by_move = |ty: Ty<'tcx>| !ty.is_copy_modulo_regions(cx.tcx, cx.param_env);
diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
index 050b01294..1376344cf 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
@@ -325,6 +325,11 @@ impl<'tcx> ConstToPat<'tcx> {
// `PartialEq::eq` on it.
return Err(FallbackToConstRef);
}
+ ty::FnDef(..) => {
+ self.saw_const_match_error.set(true);
+ tcx.sess.emit_err(InvalidPattern { span, non_sm_ty: ty });
+ PatKind::Wild
+ }
ty::Adt(adt_def, _) if !self.type_marked_structural(ty) => {
debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty,);
self.saw_const_match_error.set(true);
@@ -332,20 +337,20 @@ impl<'tcx> ConstToPat<'tcx> {
tcx.sess.emit_err(err);
PatKind::Wild
}
- ty::Adt(adt_def, substs) if adt_def.is_enum() => {
+ ty::Adt(adt_def, args) if adt_def.is_enum() => {
let (&variant_index, fields) = cv.unwrap_branch().split_first().unwrap();
let variant_index =
VariantIdx::from_u32(variant_index.unwrap_leaf().try_to_u32().ok().unwrap());
PatKind::Variant {
adt_def: *adt_def,
- substs,
+ args,
variant_index,
subpatterns: self.field_pats(
fields.iter().copied().zip(
adt_def.variants()[variant_index]
.fields
.iter()
- .map(|field| field.ty(self.tcx(), substs)),
+ .map(|field| field.ty(self.tcx(), args)),
),
)?,
}
@@ -354,9 +359,9 @@ impl<'tcx> ConstToPat<'tcx> {
subpatterns: self
.field_pats(cv.unwrap_branch().iter().copied().zip(fields.iter()))?,
},
- ty::Adt(def, substs) => PatKind::Leaf {
+ ty::Adt(def, args) => PatKind::Leaf {
subpatterns: self.field_pats(cv.unwrap_branch().iter().copied().zip(
- def.non_enum_variant().fields.iter().map(|field| field.ty(self.tcx(), substs)),
+ def.non_enum_variant().fields.iter().map(|field| field.ty(self.tcx(), args)),
))?,
},
ty::Slice(elem_ty) => PatKind::Slice {
@@ -440,7 +445,7 @@ impl<'tcx> ConstToPat<'tcx> {
}
}
},
- ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::FnDef(..) => PatKind::Constant {
+ ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) => PatKind::Constant {
value: mir::ConstantKind::Ty(ty::Const::new_value(tcx, cv, ty)),
},
ty::FnPtr(..) | ty::RawPtr(..) => unreachable!(),
diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
index 9df6d2f43..bee1c4e46 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
@@ -306,9 +306,9 @@ impl fmt::Debug for IntRange {
let (lo, hi) = self.boundaries();
let bias = self.bias;
let (lo, hi) = (lo ^ bias, hi ^ bias);
- write!(f, "{}", lo)?;
+ write!(f, "{lo}")?;
write!(f, "{}", RangeEnd::Included)?;
- write!(f, "{}", hi)
+ write!(f, "{hi}")
}
}
@@ -922,7 +922,7 @@ impl<'tcx> SplitWildcard<'tcx> {
let kind = if cx.is_uninhabited(*sub_ty) { FixedLen(0) } else { VarLen(0, 0) };
smallvec![Slice(Slice::new(None, kind))]
}
- ty::Adt(def, substs) if def.is_enum() => {
+ ty::Adt(def, args) if def.is_enum() => {
// If the enum is declared as `#[non_exhaustive]`, we treat it as if it had an
// additional "unknown" constructor.
// There is no point in enumerating all possible variants, because the user can't
@@ -950,21 +950,19 @@ impl<'tcx> SplitWildcard<'tcx> {
let is_secretly_empty =
def.variants().is_empty() && !is_exhaustive_pat_feature && !pcx.is_top_level;
- let mut ctors: SmallVec<[_; 1]> = def
- .variants()
- .iter_enumerated()
- .filter(|(_, v)| {
- // If `exhaustive_patterns` is enabled, we exclude variants known to be
- // uninhabited.
- !is_exhaustive_pat_feature
- || v.inhabited_predicate(cx.tcx, *def).subst(cx.tcx, substs).apply(
- cx.tcx,
- cx.param_env,
- cx.module,
- )
- })
- .map(|(idx, _)| Variant(idx))
- .collect();
+ let mut ctors: SmallVec<[_; 1]> =
+ def.variants()
+ .iter_enumerated()
+ .filter(|(_, v)| {
+ // If `exhaustive_patterns` is enabled, we exclude variants known to be
+ // uninhabited.
+ !is_exhaustive_pat_feature
+ || v.inhabited_predicate(cx.tcx, *def)
+ .instantiate(cx.tcx, args)
+ .apply(cx.tcx, cx.param_env, cx.module)
+ })
+ .map(|(idx, _)| Variant(idx))
+ .collect();
if is_secretly_empty || is_declared_nonexhaustive {
ctors.push(NonExhaustive);
@@ -1156,12 +1154,12 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
ty: Ty<'tcx>,
variant: &'a VariantDef,
) -> impl Iterator<Item = (FieldIdx, Ty<'tcx>)> + Captures<'a> + Captures<'p> {
- let ty::Adt(adt, substs) = ty.kind() else { bug!() };
+ let ty::Adt(adt, args) = ty.kind() else { bug!() };
// Whether we must not match the fields of this variant exhaustively.
let is_non_exhaustive = variant.is_field_list_non_exhaustive() && !adt.did().is_local();
variant.fields.iter().enumerate().filter_map(move |(i, field)| {
- let ty = field.ty(cx.tcx, substs);
+ let ty = field.ty(cx.tcx, args);
// `field.ty()` doesn't normalize after substituting.
let ty = cx.tcx.normalize_erasing_regions(cx.param_env, ty);
let is_visible = adt.is_enum() || field.vis.is_accessible_from(cx.module, cx.tcx);
@@ -1183,11 +1181,11 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
Single | Variant(_) => match pcx.ty.kind() {
ty::Tuple(fs) => Fields::wildcards_from_tys(pcx.cx, fs.iter(), pcx.span),
ty::Ref(_, rty, _) => Fields::wildcards_from_tys(pcx.cx, once(*rty), pcx.span),
- ty::Adt(adt, substs) => {
+ ty::Adt(adt, args) => {
if adt.is_box() {
// The only legal patterns of type `Box` (outside `std`) are `_` and box
// patterns. If we're here we can assume this is a box pattern.
- Fields::wildcards_from_tys(pcx.cx, once(substs.type_at(0)), pcx.span)
+ Fields::wildcards_from_tys(pcx.cx, once(args.type_at(0)), pcx.span)
} else {
let variant = &adt.variant(constructor.variant_index_for_adt(*adt));
let tys = Fields::list_variant_nonhidden_fields(pcx.cx, pcx.ty, variant)
@@ -1294,7 +1292,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
}
fields = Fields::from_iter(cx, wilds);
}
- ty::Adt(adt, substs) if adt.is_box() => {
+ ty::Adt(adt, args) if adt.is_box() => {
// The only legal patterns of type `Box` (outside `std`) are `_` and box
// patterns. If we're here we can assume this is a box pattern.
// FIXME(Nadrieril): A `Box` can in theory be matched either with `Box(_,
@@ -1311,7 +1309,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
let pat = if let Some(pat) = pattern {
mkpat(&pat.pattern)
} else {
- DeconstructedPat::wildcard(substs.type_at(0), pat.span)
+ DeconstructedPat::wildcard(args.type_at(0), pat.span)
};
ctor = Single;
fields = Fields::singleton(cx, pat);
@@ -1437,7 +1435,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
// the pattern is a box pattern.
PatKind::Deref { subpattern: subpatterns.next().unwrap() }
}
- ty::Adt(adt_def, substs) => {
+ ty::Adt(adt_def, args) => {
let variant_index = self.ctor.variant_index_for_adt(*adt_def);
let variant = &adt_def.variant(variant_index);
let subpatterns = Fields::list_variant_nonhidden_fields(cx, self.ty, variant)
@@ -1446,7 +1444,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
.collect();
if adt_def.is_enum() {
- PatKind::Variant { adt_def: *adt_def, substs, variant_index, subpatterns }
+ PatKind::Variant { adt_def: *adt_def, args, variant_index, subpatterns }
} else {
PatKind::Leaf { subpatterns }
}
@@ -1621,7 +1619,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
// of `std`). So this branch is only reachable when the feature is enabled and
// the pattern is a box pattern.
let subpattern = self.iter_fields().next().unwrap();
- write!(f, "box {:?}", subpattern)
+ write!(f, "box {subpattern:?}")
}
ty::Adt(..) | ty::Tuple(..) => {
let variant = match self.ty.kind() {
@@ -1640,7 +1638,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
write!(f, "(")?;
for p in self.iter_fields() {
write!(f, "{}", start_or_comma())?;
- write!(f, "{:?}", p)?;
+ write!(f, "{p:?}")?;
}
write!(f, ")")
}
@@ -1676,11 +1674,11 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
write!(f, "]")
}
&FloatRange(lo, hi, end) => {
- write!(f, "{}", lo)?;
- write!(f, "{}", end)?;
- write!(f, "{}", hi)
+ write!(f, "{lo}")?;
+ write!(f, "{end}")?;
+ write!(f, "{hi}")
}
- IntRange(range) => write!(f, "{:?}", range), // Best-effort, will render e.g. `false` as `0..=0`
+ IntRange(range) => write!(f, "{range:?}"), // Best-effort, will render e.g. `false` as `0..=0`
Wildcard | Missing { .. } | NonExhaustive => write!(f, "_ : {:?}", self.ty),
Or => {
for pat in self.iter_fields() {
@@ -1688,7 +1686,7 @@ impl<'p, 'tcx> fmt::Debug for DeconstructedPat<'p, 'tcx> {
}
Ok(())
}
- Str(value) => write!(f, "{}", value),
+ Str(value) => write!(f, "{value}"),
Opaque => write!(f, "<constant pattern>"),
}
}
diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs
index 600995927..c08fe54c3 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs
@@ -23,10 +23,10 @@ use rustc_middle::mir::interpret::{
use rustc_middle::mir::{self, ConstantKind, UserTypeProjection};
use rustc_middle::mir::{BorrowKind, Mutability};
use rustc_middle::thir::{Ascription, BindingMode, FieldPat, LocalVarId, Pat, PatKind, PatRange};
-use rustc_middle::ty::subst::{GenericArg, SubstsRef};
use rustc_middle::ty::CanonicalUserTypeAnnotation;
use rustc_middle::ty::TypeVisitableExt;
use rustc_middle::ty::{self, AdtDef, Region, Ty, TyCtxt, UserType};
+use rustc_middle::ty::{GenericArg, GenericArgsRef};
use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx;
@@ -416,8 +416,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
let enum_id = self.tcx.parent(variant_id);
let adt_def = self.tcx.adt_def(enum_id);
if adt_def.is_enum() {
- let substs = match ty.kind() {
- ty::Adt(_, substs) | ty::FnDef(_, substs) => substs,
+ let args = match ty.kind() {
+ ty::Adt(_, args) | ty::FnDef(_, args) => args,
ty::Error(_) => {
// Avoid ICE (#50585)
return PatKind::Wild;
@@ -426,7 +426,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
};
PatKind::Variant {
adt_def,
- substs,
+ args,
variant_index: adt_def.variant_index_with_id(variant_id),
subpatterns,
}
@@ -439,7 +439,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
DefKind::Struct
| DefKind::Ctor(CtorOf::Struct, ..)
| DefKind::Union
- | DefKind::TyAlias
+ | DefKind::TyAlias { .. }
| DefKind::AssocTy,
_,
)
@@ -460,7 +460,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
}
};
- if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) {
+ if let Some(user_ty) = self.user_args_applied_to_ty_of_hir_id(hir_id) {
debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span);
let annotation = CanonicalUserTypeAnnotation {
user_ty: Box::new(user_ty),
@@ -496,13 +496,13 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
// Use `Reveal::All` here because patterns are always monomorphic even if their function
// isn't.
let param_env_reveal_all = self.param_env.with_reveal_all_normalized(self.tcx);
- // N.B. There is no guarantee that substs collected in typeck results are fully normalized,
+ // N.B. There is no guarantee that args collected in typeck results are fully normalized,
// so they need to be normalized in order to pass to `Instance::resolve`, which will ICE
// if given unnormalized types.
- let substs = self
+ let args = self
.tcx
- .normalize_erasing_regions(param_env_reveal_all, self.typeck_results.node_substs(id));
- let instance = match ty::Instance::resolve(self.tcx, param_env_reveal_all, def_id, substs) {
+ .normalize_erasing_regions(param_env_reveal_all, self.typeck_results.node_args(id));
+ let instance = match ty::Instance::resolve(self.tcx, param_env_reveal_all, def_id, args) {
Ok(Some(i)) => i,
Ok(None) => {
// It should be assoc consts if there's no error but we cannot resolve it.
@@ -617,16 +617,14 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
}
let typeck_root_def_id = tcx.typeck_root_def_id(def_id.to_def_id());
- let parent_substs =
- tcx.erase_regions(ty::InternalSubsts::identity_for_item(tcx, typeck_root_def_id));
- let substs =
- ty::InlineConstSubsts::new(tcx, ty::InlineConstSubstsParts { parent_substs, ty })
- .substs;
+ let parent_args =
+ tcx.erase_regions(ty::GenericArgs::identity_for_item(tcx, typeck_root_def_id));
+ let args = ty::InlineConstArgs::new(tcx, ty::InlineConstArgsParts { parent_args, ty }).args;
- let uneval = mir::UnevaluatedConst { def: def_id.to_def_id(), substs, promoted: None };
- debug_assert!(!substs.has_free_regions());
+ let uneval = mir::UnevaluatedConst { def: def_id.to_def_id(), args, promoted: None };
+ debug_assert!(!args.has_free_regions());
- let ct = ty::UnevaluatedConst { def: def_id.to_def_id(), substs: substs };
+ let ct = ty::UnevaluatedConst { def: def_id.to_def_id(), args: args };
// First try using a valtree in order to destructure the constant into a pattern.
if let Ok(Some(valtree)) =
self.tcx.const_eval_resolve_for_typeck(self.param_env, ct, Some(span))
@@ -754,7 +752,7 @@ macro_rules! ClonePatternFoldableImpls {
ClonePatternFoldableImpls! { <'tcx>
Span, FieldIdx, Mutability, Symbol, LocalVarId, usize,
Region<'tcx>, Ty<'tcx>, BindingMode, AdtDef<'tcx>,
- SubstsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>,
+ GenericArgsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>,
UserTypeProjection, CanonicalUserTypeAnnotation<'tcx>
}
@@ -804,10 +802,10 @@ impl<'tcx> PatternFoldable<'tcx> for PatKind<'tcx> {
is_primary,
}
}
- PatKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
+ PatKind::Variant { adt_def, args, variant_index, ref subpatterns } => {
PatKind::Variant {
adt_def: adt_def.fold_with(folder),
- substs: substs.fold_with(folder),
+ args: args.fold_with(folder),
variant_index,
subpatterns: subpatterns.fold_with(folder),
}
diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
index e5b635069..08cfe98bb 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
@@ -459,7 +459,7 @@ impl<'p, 'tcx> fmt::Debug for PatStack<'p, 'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "+")?;
for pat in self.iter() {
- write!(f, " {:?} +", pat)?;
+ write!(f, " {pat:?} +")?;
}
Ok(())
}
@@ -530,7 +530,7 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> {
let Matrix { patterns: m, .. } = self;
let pretty_printed_matrix: Vec<Vec<String>> =
- m.iter().map(|row| row.iter().map(|pat| format!("{:?}", pat)).collect()).collect();
+ m.iter().map(|row| row.iter().map(|pat| format!("{pat:?}")).collect()).collect();
let column_count = m.iter().map(|row| row.len()).next().unwrap_or(0);
assert!(m.iter().all(|row| row.len() == column_count));
diff --git a/compiler/rustc_mir_build/src/thir/print.rs b/compiler/rustc_mir_build/src/thir/print.rs
index 8d7c624a8..3b6276cfe 100644
--- a/compiler/rustc_mir_build/src/thir/print.rs
+++ b/compiler/rustc_mir_build/src/thir/print.rs
@@ -321,7 +321,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
print_indented!(self, format!("pat: {:?}", pat), depth_lvl + 1);
print_indented!(self, "}", depth_lvl);
}
- Match { scrutinee, arms } => {
+ Match { scrutinee, arms, .. } => {
print_indented!(self, "Match {", depth_lvl);
print_indented!(self, "scrutinee:", depth_lvl + 1);
self.print_expr(*scrutinee, depth_lvl + 2);
@@ -427,10 +427,10 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
self.print_expr(*value, depth_lvl + 2);
print_indented!(self, "}", depth_lvl);
}
- ConstBlock { did, substs } => {
+ ConstBlock { did, args } => {
print_indented!(self, "ConstBlock {", depth_lvl);
print_indented!(self, format!("did: {:?}", did), depth_lvl + 1);
- print_indented!(self, format!("substs: {:?}", substs), depth_lvl + 1);
+ print_indented!(self, format!("args: {:?}", args), depth_lvl + 1);
print_indented!(self, "}", depth_lvl);
}
Repeat { value, count } => {
@@ -499,11 +499,11 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
ZstLiteral { user_ty } => {
print_indented!(self, format!("ZstLiteral(user_ty: {:?})", user_ty), depth_lvl);
}
- NamedConst { def_id, substs, user_ty } => {
+ NamedConst { def_id, args, user_ty } => {
print_indented!(self, "NamedConst {", depth_lvl);
print_indented!(self, format!("def_id: {:?}", def_id), depth_lvl + 1);
print_indented!(self, format!("user_ty: {:?}", user_ty), depth_lvl + 1);
- print_indented!(self, format!("substs: {:?}", substs), depth_lvl + 1);
+ print_indented!(self, format!("args: {:?}", args), depth_lvl + 1);
print_indented!(self, "}", depth_lvl);
}
ConstParam { param, def_id } => {
@@ -560,7 +560,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
format!("variant_index: {:?}", adt_expr.variant_index),
depth_lvl + 1
);
- print_indented!(self, format!("substs: {:?}", adt_expr.substs), depth_lvl + 1);
+ print_indented!(self, format!("args: {:?}", adt_expr.args), depth_lvl + 1);
print_indented!(self, format!("user_ty: {:?}", adt_expr.user_ty), depth_lvl + 1);
for (i, field_expr) in adt_expr.fields.iter().enumerate() {
@@ -662,11 +662,11 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
print_indented!(self, "}", depth_lvl + 1);
}
- PatKind::Variant { adt_def, substs, variant_index, subpatterns } => {
+ PatKind::Variant { adt_def, args, variant_index, subpatterns } => {
print_indented!(self, "Variant {", depth_lvl + 1);
print_indented!(self, "adt_def: ", depth_lvl + 2);
self.print_adt_def(*adt_def, depth_lvl + 3);
- print_indented!(self, format!("substs: {:?}", substs), depth_lvl + 2);
+ print_indented!(self, format!("args: {:?}", args), depth_lvl + 2);
print_indented!(self, format!("variant_index: {:?}", variant_index), depth_lvl + 2);
if subpatterns.len() > 0 {
@@ -784,11 +784,11 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
}
fn print_closure_expr(&mut self, expr: &ClosureExpr<'tcx>, depth_lvl: usize) {
- let ClosureExpr { closure_id, substs, upvars, movability, fake_reads } = expr;
+ let ClosureExpr { closure_id, args, upvars, movability, fake_reads } = expr;
print_indented!(self, "ClosureExpr {", depth_lvl);
print_indented!(self, format!("closure_id: {:?}", closure_id), depth_lvl + 1);
- print_indented!(self, format!("substs: {:?}", substs), depth_lvl + 1);
+ print_indented!(self, format!("args: {:?}", args), depth_lvl + 1);
if upvars.len() > 0 {
print_indented!(self, "upvars: [", depth_lvl + 1);
diff --git a/compiler/rustc_mir_build/src/thir/util.rs b/compiler/rustc_mir_build/src/thir/util.rs
index c58ed1ac0..9106b4d33 100644
--- a/compiler/rustc_mir_build/src/thir/util.rs
+++ b/compiler/rustc_mir_build/src/thir/util.rs
@@ -9,7 +9,7 @@ pub(crate) trait UserAnnotatedTyHelpers<'tcx> {
/// Looks up the type associated with this hir-id and applies the
/// user-given substitutions; the hir-id must map to a suitable
/// type.
- fn user_substs_applied_to_ty_of_hir_id(
+ fn user_args_applied_to_ty_of_hir_id(
&self,
hir_id: hir::HirId,
) -> Option<CanonicalUserType<'tcx>> {