mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Use Arena inside hir::TraitMethod.
This commit is contained in:
parent
deac631d7f
commit
66f9198047
@ -850,7 +850,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
|||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
walk_list!(visitor, visit_nested_body, default);
|
walk_list!(visitor, visit_nested_body, default);
|
||||||
}
|
}
|
||||||
TraitItemKind::Method(ref sig, TraitMethod::Required(ref param_names)) => {
|
TraitItemKind::Method(ref sig, TraitMethod::Required(param_names)) => {
|
||||||
visitor.visit_id(trait_item.hir_id);
|
visitor.visit_id(trait_item.hir_id);
|
||||||
visitor.visit_fn_decl(&sig.decl);
|
visitor.visit_fn_decl(&sig.decl);
|
||||||
for ¶m_name in param_names {
|
for ¶m_name in param_names {
|
||||||
|
@ -787,6 +787,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||||||
}
|
}
|
||||||
AssocItemKind::Fn(ref sig, None) => {
|
AssocItemKind::Fn(ref sig, None) => {
|
||||||
let names = self.lower_fn_params_to_names(&sig.decl);
|
let names = self.lower_fn_params_to_names(&sig.decl);
|
||||||
|
let names: &[Ident] = self.arena.alloc_from_iter(names.into_iter());
|
||||||
let (generics, sig) =
|
let (generics, sig) =
|
||||||
self.lower_method_sig(&i.generics, sig, trait_item_def_id, false, None);
|
self.lower_method_sig(&i.generics, sig, trait_item_def_id, false, None);
|
||||||
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
|
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
|
||||||
|
@ -1946,9 +1946,9 @@ pub struct TraitItem<'hir> {
|
|||||||
|
|
||||||
/// Represents a trait method's body (or just argument names).
|
/// Represents a trait method's body (or just argument names).
|
||||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||||
pub enum TraitMethod {
|
pub enum TraitMethod<'hir> {
|
||||||
/// No default body in the trait, just a signature.
|
/// No default body in the trait, just a signature.
|
||||||
Required(HirVec<Ident>),
|
Required(&'hir [Ident]),
|
||||||
|
|
||||||
/// Both signature and body are provided in the trait.
|
/// Both signature and body are provided in the trait.
|
||||||
Provided(BodyId),
|
Provided(BodyId),
|
||||||
@ -1960,7 +1960,7 @@ pub enum TraitItemKind<'hir> {
|
|||||||
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
|
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
|
||||||
Const(&'hir Ty, Option<BodyId>),
|
Const(&'hir Ty, Option<BodyId>),
|
||||||
/// A method with an optional body.
|
/// A method with an optional body.
|
||||||
Method(FnSig<'hir>, TraitMethod),
|
Method(FnSig<'hir>, TraitMethod<'hir>),
|
||||||
/// An associated type with (possibly empty) bounds and optional concrete
|
/// An associated type with (possibly empty) bounds and optional concrete
|
||||||
/// type.
|
/// type.
|
||||||
Type(GenericBounds, Option<&'hir Ty>),
|
Type(GenericBounds, Option<&'hir Ty>),
|
||||||
|
@ -336,7 +336,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem<'_>) {
|
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem<'_>) {
|
||||||
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.kind {
|
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = item.kind {
|
||||||
self.check_snake_case(cx, "trait method", &item.ident);
|
self.check_snake_case(cx, "trait method", &item.ident);
|
||||||
for param_name in pnames {
|
for param_name in pnames {
|
||||||
self.check_snake_case(cx, "variable", param_name);
|
self.check_snake_case(cx, "variable", param_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user