News for hackers. Stuff that matters.
Re:Rust project goals: Immobile types and guaranteed destruc... by mcherm on Monday August 03, 2026 @08:36AM (#49154940)
No, the point of Pin is to wrap types that CAN move. If the type were !Move then Pin wouldn't be needed.
Re:Rust project goals: Immobile types and guaranteed destruc... by Dagonfly on Monday August 03, 2026 @09:45AM (#49155740)
> the point of Pin is to wrap types that CAN move.

I would highlight that there are many cases where you CAN move an object safely until a certain operation requires the object to "stay put" in place.

Pin allows for that by tying the object to the place only when required. That's why Pin relates to both the object and the place.

Meanwhile, !Move types can't ever move. The object has to remain in the inital place it was constructed in. !Move requires in-place construction and emplacement to be ergonomic at all.

Re:Rust project goals: Immobile types and guaranteed destruc... by Mond_ on Monday August 03, 2026 @02:08PM (#49159391)
Stupid question, can't this trivially be solved by having a movable constructor / builder type that then gets turned into a non-movable type when built?
Re:Rust project goals: Immobile types and guaranteed destruc... by Dagonfly on Monday August 03, 2026 @03:26PM (#49160299)
Sure, thats one reason why IntoFuture and Future exist. Imo, in hindsight this is also main mistake in aysnc Rust: The whole async system should be build around IntoFuture rather than Future (async fn should return impl IntoFuture).

That way you could pass around IntoFutures without being affected by auto traits leaking. Only when you actually call .await() or .poll() would the immovable Future materialize.

Re:Rust project goals: Immobile types and guaranteed destruc... by yoshuaw on Monday August 03, 2026 @05:48PM (#49161910)
You're right that this is an important issue. I wrote a post explaining this in some detail, so at the very least we avoid having the same problem with generator functions:

https://blog.yoshuawuyts.com/gen-auto-trait-problem

Re:Rust project goals: Immobile types and guaranteed destruc... by stymaar on Tuesday August 04, 2026 @04:07AM (#49165645)
Thanks for the explanation (though I have to admit I liked your old blog theme more).

Since it's just a matter of how async get desugared, can it be changed through an edition?

Re:Rust project goals: Immobile types and guaranteed destruc... by Dagonfly on Tuesday August 04, 2026 @04:40AM (#49165850)
Oh yeah, I've read about all your blog post on this topic :)

To dump some ideas on you: I think one missing piece might be that FnOnce() -> impl Future should implement IntoFuture. Async runtimes would then use IntoFuture in their APIs agressively.

I call this a "workload blueprint" at work. Its a closure/type that contains all the info to start the workload, but in a minimal form. In Rust terms this would be a buildprint that is ideally Send + Move + Forget + 'static, even if the actual work (and the backing struct of the Future) is !Send (e.g. It holds an Rc across await points).

Runtimes could use this for their advantage: There would be a global pool of "workload blueprint" that can be stolen by any executer thread, but once a !Send workload has started on one thread it can't be migrated to another.

This in combination with matklad's ideas about seperating TaskSend from ThreadSend (https://matklad.github.io/2023/12/10/nsfw.html) would solve most of my async pain points.

Re:Rust project goals: Immobile types and guaranteed destruc... by 10000truths on Monday August 03, 2026 @03:03PM (#49160061)
> I would highlight that there are many cases where you CAN move an object safely until a certain operation requires the object to "stay put" in place.

You could model this with a state machine enum where the "stay put" phase is a variant that accepts a !Move, like so:

  enum StateMachine<PinnedState: ?Move> {
      InitialState,
      State1(String),
      State2(Box<PinnedState>),
      TerminalState,
  }
Re:Rust project goals: Immobile types and guaranteed destruc... by simonask on Monday August 03, 2026 @08:46AM (#49155049)
I guess `!Move` is largely equivalent to `Unpin` for the purposes of `Pin`, so for example Pin's safe constructor `Pin::new()` can be re-expressed in terms of `!Move` instead of `Unpin`. Today you need unsafe code to pin a `!Unpin` (i.e. "movable") type.

But I also suspect there are important differences between `!Move` and `Unpin` that I'm not sure about.

Re:Rust project goals: Immobile types and guaranteed destruc... by stymaar on Monday August 03, 2026 @02:46PM (#49159824)
This whole thread summarizes what's wrong with Pin: it's so confusing everyone in here got something wrong. (Just to address your mistake in particular Unpin is almost the opposite of !Move: it's the trait that represents things that can be un-pinned, that is: moved despite having been pinned. See https://doc.rust-lang.org/std/pin/index.html#unpin).
Re:Rust project goals: Immobile types and guaranteed destruc... by simonask on Tuesday August 04, 2026 @03:48AM (#49165525)
Right, of course. Yeah, it's an API riddled with so many double negatives it's hard to keep track.