From: Lukas Wirth Date: Sat, 27 Nov 2021 18:12:47 +0000 (+0100) Subject: fix: Show parameter hints unconditionally for logical not expressions X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=76022bfd60bfc9a7e8f4f0971ef09d3e25563dd2;p=rust.git fix: Show parameter hints unconditionally for logical not expressions --- diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 985d3a4ecca..b479a20beb0 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -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);