mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
diagnostic to remove trailing return
This commit is contained in:
parent
e07183461f
commit
2987fac76f
5 changed files with 318 additions and 2 deletions
|
@ -68,6 +68,7 @@ diagnostics![
|
|||
PrivateAssocItem,
|
||||
PrivateField,
|
||||
ReplaceFilterMapNextWithFindMap,
|
||||
RemoveTrailingReturn,
|
||||
RemoveUnnecessaryElse,
|
||||
TraitImplIncorrectSafety,
|
||||
TraitImplMissingAssocItems,
|
||||
|
@ -343,6 +344,12 @@ pub struct TraitImplRedundantAssocItems {
|
|||
pub assoc_item: (Name, AssocItem),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RemoveTrailingReturn {
|
||||
pub file_id: HirFileId,
|
||||
pub return_expr: AstPtr<ast::Expr>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RemoveUnnecessaryElse {
|
||||
pub if_expr: InFile<AstPtr<ast::IfExpr>>,
|
||||
|
@ -450,6 +457,17 @@ impl AnyDiagnostic {
|
|||
Err(SyntheticSyntax) => (),
|
||||
}
|
||||
}
|
||||
BodyValidationDiagnostic::RemoveTrailingReturn { return_expr } => {
|
||||
if let Ok(source_ptr) = source_map.expr_syntax(return_expr) {
|
||||
return Some(
|
||||
RemoveTrailingReturn {
|
||||
file_id: source_ptr.file_id,
|
||||
return_expr: source_ptr.value,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
BodyValidationDiagnostic::RemoveUnnecessaryElse { if_expr } => {
|
||||
if let Ok(source_ptr) = source_map.expr_syntax(if_expr) {
|
||||
if let Some(ptr) = source_ptr.value.cast::<ast::IfExpr>() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue