Skip to content

Commit 3a95864

Browse files
committed
Unconditionally enable location links in inlay hints again
1 parent 5306eb0 commit 3a95864

File tree

7 files changed

+38
-54
lines changed

7 files changed

+38
-54
lines changed

crates/ide/src/inlay_hints.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ mod discriminant;
3131

3232
#[derive(Clone, Debug, PartialEq, Eq)]
3333
pub struct InlayHintsConfig {
34-
pub location_links: bool,
3534
pub render_colons: bool,
3635
pub type_hints: bool,
3736
pub discriminant_hints: DiscriminantHints,
@@ -240,7 +239,6 @@ struct InlayHintLabelBuilder<'a> {
240239
db: &'a RootDatabase,
241240
result: InlayHintLabel,
242241
last_part: String,
243-
location_link_enabled: bool,
244242
location: Option<FileRange>,
245243
}
246244

@@ -252,9 +250,6 @@ impl fmt::Write for InlayHintLabelBuilder<'_> {
252250

253251
impl HirWrite for InlayHintLabelBuilder<'_> {
254252
fn start_location_link(&mut self, def: ModuleDefId) {
255-
if !self.location_link_enabled {
256-
return;
257-
}
258253
if self.location.is_some() {
259254
never!("location link is already started");
260255
}
@@ -266,9 +261,6 @@ impl HirWrite for InlayHintLabelBuilder<'_> {
266261
}
267262

268263
fn end_location_link(&mut self) {
269-
if !self.location_link_enabled {
270-
return;
271-
}
272264
self.make_new_part();
273265
}
274266
}
@@ -334,7 +326,6 @@ fn label_of_ty(
334326
db: sema.db,
335327
last_part: String::new(),
336328
location: None,
337-
location_link_enabled: config.location_links,
338329
result: InlayHintLabel::default(),
339330
};
340331
let _ = rec(sema, famous_defs, config.max_length, ty, &mut label_builder);
@@ -495,7 +486,6 @@ mod tests {
495486
use super::ClosureReturnTypeHints;
496487

497488
pub(super) const DISABLED_CONFIG: InlayHintsConfig = InlayHintsConfig {
498-
location_links: false,
499489
discriminant_hints: DiscriminantHints::Never,
500490
render_colons: false,
501491
type_hints: false,
@@ -513,16 +503,14 @@ mod tests {
513503
max_length: None,
514504
closing_brace_hints_min_lines: None,
515505
};
516-
pub(super) const DISABLED_CONFIG_WITH_LINKS: InlayHintsConfig =
517-
InlayHintsConfig { location_links: true, ..DISABLED_CONFIG };
518506
pub(super) const TEST_CONFIG: InlayHintsConfig = InlayHintsConfig {
519507
type_hints: true,
520508
parameter_hints: true,
521509
chaining_hints: true,
522510
closure_return_type_hints: ClosureReturnTypeHints::WithBlock,
523511
binding_mode_hints: true,
524512
lifetime_elision_hints: LifetimeElisionHints::Always,
525-
..DISABLED_CONFIG_WITH_LINKS
513+
..DISABLED_CONFIG
526514
};
527515

528516
#[track_caller]

crates/ide/src/inlay_hints/bind_pat.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ mod tests {
188188
use crate::{fixture, inlay_hints::InlayHintsConfig};
189189

190190
use crate::inlay_hints::tests::{
191-
check, check_expect, check_with_config, DISABLED_CONFIG, DISABLED_CONFIG_WITH_LINKS,
192-
TEST_CONFIG,
191+
check, check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG,
193192
};
194193
use crate::ClosureReturnTypeHints;
195194

@@ -285,7 +284,7 @@ fn main() {
285284
fn iterator_hint_regression_issue_12674() {
286285
// Ensure we don't crash while solving the projection type of iterators.
287286
check_expect(
288-
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG_WITH_LINKS },
287+
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
289288
r#"
290289
//- minicore: iterators
291290
struct S<T>(T);

crates/ide/src/inlay_hints/chaining.rs

+33-14
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ mod tests {
7272
use expect_test::expect;
7373

7474
use crate::{
75-
inlay_hints::tests::{
76-
check_expect, check_with_config, DISABLED_CONFIG, DISABLED_CONFIG_WITH_LINKS,
77-
TEST_CONFIG,
78-
},
75+
inlay_hints::tests::{check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG},
7976
InlayHintsConfig,
8077
};
8178

@@ -87,11 +84,7 @@ mod tests {
8784
#[test]
8885
fn chaining_hints_ignore_comments() {
8986
check_expect(
90-
InlayHintsConfig {
91-
type_hints: false,
92-
chaining_hints: true,
93-
..DISABLED_CONFIG_WITH_LINKS
94-
},
87+
InlayHintsConfig { type_hints: false, chaining_hints: true, ..DISABLED_CONFIG },
9588
r#"
9689
struct A(B);
9790
impl A { fn into_b(self) -> B { self.0 } }
@@ -197,14 +190,40 @@ fn main() {
197190
range: 143..190,
198191
kind: Chaining,
199192
label: [
200-
"C",
193+
"",
194+
InlayHintLabelPart {
195+
text: "C",
196+
linked_location: Some(
197+
FileRange {
198+
file_id: FileId(
199+
0,
200+
),
201+
range: 51..52,
202+
},
203+
),
204+
tooltip: "",
205+
},
206+
"",
201207
],
202208
},
203209
InlayHint {
204210
range: 143..179,
205211
kind: Chaining,
206212
label: [
207-
"B",
213+
"",
214+
InlayHintLabelPart {
215+
text: "B",
216+
linked_location: Some(
217+
FileRange {
218+
file_id: FileId(
219+
0,
220+
),
221+
range: 29..30,
222+
},
223+
),
224+
tooltip: "",
225+
},
226+
"",
208227
],
209228
},
210229
]
@@ -215,7 +234,7 @@ fn main() {
215234
#[test]
216235
fn struct_access_chaining_hints() {
217236
check_expect(
218-
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG_WITH_LINKS },
237+
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
219238
r#"
220239
struct A { pub b: B }
221240
struct B { pub c: C }
@@ -284,7 +303,7 @@ fn main() {
284303
#[test]
285304
fn generic_chaining_hints() {
286305
check_expect(
287-
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG_WITH_LINKS },
306+
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
288307
r#"
289308
struct A<T>(T);
290309
struct B<T>(T);
@@ -380,7 +399,7 @@ fn main() {
380399
#[test]
381400
fn shorten_iterator_chaining_hints() {
382401
check_expect(
383-
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG_WITH_LINKS },
402+
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
384403
r#"
385404
//- minicore: iterators
386405
use core::iter;

crates/ide/src/inlay_hints/closing_brace.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ pub(super) fn hints(
107107
return None;
108108
}
109109

110-
let linked_location = config
111-
.location_links
112-
.then(|| name_range.map(|range| FileRange { file_id, range }))
113-
.flatten();
110+
let linked_location = name_range.map(|range| FileRange { file_id, range });
114111
acc.push(InlayHint {
115112
range: closing_token.text_range(),
116113
kind: InlayKind::ClosingBrace,

crates/ide/src/static_index.rs

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ impl StaticIndex<'_> {
107107
.analysis
108108
.inlay_hints(
109109
&InlayHintsConfig {
110-
location_links: true,
111110
render_colons: true,
112111
discriminant_hints: crate::DiscriminantHints::Fieldless,
113112
type_hints: true,

crates/rust-analyzer/src/bin/main.rs

-2
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ fn run_server() -> Result<()> {
183183
}
184184
}
185185

186-
config.client_specific_adjustments(&initialize_params.client_info);
187-
188186
let server_capabilities = rust_analyzer::server_capabilities(&config);
189187

190188
let initialize_result = lsp_types::InitializeResult {

crates/rust-analyzer/src/config.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use ide_db::{
2020
SnippetCap,
2121
};
2222
use itertools::Itertools;
23-
use lsp_types::{ClientCapabilities, ClientInfo, MarkupKind};
23+
use lsp_types::{ClientCapabilities, MarkupKind};
2424
use project_model::{
2525
CargoConfig, CargoFeatures, ProjectJson, ProjectJsonData, ProjectManifest, RustcSource,
2626
UnsetTestCrates,
@@ -342,8 +342,6 @@ config_data! {
342342
inlayHints_lifetimeElisionHints_enable: LifetimeElisionDef = "\"never\"",
343343
/// Whether to prefer using parameter names as the name for elided lifetime hints if possible.
344344
inlayHints_lifetimeElisionHints_useParameterNames: bool = "false",
345-
/// Whether to use location links for parts of type mentioned in inlay hints.
346-
inlayHints_locationLinks: bool = "true",
347345
/// Maximum length for inlay hints. Set to null to have an unlimited length.
348346
inlayHints_maxLength: Option<usize> = "25",
349347
/// Whether to show function parameter name inlay hints at the call
@@ -728,19 +726,6 @@ impl Config {
728726
}
729727
}
730728

731-
pub fn client_specific_adjustments(&mut self, client_info: &Option<ClientInfo>) {
732-
// FIXME: remove this when we drop support for vscode 1.65 and below
733-
if let Some(client) = client_info {
734-
if client.name.contains("Code") || client.name.contains("Codium") {
735-
if let Some(version) = &client.version {
736-
if version.as_str() < "1.76" {
737-
self.data.inlayHints_locationLinks = false;
738-
}
739-
}
740-
}
741-
}
742-
}
743-
744729
pub fn update(&mut self, mut json: serde_json::Value) -> Result<(), ConfigUpdateError> {
745730
tracing::info!("updating config from JSON: {:#}", json);
746731
if json.is_null() || json.as_object().map_or(false, |it| it.is_empty()) {
@@ -1229,7 +1214,6 @@ impl Config {
12291214

12301215
pub fn inlay_hints(&self) -> InlayHintsConfig {
12311216
InlayHintsConfig {
1232-
location_links: self.data.inlayHints_locationLinks,
12331217
render_colons: self.data.inlayHints_renderColons,
12341218
type_hints: self.data.inlayHints_typeHints_enable,
12351219
parameter_hints: self.data.inlayHints_parameterHints_enable,

0 commit comments

Comments
 (0)