Skip to content

fix: Remove a redundant <never-to-any> from adjustment hints for let-else #13765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions crates/ide/src/inlay_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,20 @@ fn adjustment_hints(
}

let parent = expr.syntax().parent().and_then(ast::Expr::cast);

// If this is a tail expression in the let-else, suppress the hints
if let Some(stmt_list) = expr.syntax().parent().and_then(ast::StmtList::cast) {
if let Some(block) = stmt_list.syntax().parent().and_then(ast::BlockExpr::cast) {
if block.syntax().parent().and_then(ast::LetElse::cast).is_some() {
if let Some(tail) = block.tail_expr() {
if &tail == expr {
return None;
}
}
}
}
}

let descended = sema.descend_node_into_attributes(expr.clone()).pop();
let desc_expr = descended.as_ref().unwrap_or(expr);
let adjustments = sema.expr_adjustments(desc_expr).filter(|it| !it.is_empty())?;
Expand Down Expand Up @@ -3114,6 +3128,9 @@ fn main() {
//^^^^^^^<unsize>
//^^^^^^^&mut $
//^^^^^^^*

// Check that let-else doesn't produce <never-to-any>
let () = () else { return };
}

#[derive(Copy, Clone)]
Expand Down