diff options
-rw-r--r-- | crates/ide/src/inlay_hints.rs | 29 | ||||
-rw-r--r-- | docs/user/manual.adoc | 7 |
2 files changed, 35 insertions, 1 deletions
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index cccea129a..49d8e4ae1 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs | |||
@@ -378,7 +378,11 @@ fn is_enum_name_similar_to_param_name( | |||
378 | fn get_string_representation(expr: &ast::Expr) -> Option<String> { | 378 | fn get_string_representation(expr: &ast::Expr) -> Option<String> { |
379 | match expr { | 379 | match expr { |
380 | ast::Expr::MethodCallExpr(method_call_expr) => { | 380 | ast::Expr::MethodCallExpr(method_call_expr) => { |
381 | Some(method_call_expr.name_ref()?.to_string()) | 381 | let name_ref = method_call_expr.name_ref()?; |
382 | match name_ref.text().as_str() { | ||
383 | "clone" => method_call_expr.receiver().map(|rec| rec.to_string()), | ||
384 | name_ref => Some(name_ref.to_owned()), | ||
385 | } | ||
382 | } | 386 | } |
383 | ast::Expr::RefExpr(ref_expr) => get_string_representation(&ref_expr.expr()?), | 387 | ast::Expr::RefExpr(ref_expr) => get_string_representation(&ref_expr.expr()?), |
384 | _ => Some(expr.to_string()), | 388 | _ => Some(expr.to_string()), |
@@ -1208,4 +1212,27 @@ fn main() { | |||
1208 | "#, | 1212 | "#, |
1209 | ); | 1213 | ); |
1210 | } | 1214 | } |
1215 | |||
1216 | #[test] | ||
1217 | fn hide_param_hints_for_clones() { | ||
1218 | check_with_config( | ||
1219 | InlayHintsConfig { | ||
1220 | parameter_hints: true, | ||
1221 | type_hints: false, | ||
1222 | chaining_hints: false, | ||
1223 | max_length: None, | ||
1224 | }, | ||
1225 | r#" | ||
1226 | fn foo(bar: i32, baz: String, qux: f32) {} | ||
1227 | |||
1228 | fn main() { | ||
1229 | let bar = 3; | ||
1230 | let baz = &"baz"; | ||
1231 | let fez = 1.0; | ||
1232 | foo(bar.clone(), baz.clone(), fez.clone()); | ||
1233 | //^^^^^^^^^^^ qux | ||
1234 | } | ||
1235 | "#, | ||
1236 | ); | ||
1237 | } | ||
1211 | } | 1238 | } |
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc index 7e8adcdb7..b9d907a4a 100644 --- a/docs/user/manual.adoc +++ b/docs/user/manual.adoc | |||
@@ -366,6 +366,13 @@ Cursor position or selection is signified by `┃` character. | |||
366 | 366 | ||
367 | include::./generated_assists.adoc[] | 367 | include::./generated_assists.adoc[] |
368 | 368 | ||
369 | == Diagnostics | ||
370 | |||
371 | While most errors and warnings provided by rust-analyzer come from the `cargo check` integration, there's a growing number of diagnostics implemented using rust-analyzer's own analysis. | ||
372 | These diagnostics don't respect `#[allow]` or `#[deny]` attributes yet, but can be turned off using the `rust-analyzer.diagnostics.enable`, `rust-analyzer.diagnostics.enableExperimental` or `rust-analyzer.diagnostics.disabled` settings. | ||
373 | |||
374 | include::./generated_diagnostic.adoc[] | ||
375 | |||
369 | == Editor Features | 376 | == Editor Features |
370 | === VS Code | 377 | === VS Code |
371 | 378 | ||