Skip to content

Add an assert_size attribute for structs #18161

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

Closed
kmcallister opened this issue Oct 19, 2014 · 4 comments
Closed

Add an assert_size attribute for structs #18161

kmcallister opened this issue Oct 19, 2014 · 4 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@kmcallister
Copy link
Contributor

size_of is maybe the top use case for function evaluation in static asserts, which doesn't seem like it will happen any time soon. We can satisfy this use case with a very simple and self-contained feature, e.g.

#[assert_size(48)]
struct StringCacheEntry {
    next_in_bucket: *mut StringCacheEntry,
    hash: u64,
    ref_count: AtomicInt,
    string: String,
}

I think making this kind of assertion painless will help programs avoid performance regressions.

@kmcallister kmcallister added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-papercut A-attributes Area: Attributes (`#[…]`, `#![…]`) labels Oct 19, 2014
@mahkoh
Copy link
Contributor

mahkoh commented Oct 19, 2014

More special cases due to the lack of CTFE.

@thestinger
Copy link
Contributor

I don't think we should add a bunch of very special cased hacks to work around a clearly desirable language feature.

@steveklabnik
Copy link
Member

closing in favor of rust-lang/rfcs#591

@mahkoh
Copy link
Contributor

mahkoh commented Feb 16, 2015

I don't see how that RFC solves this issue.

lnicola pushed a commit to lnicola/rust that referenced this issue Sep 25, 2024
fix: Better support references in consuming postfix completions

Fixes rust-lang#18155.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants