1. 100
  1.  

    1. 32

      So many good changes in this edition, but I think my favorite is the block tail expression temporaries change, because it means you can finally wrap an expression in a block to drop any temporaries in that expression. This means code like

      match process_value(mutex.lock().unwrap()) {
          Ok(()) => { do_stuff(); }
          Err(e) => { log_err(e); }
      }
      

      can be fixed to stop holding the lock across the whole match using a simple block, like

      match { process_value(mutex.lock().unwrap()) } {
          Ok(()) => { do_stuff(); }
          Err(e) = { log_err(e); }
      }
      

      instead of having to extract the scrutinee out into a separate variable.

      1. 11

        Woooah I didn’t grok that until you pointed out. So this is at least a new option for working aroud https://fasterthanli.me/articles/a-rust-match-made-in-hell ?

        Edit: Indeed, this small example is a deadlock under 2021 Edition but not under 2024 Edition.

        1. 3

          YAAAAS!! The release notes prominently mention “if let temporary scope” (avoiding the same issue for if let by default, even without having to use a curly block), but it’s very nice to hear that there’s also a general solution for any place now.

        2. 10

          Big update, lots of good unsafe stuff in the new edition. Setting env vars, extern blocks, attributes, unsafe fn bodies, static mut references banned altogether. All of these things make unsafe code easier, or clearer at least.

          Also a huge fan of formatting being tied to editions so it can improve without churn.

          It’s nice that the “breaking” changes made in editions tend to be quite small things which unblock larger features later or just make life a tiny bit easier. It seems unlikely for any of these changes to be difficult to accommodate and I imagine cargo fix will do most of the work.

          1. 8

            Async closures fixes such a massive hole, stoked to see it stable

            1. 3

              THANK GOD we finally have async closures, this was such a pain to work around

              1. 2

                One thing I’ve always wondered is why Rust doesn’t use major version increments for major editions like this? The only thing I can think of is the residual fear of the Python 2 -> 3 jump. Or do they just not use semver?

                1. 20

                  Because Editions are not breaking changes in that sense: Rust 1.85 will compile your project from Rust 1.80 just fine.

                  Editions introduce breaking changes, but they are opt-in on a crate level and can be mixed: you can upgrade without your dependencies having moved to the new Editions, or choose to not upgrade even if your dependencies do (although you then need to use a new-enough compiler of course, but your code doesn’t need to change).

                  If they ever decide that’s not enough, something really needs to be broken properly for everybody in a way Editions can’t express, then it’ll be a major version increase.

                  1. 1

                    Oh the updates and forthcoming undeprecation of std::env::home_dir is a nice change.

                    1. 1

                      I’m happy to see that powerpc64le-unknown-linux-musl is now Tier 2.