1
Fork 0

Address review comments.

This commit is contained in:
Nicholas Nethercote 2025-04-10 09:39:21 +10:00
parent 1b3fc585cb
commit 663a317c20
6 changed files with 11 additions and 8 deletions

View file

@ -2500,7 +2500,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
); );
let ty::Tuple(params) = tupled_params.kind() else { return }; let ty::Tuple(params) = tupled_params.kind() else { return };
// Find the first argument with a matching type, get its ident // Find the first argument with a matching type and get its identifier.
let Some(this_name) = params.iter().zip(tcx.hir_body_param_idents(closure.body)).find_map( let Some(this_name) = params.iter().zip(tcx.hir_body_param_idents(closure.body)).find_map(
|(param_ty, ident)| { |(param_ty, ident)| {
// FIXME: also support deref for stuff like `Rc` arguments // FIXME: also support deref for stuff like `Rc` arguments

View file

@ -1169,7 +1169,7 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
collector.cx.dcx().emit_err(RemoveNodeNotSupported { span, descr: Self::descr() }); collector.cx.dcx().emit_err(RemoveNodeNotSupported { span, descr: Self::descr() });
} }
/// All of the idents (items) declared by this node. /// All of the identifiers (items) declared by this node.
/// This is an approximation and should only be used for diagnostics. /// This is an approximation and should only be used for diagnostics.
fn declared_idents(&self) -> Vec<Ident> { fn declared_idents(&self) -> Vec<Ident> {
vec![] vec![]

View file

@ -3399,7 +3399,7 @@ pub struct BareFnTy<'hir> {
pub abi: ExternAbi, pub abi: ExternAbi,
pub generic_params: &'hir [GenericParam<'hir>], pub generic_params: &'hir [GenericParam<'hir>],
pub decl: &'hir FnDecl<'hir>, pub decl: &'hir FnDecl<'hir>,
// `Option` because bare fn parameter idents are optional. We also end up // `Option` because bare fn parameter identifiers are optional. We also end up
// with `None` in some error cases, e.g. invalid parameter patterns. // with `None` in some error cases, e.g. invalid parameter patterns.
pub param_idents: &'hir [Option<Ident>], pub param_idents: &'hir [Option<Ident>],
} }

View file

@ -1436,7 +1436,7 @@ rustc_queries! {
} }
query fn_arg_idents(def_id: DefId) -> &'tcx [Option<rustc_span::Ident>] { query fn_arg_idents(def_id: DefId) -> &'tcx [Option<rustc_span::Ident>] {
desc { |tcx| "looking up function parameter idents for `{}`", tcx.def_path_str(def_id) } desc { |tcx| "looking up function parameter identifiers for `{}`", tcx.def_path_str(def_id) }
separate_provide_extern separate_provide_extern
} }

View file

@ -199,7 +199,8 @@ impl AssocItems {
self.items.get_by_key(name) self.items.get_by_key(name)
} }
/// Returns the associated item with the given ident and `AssocKind`, if one exists. /// Returns the associated item with the given identifier and `AssocKind`, if one exists.
/// The identifier is matched hygienically.
pub fn find_by_ident_and_kind( pub fn find_by_ident_and_kind(
&self, &self,
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
@ -212,7 +213,8 @@ impl AssocItems {
.find(|item| tcx.hygienic_eq(ident, item.ident(tcx), parent_def_id)) .find(|item| tcx.hygienic_eq(ident, item.ident(tcx), parent_def_id))
} }
/// Returns the associated item with the given ident and any of `AssocKind`, if one exists. /// Returns the associated item with the given identifier and any of `AssocKind`, if one
/// exists. The identifier is matched hygienically.
pub fn find_by_ident_and_kinds( pub fn find_by_ident_and_kinds(
&self, &self,
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
@ -224,7 +226,8 @@ impl AssocItems {
kinds.iter().find_map(|kind| self.find_by_ident_and_kind(tcx, ident, *kind, parent_def_id)) kinds.iter().find_map(|kind| self.find_by_ident_and_kind(tcx, ident, *kind, parent_def_id))
} }
/// Returns the associated item with the given ident in the given `Namespace`, if one exists. /// Returns the associated item with the given identifier in the given `Namespace`, if one
/// exists. The identifier is matched hygienically.
pub fn find_by_ident_and_namespace( pub fn find_by_ident_and_namespace(
&self, &self,
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,

View file

@ -1940,7 +1940,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// its supposed definition name (`def_name`). The method also needs `DefId` of the supposed /// its supposed definition name (`def_name`). The method also needs `DefId` of the supposed
/// definition's parent/scope to perform comparison. /// definition's parent/scope to perform comparison.
pub fn hygienic_eq(self, use_ident: Ident, def_ident: Ident, def_parent_def_id: DefId) -> bool { pub fn hygienic_eq(self, use_ident: Ident, def_ident: Ident, def_parent_def_id: DefId) -> bool {
// We could use `Ident::eq` here, but we deliberately don't. The ident // We could use `Ident::eq` here, but we deliberately don't. The identifier
// comparison fails frequently, and we want to avoid the expensive // comparison fails frequently, and we want to avoid the expensive
// `normalize_to_macros_2_0()` calls required for the span comparison whenever possible. // `normalize_to_macros_2_0()` calls required for the span comparison whenever possible.
use_ident.name == def_ident.name use_ident.name == def_ident.name