Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add an option to hide adjustment hints outside of unsafe blocks and functions #13817

Merged

Conversation

WaffleLapkin
Copy link
Member

As the title suggests: this PR adds an option (namely rust-analyzer.inlayHints.expressionAdjustmentHints.hideOutsideUnsafe) that allows to hide adjustment hints outside of unsafe blocks and functions:

2022-12-21_23-11

Requested by @BoxyUwU <3

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 21, 2022
crates/hir/src/lib.rs Outdated Show resolved Hide resolved
@@ -110,6 +121,59 @@ pub(super) fn hints(
Some(())
}

fn is_inside_unsafe(sema: &Semantics<'_, RootDatabase>, node: &SyntaxNode) -> bool {
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems to be working fine, but I'm left wondering if there is a better way...

crates/hir/src/semantics.rs Outdated Show resolved Hide resolved
@@ -1458,6 +1470,59 @@ impl<'db> SemanticsImpl<'db> {
.map(|ty| ty.original.is_packed(self.db))
.unwrap_or(false)
}

fn is_inside_unsafe(&self, node: &SyntaxNode) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fn is_inside_unsafe(&self, node: &SyntaxNode) -> bool {
fn is_inside_unsafe(&self, node: &ast::Expr)-> bool {

This handles expressions so it should only take such

@rust-cloud-vms rust-cloud-vms bot force-pushed the hide_adjustment_hints_outside_of_unsafe branch from bb3a66b to 94d0772 Compare December 21, 2022 23:00
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
@rust-cloud-vms rust-cloud-vms bot force-pushed the hide_adjustment_hints_outside_of_unsafe branch from 94d0772 to 1038db5 Compare December 21, 2022 23:00
@Veykril
Copy link
Member

Veykril commented Dec 22, 2022

This might not play completely nice with macro expansions, but we'll see
@bors r+

@bors
Copy link
Collaborator

bors commented Dec 22, 2022

📌 Commit 1038db5 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Dec 22, 2022

⌛ Testing commit 1038db5 with merge eb3963b...

@bors
Copy link
Collaborator

bors commented Dec 22, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing eb3963b to master...

@bors bors merged commit eb3963b into rust-lang:master Dec 22, 2022
@bors bors mentioned this pull request Dec 22, 2022
@WaffleLapkin WaffleLapkin deleted the hide_adjustment_hints_outside_of_unsafe branch January 9, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants