mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-11 14:18:39 +00:00
Add a new config to allow renaming of non-local items
With #15656 we started disallowing renaming of non-local items. Although this makes sense there are some false positives that impacted users' workflows. So this config aims to mitigate this by giving users the liberty to disable this feature.
This commit is contained in:
parent
5b62ebc23f
commit
9bd9a17ce5
8 changed files with 65 additions and 17 deletions
|
@ -71,14 +71,17 @@ impl Definition {
|
|||
&self,
|
||||
sema: &Semantics<'_, RootDatabase>,
|
||||
new_name: &str,
|
||||
rename_external: bool,
|
||||
) -> Result<SourceChange> {
|
||||
// self.krate() returns None if
|
||||
// self is a built-in attr, built-in type or tool module.
|
||||
// it is not allowed for these defs to be renamed.
|
||||
// cases where self.krate() is None is handled below.
|
||||
if let Some(krate) = self.krate(sema.db) {
|
||||
if !krate.origin(sema.db).is_local() {
|
||||
bail!("Cannot rename a non-local definition.")
|
||||
// Can we not rename non-local items?
|
||||
// Then bail if non-local
|
||||
if !rename_external && !krate.origin(sema.db).is_local() {
|
||||
bail!("Cannot rename a non-local definition. Set `renameExternalItems` to `true` to allow renaming for this item.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue