-
-
Notifications
You must be signed in to change notification settings - Fork 931
Closed
Labels
C-enhancementCategory - New feature or requestCategory - New feature or request
Description
I tried to introduce new methods in PR #5491 , but encountered:
pub fn get_function_like_declaration<'b>(
node: &AstNode<'b>,
ctx: &LintContext<'b>,
) -> Option<&'b BindingIdentifier<'b>> {
let parent = outermost_paren_parent(node, ctx)?;
if let AstKind::VariableDeclarator(decl) = parent.kind() {
let ident = decl.id.get_binding_identifier()?;
Some(ident)
} else {
None
}
}to
pub fn get_function_like_declaration<'b>(
node: &AstNode<'b>,
ctx: &LintContext<'b>,
) -> Option<&'b BindingIdentifier<'b>> {
let parent = outermost_paren_parent(node, ctx)?;
let decl = parent.kind().as_variable_declarator()?;
let ident = decl.id.get_binding_identifier()?;
Some(ident)
}error:
temporary value created hererustc[E0515](https://doc.rust-lang.org/error-index.html#E0515)
ast_util.rs(436, 5): original diagnostic
// size = 8, align = 0x8
let parent: &AstNode<'_>When I changed the method to the following, there was no longer this problem.
pub fn as_variable_declarator(self) -> Option<&'a VariableDeclarator<'a>> {
if let Self::VariableDeclarator(v) = self {
Some(v)
} else {
None
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-enhancementCategory - New feature or requestCategory - New feature or request
Type
Fields
Give feedbackPriority
None yet