Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
562b485
Provide a setting to disable showing rename conflicts
ChayimFriedman2 Jul 7, 2025
ef4a741
Add bidirectional messaging proc-macro-srv
Shourya742 Nov 27, 2025
8bcb4db
remove salsa dependency check on proc_macro_srv_cli
Shourya742 Dec 15, 2025
a1f3d72
make json-new as default protocol choice for proc-macro-srv-cli
Shourya742 Dec 15, 2025
4f57d5b
Fix LSP configuration request handling
michaelgruenewald Dec 17, 2025
9289099
add request id to requests
Shourya742 Dec 18, 2025
abaf959
refactor the main loop in proc_macro-srv-cli
Shourya742 Dec 18, 2025
5cdad62
make imports proper
Shourya742 Dec 18, 2025
b65078e
change request id to u32 to make powerpc happy
Shourya742 Dec 18, 2025
e337275
RISC-V: Add virtual target feature: `zkne_or_zknd`
a4lg Sep 14, 2025
288c372
RISC-V: Use inline assembly and `zkne_or_zknd` on (Zkne or Zknd) intr…
a4lg Sep 19, 2025
ba9cc48
Prepare for merging from rust-lang/rust
invalid-email-address Dec 22, 2025
de0a0ef
Merge ref 'f41f40408d71' from rust-lang/rust
invalid-email-address Dec 22, 2025
b91ed30
Merge pull request #21318 from rust-lang/rustc-pull
lnicola Dec 22, 2025
2327823
remove request_id, rename postcardNew to BidirectionalPostcardPrototy…
Shourya742 Dec 22, 2025
3db62cf
comment out disabled workflow
Shourya742 Dec 22, 2025
8e21457
remove envelop and keep it simple
Shourya742 Dec 22, 2025
7c50ee6
rename PostcardNew to bidirectional-postcard-prototype
Shourya742 Dec 22, 2025
6c525fa
remove internal callbacks, and move callback to rust-analyzer level
Shourya742 Dec 23, 2025
cf02cff
remove channels with callbacks in proc-macro-srv
Shourya742 Dec 23, 2025
d0e14f1
fix: Fix flycheck generations not being synced for multiple workspaces
Veykril Dec 23, 2025
184e062
chore: remove unwanted comments, extra lines and putting cli srv on d…
Shourya742 Dec 23, 2025
d0f86f6
Merge pull request #21326 from Veykril/push-vzswtlulupxv
ShoyuVanilla Dec 23, 2025
d6a2a52
return error on combination of bidirectional message and json framing
Shourya742 Dec 23, 2025
df2833d
Fix typo in a URL
ada4a Dec 23, 2025
022164f
Merge pull request #21327 from ada4a/patch-1
lnicola Dec 23, 2025
5c99ebf
Fix indent for convert_to_guarded_return
A4-Tacks Dec 24, 2025
faac1b5
Prepare for merging from rust-lang/rust
invalid-email-address Dec 25, 2025
a1ae5af
Merge ref 'e7d44143a12a' from rust-lang/rust
invalid-email-address Dec 25, 2025
a8ad2e2
Merge pull request #21331 from rust-lang/rustc-pull
lnicola Dec 25, 2025
38ff5a7
Introduce cargo-machete ci step
Veykril Dec 25, 2025
4b68b7a
Merge pull request #21334 from Veykril/veykril/push-ozmlxzxpvrun
Veykril Dec 25, 2025
2c7bd6d
Store closures with "tupled" inputs
ChayimFriedman2 Dec 25, 2025
ebb0d0b
Make builtin derives cheaper, by not really expanding them, instead s…
ChayimFriedman2 Dec 2, 2025
2f3a23c
Stabilize type mismatch diagnostic 🎉
ChayimFriedman2 Dec 26, 2025
9d0a93f
Merge pull request #21337 from ChayimFriedman2/stabilize-type-mismatc…
ChayimFriedman2 Dec 26, 2025
2986b27
Merge pull request #21249 from Shourya742/2025-11-27-bidirectional-pr…
Veykril Dec 26, 2025
856cc54
Merge pull request #21335 from ChayimFriedman2/tupled-closure
Veykril Dec 26, 2025
4665de5
Merge pull request #21330 from A4-Tacks/to-guarded-indent
Veykril Dec 26, 2025
9fcf441
Merge pull request #21297 from osdyne/fix-lsp-configuration-request
Veykril Dec 26, 2025
abefb52
Merge pull request #20193 from ChayimFriedman2/setting-rename-conflict
Veykril Dec 26, 2025
04529b2
Allow IDE layer to "see" fake builtin derive impls
ChayimFriedman2 Dec 3, 2025
02763ff
Test builtin derives expansions
ChayimFriedman2 Dec 26, 2025
50ed4e9
Merge pull request #21200 from ChayimFriedman2/fake-impls
Veykril Dec 26, 2025
abf2259
add bidirectionalHandler trait
Shourya742 Dec 26, 2025
8f141ea
remove old subreq/resp constructs
Shourya742 Dec 26, 2025
8aa8594
adapt source_text to new handler
Shourya742 Dec 26, 2025
22fbbd4
Add macro segment completion
A4-Tacks Sep 25, 2025
2316906
add bidirectional handle in proc-macro-srv-cli to interact with clien…
Shourya742 Dec 27, 2025
8ae38dc
rename handler's to be context specific
Shourya742 Dec 27, 2025
38f1ccc
make source_text take non mutable reference of self
Shourya742 Dec 27, 2025
720d9ee
remove crossbeam-channel from proc-macro-srv-cli
Shourya742 Dec 27, 2025
9ab53d6
Merge pull request #21340 from Shourya742/2025-12-26-better-bm-ergono…
Veykril Dec 27, 2025
06a6a00
Minor fixup
A4-Tacks Dec 27, 2025
e80997d
Fix grammar in "Use of AI tools" section
yotamofek Dec 27, 2025
e90e264
Merge pull request #20741 from A4-Tacks/comp-macro-segment
Veykril Dec 27, 2025
61203a0
internal: Move library and local root inputs to base-db
Veykril Dec 27, 2025
31b0cb9
Merge pull request #21341 from Veykril/veykril/push-wsrtvrkzqyvr
Veykril Dec 27, 2025
d494dbc
make framing buffer send
Shourya742 Dec 27, 2025
462b4a0
attach lifetime to ProcMacroClientHandle and make necessary changes t…
Shourya742 Dec 27, 2025
359fe9a
remove read and write generics, also remove lock from the beginning a…
Shourya742 Dec 27, 2025
7e873db
rename BidirectionalStruct to ProcMacroClientHandle
Shourya742 Dec 27, 2025
43cda6d
remove unwraps from source_text impl
Shourya742 Dec 27, 2025
671aab6
make expand ProcMacroServerSpan type live longer
Shourya742 Dec 27, 2025
6ff77ac
Merge pull request #21345 from Shourya742/2025-12-27-remove-channel-mess
ChayimFriedman2 Dec 27, 2025
a9da655
Bring back fixpoint iteration for variance
ChayimFriedman2 Dec 27, 2025
fc1cb48
Fix tests that relied on the default variance to be invariant
ChayimFriedman2 Dec 27, 2025
28b8503
Merge pull request #21348 from ChayimFriedman2/reenable-variance
ChayimFriedman2 Dec 27, 2025
bb5c82c
Don't use MIR ProjectionElem in closure analysis
flodiebold Dec 4, 2025
0146f8d
Merge pull request #21344 from flodiebold/push-prxvkyqorowx
ChayimFriedman2 Dec 27, 2025
a5bdd10
Merge pull request #21342 from yotamofek/patch-1
Veykril Dec 27, 2025
c27f6d5
Fix parsing of `format_args!("...", keyword=...)`
ChayimFriedman2 Dec 28, 2025
6851e39
Make token trees no longer generic over the span
ChayimFriedman2 Dec 28, 2025
33ad9ca
Merge pull request #21349 from ChayimFriedman2/no-generic-span
Veykril Dec 28, 2025
fa8649f
minor: Remove unneded allocation in proc-macro-srv-cli
Veykril Dec 28, 2025
49c5102
Merge pull request #21351 from ChayimFriedman2/format-args-kw
Veykril Dec 28, 2025
5a119a5
Merge pull request #21352 from Veykril/push-knwlqypxtukr
Veykril Dec 28, 2025
1ce1fae
Fix duplicate record functional update
A4-Tacks Dec 28, 2025
b717c74
perf: Pre-allocate some buffers in parsing
Veykril Dec 28, 2025
f574941
Merge pull request #21353 from Veykril/push-wquzszzrzwpu
Veykril Dec 28, 2025
5adad1a
perf: Reduce channel lock contention for drop-threads
Veykril Dec 28, 2025
72b409d
Merge pull request #21355 from Veykril/push-zkmupnykkvln
Veykril Dec 28, 2025
11df3a0
Drop AstIdMap asynchronously
Veykril Dec 28, 2025
ecb0c4c
internal: Collect garbage after events when quiescient
Veykril Dec 28, 2025
1ea45e0
Merge pull request #21357 from Veykril/push-rsulypnywlsv
Veykril Dec 28, 2025
6f551be
Reduce allocations in `GarbageCollector`
Veykril Dec 28, 2025
8235c35
Do not unnecessarily re-trigger garbage collection if no inputs have …
Veykril Dec 28, 2025
4fba51d
Merge pull request #21356 from Veykril/push-oumpxzuwmuwp
Veykril Dec 28, 2025
31fb833
fix: Fix hover for infer type not working
Veykril Dec 28, 2025
138034f
Merge pull request #21358 from Veykril/push-sxkppmzqvurw
Veykril Dec 28, 2025
9a93243
Merge pull request #21354 from A4-Tacks/dedup-record-update
Veykril Dec 28, 2025
4ae2848
Prompt the user in VSCode to add the rust-anaylzer componenet to the …
Veykril Dec 28, 2025
75fa8a0
Merge pull request #21359 from Veykril/push-syvnrvtmlsqk
Veykril Dec 28, 2025
49b6f67
Separate the public `tt` API from how they're stored
ChayimFriedman2 Dec 29, 2025
175e297
Make `tt::Literal` use one `Symbol` for the text and the suffix
ChayimFriedman2 Dec 29, 2025
29f9397
docs: fix typo in std::io::buffered
AsakuraMizu Dec 24, 2025
00f80b4
Merge pull request #21362 from ChayimFriedman2/compress-spans-v2
Veykril Dec 29, 2025
b0ff573
feat: implement configuration to change subcommand for test and bench
dfireBird Dec 20, 2025
bb4d75f
fix clippy errors
dfireBird Dec 29, 2025
cd2c209
Fix Clippy
ChayimFriedman2 Dec 29, 2025
7069629
chore: add `test_name` placeholder in config
dfireBird Dec 29, 2025
9cb0713
Merge pull request #21366 from ChayimFriedman2/fix-clippy
ChayimFriedman2 Dec 29, 2025
192bbd1
Have an `upvars_mentioned()` query that only computes what upvars a c…
ChayimFriedman2 Dec 29, 2025
edae151
Merge pull request #21308 from dfireBird/runnable-subcommand-config
ChayimFriedman2 Dec 29, 2025
3d9856d
Merge pull request #21367 from ChayimFriedman2/upvars
Veykril Dec 30, 2025
9508cd1
Compress token trees for best memory usage
ChayimFriedman2 Dec 29, 2025
c24dff6
Merge pull request #21363 from ChayimFriedman2/compress-spans-real
ChayimFriedman2 Dec 30, 2025
975aa0d
Add `#[rust_analyzer::macro_style()]` attribute to control macro comp…
ChayimFriedman2 Dec 30, 2025
df99881
Adapt macros in rust-analyzer to new attribute
ChayimFriedman2 Dec 30, 2025
ef8d943
Remove `feature(string_deref_patterns)`
Zalathar Dec 31, 2025
935e3cb
fix: don't fire `non_camel_case_types` lint for structs/enums marked …
Jefffrey Dec 31, 2025
a5e6198
Merge pull request #21374 from Jefffrey/excuse-non-camel-case-repr-c
ChayimFriedman2 Dec 31, 2025
5bb8d5d
Merge pull request #21370 from ChayimFriedman2/macro-brace-style
Veykril Dec 31, 2025
c19e9ec
Fix incorrect dyn hint in `impl Trait for`
A4-Tacks Dec 31, 2025
6d0f23c
Merge pull request #21375 from A4-Tacks/impl-trait-target-and-dyn-hint
ChayimFriedman2 Dec 31, 2025
1a4e7f9
Use --print target-libdir in run-make tests
bjorn3 Dec 31, 2025
dc103c4
Rollup merge of #146798 - a4lg:riscv-intrinsics-zkne_or_zknd, r=Amanieu
JonathanBrouwer Dec 31, 2025
f366fa5
Rollup merge of #150337 - AsakuraMizu:main, r=jhpratt
JonathanBrouwer Dec 31, 2025
15c467b
Rollup merge of #150530 - Zalathar:string-deref-patterns, r=jackh726
JonathanBrouwer Dec 31, 2025
8dc15d2
Rollup merge of #150543 - lnicola:sync-from-ra, r=lnicola
JonathanBrouwer Dec 31, 2025
552918b
Rollup merge of #150544 - bjorn3:run_make_print_target_libdir, r=Urga…
JonathanBrouwer Dec 31, 2025
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
Next Next commit
Provide a setting to disable showing rename conflicts
  • Loading branch information
ChayimFriedman2 committed Oct 27, 2025
commit 562b485585a8da7fd0aee010d684a0c4663fafaa
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use ide_db::{
SnippetCap,
assists::ExprFillDefaultMode,
imports::{import_assets::ImportPathConfig, insert_use::InsertUseConfig},
rename::RenameConfig,
};

use crate::AssistKind;
Expand All @@ -27,6 +28,7 @@ pub struct AssistConfig {
pub code_action_grouping: bool,
pub expr_fill_default: ExprFillDefaultMode,
pub prefer_self_ty: bool,
pub show_rename_conflicts: bool,
}

impl AssistConfig {
Expand All @@ -46,4 +48,8 @@ impl AssistConfig {
allow_unstable,
}
}

pub fn rename_config(&self) -> RenameConfig {
RenameConfig { show_conflicts: self.show_rename_conflicts }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ pub(crate) fn remove_underscore(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
"Remove underscore from a used variable",
text_range,
|builder| {
let changes = def.rename(&ctx.sema, new_name, RenameDefinition::Yes).unwrap();
let changes = def
.rename(&ctx.sema, new_name, RenameDefinition::Yes, &ctx.config.rename_config())
.unwrap();
builder.source_change = changes;
},
)
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-assists/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub(crate) const TEST_CONFIG: AssistConfig = AssistConfig {
code_action_grouping: true,
expr_fill_default: ExprFillDefaultMode::Todo,
prefer_self_ty: false,
show_rename_conflicts: true,
};

pub(crate) const TEST_CONFIG_NO_GROUPING: AssistConfig = AssistConfig {
Expand All @@ -59,6 +60,7 @@ pub(crate) const TEST_CONFIG_NO_GROUPING: AssistConfig = AssistConfig {
code_action_grouping: false,
expr_fill_default: ExprFillDefaultMode::Todo,
prefer_self_ty: false,
show_rename_conflicts: true,
};

pub(crate) const TEST_CONFIG_NO_SNIPPET_CAP: AssistConfig = AssistConfig {
Expand All @@ -80,6 +82,7 @@ pub(crate) const TEST_CONFIG_NO_SNIPPET_CAP: AssistConfig = AssistConfig {
code_action_grouping: true,
expr_fill_default: ExprFillDefaultMode::Todo,
prefer_self_ty: false,
show_rename_conflicts: true,
};

pub(crate) const TEST_CONFIG_IMPORT_ONE: AssistConfig = AssistConfig {
Expand All @@ -101,6 +104,7 @@ pub(crate) const TEST_CONFIG_IMPORT_ONE: AssistConfig = AssistConfig {
code_action_grouping: true,
expr_fill_default: ExprFillDefaultMode::Todo,
prefer_self_ty: false,
show_rename_conflicts: true,
};

fn assists(
Expand Down
53 changes: 34 additions & 19 deletions src/tools/rust-analyzer/crates/ide-db/src/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ use crate::{
traits::convert_to_def_in_trait,
};

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RenameConfig {
pub show_conflicts: bool,
}

pub type Result<T, E = RenameError> = std::result::Result<T, E>;

#[derive(Debug)]
Expand Down Expand Up @@ -81,6 +86,7 @@ impl Definition {
sema: &Semantics<'_, RootDatabase>,
new_name: &str,
rename_definition: RenameDefinition,
config: &RenameConfig,
) -> Result<SourceChange> {
// self.krate() returns None if
// self is a built-in attr, built-in type or tool module.
Expand Down Expand Up @@ -109,10 +115,15 @@ impl Definition {
bail!("Cannot rename a builtin attr.")
}
Definition::SelfType(_) => bail!("Cannot rename `Self`"),
Definition::Macro(mac) => {
rename_reference(sema, Definition::Macro(mac), new_name, rename_definition, edition)
}
def => rename_reference(sema, def, new_name, rename_definition, edition),
Definition::Macro(mac) => rename_reference(
sema,
Definition::Macro(mac),
new_name,
rename_definition,
edition,
config,
),
def => rename_reference(sema, def, new_name, rename_definition, edition, config),
}
}

Expand Down Expand Up @@ -338,6 +349,7 @@ fn rename_reference(
new_name: &str,
rename_definition: RenameDefinition,
edition: Edition,
config: &RenameConfig,
) -> Result<SourceChange> {
let (mut new_name, ident_kind) = IdentifierKind::classify(edition, new_name)?;

Expand Down Expand Up @@ -396,7 +408,8 @@ fn rename_reference(
if rename_definition == RenameDefinition::Yes {
// This needs to come after the references edits, because we change the annotation of existing edits
// if a conflict is detected.
let (file_id, edit) = source_edit_from_def(sema, def, &new_name, &mut source_change)?;
let (file_id, edit) =
source_edit_from_def(sema, config, def, &new_name, &mut source_change)?;
source_change.insert_source_edit(file_id, edit);
}
Ok(source_change)
Expand Down Expand Up @@ -554,6 +567,7 @@ fn source_edit_from_name_ref(

fn source_edit_from_def(
sema: &Semantics<'_, RootDatabase>,
config: &RenameConfig,
def: Definition,
new_name: &Name,
source_change: &mut SourceChange,
Expand All @@ -562,21 +576,22 @@ fn source_edit_from_def(
if let Definition::Local(local) = def {
let mut file_id = None;

let conflict_annotation = if !sema.rename_conflicts(&local, new_name).is_empty() {
Some(
source_change.insert_annotation(ChangeAnnotation {
label: "This rename will change the program's meaning".to_owned(),
needs_confirmation: true,
description: Some(
"Some variable(s) will shadow the renamed variable \
let conflict_annotation =
if config.show_conflicts && !sema.rename_conflicts(&local, new_name).is_empty() {
Some(
source_change.insert_annotation(ChangeAnnotation {
label: "This rename will change the program's meaning".to_owned(),
needs_confirmation: true,
description: Some(
"Some variable(s) will shadow the renamed variable \
or be shadowed by it if the rename is performed"
.to_owned(),
),
}),
)
} else {
None
};
.to_owned(),
),
}),
)
} else {
None
};

for source in local.sources(sema.db) {
let source = match source.source.clone().original_ast_node_rooted(sema.db) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::IncorrectCase) -> Option<Vec<Ass
let label = format!("Rename to {}", d.suggested_text);
let mut res = unresolved_fix("change_case", &label, frange.range);
if ctx.resolve.should_resolve(&res.id) {
let source_change = def.rename(&ctx.sema, &d.suggested_text, RenameDefinition::Yes);
let source_change = def.rename(
&ctx.sema,
&d.suggested_text,
RenameDefinition::Yes,
&ctx.config.rename_config(),
);
res.source_change = Some(source_change.ok().unwrap_or_default());
}

Expand Down
7 changes: 7 additions & 0 deletions src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ use ide_db::{
generated::lints::{CLIPPY_LINT_GROUPS, DEFAULT_LINT_GROUPS, DEFAULT_LINTS, Lint, LintGroup},
imports::insert_use::InsertUseConfig,
label::Label,
rename::RenameConfig,
source_change::SourceChange,
syntax_helpers::node_ext::parse_tt_as_comma_sep_paths,
};
Expand Down Expand Up @@ -236,6 +237,7 @@ pub struct DiagnosticsConfig {
pub prefer_absolute: bool,
pub term_search_fuel: u64,
pub term_search_borrowck: bool,
pub show_rename_conflicts: bool,
}

impl DiagnosticsConfig {
Expand Down Expand Up @@ -264,8 +266,13 @@ impl DiagnosticsConfig {
prefer_absolute: false,
term_search_fuel: 400,
term_search_borrowck: true,
show_rename_conflicts: true,
}
}

pub fn rename_config(&self) -> RenameConfig {
RenameConfig { show_conflicts: self.show_rename_conflicts }
}
}

struct DiagnosticsContext<'a> {
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rust-analyzer/crates/ide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,9 @@ impl Analysis {
&self,
file_id: FileId,
new_name_stem: &str,
config: &RenameConfig,
) -> Cancellable<Option<SourceChange>> {
self.with_db(|db| rename::will_rename_file(db, file_id, new_name_stem))
self.with_db(|db| rename::will_rename_file(db, file_id, new_name_stem, config))
}

pub fn structural_search_replace(
Expand Down
21 changes: 16 additions & 5 deletions src/tools/rust-analyzer/crates/ide/src/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct RenameConfig {
pub prefer_no_std: bool,
pub prefer_prelude: bool,
pub prefer_absolute: bool,
pub show_conflicts: bool,
}

impl RenameConfig {
Expand All @@ -42,6 +43,10 @@ impl RenameConfig {
allow_unstable: true,
}
}

fn ide_db_config(&self) -> ide_db::rename::RenameConfig {
ide_db::rename::RenameConfig { show_conflicts: self.show_conflicts }
}
}

/// This is similar to `collect::<Result<Vec<_>, _>>`, but unlike it, it succeeds if there is *any* `Ok` item.
Expand Down Expand Up @@ -190,7 +195,7 @@ pub(crate) fn rename(
return rename_to_self(&sema, local);
}
}
def.rename(&sema, new_name.as_str(), rename_def)
def.rename(&sema, new_name.as_str(), rename_def, &config.ide_db_config())
})),
};

Expand All @@ -205,11 +210,13 @@ pub(crate) fn will_rename_file(
db: &RootDatabase,
file_id: FileId,
new_name_stem: &str,
config: &RenameConfig,
) -> Option<SourceChange> {
let sema = Semantics::new(db);
let module = sema.file_to_module_def(file_id)?;
let def = Definition::Module(module);
let mut change = def.rename(&sema, new_name_stem, RenameDefinition::Yes).ok()?;
let mut change =
def.rename(&sema, new_name_stem, RenameDefinition::Yes, &config.ide_db_config()).ok()?;
change.file_system_edits.clear();
Some(change)
}
Expand Down Expand Up @@ -803,8 +810,12 @@ mod tests {

use super::{RangeInfo, RenameConfig, RenameError};

const TEST_CONFIG: RenameConfig =
RenameConfig { prefer_no_std: false, prefer_prelude: true, prefer_absolute: false };
const TEST_CONFIG: RenameConfig = RenameConfig {
prefer_no_std: false,
prefer_prelude: true,
prefer_absolute: false,
show_conflicts: true,
};

#[track_caller]
fn check(
Expand Down Expand Up @@ -893,7 +904,7 @@ mod tests {
) {
let (analysis, position) = fixture::position(ra_fixture);
let source_change = analysis
.will_rename_file(position.file_id, new_name)
.will_rename_file(position.file_id, new_name, &TEST_CONFIG)
.unwrap()
.expect("Expect returned a RenameError");
expect.assert_eq(&filter_expect(source_change))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ impl flags::AnalysisStats {
style_lints: false,
term_search_fuel: 400,
term_search_borrowck: true,
show_rename_conflicts: true,
},
ide::AssistResolveStrategy::All,
analysis.editioned_file_id_to_vfs(file_id),
Expand Down
6 changes: 6 additions & 0 deletions src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,9 @@ config_data! {
///
/// E.g. `use ::std::io::Read;`.
imports_prefixExternPrelude: bool = false,

/// Whether to warn when a rename will cause conflicts (change the meaning of the code).
rename_showConflicts: bool = true,
}
}

Expand Down Expand Up @@ -1702,6 +1705,7 @@ impl Config {
ExprFillDefaultDef::Underscore => ExprFillDefaultMode::Underscore,
},
prefer_self_ty: *self.assist_preferSelf(source_root),
show_rename_conflicts: *self.rename_showConflicts(source_root),
}
}

Expand All @@ -1710,6 +1714,7 @@ impl Config {
prefer_no_std: self.imports_preferNoStd(source_root).to_owned(),
prefer_prelude: self.imports_preferPrelude(source_root).to_owned(),
prefer_absolute: self.imports_prefixExternPrelude(source_root).to_owned(),
show_conflicts: *self.rename_showConflicts(source_root),
}
}

Expand Down Expand Up @@ -1809,6 +1814,7 @@ impl Config {
style_lints: self.diagnostics_styleLints_enable(source_root).to_owned(),
term_search_fuel: self.assist_termSearch_fuel(source_root).to_owned() as u64,
term_search_borrowck: self.assist_termSearch_borrowcheck(source_root).to_owned(),
show_rename_conflicts: *self.rename_showConflicts(source_root),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,11 @@ pub(crate) fn handle_will_rename_files(
}
})
.filter_map(|(file_id, new_name)| {
snap.analysis.will_rename_file(file_id?, &new_name).ok()?
let file_id = file_id?;
let source_root = snap.analysis.source_root_id(file_id).ok();
snap.analysis
.will_rename_file(file_id, &new_name, &snap.config.rename(source_root))
.ok()?
})
.collect();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ fn integrated_diagnostics_benchmark() {
prefer_absolute: false,
term_search_fuel: 400,
term_search_borrowck: true,
show_rename_conflicts: true,
};
host.analysis()
.full_diagnostics(&diagnostics_config, ide::AssistResolveStrategy::None, file_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,13 @@ Default: `false`
Exclude tests from find-all-references and call-hierarchy.


## rust-analyzer.rename.showConflicts {#rename.showConflicts}

Default: `true`

Whether to warn when a rename will cause conflicts (change the meaning of the code).


## rust-analyzer.runnables.command {#runnables.command}

Default: `null`
Expand Down
10 changes: 10 additions & 0 deletions src/tools/rust-analyzer/editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,16 @@
}
}
},
{
"title": "Rename",
"properties": {
"rust-analyzer.rename.showConflicts": {
"markdownDescription": "Whether to warn when a rename will cause conflicts (change the meaning of the code).",
"default": true,
"type": "boolean"
}
}
},
{
"title": "Runnables",
"properties": {
Expand Down