Remix.run Logo
▲ jvanderbot 4 hours ago

Not really. I've worked with rust for 4 years, systems side, and never had to write a custom drop implementation. That's the gotcha here, not the rigamarole with the static+Send option type (which _would_ be something you'd encounter in prod).

▲bryanlarsen 4 hours ago | parent | next [-]

I've written dozens of custom Drop implementations. Well, many of them are named cleanup because of the async Drop mess in Rust, but...

▲dwattttt 2 hours ago | parent | next [-]

How many of them only conditionally implement Drop, based on a generic param lifetime?

▲Xirdus 2 hours ago | parent [-]

Why would you ever conditionally custom impl Drop? I don't think I've ever seen that pattern, and I can't think of a use case.

▲jvanderbot 2 hours ago | parent | prev [-]

OK. That's good to know. I'm not sure why sharing our professional experience with this type of code is controversial, but here we are.

▲neysofu 3 hours ago | parent | prev | next [-]

That's easily the exception rather than the rule. I've seen custom `Drop` implementations in almost every non-trivial Rust codebase I worked on.

▲gspr 3 hours ago | parent | prev | next [-]

A custom `Drop` appears very quickly with FFI code. Suppose for example you interface with some C library that expects you to call a function to release some resources.

▲ an hour ago | parent | prev | next [-]
[deleted]
▲rvz 2 hours ago | parent | prev [-]

Now we are at the phase where, Rust is “safe” but only if you use it “correctly” and without using X language feature or a custom Y feature.

This is the problem when a language advertises with “guarantees” and it turns out it never had any due to many false assumptions by their promoters.

So what other soundness bugs are there in the language that we need to know about?

▲jvanderbot 2 hours ago | parent | next [-]

I'm not defending rust here - a correctness bug invalidates the premise. But I am saying that I've never seen a custom drop in production.

For some reason this is controversial, but it remains true.

▲bryanlarsen 2 hours ago | parent | next [-]

You said/implied 2 things:

- you've never written a custom Drop

- "Not really". Implying that your experience generalizes

I've written a bunch of rust programs without custom Drop. I believe your first statement. There are large classes of programs that don't need it. There are also many that do. I think your statement says a lot more about what kind of programs you work on than about custom Drop not being common. People are downvoting the implication that custom Drop is not a common pattern.

▲cmrdporcupine 2 hours ago | parent | prev [-]

Custom drops are all over the place. As others have said.

But not custom drops that are doing variadic type stuff like this, usually.

▲cmrdporcupine 2 hours ago | parent | prev [-]

No we're in a situation where a bug in the type checker was found and will be fixed and a new release will be made.

That it took 11 years for someone to come across this is a fairly intense counterargument to your attempt to paint this as a language with dangerous footguns.