@jhpratt@mastodon.social avatar

jhpratt

@jhpratt@mastodon.social

Contributor to Rust's compiler and standard library. Maintainer of Rust crates including time, deranged, powerfmt, num_threads, and num-conv. Third degree black belt in American Kenpo 🥋

jhpratt on most platforms

This profile is from a federated server and may be incomplete. Browse more on the original instance.

jhpratt, to random
@jhpratt@mastodon.social avatar

@frameworkcomputer laptop received! 64 GB of RAM and a 2 TB SSD later, there's definitely a bit of a learning curve on my first new (personal) laptop in a few years.

Manufacturing tolerances were decent, though the trackpad did have the edges curved up slightly. A small amount of force got it to be within my expectations. There is essentially zero gap between the spacers and trackpad module, which is awesome. My only "surprise", so to speak is that the top of the lower spacers have a hard edge.

jhpratt, to reddit
@jhpratt@mastodon.social avatar

Well, apparently I'm banned on #Reddit site-wide. When someone appears to be a threat to themself, I report it. How dare I use their report system in the manner intended? Banning someone for that sends the wrong message.

I've been doxxed, harassed, threatened, and even reported a terroristic threat in the past, yet the admins refuse to consider the mere possiiblity of good faith despite a decade on the site with no issues. And naturally they won't give anything other than a canned response.

jhpratt,
@jhpratt@mastodon.social avatar

I only ever really participated in was the Rust subreddit, but not being able to is a negative for everyone. The subreddit I moderated already has obvious rule violations (including further harassment directed towards me) that can't be addressed by anyone, as I was the sole moderator. Good job #Reddit.

jhpratt, to rust
@jhpratt@mastodon.social avatar

Hit an edge case in the #Rust compiler that appears to be quadratic at best and potentially exponential. Trivial to make happen with real-world code. Investigating...

#RustLang #programming

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber Me too! I'm going to use the self-profile feature to try to determine where time is being spent. Creating a minimal reproduction may be tricky, as the underlying library is relatively intertwined.

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber Oh, I forgot to mention. This happens with cargo check, so it is unquestionably rustc and not LLVM.

jhpratt,
@jhpratt@mastodon.social avatar

@predrag @ekuber

Discarding the smallest checks as insignificant, it's certainly exponential. Best fit is an exponent of 1.27749 × the number of methods chained; correlation is 0.992.

A chain of 11 methods took 7m51s to type check, and I didn't dare to try 12 (which was my original code).

typeck: 28.941%
normalize_canonicalized_projection_ty 26.938%
type_op_prove_predicate 25.097%
codegen_select_candidate 12.080%
LLVM_passes 5.534%

Any tips on creating a minimal example for an issue?

jhpratt,
@jhpratt@mastodon.social avatar

@ekuber @predrag Very much so — every part of the API is based around trait impls. Stubbing bodies is a good starting place.

jhpratt, to rust
@jhpratt@mastodon.social avatar

Now that it's public, I can say that I will be speaking (again) at #RustConf in Montréal! Catch me there or online in September.

#Rust #RustLang #programming

jhpratt, to firefox
@jhpratt@mastodon.social avatar

I like #Firefox, but it is definitely trailing behind other browsers. PWAs, WebUSB, stacked/grouped tabs, and far more are present in a number of browsers and are all incredibly useful. Firefox has none of these. I thought translation was an extension because FF communication is crap.

I refuse to use Chrome out of principle, and Vivaldi is the only browser that even seems remotely what I want. But whenever I've tried it, I quickly ran into trivial, obvious bugs that I had reported years prior.

jhpratt,
@jhpratt@mastodon.social avatar
jhpratt, to rust
@jhpratt@mastodon.social avatar

Preview of what I have been working on recently. The core of this crate is a mere two traits. The crate will ship with a number of parsers and combinators, none of which rely on anything not exposed to downstream users.

I've attached a real-world situation, taken verbatim from the test suite. Parsing integers isn't as efficient as it could be yet, as it's using a naïve method.

Parsing in general compiles to be extremely efficient, and using it is ergonomic.

#Rust #RustLang #programming

pub trait Combinator<'input, P> where P: ByteParser<'input>, { type NewParser: ByteParser<'input>; fn apply_to(self, parser: P) -> Self::NewParser; }
#[test] fn parse_date() -> parcom::Result<()> { let parser = ascii::int:: .limit_length(4) .and(verbatim(b"-").discard()) .and(ascii::int::.limit_length(2)) .and(verbatim(b"-").discard()) .and(ascii::int::.limit_length(2)); let (seq!(year, _, month, _, day), remaining) = parser.parse("2021-07-04")?.into_parts(); assert!(remaining.is_empty()); assert_eq!(year, 2021); assert_eq!(month, 7); assert_eq!(day, 4); Ok(()) }

jhpratt, to rust
@jhpratt@mastodon.social avatar

So now that -Zcheck-cfg is stabilized and enabled by default, there's no way to tell the compiler about custom cfgs other than a build script?

I routinely use a custom cfg for rustdoc so that I can use nightly features when publishing (both with docs.rs and CI). #[cfg(coverage)] is also used in some places.

Apparently spurious warnings are extremely wide-spread, so I'm not clear on why this was stabilized with such a glaring hole in it.

#Rust #RustLang

jhpratt, to rust
@jhpratt@mastodon.social avatar

In #Rust, how can I leverage the type system to enforce that one object originates from another? Even requiring the lifetime be exact ('a: 'b and 'b: 'a) wouldn't work.

Basically, I have struct Bytes&lt;'a&gt;(&amp;'a [u8]); and want to prevent someone from creating an arbitrary value that can be swapped in for the correct one. Yet at the same time it is essential that arbitrary values can be created.

Basically I'm trying to enforce my own version of provenance…

#RustLang

jhpratt,
@jhpratt@mastodon.social avatar

I believe I've done it. After a few attempts, I was able to enforce provenance while minimally affecting the API.

Implementing a trait now has a trivial amount of overhead, while end users will see no difference whatsoever from what I wanted.

To those wondering, I ended up using the closure hack along with forcing invariance. GhostCell, while neat, only appears to work within a single function.

Should I write something up about this? It's an interesting problem.

#Rust #RustLang #programming

jhpratt,
@jhpratt@mastodon.social avatar

Note that there would be one reason that I might want to hold out on doing a write-up, but I'll know for sure if it would be a concern in a couple days.

jhpratt, to random
@jhpratt@mastodon.social avatar

Yet another round of layoffs at Tesla, and this time I'm part of it.

If anyone is aware of full time work that I may be interested in, let me know! I'm located in the US (upstate NY specifically) and an open to relocation, though I would prefer remote.

#FediHire

jhpratt, to random
@jhpratt@mastodon.social avatar

As of today, Donald Trump is a convicted criminal.

jhpratt,
@jhpratt@mastodon.social avatar

@underlap The contempt of court was criminal, not civil.

"The Court finds Defendant in criminal contempt for willfully disobeying a lawful mandate
of this Court in violation of Judiciary Law Section 750(3) on nine separate occasions."

https://www.nycourts.gov/LegacyPDFS/press/PDFs/D.O.motion4contempt-FINAL.pdf

ekuber, to rust
@ekuber@hachyderm.io avatar

Somewhat cursed #RustLang idea: "attributes at a distance"

#![attr(target = crate::foo::Bar)]

mod foo {  
 struct Bar;  
}  

What would you use this for?

jhpratt,
@jhpratt@mastodon.social avatar

@ekuber Allowing something deprecated is an obvious situation to me

jhpratt,
@jhpratt@mastodon.social avatar

@ekuber Ah, I misunderstood what was being suggested. I have no idea why you'd want that 😅

jhpratt, to random
@jhpratt@mastodon.social avatar

What happened with #xz is precisely why I ceased support of serde versions that had pre-compiled binaries included. It doesn't matter how trustworthy someone seems or how long they've been maintaining a project.

I caught flak from a number of people, including one person (in person, and respectfully!) saying that I was "policing the ecosystem". Which...yes, that's the point. Unknown, unverified binaries being executed is unacceptable and dangerous until proven safe, not the other way around.

jhpratt, to rust
@jhpratt@mastodon.social avatar

Looking back at some of the #Rust crates that I've published as spin-offs from time:

  • deranged (range-bounded integers)
  • num-conv (avoiding as casts)
  • num_threads (thread count for current process)
  • powerfmt (making it easier to implement Display while following formatting flags)
  • standback (backporting the standard library to older compilers)

Only standback is no longer maintained, as I don't need it any more. All the others are maintained, with num_threads having a co-maintainer.

jhpratt,
@jhpratt@mastodon.social avatar

Check out the crates! No published crates other than my own and forks have any as a dependency, despite all of them being useful! There are two other spin-off crates in progress, bringing the total to seven crates that aren't an integral part of time.

jhpratt, to rust
@jhpratt@mastodon.social avatar

For those that wanted a comparison between the time and chrono crates, here's an excellent overview of some differences between the crates:

https://users.rust-lang.org/t/the-state-of-time-in-rust-leaps-and-bounds/107620?u=jhpratt

#Rust #RustLang #programming

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines