aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-14 17:08:12 +0100
committerAleksey Kladov <[email protected]>2021-06-14 17:08:12 +0100
commit9fb67e7477a43fc91946f17c00205b7e31db00d8 (patch)
treed8bbae97eb17928ad524d9c16bb0c689119b478c /crates/ide_db
parent26c978f258ed2af45a6979eefea9860c1eaeacda (diff)
internal: document rename challenges
Diffstat (limited to 'crates/ide_db')
-rw-r--r--crates/ide_db/src/rename.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/crates/ide_db/src/rename.rs b/crates/ide_db/src/rename.rs
index 877650df0..d77602453 100644
--- a/crates/ide_db/src/rename.rs
+++ b/crates/ide_db/src/rename.rs
@@ -1,3 +1,25 @@
1//! Rename infrastructure for rust-analyzer. It is used primarily for the
2//! literal "rename" in the ide (look for tests there), but it is also available
3//! as a general-purpose service. For example, it is used by the fix for the
4//! "incorrect case" diagnostic.
5//!
6//! It leverages the [`crate::search`] functionality to find what needs to be
7//! renamed. The actual renames are tricky -- field shorthands need special
8//! attention, and, when renaming modules, you also want to rename files on the
9//! file system.
10//!
11//! Another can of worms are macros:
12//!
13//! ```
14//! macro_rules! m { () => { fn f() {} } }
15//! m!();
16//! fn main() {
17//! f() // <- rename me
18//! }
19//! ```
20//!
21//! The correct behavior in such cases is probably to show a dialog to the user.
22//! Our current behavior is ¯\_(ツ)_/¯.
1use std::fmt; 23use std::fmt;
2 24
3use base_db::{AnchoredPathBuf, FileId, FileRange}; 25use base_db::{AnchoredPathBuf, FileId, FileRange};
@@ -64,7 +86,8 @@ impl Definition {
64 // incorrect for renames. The safe behavior would be to return an error for 86 // incorrect for renames. The safe behavior would be to return an error for
65 // such cases. The correct behavior would be to return an auxiliary list of 87 // such cases. The correct behavior would be to return an auxiliary list of
66 // "can't rename these occurrences in macros" items, and then show some kind 88 // "can't rename these occurrences in macros" items, and then show some kind
67 // of a dialog to the user. 89 // of a dialog to the user. See:
90 cov_mark::hit!(macros_are_broken_lol);
68 91
69 let res = match self { 92 let res = match self {
70 Definition::Macro(mac) => { 93 Definition::Macro(mac) => {