-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Provide structured suggestion on unsized fields and fn params #74228
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
| | ||
LL | value: &T, | ||
| ^ | ||
help: boxed trait objects have a statically known size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this help slightly misleading? T
is a type parameter, not a trait object here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point. I could say boxed types have...
and that would be more accurate always at the cost of not giving people some jargon to google... I'll see if I can make it conditional on the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about "heap allocated types always have a statically known size"? Edit: last commit has this wording.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I personally don't really like "heap allocated types", as an object of the type is allocated on the heap, not the type itself 😅
Not sure what's the best wording here, but maybe "boxed types always have a statically known size" which seems more correct to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to introduce a bit of jargon here, as Box
is already mentioned in the code suggestion itself, to tie the concept of "heap allocations" and "Box
". That being said I see your point. Lets merge this as is to avoid bitrot (I don't think the wording is outright wrong, just suboptimal), but let's open a follow up PR to improve the wording?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lcnr what about "the Box
type always has a statically known size and allocates its contents in the heap"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, r=me after squashing a little
Should I squash all into one commit or just squash the fixup commits where they belong? |
Whichever you prefer, I tend to do the latter. |
@bors r+ |
📌 Commit 2d0f3eb has been approved by |
🌲 The tree is currently closed for pull requests below priority 20, this pull request will be tested once the tree is reopened |
Provide structured suggestion on unsized fields and fn params * Suggest borrowing or boxing unsized fields * Suggest borrowing fn parameters * Remove some verbosity of unsized errors * Remove `on_unimplemented` note from `trait Sized` Fix rust-lang#23286, fix rust-lang#28653. r? @davidtwco
@bors r=davidtwco |
📌 Commit ff75395 has been approved by |
🌲 The tree is currently closed for pull requests below priority 5, this pull request will be tested once the tree is reopened |
…arth Rollup of 11 pull requests Successful merges: - rust-lang#73759 (Add missing Stdin and StdinLock examples) - rust-lang#74211 (Structured suggestion when not using struct pattern) - rust-lang#74228 (Provide structured suggestion on unsized fields and fn params) - rust-lang#74252 (Don't allow `DESTDIR` to influence LLVM builds) - rust-lang#74263 (Slight reorganization of sys/(fast_)thread_local) - rust-lang#74271 (process_unix: prefer i32::*_be_bytes over manually shifting bytes) - rust-lang#74272 (pprust: support multiline comments within lines) - rust-lang#74332 (Update cargo) - rust-lang#74334 (bootstrap: Improve wording on docs for `verbose-tests`) - rust-lang#74336 (typeck: use `item_name` in cross-crate packed diag) - rust-lang#74340 (lint: use `transparent_newtype_field` to avoid ICE) Failed merges: r? @ghost
on_unimplemented
note fromtrait Sized
Fix #23286, fix #28653.
r? @davidtwco