postmono const expression conditions
note that you’d also need to do a similar check for alignment, which is omitted for brevity
UPD: as @arjentix pointed out, this will also only work in
playground
note that you’d also need to do a similar check for alignment, which is omitted for brevity
UPD: as @arjentix pointed out, this will also only work in
cargo build/cargo test; the check will be skipped in cargo checkplayground
🔥7👍1
a bit late to the party, but couldn’t pass this one
method resolution depends on compiler’s mutable internal state, which you can observe by calling a method on an integer literal
playground
Rust issue (two Zulip threads linked inside)
CI failures for naive fix
method resolution depends on compiler’s mutable internal state, which you can observe by calling a method on an integer literal
playground
Rust issue (two Zulip threads linked inside)
CI failures for naive fix
🤔12😱9🎉4❤1👍1😁1🤯1
playground
UCG issue
proposed patch
❤6🔥5👍1🤯1
Awful Rust snippets for fun and profit
my fix for this problem was merged and will be stable in rustc 1.81, unless something goes wrong
https://github.com/rust-lang/rust/pull/123043
https://github.com/rust-lang/rust/pull/123043
GitHub
Disable dead variant removal for `#[repr(C)]` enums. by GoldsteinE · Pull Request #123043 · rust-lang/rust
This prevents removing dead branches from a #[repr(C)] enum (they now get discriminants allocated as if they were inhabited).
Implementation notes: ABI of something like
#[repr(C)]
enum Foo {
F...
Implementation notes: ABI of something like
#[repr(C)]
enum Foo {
F...
👍8🔥4❤3
match match is legal and can be occasionally useful- playground
- real-world example from rust-analyzer
- people even do if if sometimes
thanks to @LennyLizowzskiy for suggesting this!
🤯17👍6🥰3😐2❤1🔥1
a slightly more fun slash cursed variation on a standard “enum-instead-of-bool” trick
playground
don’t use booleans — an explanation on why would you even want that
thanks to @Ddystopia_0 for inspiring this one!
playground
don’t use booleans — an explanation on why would you even want that
thanks to @Ddystopia_0 for inspiring this one!
👀7❤4👍2😱1🥴1
parsing sequences (like dates or version strings) by matching on part index
playground
original example
thanks to @kanashimia for suggesting this one!
playground
original example
thanks to @kanashimia for suggesting this one!
🤯13🔥5👍2
1.80 now warns on
playground
release notes about the warning
(also yay 300 subscribers!)
#[cfg(skip)], so here’s a workaroundplayground
release notes about the warning
(also yay 300 subscribers!)
🔥12😁7⚡3😨3👎1
wrote down some thoughts about error handling, specifically a pattern that I call “progress pattern” (probably it has another name somewhere, but I’m not aware of it)
https://github.com/GoldsteinE/gh-blog/blob/master/error_progress/README.md
thanks to @meowaffle for reviewing this!
(btw, are y’all ok with breaking the format like this sometimes?)
https://github.com/GoldsteinE/gh-blog/blob/master/error_progress/README.md
thanks to @meowaffle for reviewing this!
(btw, are y’all ok with breaking the format like this sometimes?)
👍18🔥1😨1
iex by @purplesyringa automatically adds its attribute to the docs by injecting a
code link
<style> tagcode link
🐳9❤2🤯2
Awful Rust snippets for fun and profit
iex by @purplesyringa automatically adds its attribute to the docs by injecting a <style> tag code link
check out the crate btw, it’s really cool
blog post
blog post
purplesyringa's blog
You might want to use panics for error handling
Rust’s approach to error handling comes at a cost. The Result type often doesn’t fit in CPU registers, and callers of fallible functions have to check whether the returned value is Ok or Err. That’s a stack spill, a comparison, a branch, and a lot of error…
❤5
mixed-site hygiene might be surprising
original blogpost (read it, it’s cool!)
playground
thanks to @alexpyattaev for suggesting this!
original blogpost (read it, it’s cool!)
playground
thanks to @alexpyattaev for suggesting this!
🔥10🤯4👍2❤1🥴1
cyclic associated types are okay under lazy normalization / next solver
(you need
godbolt
tracking issue
(you need
?Sized though, otherwise it tries to prove Assoc: Sized and fails)godbolt
tracking issue
🤯13
macros can close over their environment, “breaking” hygiene
playground
I’d like to give a link to documentation here, but I don’t think this is actually documented anywhere? neither reference nor TLBORM mention it as far as I can see
UPD: ferrocene specification
playground
I’d like to give a link to documentation here, but I don’t think this is actually documented anywhere? neither reference nor TLBORM mention it as far as I can see
UPD: ferrocene specification
❤5🤯3👍2😁1
Awful Rust snippets for fun and profit
so, a quick PSA moment The Rust Foundation (not to be confused with The Rust Project, who actually develop Rust) is currently planning to put up trademark policies that are so restrictive that this channel would be affected. essentially, they want to prohibit…
I’m sorry, but we seemingly need to do the same exact thing again
the new draft is somewhat better, but it still has at least two issues:
— it requires explicit approval to host events that are not free to attend, which includes even non-commercial events, since renting a venue isn’t actually free
— its wording around modified versions prohibits forking the compiler to send a PR, since you’re publicly distributing a modified version under the trademarked name
announces:
https://blog.rust-lang.org/2024/11/06/trademark-update.html
https://foundation.rust-lang.org/news/rust-trademark-policy-updates/
policy draft:
https://drive.google.com/file/d/1hjTx11Fb-4W7RQLmp3R8BLDACc7zxIpG/view?usp=sharing
feedback form:
https://docs.google.com/forms/d/e/1FAIpQLSeU1Ocopa0v9UZn_ZSTkKQM7gqZIrt63lCFz-xtogcFHMtkAg/viewform?usp=sf_link
please, read the policy and use the form to file your concerns if you have any. (please, don’t send my concerns without reading the policy yourself, that’s just spam)
the new draft is somewhat better, but it still has at least two issues:
— it requires explicit approval to host events that are not free to attend, which includes even non-commercial events, since renting a venue isn’t actually free
— its wording around modified versions prohibits forking the compiler to send a PR, since you’re publicly distributing a modified version under the trademarked name
announces:
https://blog.rust-lang.org/2024/11/06/trademark-update.html
https://foundation.rust-lang.org/news/rust-trademark-policy-updates/
policy draft:
https://drive.google.com/file/d/1hjTx11Fb-4W7RQLmp3R8BLDACc7zxIpG/view?usp=sharing
feedback form:
https://docs.google.com/forms/d/e/1FAIpQLSeU1Ocopa0v9UZn_ZSTkKQM7gqZIrt63lCFz-xtogcFHMtkAg/viewform?usp=sf_link
please, read the policy and use the form to file your concerns if you have any. (please, don’t send my concerns without reading the policy yourself, that’s just spam)
😭7👍2🤬2🙈2