Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions crates/ide/src/inlay_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ pub struct InlayHintsConfig<'a> {
pub implied_dyn_trait_hints: bool,
pub lifetime_elision_hints: LifetimeElisionHints,
pub param_names_for_lifetime_elision_hints: bool,
pub hide_inferred_type_hints: bool,
pub hide_named_constructor_hints: bool,
pub hide_closure_initialization_hints: bool,
pub hide_closure_parameter_hints: bool,
Expand Down Expand Up @@ -900,6 +901,7 @@ mod tests {
adjustment_hints_mode: AdjustmentHintsMode::Prefix,
adjustment_hints_hide_outside_unsafe: false,
binding_mode_hints: false,
hide_inferred_type_hints: false,
hide_named_constructor_hints: false,
hide_closure_initialization_hints: false,
hide_closure_parameter_hints: false,
Expand Down
20 changes: 19 additions & 1 deletion crates/ide/src/inlay_hints/placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(super) fn type_hints(
display_target: DisplayTarget,
placeholder: InferType,
) -> Option<()> {
if !config.type_hints {
if !config.type_hints || config.hide_inferred_type_hints {
return None;
}

Expand Down Expand Up @@ -73,4 +73,22 @@ fn foo() {
"#,
);
}

#[test]
fn hide_inferred_types() {
check_with_config(
InlayHintsConfig {
type_hints: true,
hide_inferred_type_hints: true,
..DISABLED_CONFIG
},
r#"
struct S<T>(T);
fn foo() {
let t: (_, _, [_; _]) = (1_u32, S(2), [false] as _);
}
"#,
);
}
}
1 change: 1 addition & 0 deletions crates/ide/src/static_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl StaticIndex<'_> {
adjustment_hints_hide_outside_unsafe: false,
implicit_drop_hints: false,
implied_dyn_trait_hints: false,
hide_inferred_type_hints: false,
hide_named_constructor_hints: false,
hide_closure_initialization_hints: false,
hide_closure_parameter_hints: false,
Expand Down
1 change: 1 addition & 0 deletions crates/rust-analyzer/src/cli/analysis_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ impl flags::AnalysisStats {
implied_dyn_trait_hints: true,
lifetime_elision_hints: ide::LifetimeElisionHints::Always,
param_names_for_lifetime_elision_hints: true,
hide_inferred_type_hints: false,
hide_named_constructor_hints: false,
hide_closure_initialization_hints: false,
hide_closure_parameter_hints: false,
Expand Down
4 changes: 4 additions & 0 deletions crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ config_data! {
/// Hide inlay parameter type hints for closures.
inlayHints_typeHints_hideClosureParameter: bool = false,

/// Hide inlay type hints for inferred types.
inlayHints_typeHints_hideInferredTypes: bool = false,

/// Hide inlay type hints for constructors.
inlayHints_typeHints_hideNamedConstructor: bool = false,

Expand Down Expand Up @@ -1937,6 +1940,7 @@ impl Config {
hide_named_constructor_hints: self
.inlayHints_typeHints_hideNamedConstructor()
.to_owned(),
hide_inferred_type_hints: self.inlayHints_typeHints_hideInferredTypes().to_owned(),
hide_closure_initialization_hints: self
.inlayHints_typeHints_hideClosureInitialization()
.to_owned(),
Expand Down
7 changes: 7 additions & 0 deletions docs/book/src/configuration_generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,13 @@ Default: `false`
Hide inlay parameter type hints for closures.


## rust-analyzer.inlayHints.typeHints.hideInferredTypes {#inlayHints.typeHints.hideInferredTypes}

Default: `false`

Hide inlay type hints for inferred types.


## rust-analyzer.inlayHints.typeHints.hideNamedConstructor {#inlayHints.typeHints.hideNamedConstructor}

Default: `false`
Expand Down
10 changes: 10 additions & 0 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2466,6 +2466,16 @@
}
}
},
{
"title": "Inlay Hints",
"properties": {
"rust-analyzer.inlayHints.typeHints.hideInferredTypes": {
"markdownDescription": "Hide inlay type hints for inferred types.",
"default": false,
"type": "boolean"
}
}
},
{
"title": "Inlay Hints",
"properties": {
Expand Down