Tim McNamara
@timclicks.dev
Trainer and consultant on the Rust programming language. Author of Rust in Action. Team climate. Walkable neighbourhoods are nice, actually.
Signal: @timclicks.01
Signal: @timclicks.01
p.s.s. You can help feed the algorithm by subscribing to make the numbers go up. It helps!!
November 11, 2025 at 10:59 PM
p.s.s. You can help feed the algorithm by subscribing to make the numbers go up. It helps!!
p.s. I have begun to think about how to be more active on here. Is there questions that would be useful to talk or write about?
November 11, 2025 at 10:59 PM
p.s. I have begun to think about how to be more active on here. Is there questions that would be useful to talk or write about?
It was added very recently (version 1.91.0). Try `rustup update`.
November 10, 2025 at 9:12 PM
It was added very recently (version 1.91.0). Try `rustup update`.
And if you're curious about why "deny(...)" is on every line, it's because I find that this style works best with version control.
November 10, 2025 at 3:12 AM
And if you're curious about why "deny(...)" is on every line, it's because I find that this style works best with version control.
Article with more info: www.patreon.com/posts/deny-...
November 9, 2025 at 11:34 PM
Article with more info: www.patreon.com/posts/deny-...
November 9, 2025 at 11:34 PM
Being stricter will be annoying at first. Your project won't build. It'll be slower to get the next feature out.
But remember when you were "fighting the borrow checker". It was frustrating and development slow. After a while, things got easier. After some time, you started appreciating the check.
But remember when you were "fighting the borrow checker". It was frustrating and development slow. After a while, things got easier. After some time, you started appreciating the check.
November 9, 2025 at 11:34 PM
Being stricter will be annoying at first. Your project won't build. It'll be slower to get the next feature out.
But remember when you were "fighting the borrow checker". It was frustrating and development slow. After a while, things got easier. After some time, you started appreciating the check.
But remember when you were "fighting the borrow checker". It was frustrating and development slow. After a while, things got easier. After some time, you started appreciating the check.
These warnings prevent UB:
#![deny(deref_nullptr)]
#![deny(integer_to_ptr_transmutes)]
#![deny(invalid_value)]
#![deny(invalid_from_utf8)]
#![deny(never_type_fallback_flowing_into_unsafe)]
#![deny(ptr_to_integer_transmute_in_consts)]
#![deny(static_mut_refs)]
#![deny(deref_nullptr)]
#![deny(integer_to_ptr_transmutes)]
#![deny(invalid_value)]
#![deny(invalid_from_utf8)]
#![deny(never_type_fallback_flowing_into_unsafe)]
#![deny(ptr_to_integer_transmute_in_consts)]
#![deny(static_mut_refs)]
November 9, 2025 at 11:34 PM
These warnings prevent UB:
#![deny(deref_nullptr)]
#![deny(integer_to_ptr_transmutes)]
#![deny(invalid_value)]
#![deny(invalid_from_utf8)]
#![deny(never_type_fallback_flowing_into_unsafe)]
#![deny(ptr_to_integer_transmute_in_consts)]
#![deny(static_mut_refs)]
#![deny(deref_nullptr)]
#![deny(integer_to_ptr_transmutes)]
#![deny(invalid_value)]
#![deny(invalid_from_utf8)]
#![deny(never_type_fallback_flowing_into_unsafe)]
#![deny(ptr_to_integer_transmute_in_consts)]
#![deny(static_mut_refs)]
Denying specific lints is one way to reduce this risk while also benefiting from increased protection.
November 9, 2025 at 11:34 PM
Denying specific lints is one way to reduce this risk while also benefiting from increased protection.
But, do not do this in your CI/CD system. If you do, you'll risk your build breaking at any time in the future as new warnings are added to Rust.
This is much more serious than it sounds because it'll probably happen as soon as you don't want it to.
This is much more serious than it sounds because it'll probably happen as soon as you don't want it to.
November 9, 2025 at 11:34 PM
But, do not do this in your CI/CD system. If you do, you'll risk your build breaking at any time in the future as new warnings are added to Rust.
This is much more serious than it sounds because it'll probably happen as soon as you don't want it to.
This is much more serious than it sounds because it'll probably happen as soon as you don't want it to.
Adding this attribute to the top of your crate is probably the easiest way to do promote warnings to errors:
#![deny(warnings)
Cargo also respects the RUSTFLAGS environment variable. This is the most general purpose solution.
RUSTFLAGS= -D warnings
#![deny(warnings)
Cargo also respects the RUSTFLAGS environment variable. This is the most general purpose solution.
RUSTFLAGS= -D warnings
November 9, 2025 at 11:34 PM
Adding this attribute to the top of your crate is probably the easiest way to do promote warnings to errors:
#![deny(warnings)
Cargo also respects the RUSTFLAGS environment variable. This is the most general purpose solution.
RUSTFLAGS= -D warnings
#![deny(warnings)
Cargo also respects the RUSTFLAGS environment variable. This is the most general purpose solution.
RUSTFLAGS= -D warnings
Granted, most are esoteric. But, even so, very it's easy to protect yourself from them. You ask the Rust compiler to deny building a project if a warning is triggered.
November 9, 2025 at 11:34 PM
Granted, most are esoteric. But, even so, very it's easy to protect yourself from them. You ask the Rust compiler to deny building a project if a warning is triggered.
Yeah I've made that mistake once or twice before too.
November 7, 2025 at 9:57 AM
Yeah I've made that mistake once or twice before too.
That's an excellent point!
November 7, 2025 at 9:48 AM
That's an excellent point!
As an aside, I would have written this for readability and to remove a comparison:
match intrinsics::ptr_guaranteed_cmp(self, other) {
0 => Some(false),
1 => Some(true),
2 => None,
_ => unreachable!(),
}
(But this is used in const contexts, so I guess the nested if is ok)
match intrinsics::ptr_guaranteed_cmp(self, other) {
0 => Some(false),
1 => Some(true),
2 => None,
_ => unreachable!(),
}
(But this is used in const contexts, so I guess the nested if is ok)
November 7, 2025 at 3:46 AM
As an aside, I would have written this for readability and to remove a comparison:
match intrinsics::ptr_guaranteed_cmp(self, other) {
0 => Some(false),
1 => Some(true),
2 => None,
_ => unreachable!(),
}
(But this is used in const contexts, so I guess the nested if is ok)
match intrinsics::ptr_guaranteed_cmp(self, other) {
0 => Some(false),
1 => Some(true),
2 => None,
_ => unreachable!(),
}
(But this is used in const contexts, so I guess the nested if is ok)
Here's the link to the function. Unfortunately, it's behind a nightly flag because only the standard library gets nice things 😅 doc.rust-lang.org/std/primitiv...
pointer - Rust
Raw, unsafe pointers, `*const T`, and `*mut T`.
doc.rust-lang.org
November 7, 2025 at 3:46 AM
Here's the link to the function. Unfortunately, it's behind a nightly flag because only the standard library gets nice things 😅 doc.rust-lang.org/std/primitiv...
Why is this useful? For most people, it's fun trivia.
For programmers hunting performance, this guarantee facilitates compile-time null checks. Null checks happen billions of times in the life of a program, so saving a microsecond or so can be quite useful.
For programmers hunting performance, this guarantee facilitates compile-time null checks. Null checks happen billions of times in the life of a program, so saving a microsecond or so can be quite useful.
November 7, 2025 at 12:31 AM
Why is this useful? For most people, it's fun trivia.
For programmers hunting performance, this guarantee facilitates compile-time null checks. Null checks happen billions of times in the life of a program, so saving a microsecond or so can be quite useful.
For programmers hunting performance, this guarantee facilitates compile-time null checks. Null checks happen billions of times in the life of a program, so saving a microsecond or so can be quite useful.
Raw pointers have a "guaranteed_eq" method that's even more guaranteed than the Eq trait.
November 7, 2025 at 12:31 AM
Raw pointers have a "guaranteed_eq" method that's even more guaranteed than the Eq trait.