Skip to content

Properly handle shorthands in destructure patterns when renaming#6552

Merged
bors[bot] merged 4 commits intorust-lang:masterfrom
Veykril:rename
Nov 15, 2020
Merged

Properly handle shorthands in destructure patterns when renaming#6552
bors[bot] merged 4 commits intorust-lang:masterfrom
Veykril:rename

Conversation

@Veykril
Copy link
Copy Markdown
Member

@Veykril Veykril commented Nov 14, 2020

Fixes #6548 and #6551.

Comment thread crates/ide/src/references/rename.rs Outdated
}

#[test]
fn test_struct_field_destructure_into_shorthand() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, should we also check for destructuring in arguments too fn foo()?

Nit: we can also put all rename tests into one snippet to slightly reduce the test count, diff size, etc.

Copy link
Copy Markdown
Member Author

@Veykril Veykril Nov 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the nit you mean as in merging most of the before_fixtures of the difference cases to reuse them behind a static? Ah nevermind you mean merging the test functions and test multiple things per test.

And yes, testing for parameter destructuring also seems like a good idea

Copy link
Copy Markdown
Member Author

@Veykril Veykril Nov 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I don't think we can put the tests together though, as they require slightly different fixtures and/or different <|> cursor positions. Edit: Actually two can be put together as their expected fixture is the same.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, never mind then, I din't think it's worth supporting the multiple caret tests for this case.

Comment thread crates/ide/src/references/rename.rs
TextRange::new(reference.file_range.range.end(), reference.file_range.range.end())
}
ReferenceKind::RecordFieldExprOrPat => {
mark::hit!(test_rename_field_expr_pat);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@SomeoneToIgnore
Copy link
Copy Markdown
Contributor

bors r+

@bors
Copy link
Copy Markdown
Contributor

bors Bot commented Nov 15, 2020

}
}

pub fn name_ref(&self) -> Option<ast::NameRef> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same thing here -- this methong is non-primitives -- it's a convenience function which reaches deep into the node. We should have such functions, but not as inherent methods on AST nodes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same -- see my recent comment on another PR :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Renaming a struct initializer to match the field name should use shorthand record syntax

3 participants