10876: fix: Show parameter hints unconditionally for logical not expressions r=Veykril a=Veykril

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8491
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-11-27 18:14:59 +00:00 committed by GitHub
commit d9b2291f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,10 @@
use either::Either;
use hir::{known, Callable, HasVisibility, HirDisplay, Semantics, TypeInfo};
use ide_db::RootDatabase;
use ide_db::{base_db::FileRange, helpers::FamousDefs};
use ide_db::{base_db::FileRange, helpers::FamousDefs, RootDatabase};
use itertools::Itertools;
use stdx::to_lower_snake_case;
use syntax::{
ast::{self, AstNode, HasArgList, HasName},
ast::{self, AstNode, HasArgList, HasName, UnaryOp},
match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T,
};
@ -421,6 +420,10 @@ fn should_hide_param_name_hint(
return true;
}
if matches!(argument, ast::Expr::PrefixExpr(prefix) if prefix.op_kind() == Some(UnaryOp::Not)) {
return false;
}
let fn_name = match callable.kind() {
hir::CallableKind::Function(it) => Some(it.name(sema.db).to_smol_str()),
_ => None,
@ -868,7 +871,8 @@ fn non_ident_pat((a, b): (u32, u32)) {}
fn main() {
const PARAM: u32 = 0;
foo(PARAM);
foo(!PARAM);
// ^^^^^^ param
check("");
map(0);