Skip to content

render const value in completions label details - #23266

Merged
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
BenjaminBrienen:const-label-details
Sep 3, 2026
Merged

render const value in completions label details#23266
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
BenjaminBrienen:const-label-details

Conversation

@BenjaminBrienen

@BenjaminBrienen BenjaminBrienen commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

I think this would be neat. You may be brutal with the feedback on the code.

Screenshot_2026-08-31_21-06-16

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 31, 2026
@sk0g

sk0g commented Aug 31, 2026

Copy link
Copy Markdown

This would be very helpful! RustRover does something similar and it's quite helpful when looking over convenience shortcuts for types you aren't familiar with.

Would it be possible to align the syntax of this a bit more with that of associated type defaults? https://rust-lang.github.io/rfcs/2532-associated-type-defaults.html

Eg

            ct A  = 123  pub const A: i32
// Becomes
            ct A   pub const A: i32 = 123

Edit: actually not sure, looking at the examples in the screenshot, how it works right now would look a lot more reasonable than shoving everything to the right edge.

@BenjaminBrienen

Copy link
Copy Markdown
Contributor Author

CI failure is a regression in #23257

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

You need to rebase on master.

@BenjaminBrienen

Copy link
Copy Markdown
Contributor Author

done

@rustbot

rustbot commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@ChayimFriedman2 ChayimFriedman2 left a comment

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.

I think it will be better to display the evaluated const value, like we do in other places (e.g. hover).

View changes since this review

Comment thread crates/ide-completion/src/completions/format_string.rs Outdated
@BenjaminBrienen
BenjaminBrienen force-pushed the const-label-details branch 2 times, most recently from 88fbccd to f475bb1 Compare September 1, 2026 09:34
@BenjaminBrienen

Copy link
Copy Markdown
Contributor Author

Done. I tried adding a unit test for rendering u32::MAX, but the completion didn't show up at all. It does work, though:
Screenshot_2026-09-01_11-33-48

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

You probably need to include something from minicore.

@BenjaminBrienen

Copy link
Copy Markdown
Contributor Author

Ok, I added that under uint_consts. Hopefully the name is ok.

Comment thread crates/test-utils/src/minicore.rs Outdated
Comment thread crates/ide-completion/src/completions/format_string.rs Outdated
Comment thread crates/ide-completion/src/completions/format_string.rs Outdated
@BenjaminBrienen

Copy link
Copy Markdown
Contributor Author

Is "feaures" a typo in rustc? 😂️

@BenjaminBrienen

Copy link
Copy Markdown
Contributor Author

rust-lang/rust#162115

@ChayimFriedman2 ChayimFriedman2 left a comment

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.

Just fix the typos and LGTM.

View changes since this review

Comment thread crates/ide-completion/src/item.rs Outdated
@ChayimFriedman2

Copy link
Copy Markdown
Contributor

You overrode the commit message...

@ChayimFriedman2 ChayimFriedman2 left a comment

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.

@ChayimFriedman2
ChayimFriedman2 added this pull request to the merge queue Sep 3, 2026
Merged via the queue into rust-lang:master with commit 97e1c09 Sep 3, 2026
19 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 3, 2026
@BenjaminBrienen
BenjaminBrienen deleted the const-label-details branch September 3, 2026 07:20
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.

4 participants