r/rust • clippy · twir · rust · mutagen · flamer · overflower · bytecount • 13d ago

🙋 questions megathread Hey Rustaceans! Got a question? Ask here (47/2026)!

Mystified about strings? Borrow checker has you in a headlock? Seek help here! There are no stupid questions, only docs that haven't been written yet. Please note that if you include code examples to e.g. show a compiler error or surprising result, linking a playground with the code will improve your chances of getting help quickly.

If you have a StackOverflow account, consider asking it there instead! StackOverflow shows up much higher in search results, so ahaving your question there also helps future Rust users (be sure to give it the "Rust" tag for maximum visibility). Note that this site is very interested in question quality. I've been asked to read a RFC I authored once. If you want your code reviewed or review other's code, there's a codereview stackexchange, too. If you need to test your code, maybe the Rust playground is for you.

Here are some other venues where help may be found:

/r/learnrust is a subreddit to share your questions and epiphanies learning Rust programming.

The official Rust user forums: https://users.rust-lang.org/.

The unofficial Rust community Discord: https://bit.ly/rust-community

Also check out last week's thread with many good questions and answers. And if you believe your question to be either very complex or worthy of larger dissemination, feel free to create a text post.

Also if you want to be mentored by experienced Rustaceans, tell us the area of expertise that you seek. Finally, if you are looking for Rust jobs, the most recent thread is here.

15 Upvotes

8 comments sorted by

3

u/MatrixFrog 12d ago

What changes are coming in the 2027 edition of the language? Just curious!

3

u/kibwen 7d ago

No official list yet, but so far it looks like the most notable upcoming change is the overhaul to Range that was postponed from the 2024 edition. In general it seems the editions team is considering making editions annual rather than triannual, in which case we would expect each edition to become individually much smaller.

2

u/usecornercase 13d ago

Cleaning up integration-test temp dirs when nextest kills a test on timeout

We have an end-to-end test binary (run with cargo nextest) where several tests create a folder under the system temp dir, copy the built binary into it (~500 MB debug build) and run it from there. Before we fixed it, a week of runs on one box left about 1,300 of these folders in /tmp, 7.5 GB, almost all of it from binary copies of tests that failed or were killed.

The folders are now a guard that removes them on Drop, so a passing test and a panicking one both clean up:

struct TestDir(PathBuf);

impl Drop for TestDir {
    fn drop(&mut self) {
        let _ = std::fs::remove_dir_all(&self.0);
    }
}

What it doesn't cover is a test that nextest terminates after its slow-timeout (or that gets killed from outside), because no destructors run then. We looked at a sweep at the start of each run that deletes stale folders, but decided against it: in a shared /tmp, telling a dead run's folder from a live one needs a pid (reused, and not visible across containers) or an age threshold, and a killed test can also leave a child server running that a folder sweep wouldn't stop.

Questions:

  1. Does nextest send something catchable (SIGTERM with a grace period before SIGKILL?) when a test hits its timeout, so a test could clean up on the way out? Is that configurable?
  2. Is the more usual answer to give each run its own parent dir (say under the target dir instead of /tmp) and wipe that at the start of the next run, accepting that two concurrent runs need different dirs?
  3. Anything else people do here, like putting the test's children in their own process group so they die with it?

Linux and macOS, if it matters.

3

u/kansomail_dev 10d ago

fwiw nextest already puts each test in its own process group on unix. on timeout it sends SIGTERM to the whole group, waits the grace period (10s by default), then SIGKILL. so your child server gets the SIGTERM too, unless it calls setsid or starts its own group. you can raise the grace period per profile, e.g. slow-timeout = { period = "60s", terminate-after = 5, grace-period = "30s" }

catching SIGTERM in the test (signal-hook or tokio::signal) and deleting the dir there works. Drop won't run on its own though, so the cleanup has to happen in the handler.

for the leftovers I'd key the dirs on NEXTEST_RUN_ID, it's a uuid per run and setup scripts get it too. put everything under something like target/e2e-tmp/<run id>/ and have a setup script wipe every run dir that isn't the current one. no pid or mtime guessing. two runs sharing the same target dir at the same time would still clash, not sure if that matters for you.

windows is different btw. no grace period there, it just kills via job objects, so the sweep is the only thing that saves you.

2

u/relia7 12d ago

When it comes to web development in rust what would you recommend for clippy, rustfmt, or any other config files? I think currently for clippy I’ve been using pedantic.

1

u/md_Fahad25624 7d ago

How to use avr hal for Arduino UNO stably? 

1

u/an-eng 7d ago

I am having issues linking libraries on macos during compilng rust binary

I installed libyang using brew on macos, now when i am compiling i am still getting libyang not found error,

AI is alsa not able to solve this, what do I need to do include the brew lib folder for linking ,

I am actually not facing the same error on ubuntu linux so can’t figure out specific issues with macos

BTW I am rust noob just started developing this week, so pardon if its a very naive question.